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

📄 ap_enter_noinvoiceinvinorder1_d.pas

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

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

Type
  TFrm_Ap_Enter_NoInvoiceInvInOrder1_D = Class(TFrm_Base_Entry_Detail)
    Label1: TLabel;
    Label2: TLabel;
    lbl_ItemName1: TLabel;
    Label4: TLabel;
    lbl_UomName1: TLabel;
    edt_BillLineRemArk: TEdit;
    Label5: TLabel;
    Label6: TLabel;
    Extedt_InvBillNoTaxAmount: TExtEdit;
    Label9: TLabel;
    Extedt_ItemCode: TLinkEdit;
    lbl_ItemName: TEdit;
    Edit_LineNo: TEdit;
    Label3: TLabel;
    Label7: TLabel;
    Edt_InvBillNoTaxPrice: TEdit;
    Edt_InvBillPrice: TEdit;
    Label8: TLabel;
    Edt_InvBillQty: TEdit;
    Extedt_InvBillAmount: TExtEdit;
    procedure FormCreate(Sender: TObject);
    procedure InvItemCodeCheck(Sender: TObject);
    procedure Extedt_ItemCodeButtonClick(Sender: TObject);
    procedure btn_okClick(Sender: TObject);
    procedure Edt_InvBillQtyExit(Sender: TObject);
    procedure Edt_InvBillNoTaxPriceExit(Sender: TObject);
    procedure Edt_InvBillPriceExit(Sender: TObject);
  private
    oldPrice,oldAmount,oldnotaxPrice,oldnotaxAmount,outType,outCode,currencyCode,
    Vendortaxrate_Percent,ExchRate,fdate,fwhCode,fWhPositionCode,fVendorCode:string;
    LineNo:Integer;
    { Private declarations }
  public
      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_Ap_Enter_NoInvoiceInvInOrder1_D:TFrm_Ap_Enter_NoInvoiceInvInOrder1_D;

implementation

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

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

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

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.InitControls;
begin//根据AdoQry_Body当前值,初始化Form的控件
  inherited;
  with AdoQry_Body do
  begin
    if status='Add' then
    begin
      if  isempty then
        LineNo:=1
      else
        LineNo:=LineNo+1;
      Edit_LineNo.text:=inttostr(LineNo);
      ExtEdt_ItemCode.Text:='';
      Lbl_ItemName.text:='';
      edt_BillLineRemArk.text:='';
      Extedt_InvBillNoTaxAmount.text:='0';
      Extedt_InvBillAmount.text:='0' ;
      Edt_InvBillNoTaxPrice.text:='0';
      Edt_InvBillPrice.text:='0';
      oldPrice:='0';
      oldAmount:='0';
      oldnotaxPrice:='0';
      oldnotaxAmount:='0';
    end
    else
    begin
      Edit_LineNo.text:=fieldbyname('InvBillLineNo').asstring;
      ExtEdt_ItemCode.Text:=fieldbyname('ItemCode').asstring;
      Lbl_ItemName.text:=fieldbyname('ItemName').asstring;
      Edt_InvBillNoTaxPrice.text:=fieldbyname('InvBillNoTaxPrice').AsString;
      Edt_InvBillPrice.text:=fieldbyname('InvBillPrice').AsString;
      Extedt_InvBillNoTaxAmount.text:=fieldbyname('InvBillNoTaxAmount').asstring;
      Extedt_InvBillAmount.text:=fieldbyname('InvBillAmount').asstring;
      edt_BillLineRemArk.text:=fieldbyname('BillLineRemArk').asstring;
    end;
  end;
  Edit_LineNo.enabled:=False;
  lbl_ItemName.enabled:=False;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.SaveBodyData;
begin//把Form的控件值写入缓存,要Post
  inherited;
  with AdoQry_Body do
  begin
   if status='Add' then
      fieldbyname('InvBilllineno').asinteger:=LineNo
    else
      fieldbyname('InvBilllineno').asinteger:=strtoint(Edit_LineNo.text);
    // fieldbyname('InvBillid').asinteger:=strtoint(Frm_Inv_OtherIn_B.Bill_id);
    fieldbyname('ItemCode').AsString:=ExtEdt_ItemCode.Text;
    fieldbyname('ItemName').AsString:=Lbl_ItemName.text;
    fieldbyname('BilllineremArk').AsString:=edt_BillLineRemArk.Text;
    //不管是外币还是人民币都放到四个字段中,只提供显示。在存盘时再按汇率计算
    fieldbyname('InvBillQty').asstring:=Edt_InvBillQty.text;
    fieldbyname('InvBillNoTaxAmount').AsString:=Extedt_InvBillNoTaxAmount.text;
    fieldbyname('InvBillAmount').AsString:=Extedt_InvBillAmount.text;
    fieldbyname('InvBillNoTaxPrice').AsString:=Edt_InvBillNoTaxPrice.text;
    fieldbyname('InvBillPrice').AsString:=Edt_InvBillPrice.text;

    //如果是人民币,则以人民币*汇率,如果是外币,则以外币/汇率
  {  if currencyCode='00' then
    begin
      fieldbyname('InvBillPrice').AsString:=Extedt_Price.text;
      fieldbyname('InvBillAmount').AsString:=floattostr(strtofloat(Extedt_Price.text)*strtofloat(Extedt_InvBillqty.text));
      fieldbyname('InvBillnotaxPrice').AsString:=Extedt_NotaxPrice.text;
      fieldbyname('InvBillnotaxAmount').AsString:=floattostr(strtofloat(ExtEdt_InvBillqty.Text)*strtofloat(Extedt_NotaxPrice.text));
      fieldbyname('InvBillPricec').AsString:=floattostr(strtofloat(Extedt_NotaxPrice.text)*(1+strtofloat(Vendortaxrate_Percent)/100)*strtofloat(ExchRate));
      fieldbyname('InvBillAmountc').AsString:=floattostr(strtofloat(Extedt_NotaxPrice.text)*(1+strtofloat(Vendortaxrate_Percent)/100)*strtofloat(ExchRate)*strtofloat(ExtEdt_InvBillqty.Text));
      fieldbyname('InvBillnotaxPricec').AsString:=floattostr(strtofloat(Extedt_NotaxPrice.text)*strtofloat(ExchRate));
      fieldbyname('InvBillnotaxAmountc').AsString:=floattostr(strtofloat(Extedt_NotaxPrice.text)*strtofloat(ExchRate)*strtofloat(ExtEdt_InvBillqty.Text))
    end
    else
    begin
      fieldbyname('InvBillPrice').AsString:=floattostr(strtofloat(Extedt_NotaxPrice.text)/strtofloat(ExchRate)*(1+strtofloat(Vendortaxrate_Percent)/100));
      fieldbyname('InvBillAmount').AsString:=floattostr(strtofloat(Extedt_NotaxPrice.text)/strtofloat(ExchRate)*(1+strtofloat(Vendortaxrate_Percent)/100)*strtofloat(Extedt_InvBillqty.text));
      fieldbyname('InvBillnotaxPrice').AsString:=floattostr(strtofloat(Extedt_NotaxPrice.text)/strtofloat(ExchRate));
      fieldbyname('InvBillnotaxAmount').AsString:=floattostr(strtofloat(ExtEdt_InvBillqty.Text)*strtofloat(Extedt_NotaxPrice.text)/strtofloat(ExchRate));
      fieldbyname('InvBillPricec').AsString:=Extedt_Price.text;
      fieldbyname('InvBillAmountc').AsString:=floattostr(strtofloat(Extedt_Price.text)*strtofloat(ExtEdt_InvBillqty.Text));
      fieldbyname('InvBillnotaxPricec').AsString:=Extedt_NotaxPrice.text;
      fieldbyname('InvBillnotaxAmountc').AsString:=floattostr(strtofloat(Extedt_NotaxPrice.text)*strtofloat(ExtEdt_InvBillqty.Text));
    end;}
    Post;
  end;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.FormCreate(Sender: TObject);
begin
  inherited;
  SetFocus_Control:=ExtEdt_ItemCode;//设置新增时要聚焦的控件
end;


procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.SetStatus(CurrentStatus:String;var EnableControls:String);
begin
  //增加时对各控件的控制,如果增加,还要对录入行进行控制
  if CurrentStatus='Add' then
  begin
    {if AdoQry_Body.RecordCount>=Frm_Ap_Enter_NoInvoiceInvInOrderH.Billlines then
    begin
      EnableControls:='None';
      DispInfo('本单据最多只允许输入'+inttostr(Frm_Ap_Enter_NoInvoiceInvInOrderH.Billlines)+'条单据行',1);
    end;}
  end
  else if CurrentStatus='AllEdit' then
    begin
      EnableControls:='edt_BillLineRemArk,'
                     +' Edt_InvBillQty,Edt_InvBillNoTaxPrice,Edt_InvBillPrice,Extedt_ItemCode,';
    end
  else
    EnableControls:='None';
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_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
    Extedt_ItemCode.setfocus;
    abort;
  end;}
  //物料不能重复的检验
  if status='Add' then
  begin
  AdoQry_Body.First;
  if AdoQry_Body.locate('ItemCode',Extedt_ItemCode.text,[]) then
  begin
    DispInfo('该物料已经存在,不允许增加或修改!',1);
    Extedt_ItemCode.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);
        Extedt_ItemCode.SetFocus;
        Abort;
      end
    end;
  end;
  //取物料的计量单位
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add('select u.UomName ,i.ItemName from Item i ,Uom u where i.ItemCode='''+Trim(Extedt_ItemCode.text)+''' and i.UomCode=u.UomCode ');
    open;
    lbl_ItemName.text:=fieldbyname('ItemName').asstring;
  end;
  //如果物料与Extedt_ItemCode的值是为改变,如果没有改,则不做下面事件 ChangeD基类参数
  if not Changed then
  exit;
  {//在PC表中取物料单价
 // if outType='供应商' then
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add(' select case when  pcline.FormalPricePass=1 then pcline.PCNoTaxPrice_Formal else pcline.PCNoTaxPrice end as InvBillNoTaxPrice ,'+
                   ' case when  pcline.FormalPricePass=1 then pcline.PCTaxPrice_Formal else pcline.PCTaxPrice end  as InvBillPrice ' +
            ' from pcline left join pc  on pcline.pcno=pc.pcno '+
            ' where pc.VendorCode='''+fVendorCode+''' and pcline.ItemCode='''+Trim(Extedt_ItemCode.text)+''' ');
    open;
    if not eof then
    begin
      edt_InvBillNoTaxPrice.Text :=fieldbyname('InvBillNoTaxPrice').asstring;
      Edt_InvBillPrice.text:=fieldbyname('InvBillPrice').asstring;
    end;
  end;}
  with AdoQry_tmp do
  begin
    Close;
    sql.clear;
    sql.Add(' select Price from Sc_PriceMaster where  ItemCode='''+Trim(Extedt_ItemCode.text)+''' ');
    open;
    if not eof then
    begin
      edt_InvBillNoTaxPrice.Text :=fieldbyname('Price').asstring;
      Edt_InvBillPrice.text:=floattostr(fieldbyname('Price').asfloat*(1+strtofloat(Vendortaxrate_Percent)/100.00));
    end ;
    {else
    begin
      DispInfo('此物料还没有定义标准价格',3);
      abort;
    end;}
  end;

end;



procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.Extedt_ItemCodeButtonClick(Sender: TObject);
begin
  inherited;
  CommonHint(Sender,AdoQry_Tmp,'ItemName','物料名称','ItemCode',
      '物料代码','Item','ItemUsable=1 and ItemType in (0,2)');
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.btn_okClick(Sender: TObject);
begin
  {Extedt_InvBillNoTaxAmountExit(Extedt_InvBillNoTaxAmount);
  Extedt_InvBillAmountExit(Extedt_InvBillAmount);}
  Edt_InvBillQtyExit(Edt_InvBillQty);
  Edt_InvBillNoTaxPriceExit(Edt_InvBillNoTaxPrice);
  Edt_InvBillPriceExit(Edt_InvBillPrice);
  if strtofloat(Edt_InvBillQty.text)=0 then
  begin
    DispInfo('数量不能为零!',1);
    Edt_InvBillQty.setfocus;
    abort;
  end;
  if strtofloat(Edt_InvBillNoTaxPrice.text)=0 then
  begin
    DispInfo('未税价不能为零!',1);
    Edt_InvBillNoTaxPrice.setfocus;
    abort;
  end;
  if strtofloat(Edt_InvBillPrice.text)=0 then
  begin
    DispInfo('含税价不能为零!',1);
    Edt_InvBillPrice.setfocus;
    abort;
  end;
  inherited;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.Edt_InvBillQtyExit(
  Sender: TObject);
begin
  inherited;
  FloatCheck(Edt_InvBillQty);
  Extedt_InvBillNoTaxAmount.text:=formatfloat('#.##',strtofloat(Edt_InvBillQty.text)*strtofloat(Edt_InvBillNoTaxPrice.text)) ;
  Extedt_InvBillAmount.text:=formatfloat('#.##',strtofloat(Edt_InvBillQty.text)*strtofloat(Edt_InvBillPrice.text));  
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.Edt_InvBillNoTaxPriceExit(
  Sender: TObject);
begin
  inherited;
  FloatCheck(Edt_InvBillNoTaxPrice);
  Edt_InvBillPrice.text:= formatfloat('#.####',strtofloat(Edt_InvBillNoTaxPrice.text)*(1+strtofloat(Vendortaxrate_Percent)/100.00));
  Extedt_InvBillAmount.text:=formatfloat('#.##',strtofloat(Edt_InvBillQty.text)*strtofloat(Edt_InvBillPrice.text));
  Extedt_InvBillNoTaxAmount.text:=formatfloat('#.##',strtofloat(Edt_InvBillQty.text)*strtofloat(Edt_InvBillNoTaxPrice.text)) ;
end;

procedure TFrm_Ap_Enter_NoInvoiceInvInOrder1_D.Edt_InvBillPriceExit(
  Sender: TObject);
begin
  inherited;
  FloatCheck(Edt_InvBillPrice);
  Edt_InvBillNoTaxPrice.text:=formatfloat('#.####',strtofloat(Edt_InvBillPrice.text)/(1+strtofloat(Vendortaxrate_Percent)/100.00));
  Extedt_InvBillAmount.text:=formatfloat('#.##',strtofloat(Edt_InvBillQty.text)*strtofloat(Edt_InvBillPrice.text));
  Extedt_InvBillNoTaxAmount.text:=formatfloat('#.##',strtofloat(Edt_InvBillQty.text)*strtofloat(Edt_InvBillNoTaxPrice.text)) ;
end;

end.



⌨️ 快捷键说明

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