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

📄 inv_purchinaudit_d.pas

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

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

Type
  TFrm_Inv_PurchInAudit_D = Class(TFrm_Base_Entry_Detail)
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    lbl_ItemName: TLabel;
    lbl_InvBillqty: TLabel;
    Extedt_InvBillPrice: TExtEdit;
    Extedt_InvBillAmount: TExtEdit;
    Extedt_InvBillnotaxPrice: TExtEdit;
    Label6: TLabel;
    Label7: TLabel;
    Label8: TLabel;
    Extedt_InvBillnotaxAmount: TExtEdit;
    Label9: TLabel;
    lbl_ItemCode: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure Extedt_InvBillAmountExit(Sender: TObject);
    procedure Extedt_InvBillPriceExit(Sender: TObject);
    procedure Extedt_InvBillnotaxPriceExit(Sender: TObject);
    procedure Extedt_InvBillnotaxAmountExit(Sender: TObject);
  private
    InvBilltaxrate:real;
    BillTypeCode:string;
    { Private declarations }
  public
      procedure InitControls; Override;//根据AdoQry_Body当前值,初始化Form的控件
      procedure SaveBodyData; Override;//把Form的控件值写入缓存,要Post

    //设置在部分修改状态下,那些控件Enable=True
    { Public declarations }
  end;

var
  Frm_Inv_PurchInAudit_D: TFrm_Inv_PurchInAudit_D;

implementation

uses Sys_Global,Inv_OtherIn_B, Inv_OtherIn_H, Inv_OtherInAudit_B;
{$R *.DFM}

procedure TFrm_Inv_PurchInAudit_D.InitControls;
begin//根据AdoQry_Body当前值,初始化Form的控件
  inherited;
  BillTypeCode:=Param1;
  if BillTypeCode='0101' then
    Caption:='采购入库核价'
  else if BillTypeCode='0102' then
    Caption:='进口采购入库核价'
  else
    Caption:='委外加工入库核价';

  with AdoQry_Body do
  begin
    if status='Add' then
    begin
    end
    else
    begin
      InvBilltaxrate:=AdoQry_Head.fieldbyname('InvBilltaxrate').asfloat;
      lbl_ItemCode.Caption:=fieldbyname('ItemCode').asstring;
      Lbl_ItemName.Caption:=fieldbyname('ItemName').asstring;
      lbl_InvBillqty.Caption:=fieldbyname('InvBillqty').asstring;
      ExtEdt_InvBillPrice.Text:=fieldbyname('InvBillPrice').asstring;
      ExtEdt_InvBillAmount.Text:=fieldbyname('InvBillAmount').asstring;
      ExtEdt_InvBillnotaxPrice.Text:=fieldbyname('InvBillnotaxPrice').asstring;
      ExtEdt_InvBillnotaxAmount.Text:=fieldbyname('InvBillnotaxAmount').asstring;
    end;
  end;

  //状态控制-----
  Extedt_InvBillnotaxAmount.ReadOnly:=False;
  Extedt_InvBillnotaxAmount.TabStop:=True;
  Extedt_InvBillAmount.ReadOnly:=False;
  Extedt_InvBillAmount.TabStop :=True;
  Extedt_InvBillnotaxPrice.ReadOnly:=False;
  Extedt_InvBillnotaxPrice.TabStop :=True;
  Extedt_InvBillPrice.ReadOnly:=False;
  Extedt_InvBillPrice.TabStop :=True;
  //------------
 // inherited;
end;

procedure TFrm_Inv_PurchInAudit_D.SaveBodyData;
begin//把Form的控件值写入缓存,要Post
  inherited;
  with AdoQry_Body do
  begin
    fieldbyname('InvBillPrice').AsString:=ExtEdt_InvBillPrice.Text;
    fieldbyname('InvBillAmount').AsString:=Extedt_InvBillAmount.text;
    fieldbyname('InvBillnotaxPrice').AsString:=Extedt_InvBillnotaxPrice.text;
    fieldbyname('InvBillnotaxAmount').AsString:=ExtEdt_InvBillnotaxAmount.Text;
    Post;
  end;
end;

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



procedure TFrm_Inv_PurchInAudit_D.Extedt_InvBillAmountExit(Sender: TObject);
var
  InvBillqty,InvBillPrice,InvBillAmount,InvBillnotaxPrice,InvBillnotaxAmount:real;
begin
  inherited;
   if ActiveControl.Name='btn_Cancel' then
    exit;
  floatcheck(sender);
  //数量
  InvBillqty:=AdoQry_Body.fieldbyname('InvBillqty').asfloat;
    //含税金额
     {  如果输入含税金额,则
     含税单价=含税金额/数量
     不含税金额=含税金额/(1+税率/100)
     不含税单价=不含税金额/数量}
  InvBillAmount:=strtofloat(Extedt_InvBillAmount.text);
  //含税单价
  InvBillPrice:=InvBillAmount/InvBillqty;

  //不含税金额
  InvBillnotaxAmount:=round(InvBillAmount/(1+InvBilltaxrate/100)*100)/100;
  //不含税单价
  InvBillnotaxPrice:=InvBillnotaxAmount/InvBillqty;

  Extedt_InvBillPrice.text:=floattostr(InvBillPrice);
  Extedt_InvBillnotaxPrice.text:=floattostr(InvBillnotaxPrice);
  Extedt_InvBillnotaxAmount.text:=floattostr(InvBillnotaxAmount);
  
end;

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

  //含税单价
  InvBillPrice:=strtofloat(Extedt_InvBillPrice.text);
  //含税金额
  InvBillAmount:=round(InvBillPrice*InvBillqty*100)/100;
  //不含税金额
  InvBillnotaxAmount:=round(InvBillAmount/(1+InvBilltaxrate/100)*100)/100;
  //不含税单价
  InvBillnotaxPrice:=InvBillnotaxAmount/InvBillqty;

  Extedt_InvBillAmount.text:=floattostr(InvBillAmount);
  Extedt_InvBillnotaxPrice.text:=floattostr(InvBillnotaxPrice);
  Extedt_InvBillnotaxAmount.text:=floattostr(InvBillnotaxAmount);

end;

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

  //含税金额
  InvBillAmount:=round(InvBillnotaxAmount*(1+InvBilltaxrate/100)*100)/100;
  //含税单价
  InvBillPrice:=InvBillAmount/InvBillqty;

  Extedt_InvBillPrice.text:=floattostr(InvBillPrice);
  Extedt_InvBillAmount.text:=floattostr(InvBillAmount);
  Extedt_InvBillnotaxAmount.text:=floattostr(InvBillnotaxAmount);
end;

procedure TFrm_Inv_PurchInAudit_D.Extedt_InvBillnotaxAmountExit(
  Sender: TObject);
var
  InvBillqty,InvBillPrice,InvBillAmount,InvBillnotaxPrice,InvBillnotaxAmount:real;
begin
  inherited;
   if ActiveControl.Name='btn_Cancel' then
    exit;
  floatcheck(sender);
  //数量
  InvBillqty:=strtofloat(lbl_InvBillqty.Caption);
    {   如果输入不含税金额,则
        不含税单价=不含税金额/数量
        含税金额=不含税金额*(1+税率/100)
        含税单价=含税金额/数量}
  //不含税金额
  InvBillnotaxAmount:=strtofloat(Extedt_InvBillnotaxAmount.text);
  //不含税单价
  InvBillnotaxPrice:=InvBillnotaxAmount/InvBillqty;

  //含税金额
  InvBillAmount:=round(InvBillnotaxAmount*(1+InvBilltaxrate/100)*100)/100;
  //含税单价
  InvBillPrice:=InvBillAmount/InvBillqty;

  Extedt_InvBillPrice.text:=floattostr(InvBillPrice);
  Extedt_InvBillAmount.text:=floattostr(InvBillAmount);
  Extedt_InvBillnotaxPrice.text:=floattostr(InvBillnotaxPrice);
 
end;

end.

⌨️ 快捷键说明

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