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

📄 stk_enter_checkinvbill_d.pas

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

Interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Base_Entry_Detail, Db, AdODB, ExtCtrls, StdCtrls, ExtEdit, linkedit;

Type
  TFrm_Stk_Enter_CheckInvBill_D = Class(TFrm_Base_Entry_Detail)
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Label5: TLabel;
    Edt_BatchNo: TEdit;
    Edt_InvBillLineNo: TEdit;
    Label1: TLabel;
    Label6: TLabel;
    Edt_PLCause: TEdit;
    Label7: TLabel;
    Edt_AccountQty: TEdit;
    Label9: TLabel;
    Edt_ProfitLossQty: TEdit;
    Label10: TLabel;
    Edt_CheckQty: TEdit;
    Edt_ItemName: TEdit;
    Edt_UomName: TEdit;
    LEdt_ItemCode: TLinkEdit;
    procedure Edt_AccountQtyExit(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure Edt_InvBillLineNoExit(Sender: TObject);
    procedure Edt_BatchNoExit(Sender: TObject);
    procedure Edt_BatchNoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure btn_okClick(Sender: TObject);
    procedure LEdt_ItemCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure LEdt_ItemCodeButtonClick(Sender: TObject);
    procedure LEdt_ItemCodeExit(Sender: TObject);
    procedure Edt_CheckQtyExit(Sender: TObject);
  private
    { Private declarations }
    CurrentInvField:string;
    LineCount:Integer;
    flag:integer;
    lineNo:integer;
    FWhCode:string;
    //FBillTypeCode:String;//根据采购订单的类型确定对应的单据类型是什么
    FWhPositionCode:String;//该变量记录的是某仓库“待检”属性的货位的代码
    {Ffdays:Integer;//比订单要求的“约定交货期”提前多少天到货可以接受
    Fbdays:Integer;//比订单要求的“约定交货期”滞后多少天到货可以接受
    Foqty:Double;//比订单要求的“约定交货量”超过百分之多少可以接受}
  public
    { Public declarations }
    procedure InitControls; Override;
    procedure SaveBodyData; Override;
    procedure SetStatus(CurrentStatus:String;var EnableControls:String); Override;
    procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,
      FrmParam6:String);Override;
  end;

var
  Frm_Stk_Enter_CheckInvBill_D: TFrm_Stk_Enter_CheckInvBill_D;

implementation

uses Sys_Global,Inv_CheckInmoHint,Inv_Global;

{$R *.DFM}

{ TFrm_Inv_SaleMaterial_D }

procedure TFrm_Stk_Enter_CheckInvBill_D.InitControls;
begin
  SetFocus_Control:=LEdt_ItemCode;
  inherited;
  with AdoQry_Body do
  begin
    if Status='Add'  then
    begin
      if AdoQry_Body.IsEmpty then
       begin
        lineNo:=1

       end
       else
       begin
         AdoQry_Body.refresh;
         AdoQry_Body.Sort:='InvBillLineNo';
         AdoQry_Body.Last ;
         lineno:=fieldbyname('InvBillLineNo').asinteger+1 ;
       end;
        Edt_InvBillLineNo.Text:=inttostr(lineNo);
    end
    else
     Edt_InvBillLineNo.Text:=fieldbyname('InvBillLineNo').AsString;
    LEdt_ItemCode.text:=fieldbyname('ItemCode').AsString;
    edt_ItemName.text:=fieldbyname('ItemName').AsString;
    edt_UomName.text:=fieldbyname('UomName').AsString;
    Edt_PLCause.Text:=fieldbyname('PLCause').AsString;
    if (Status='Add')and(AdoQry_Body.IsEmpty) then
    begin
      Edt_AccountQty.text:='0';
      Edt_CheckQty.text:='0';
      Edt_ProfitLossQty.text:='0';
      Edt_BatchNo.Text:='';
    end
    else
    begin
      Edt_AccountQty.text:=AdoQry_Body.fieldbyname('AccountQty').asstring;
      Edt_CheckQty.text:=AdoQry_Body.fieldbyname('CheckQty').asstring;
      Edt_ProfitLossQty.text:=AdoQry_Body.fieldbyname('ProfitLossQty').asstring;
      Edt_BatchNo.Text:=AdoQry_Body.fieldbyname('BatchNo').AsString;
    end;
  end;
  if (Status<>'ReadOnly') then
  begin
    AdoQry_tmp.Close;
    AdoQry_tmp.SQL.Text:='Select WhPositionType From WhPosition'
      +' Where WhPositionCode='''+FWhPositionCode+''''
      +' And WHCode='''+FWhCode+'''';
    AdoQry_tmp.Open;
    case AdoQry_tmp.fieldbyname('WhPositionType').AsInteger Of
      0:CurrentInvField:='OnHandInv';
      1:CurrentInvField:='OnCheckInv';
      2:CurrentInvField:='FreezeInv';
      3:CurrentInvField:='WasterInv';
      4:CurrentInvField:='OnShipInv';
    end;
  end;
  flag:=0;
  Edt_InvBillLineNo.Enabled :=False;
  edt_ItemName.Enabled :=False;
  Edt_UomName.Enabled :=False;
  Edt_AccountQty.enabled:=False;
  Edt_ProfitLossQty.enabled:=False;
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.SaveBodyData;
begin//把Form的控件值写入缓存,要Post
  inherited;
  with AdoQry_Body do
  begin
    if Status='Add'  then
      insert;
    if Status='AllEdit'  then
      edit;
    fieldbyname('InvBillLineNo').AsString:=Edt_InvBillLineNo.Text;
    fieldbyname('ItemCode').AsString:=Ledt_ItemCode.text;
    fieldbyname('ItemName').AsString:=edt_ItemName.text;
    fieldbyname('UomName').AsString:=edt_UomName.text;
    fieldbyname('BatchNo').AsString:=Edt_BatchNo.Text;
    fieldbyname('AccountQty').AsString:=Edt_AccountQty.Text;
    fieldbyname('CheckQty').AsString:=Edt_CheckQty.Text;
    fieldbyname('ProfitLossQty').AsString:=Edt_ProfitLossQty.Text;
    fieldbyname('PLCause').AsString:=Edt_PLCause.Text;
    Post;
  end;
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.SetStatus(CurrentStatus: String;
  var EnableControls: String);
begin
  inherited;
  if CurrentStatus='Add' then
  begin
    {if LineCount=-1 then
    begin
      AdoQry_Tmp.Close;
      AdoQry_Tmp.SQL.Text:='Select BillLines'
        +' From BillType'
        +' Where BillTypeCode='''+'1102'+'''';
      AdoQry_Tmp.Open;
      LineCount:=AdoQry_Tmp.fieldbyname('BillLines').AsInteger;
    end;
    if AdoQry_Body.RecordCount>=LineCount then
    begin
      EnableControls:='None';
      DispInfo('本单据最多只允许输入'+IntToStr(LineCount)+'条单据行!',3);
    end;}
  end;
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.Edt_AccountQtyExit(Sender: TObject);
begin
  inherited;
  {if(ActiveControl.Name='btn_Cancel')  then
    Abort;
   FloatCheck(Sender);
  if StrToFloat(TEdit(Sender).Text)<=0 then
  begin
    DispInfo(' 数量不能小于等于零!',3);
    TWinControl(Sender).SetFocus;
    Abort;
  end;}
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.FormCreate(Sender: TObject);
begin
  inherited;
  LineCount:=-1;
  flag:=0;
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.Edt_InvBillLineNoExit(Sender: TObject);
var
  BookMArk:TBookMArk;
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel')then
    Abort;
  IntegerCheck(Sender);
  if (Status='Add') then
  begin
    BookMArk:=AdoQry_Body.GetBookmArk;
    try
      AdoQry_Body.First;
      while not AdoQry_Body.Eof do
      begin
        if AdoQry_Body.fieldbyname('InvBillLineNo').AsString=TEdit(Sender).Text then
        begin
          TWinControl(Sender).SetFocus;
          DispInfo(' 同一张单据中不能有相同的盘点单行号! ',3);
          Abort;
        end;
        AdoQry_Body.Next;
      end;
    finally
      AdoQry_Body.GotoBookmArk(BookmArk);
      AdoQry_Body.FreeBookmArk(BookmArk);
    end;
  end;
  {if not DefaultWHCheck(AdoQry_Tmp,AdoQry_Head.fieldbyname('WHCode').AsString,
    Ledt_ItemCode.text) then
  begin
    TWinControl(Sender).SetFocus;
    Abort;
  end;}
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.SetFormParam(FrmParam1, FrmParam2, FrmParam3,
  FrmParam4, FrmParam5, FrmParam6: String);
begin
  inherited;
  //FBillTypeCode:=FrmParam1;
  FWhCode:= FrmParam1;
  FWhPositionCode:=FrmParam2;
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.Edt_BatchNoExit(Sender: TObject);
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel')then
    Abort;
  {if (TEdit(Sender).ReadOnly=False)and(TEdit(Sender).Text<>'') then
  begin
    if not BatchNoCheck(AdoQry_Tmp,TEdit(Sender).Text,ledt_ItemCode.Caption
      ,AdoQry_Head.fieldbyname('VendorCode').AsString
      ,AdoQry_Head.fieldbyname('OnCheckDate').AsString) then
    begin
      TWinControl(Sender).SetFocus;
      Abort;
    end;
  end; }
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.Edt_BatchNoKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  {if (Key=120)and(TEdit(Sender).ReadOnly=False) then
    TEdit(Sender).Text:=BatchHint(DBConnect,Ledt_ItemCode.text
      ,AdoQry_Head.fieldbyname('VendorCode').AsString
      ,AdoQry_Head.fieldbyname('WHCode').AsString
      ,FWhPositionCode);}
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.btn_okClick(Sender: TObject);
begin
  flag:=1;
  if Trim(LEdt_ItemCode.text)='' then
  begin
    DispInfo('物料代码不为空!',3);
    LEdt_ItemCode.SetFocus ;
    abort;
  end;
  if Trim(Edt_CheckQty.text)='' then
  begin
    DispInfo('盘点数量不为空!',3);
    Edt_CheckQty.SetFocus ;
    abort;
  end;
  if strtofloat(Edt_CheckQty.text)<0 then
  begin
    DispInfo('盘点数量不为负数!',3);
    Edt_CheckQty.setfocus;
    abort;
  end;
  inherited;
  flag:=0;
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.LEdt_ItemCodeKeyDown(
  Sender: TObject; var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=120 then
  CommonHint(Sender,AdoQry_Tmp,'ItemName','物料名称','ItemCode','物料代码',
             'Item','ItemUsable=1 and ItemCode in (select ItemCode from CurrentInv '+
                       ' where CurrentInv.WhPositionCode='''+FWhPositionCode+''''+
                             ' and CurrentInv.WHCode='''+FwhCode+''''+')');
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.LEdt_ItemCodeButtonClick(
  Sender: TObject);
begin
  inherited;
  CommonHint(Sender,AdoQry_Tmp,'ItemName','物料名称','ItemCode','物料代码',
             'Item','ItemUsable=1 and ItemCode in (select ItemCode from CurrentInv '+
                       ' where CurrentInv.WhPositionCode='''+FWhPositionCode+''''+
                             ' and CurrentInv.WHCode='''+FwhCode+''''+')');
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.LEdt_ItemCodeExit(Sender: TObject);
var
  BookMArk:TBookMArk;
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel')then
    Abort;
  if Trim(Ledt_ItemCode.text)='' then
  begin
    DispInfo('物料代码不能为空!',3);
    Ledt_ItemCode.setfocus;
    abort;
  end;
  if (Status='Add') then
  begin
  BookMArk:=AdoQry_Body.GetBookmArk;
  try
    AdoQry_Body.First;
    while not AdoQry_Body.Eof do
    begin
      if AdoQry_Body.fieldbyname('ItemCode').AsString=Trim(LEdt_ItemCode.Text) then
      begin
        TWinControl(Sender).SetFocus;
        DispInfo(' 同一张单据中不能有相同的物料代码!',3);
        Abort;
      end;
      AdoQry_Body.Next;
    end;
  finally
    AdoQry_Body.GotoBookmArk(BookmArk);
    AdoQry_Body.FreeBookmArk(BookmArk);
  end;
  end;
  With AdoQry_tmp do
  begin
    Close;
    Sql.text:=' select CurrentInv.ItemCode,Item.ItemName,Uom.UomName ,'+
                     ' CurrentInv.'+CurrentInvField +' as OnHandInv' +
              ' from CurrentInv left join Item on CurrentInv.ItemCode=Item.ItemCode '+
              ' left join Uom on Item.UomCode=Uom.UomCode '+
              ' where CurrentInv.ItemCode='''+Trim(Ledt_ItemCode.text)+''''+
                    ' and CurrentInv.WHCode='''+FwhCode+''''+
                    ' and CurrentInv.WhPositionCode='''+FWhPositionCode+'''';
    open;
    if isempty then
    begin
      DispInfo('此物料代码不存在或未生效!',3);
      Ledt_ItemCode.setfocus;
      abort;
    end
    else
    begin
      Edt_ItemName.text:=fieldbyname('ItemName').asstring;
      edt_UomName.text:=fieldbyname('UomName').asstring;
      Edt_AccountQty.text:=fieldbyname('OnhandInv').asstring;
      Edt_CheckQty.text:=fieldbyname('OnhandInv').asstring;
      Edt_ProfitLossQty.text:='0';
      if not BatchCtrl(AdoQry_Tmp,Ledt_ItemCode.text) then
      begin
        Edt_BatchNo.Text:='';
        Edt_BatchNo.ReadOnly:=True;
      end
      else
      begin
        Edt_BatchNo.ReadOnly:=False;
      end;
    end;
  end;
end;

procedure TFrm_Stk_Enter_CheckInvBill_D.Edt_CheckQtyExit(Sender: TObject);
begin
  inherited;
  if(ActiveControl.Name='btn_Cancel')then
    Abort;
  floatcheck(edt_CheckQty);
  Edt_ProfitLossQty.text:=formatfloat('#.00',strtofloat(Edt_CheckQty.text)-
                   strtofloat(Edt_AccountQty.text));
end;

end.

⌨️ 快捷键说明

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