⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 htxg.pas

📁 一个仓库管理中的子系统--采购子系统
💻 PAS
📖 第 1 页 / 共 2 页
字号:
   qzsjdate.DateTime:=date;
   dhsjdate.DateTime:=date;
   
   initStringGrid;
   with datamodule1.htglzbQuery do
   begin
   jfmcEdit.Text:=FieldByname('甲方单位名').asstring;
   yfmcEdit.Text:=FieldByName('乙方单位名').asstring;
   dhjeEdit.Text:=FieldByname('订货金额').asstring;
   hthEdit.Text:=FieldByName('合同号').asstring;
   qzrEdit.Text:=FieldByName('签字人').asstring;
   qzsjEdit.Text:=sqinputForm.ShowMeDate(FieldByName('签字时间').asstring);
   end;
   with datamodule1.Query3 do
   begin
   sql.Clear;
   sql.Add('select cpmc as 产品名称,xhgg as 型号规格,sldw as 数量单位,dj as 单价,dhsl as 订货数量,fkfs as 付款方式,dhsj as 到货时间,bz as 备注 from dbo.a_htglxb');
   sql.Add('where hth='+''''+hthedit.Text+'''');
   prepare;
   open;
   first;
   if RecordCount<>0 then
   For I:=1 to RecordCount do
   begin
   with stringGrid1 do
   begin
     cells[1,i]:=FieldByName('产品名称').asstring;
     cells[2,i]:=FieldBYName('型号规格').asstring;
     cells[3,i]:=FieldByName('数量单位').asstring;
     cells[4,i]:=Format('%8.2f',[strToFloat(FieldByName('单价').asstring)]);
     cells[5,i]:=Format('%8.2f',[strToFloat(FieldByName('订货数量').asstring)]);
     cells[6,i]:=Format('%8.2f',[(strToFloat(cells[4,I])*StrToFloat(cells[5,I]))]);
     cells[7,i]:=FieldByName('付款方式').asstring;
     cells[8,i]:=sqinputForm.ShowMeDate(FieldByName('到货时间').asstring);
     Cells[9,i]:=FieldByName('备注').asstring;
   end;
   next;
   end;
   end;
   datamodule1.PublicQuery1.Active:=true;
   hthstr:=hthedit.text;
end;

procedure ThtxgForm.StringGrid1DrawCell(Sender: TObject; ACol,
  ARow: Integer; Rect: TRect; State: TGridDrawState);
var
  text:string;
begin
if arow=0 then
  begin
  stringgrid1.Canvas.Brush.Color:=grid_headcolor;
  stringgrid1.Canvas.FillRect(rect);
  writetext(stringgrid1.canvas,rect.left,rect.top,rect.right,rect.bottom,4,1,stringgrid1.cells[acol,arow],font,1,true);
  exit;
  end;
text:=stringgrid1.cells[acol,arow];
if (arow mod 2) =0 then stringgrid1.Canvas.Brush.Color:=grid_highcolor
else  stringgrid1.Canvas.Brush.Color:=grid_lowcolor;
if gdSelected in state then  stringgrid1.Canvas.Brush.Color:=grid_selectedcolor;
stringgrid1.Canvas.FillRect(rect);
writetext(stringgrid1.canvas,rect.left,rect.top,rect.right,rect.bottom,1,1,text,font,2,true);

    with Sender as TStringGrid do
    begin
      if gdFocused in State then
      begin
       if ACol=3 then
       begin
        jldwCombo.SetBounds(
        Rect.Left+StringGrid1.left+1,
        Rect.Top+StringGrid1.Top+1,
        Rect.Right-Rect.Left+1,
        StringGrid1.DefaultRowHeight);
        Canvas.DrawFocusRect(Rect);
        end;
       if ACol=8 then
       begin
        dhsjDate.SetBounds(
        Rect.Left+StringGrid1.left+1,
        Rect.Top+StringGrid1.Top+1,
        Rect.Right-Rect.Left+1,
        StringGrid1.DefaultRowHeight);
        Canvas.DrawFocusRect(Rect);
       end;
    end;
    end;
end;

procedure ThtxgForm.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
    MyRowCount:=Arow;
     if ACol=3 then
      begin
       DisplayComponent(jldwComBo);
       dhsjdate.Visible:=false;
      end
      else
       if ACol=8 then
       begin
        DisplayComponent(dhsjDate);
        jldwCombo.Visible:=False;
       end
       else
       if (ACol=6)  or (ACol=3) or (ARow>datamodule1.Query3.RecordCount) then
       begin
         jldwCombo.Visible:=False;
         dhsjDate.Visible:=False;
       with StringGrid1 do
       begin
       if  (GoEditing in Options) then
        Options:=Options-[GoEditing];
       end;
       end
       else
        begin
         jldwCombo.Visible:=False;
         dhsjDate.Visible:=False;
       with StringGrid1 do
       begin
       if not (GoEditing in Options) then
        Options:=Options+[GoEditing];
       end;
       end;
end;

procedure ThtxgForm.jldwComboChange(Sender: TObject);
begin
   stringGrid1.cells[3,MyRowCount]:=jldwCombo.Text;
end;

procedure ThtxgForm.dhsjDateCloseUp(Sender: TObject);
begin
    stringGrid1.cells[8,MyRowCount]:=sqinputForm.ShowMeDate(sqinputForm.DateTo709str(dhsjDate.date));
end;

procedure ThtxgForm.qzsjDateCloseUp(Sender: TObject);
begin
    qzsjedit.Text:=sqinputForm.ShowMeDate(sqinputForm.DateTo709str(qzsjDate.date));
end;

procedure ThtxgForm.dhjeEditExit(Sender: TObject);
begin
   dhjeEdit.Text:=sqInputForm.CheckFloatData(dhjeEdit.Text);
end;

procedure ThtxgForm.dhjeEditKeyPress(Sender: TObject; var Key: Char);
begin
    if not (key in ['0'..'9','.',#8,#13]) then
    begin
      key:=#0;
      beep;
    end;
end;

procedure ThtxgForm.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
    if (stringGrid1.col=4) or (stringGrid1.col=5) then
    begin
    oldCol:=stringGrid1.col;
    oldRow:=stringGrid1.Row;
    if not (key in ['0'..'9','.',#8,#13]) then
    begin
      key:=#0;
      beep;
    end;
    end;
end;

procedure ThtxgForm.StringGrid1Click(Sender: TObject);
begin
   if (oldCol=4) or (oldCol=5) then
   begin
      stringGrid1.Cells[oldCol,oldRow]:=sqinputForm.CheckFloatData(stringGrid1.Cells[oldCol,oldRow]);
   end;
end;

procedure ThtxgForm.SpeedButton1Click(Sender: TObject);
var I,RCount:integer;
begin
    if not CheckEdit then
    exit;
    with datamodule1.PublicQuery2 do
    begin
    sql.Clear;
    sql.Add('select * From dbo.a_htglzb');
    sql.Add('where hth='+''''+hthedit.text+'''');
    prepare;
    open;
    end;
    if datamodule1.publicQuery2.RecordCount>1 then
    begin
    ShowMessage('您输入的合同在数据库中已经存在,请确认是否有输入相同的合同号!');
    exit;
    end;
    with datamodule1.publicQuery2 do
    begin
    sql.Clear;
    sql.Add('select * From dbo.a_htglxb');
    sql.Add('where hth='+''''+hthstr+'''');
    prepare;
    open;
    Rcount:=RecordCount;
    end;

    with datamodule1.PublicQuery1 do
    begin
    Requestlive:=true;
    sql.Clear;
    sql.Add('select * From dbo.a_htglzb');
    sql.Add('where hth='+''''+hthstr+'''');
    prepare;
    open;
    delete;
    insert;
    FieldByName('jfmc').asstring:=jfmcEdit.Text;
    FieldBYName('yfmc').asstring:=yfmcEdit.Text;
    FieldBYname('dhje').asfloat:=strToFloat(dhjeEdit.Text);
    FieldByname('hth').asstring:=hthEdit.Text;
    FieldByname('qzr').asstring:=qzrEdit.Text;
    FieldByName('qzsj').asstring:=sqInputForm.GetDate709(qzsjEdit.Text);
    FieldByname('bz').asstring:=bzedit.Text;
    FieldByname('lrms').asstring:=nrmsEdit.Text;
    post;
    end;
    speedButton1.Enabled:=false;
    if MessageDlg('合同管理表主表提交成功!您是否有合同具体内容要提交!',mtInformation,[mbOK,mbCancel],0) = mrCancel then
    exit;

    with datamodule1.PublicQuery1 do
    begin
    sql.Clear;
    sql.Add('select * From dbo.a_htglxb');
    prepare;
    open;
    first;
    if not CheckGrid then
    exit;

    for I:=1 to RCount do
    begin
    append;
    with stringGrid1 do
    begin
    FieldByName('hth').asstring:=hthEdit.Text;
    FieldByName('cpmc').asstring:=Cells[1,I];
    FieldBYname('xhgg').asstring:=Cells[2,I];
    FieldByname('sldw').asstring:=cells[3,I];
    FieldByName('dj').asfloat:=StrToFloat(Cells[4,I]);
    FieldBYname('dhsl').asfloat:=StrToFloat(cells[5,I]);
    FieldByName('dhsj').asstring:=sqInputForm.GetDate709(cells[8,I]);
    FieldBYname('fkfs').asstring:=Cells[7,I];
    FieldBYname('bz').asstring:=cells[9,I];
    end;
    post;
    end;
    end;
    speedButton1.Enabled:=false;
    showmessage('合同记录修改成功!');
end;

procedure ThtxgForm.SpeedButton2Click(Sender: TObject);
var I,J:integer;
begin
   For I:=1 to stringGrid1.RowCount-1 do
   For J:=1 to stringGrid1.ColCount-1 do
   begin
   if (J=4) or (J=5) then
   stringGrid1.Cells[J,I]:='0.00'
   else
   stringGrid1.Cells[J,I]:='';
   end;
   
   For I:=1 to ComponentCount-1 do
   if Components[I] is TEdit then
   Tedit(Components[I]).text:='';
   speedButton1.Enabled:=True;
end;

procedure ThtxgForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    datamodule1.PublicQuery1.RequestLive:=false;
    datamodule1.PublicQuery1.Close;
    datamodule1.publicQuery2.Close;
    datamodule1.Query3.close;
end;

procedure ThtxgForm.StringGrid1SetEditText(Sender: TObject; ACol,
  ARow: Integer; const Value: String);
begin
   if (ACol=4) or (ACol=5) then
   with stringGrid1 do
   begin
   if (Cells[4,ARow]='0.00') or (Cells[4,ARow]='') or (Cells[5,ARow]='0.00') or (Cells[5,ARow]='')then
   begin
   Cells[6,Arow]:='0.00';
   exit;
   end;
   Cells[6,Arow]:=Format('%8.2f',[(strToFloat(cells[4,ARow])*StrToFloat(cells[5,ARow]))]);
   jszj;
   end;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -