htgl.pas

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

PAS
562
字号
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 ThtlrForm.SpeedButton3Click(Sender: TObject);
begin
    close;
end;

procedure ThtlrForm.FormActivate(Sender: TObject);
begin
   qzsjdate.DateTime:=date;
   dhsjdate.DateTime:=date;
   
   initStringGrid;
   datamodule1.PublicQuery1.Active:=true;
end;

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

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

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

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

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

procedure ThtlrForm.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 ThtlrForm.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 ThtlrForm.SpeedButton1Click(Sender: TObject);
var I: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<>0 then
    begin
    ShowMessage('您输入的合同在数据库中已经存在,请确认是否有输入相同的合同号!');
    exit;
    end;
    
    with datamodule1.PublicQuery1 do
    begin
    Requestlive:=true;
    sql.Clear;
    sql.Add('select * From dbo.a_htglzb');
    prepare;
    open;
    append;
    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;
    speedButton2.Enabled:=true;
    if MessageDlg('合同管理表主表提交成功!您是否有合同具体内容要提交!',mtInformation,[mbOK,mbCancel],0) = mrCancel then
    exit;

    if not CheckGrid then
    exit;
    with datamodule1.PublicQuery1 do
    begin
    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;
    speedButton2.Enabled:=true;
    showmessage('合同记录提交成功!');
end;

procedure ThtlrForm.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;
   speedButton2.Enabled:=false;
end;

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

procedure ThtlrForm.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 + =
减小字号Ctrl + -
显示快捷键?