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

📄 sfc_monthsumqrybcppj_e.pas

📁 一个MRPII系统源代码版本
💻 PAS
字号:
unit Sfc_MonthSumQrybcppj_e;

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Detail, Db, AdODB, ExtCtrls, StdCtrls;

Type
  TFrm_Sfc_MonthSumQrybcppj_e = Class(TFrm_Base_Detail)
    Edit1: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    lbl_ItemName: TLabel;
    Label4: TLabel;
    Edit2: TEdit;
    Label3: TLabel;
    Edit3: TEdit;
    procedure Edit1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure btn_okClick(Sender: TObject);
    procedure Edit1Exit(Sender: TObject);
    procedure btn_CancelClick(Sender: TObject);
  private
    { Private declarations }
    status,theMonth,DeptCode,ItemCode:string;
    AdoQry_Head:TAdoQuery;
  public
    { Public declarations }
    procedure showstatus(aa,bb,cc,dd:string;AdoQry:TAdoQuery);
  end;

var
  Frm_Sfc_MonthSumQrybcppj_e: TFrm_Sfc_MonthSumQrybcppj_e;

implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Sfc_MonthSumQrybcppj_e.Showstatus(aa,bb,cc,dd:string;AdoQry:TAdoQuery);
begin
  AdoQry_Head:=AdoQry;
  AdoQry_tmp.Connection:=AdoQry.Connection;
  status:=aa;
  theMonth:=bb;
  DeptCode:=cc;
  ItemCode:=dd;
  if status='edit' then
  begin
    edit1.Enabled:=False;
  end;
  edit1.Text:=AdoQry_Head.fieldbyname('ite_ItemCode').asstring;
  lbl_ItemName.Caption:=AdoQry_Head.fieldbyname('ItemName').asstring;
  edit2.Text:=AdoQry_Head.fieldbyname('wipAmount').asstring;
  edit3.text:=AdoQry_Head.fieldbyname('wipqty').asstring;
end;

procedure TFrm_Sfc_MonthSumQrybcppj_e.Edit1KeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  if(Key=120)then
    CommonHint(Sender,AdoQry_Tmp,'Item.ItemName','物料名称','#MonthSumQry2.ItemCode','物料代码','Item,#MonthSumQry2','Item.ItemCode=#MonthSumQry2.ItemCode ');
end;

procedure TFrm_Sfc_MonthSumQrybcppj_e.btn_okClick(Sender: TObject);
begin
  if status='Add' then
  begin
    with AdoQry_Tmp do
    begin
      Close;
      sql.text:='select Count(*) aa from wipbcpAmount where wiPMonth='+QuotedStr(theMonth)+
              ' and DeptCode='+QuotedStr(DeptCode)+
              ' and ItemCode='+QuotedStr(ItemCode)+
              ' and ite_ItemCode='+QuotedStr(edit1.text);
      open;
      if fieldbyname('aa').AsInteger>0 then
      begin
        DispInfo('该物料已经存在!',1);
        abort;
      end;
      Close;
      sql.text:='insert wipbcpAmount(wiPMonth,DeptCode,ItemCode,ite_ItemCode,wipqty,wipAmount) select '+
                QuotedStr(theMonth)+','+
                QuotedStr(DeptCode)+','+
                QuotedStr(ItemCode)+','+
                QuotedStr(edit1.text)+','+
                edit3.Text+','+
                edit2.text;
      execsql;
    end;
    AdoQry_Head.Append;
//    AdoQry_Head.fieldbyname('wiPMonth').asstring:=theMonth;
//    AdoQry_Head.fieldbyname('DeptCode').asstring:=DeptCode;
//    AdoQry_Head.fieldbyname('ItemCode').asstring:=ItemCode;
    AdoQry_Head.fieldbyname('ite_ItemCode').asstring:=edit1.text;
    AdoQry_Head.fieldbyname('ItemName').asstring:=lbl_ItemName.Caption;
  end
  else
  begin
    with AdoQry_Tmp do
    begin
      Close;
      sql.text:='update wipbcpAmount set wipAmount='+edit2.text+','+
              ' wipqty='+edit3.Text+
              ' where wiPMonth='+QuotedStr(theMonth)+
              ' and DeptCode='+QuotedStr(DeptCode)+
              ' and ItemCode='+QuotedStr(ItemCode)+
              ' and ite_ItemCode='+QuotedStr(edit1.text);
      execsql;
    end;
    AdoQry_Head.edit;
  end;
  AdoQry_Head.fieldbyname('wipqty').AsString:=edit3.Text;
  AdoQry_Head.fieldbyname('wipAmount').asstring:=edit2.text;
  AdoQry_Head.post;
  if status='Add' then
  begin
    DispInfo('完成增加,请继续',1);
    edit1.SetFocus;
  end
  else
  begin
    Close;
    Release;
  end;
end;

procedure TFrm_Sfc_MonthSumQrybcppj_e.Edit1Exit(Sender: TObject);
begin
  inherited;
  with AdoQry_tmp do
  begin
    Close;
    sql.text:='select Item.ItemName,#MonthSumQry2.InvInqty from Item,#MonthSumQry2 where Item.ItemCode='+QuotedStr(edit1.Text)
              +'  and #MonthSumQry2.ItemCode='+QuotedStr(edit1.Text) ;
    open;
    if not eof then
    lbl_ItemName.Caption:=fieldbyname('ItemName').AsString;
    edit3.Text:=fieldbyname('InvInqty').asstring;
  end;
end;

procedure TFrm_Sfc_MonthSumQrybcppj_e.btn_CancelClick(Sender: TObject);
begin
//  inherited;
   Close;
   Release;
end;

end.

⌨️ 快捷键说明

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