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

📄 inv_noorderopin_d.pas

📁 一个MRPII系统源代码版本
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit Inv_NoOrderOpIn_D;

Interface

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

Type
  TFrm_Inv_NoOrderOpIn_D = Class(TFrm_Base_Entry_Detail)
    Extedt_ItemCode: TExtEdit;
    Extedt_InvBillqty: TExtEdit;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    lbl_ItemName: TLabel;
    Label4: TLabel;
    lbl_UomName: TLabel;
    edt_memo: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    Label7: TLabel;
    Extedt_NotaxPrice: TExtEdit;
    Extedt_NotaxAmount: TExtEdit;
    Extedt_Price: TExtEdit;
    Extedt_Amount: TExtEdit;
    Label8: TLabel;
    Label9: TLabel;
    Extedt_Batchno: TExtEdit;
    Label10: TLabel;
    procedure Extedt_InvBillqtyExit(Sender: TObject);
    procedure InvItemCodeCheck(Sender: TObject);
    procedure Extedt_PriceExit(Sender: TObject);
    procedure Extedt_AmountExit(Sender: TObject);
    procedure Extedt_NotaxPriceExit(Sender: TObject);
    procedure Extedt_NotaxAmountExit(Sender: TObject);
    procedure Extedt_NotaxPriceKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Extedt_PriceKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure Extedt_BatchnoExit(Sender: TObject);
    procedure Extedt_BatchnoKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure btn_okClick(Sender: TObject);
    procedure Extedt_ItemCodeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    oldPrice,oldAmount,oldnotaxPrice,oldnotaxAmount,outType,outCode,currencyCode,
    Vendortaxrate_Percent,ExchRate,fdate,fwhCode,fWhPositionCode,fVendorCode:string;
    { Private declarations }
  public
      AdoQry_RealOpQty:TAdoQuery;
      procedure SetStatus(CurrentStatus:String;var EnableControls:String); Override;
      procedure InitControls; Override;//根据AdoQry_Body当前值,初始化Form的控件
      procedure SaveBodyData; Override;//把Form的控件值写入缓存,要Post
      procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,
      FrmParam5,FrmParam6:String);Override;
      procedure SetFormParam1(FrmParam1,FrmParam2:string);
    //设置在部分修改状态下,那些控件Enable=True
    { Public declarations }
  end;

var
  Frm_Inv_NoOrderOpIn_D:TFrm_Inv_NoOrderOpIn_D;

implementation

uses Sys_Global,Inv_NoOrderOpIn_B,Inv_NoOrderOpIn_H,Inv_Global;
{$R *.DFM}

procedure TFrm_Inv_NoOrderOpIn_D.SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,
      FrmParam5,FrmParam6:String);
begin
  outType:=frmParam1;
  outCode:=frmParam2;
  currencyCode:=frmParam3;
  Vendortaxrate_Percent:=frmParam4;
  ExchRate:=frmParam5;
  fdate:=frmParam6;
end;

procedure TFrm_Inv_NoOrderOpIn_D.SetFormParam1(FrmParam1,FrmParam2:string);
begin
  fwhCode:=FrmParam1;
  fWhPositionCode:=FrmParam2;
end;

procedure TFrm_Inv_NoOrderOpIn_D.InitControls;
begin//根据AdoQry_Body当前值,初始化Form的控件
  inherited;
  with AdoQry_Body do
  begin
    if status='Add' then
    begin
      ExtEdt_ItemCode.Text:='';
      Lbl_ItemName.Caption:='';
      lbl_UomName.Caption:='';
      ExtEdt_InvBillQty.Text:='0';
      edt_memo.text:='';
      Extedt_Price.text:='0';
      Extedt_NotaxPrice.text:='0';
      Extedt_Amount.text:='0';
      Extedt_NotaxAmount.text:='0';
      Extedt_Batchno.text:='';
      oldPrice:='0';
      oldAmount:='0';
      oldnotaxPrice:='0';
      oldnotaxAmount:='0';
    end
    else
    begin
      ExtEdt_ItemCode.Text:=fieldbyname('ItemCode').asstring;
      Lbl_ItemName.Caption:=fieldbyname('ItemName').asstring;
      lbl_UomName.Caption:=fieldbyname('UomName').asstring;
      ExtEdt_InvBillQty.Text:=fieldbyname('InvBillqty').asstring;
      edt_memo.text:=fieldbyname('BilllineremArk').asstring;
      Extedt_Price.text:=fieldbyname('InvBillPrice').asstring;
      Extedt_NotaxPrice.text:=fieldbyname('InvBillnotaxPrice').asstring;
      Extedt_Amount.text:=fieldbyname('InvBillAmount').asstring;
      Extedt_Batchno.text:=fieldbyname('Batchno').asstring;
      Extedt_NotaxAmount.text:=fieldbyname('InvBillnotaxAmount').asstring;
      oldPrice:=fieldbyname('InvBillPrice').asstring;
      oldAmount:=fieldbyname('InvBillAmount').asstring;
      oldnotaxPrice:=fieldbyname('InvBillnotaxPrice').asstring;
      oldnotaxAmount:=fieldbyname('InvBillnotaxAmount').asstring;
    end;
  end;
end;

procedure TFrm_Inv_NoOrderOpIn_D.SaveBodyData;
begin//把Form的控件值写入缓存,要Post
  inherited;
  with AdoQry_Body do
  begin
    if status='Add' then
    begin
      Frm_Inv_NoOrderOpIn_H.InvBilllineno:=Frm_Inv_NoOrderOpIn_H.InvBilllineno+1;
      fieldbyname('InvBilllineno').asinteger:=Frm_Inv_NoOrderOpIn_H.InvBilllineno;
      btn_ok.Enabled :=False;
      GetOpQty(AdoQry_Tmp,AdoQry_RealOpQty,ExtEdt_ItemCode.text,(Frm_Inv_NoOrderOpIn_H.InvBilllineno));
      btn_ok.Enabled :=True;
    end;
   // fieldbyname('InvBillid').asinteger:=strtoint(Frm_Inv_OtherIn_B.Bill_id);
    fieldbyname('ItemCode').AsString:=ExtEdt_ItemCode.Text;
    fieldbyname('ItemName').AsString:=Lbl_ItemName.Caption;
    fieldbyname('UomName').AsString:=lbl_UomName.Caption;
    fieldbyname('InvBillqty').AsString:=ExtEdt_InvBillqty.Text;
    fieldbyname('Batchno').asstring:=Extedt_Batchno.text;
    fieldbyname('BilllineremArk').AsString:=Edt_memo.Text;
    //不管是外币还是人民币都放到四个字段中,只提供显示。在存盘时再按汇率计算
    fieldbyname('InvBillPrice').AsString:=Extedt_Price.text;
    fieldbyname('InvBillAmount').AsString:=Extedt_Amount.text;
    fieldbyname('InvBillnotaxPrice').AsString:=Extedt_NotaxPrice.text;
    fieldbyname('InvBillnotaxAmount').AsString:=Extedt_NotaxAmount.text;
    Post;

  end;
end;

procedure TFrm_Inv_NoOrderOpIn_D.Extedt_InvBillqtyExit(Sender: TObject);
begin
  inherited;
   if ActiveControl.Name='btn_Cancel' then
    exit;
  floatcheck(sender);
  if strtofloat(Extedt_InvBillqty.text)=0 then
  begin
    DispInfo('数量不能为0!',1);
    twincontrol(sender).setfocus;
    abort;
  end;

  if not InvQtyCheck
  (False,
  AdoQry_Body,
   AdoQry_tmp,
   fwhCode,
   fWhPositionCode,
   Extedt_ItemCode.text,
   'InvBillqty',
   strtofloat(Extedt_InvBillqty.text),
   True) then
   begin
     Extedt_InvBillqty.setfocus;
     abort;
   end;
end;

procedure TFrm_Inv_NoOrderOpIn_D.SetStatus(CurrentStatus:String;var EnableControls:String);
begin
  if CurrentStatus='Add' then
  begin
      SetFocus_Control:=ExtEdt_ItemCode;//设置新增时要聚焦的控件
    if AdoQry_Body.RecordCount>=Frm_Inv_NoOrderOpIn_H.Billlines then
    begin
     // EnableControls:='None';
     // DispInfo('本单据最多只允许输入'+inttostr(Frm_Inv_NoOrderOpIn_H.Billlines)+'条单据行',1);
    end;
  end
  else if CurrentStatus='AllEdit' then
    begin
      EnableControls:='Extedt_InvBillqty,Extedt_NotaxPrice,Extedt_NotaxAmount,Extedt_Price,Extedt_Amount,edt_memo,Extedt_Batchno,';
      SetFocus_Control:=Extedt_InvBillqty;//设置新增时要聚焦的控件
    end
  else
    EnableControls:='None';
end;

procedure TFrm_Inv_NoOrderOpIn_D.InvItemCodeCheck(Sender: TObject);
begin
   inherited;

  if ActiveControl.Name='btn_Cancel' then
    exit;

  if not DefaultWHCheck(AdoQry_tmp,AdoQry_Head.fieldbyname('whCode').asstring,Extedt_ItemCode.text) then
  begin
    twincontrol(sender).setfocus;
    abort;
  end;
  if status='Add' then
  begin
  AdoQry_Body.First;
  if AdoQry_Body.locate('ItemCode',Extedt_ItemCode.text,[]) then
  begin
    DispInfo('该物料已经存在,不允许增加或修改!',1);
    TWinControl(Sender).SetFocus;
    Abort;
  end
  end
  else
  begin
    if Extedt_ItemCode.text<>AdoQry_Body.fieldbyname('ItemCode').asstring then
    begin
      AdoQry_Body.First;
      if AdoQry_Body.locate('ItemCode',Extedt_ItemCode.text,[]) then
      begin
        DispInfo('该物料已经存在,不允许增加或修改!',1);
        TWinControl(Sender).SetFocus;
        Abort;
      end
    end;
  end;
  with AdoQry_tmp do
  begin
    Close;
    Sql.text:='select PmCode from Item where ItemCode='''+Trim(Extedt_ItemCode.text)+'''';
    open;
    if fieldbyname('PmCode').asinteger<>2 then
    begin
      DispInfo('物料代码的制购码必须是委外加工!',3);
      Extedt_ItemCode.SetFocus ;
      abort;
    end;
  end;
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('select u.UomName from Item i ,Uom u where i.ItemCode='''+Extedt_ItemCode.text+''' and i.UomCode=u.UomCode ');
    open;
    lbl_UomName.Caption:=fieldbyname('UomName').asstring;
  end;
  if not Changed then
  exit;
  if outType='供应商' then
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('select Price,notaxPrice from OtherPrice where VendorCode='''+outCode+''' and ItemCode='''+Extedt_ItemCode.text+''' ');
    open;
    if not eof then
    begin
      Extedt_NotaxPrice.Text :=fieldbyname('notaxPrice').asstring;
      Extedt_Price.text:=fieldbyname('Price').asstring;
    end;
  end;
end;

procedure TFrm_Inv_NoOrderOpIn_D.Extedt_PriceExit(Sender: TObject);
var
  InvBillqty,InvBillPrice,InvBillAmount,InvBillnotaxPrice,InvBillnotaxAmount:real;
begin
  inherited;
   if ActiveControl.Name='btn_Cancel' then
    exit;
  //数量
  floatcheck(sender);
  InvBillqty:=strtofloat(Extedt_InvBillqty.text);
  {  如果输入含税单价,则
     含税金额=四舍五入保留两位小数(数量*含税单价)
     不含税金额=含税金额/(1+税率/100)
     不含税单价=不含税金额/数量}
  //if ActiveControl=ExtEdt_InvBillqty then
  //  Exit;

  if InvBillqty=0.0 then
  begin
    DispInfo('数量不能为零!',1);
    Extedt_InvBillqty.setfocus;
    abort;
  end;

⌨️ 快捷键说明

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