bhgsqbqr.pas

来自「一个仓库管理中的子系统--采购子系统」· PAS 代码 · 共 210 行

PAS
210
字号
unit bhgsqbqr;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ComCtrls, Grids, ExtCtrls,DBTables;

type
  TbhgsqbqrForm = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    StringGrid2: TStringGrid;
    Panel3: TPanel;
    Label1: TLabel;
    Label2: TLabel;
    sqbidLabel: TLabel;
    rwmcLabel: TLabel;
    Label5: TLabel;
    yxnxLabel: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    lshLabel: TLabel;
    Label10: TLabel;
    sbdwLabel: TLabel;
    Label12: TLabel;
    rqLabel: TLabel;
    Label3: TLabel;
    Label9: TLabel;
    Label4: TLabel;
    bzfzrCombo: TComboBox;
    shrCombo: TComboBox;
    pzrCombo: TComboBox;
    Label11: TLabel;
    Label6: TLabel;
    bzfzrqzEdit: TEdit;
    shrqEdit: TEdit;
    bzfzrqzDate: TDateTimePicker;
    shrqDate: TDateTimePicker;
    pzrqDate: TDateTimePicker;
    pzrqEdit: TEdit;
    Label14: TLabel;
    BitBtn1: TBitBtn;
    StatusBar1: TStatusBar;
    procedure FormActivate(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure StringGrid2SelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
  private
    { Private declarations }
  public
     procedure InitbhgsqbForm;
     procedure postToBhgsqzb;
     procedure postToBhgsqxb;
    { Public declarations }
  end;

var
  bhgsqbqrForm: TbhgsqbqrForm;

implementation

uses Datamodule, sqbinput;

{$R *.DFM}

procedure TbhgsqbqrForm.postToBhgsqzb;
begin
    with datamodule1.PublicQuery1 do
    begin
    close;
    sql.Clear;
    sql.Add('select * From dbo.a_bhgsqzb');
    sql.Add('where sqbid='+''''+sqbidLabel.Caption+'''');
    open;
    if recordCount<>0 then
    begin
    close;
    exit;
    end;
    close;
    end;
    with datamodule1.bhgsqzbTable do
    begin
    try
    open;
    append;
    FieldByName('sqbid').asstring:=sqbidlabel.caption;
    post;
    close;
    except
    on EDBEngineError do
          begin
           messageDlg('写数据库时出错!',mtInformation,[mbOK],0);
           exit;
         end;
    end;
    end;
end;

procedure TbhgsqbqrForm.postToBhgsqxb;
begin
    with datamodule1.bhgsqxbTable do
    begin
    try
    open;
    append;
    FieldByname('sqbid').asstring:=sqbidLabel.caption;
    fieldByName('cpbh').asstring:=stringGrid2.Cells[1,1];
    FieldByName('hgwcjmc').asstring:=stringGrid2.cells[7,1];
    FieldByName('ly').asstring:=stringGrid2.cells[10,1];
    FieldByName('bz').asstring:=stringGrid2.cells[11,1];
    post;
    close;
    except
    on EDBEngineError do
          begin
           messageDlg('写数据库时出错!',mtInformation,[mbOK],0);
           exit;
         end;
    end;
    end;
end;

procedure TbhgsqbqrForm.InitbhgsqbForm;
begin
     with stringGrid2 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]:='时间要求';
     cells[10,0]:='理由';
     cells[11,0]:='备注';
     end;
     
end;

procedure TbhgsqbqrForm.FormActivate(Sender: TObject);
begin

   InitbhgsqbForm;
   bzfzrqzDate.DateTime:=Date;
   shrqDate.DateTime:=Date;
   pzrqDate.DateTime:=Date;
   with datamodule1.PublicQuery1 do
   begin
   sql.Clear;
   sql.Add('select * From dbo.a_cgsqzb');
   sql.Add('where sqbid='+''''+sqbidLabel.Caption+'''');
   prepare;
   open;
   rwmclabel.Caption:=FieldByName('rwmc').asstring;
   yxnxlabel.Caption:=FieldByName('yxnx').asstring;
   lshlabel.Caption:=FieldByname('lsh').asstring;
   sbdwLabel.Caption:=FieldByName('sqdw').asstring;
   rqlabel.Caption:=FieldByname('sqrq').asstring;
   close;
   sql.Clear;
   sql.Add('select * From dbo.a_cgsszb');
   sql.Add('where sqbid='+''''+sqbidlabel.caption+'''');
   prepare;
   open;
   bzfzrCombo.Text:=FieldByname('bzfzr').asstring;
   shrCombo.Text:=FieldByName('shr').asstring;
   pzrCombo.Text:=FieldByname('pzr').asstring;
   bzfzrqzEdit.Text:=sqinputForm.showmedate(FieldByName('bzqzrq').asstring);
   shrqEdit.Text:=sqInputForm.showmedate(FieldByname('shrq').asstring);
   pzrqEdit.Text:=SqinputForm.showmedate(FieldByName('pzrq').asstring);
   close;
   end;
end;

procedure TbhgsqbqrForm.BitBtn1Click(Sender: TObject);
begin
    if stringGrid2.Cells[10,1]='' then
    begin
    showMessage('请您注明为这条记录生成合格分承制方名单外临时采购产品申请表的理由');
    exit;
    end;
    postTobhgsqzb;
    postTobhgsqxb;
    bhgsqbqrForm.Close;
end;

procedure TbhgsqbqrForm.StringGrid2SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
    with stringGrid2 do
    begin
    if ((ACol=10) or (ACol=11)) and (ARow=1)  then
    begin
     if not (GoEditing in Options) then
     Options:=Options+[GoEditing];
    end
    else
    begin
     if (GoEditing in Options) then
     Options:=Options-[GoEditing];
    end;
    end;
end;

end.

⌨️ 快捷键说明

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