httj.pas

来自「一个仓库管理中的子系统--采购子系统」· PAS 代码 · 共 522 行 · 第 1/2 页

PAS
522
字号
var I:integer;
begin
with stringGrid1 do
begin
cells[1,0]:='产品名称';
cells[2,0]:='型号规格';
cells[3,0]:='数量单位';
cells[4,0]:='单价';
cells[5,0]:='订货数量';
cells[6,0]:='金额总计';
cells[7,0]:='付款方式';
cells[8,0]:='到货时间';
Cells[9,0]:='备注';
end;
for I:=1 to stringGrid1.RowCount-1 do
with stringGrid1 do
begin
cells[4,I]:='0.00';
cells[5,I]:='0.00';
Cells[6,I]:='0.00';
cells[0,I]:=IntToStr(I);
end;
end;

procedure ThttjForm.SpeedButton3Click(Sender: TObject);
begin
    close;
end;

procedure ThttjForm.FormActivate(Sender: TObject);
begin
   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;
   TotalMoney:=StrToFloat(dhjeEdit.Text);
   datamodule1.PublicQuery1.Active:=true;
end;

procedure ThttjForm.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 ThttjForm.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) 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 ThttjForm.jldwComboChange(Sender: TObject);
begin
   stringGrid1.cells[3,MyRowCount]:=jldwCombo.Text;
end;

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

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

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

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

procedure ThttjForm.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 ThttjForm.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 ThttjForm.SpeedButton1Click(Sender: TObject);
var I:integer;
begin
    if not CheckGrid then
    exit;
    with datamodule1.PublicQuery1 do
    begin
    requestlive:=true;
    sql.Clear;
    sql.Add('select * From dbo.a_htglxb');
    prepare;
    open;
    for I:=1 to Count 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 ThttjForm.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 ThttjForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    datamodule1.PublicQuery1.RequestLive:=false;
    datamodule1.PublicQuery1.Close;
    datamodule1.publicQuery2.Close;
    datamodule1.Query3.Close;
end;

procedure ThttjForm.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;
   dhjeEdit.Text:=Format('%8.3f', [TotalMoney+strToFloat(dhjeEdit.Text)]);
   end;
end;

end.

⌨️ 快捷键说明

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