📄 inv_otherin_d.pas
字号:
unit Inv_OtherIn_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Detail, Db, AdODB, ExtCtrls, StdCtrls, ExtEdit, linkedit;
Type
TFrm_Inv_OtherIn_D = Class(TFrm_Base_Entry_Detail)
Extedt_InvBillqty: TExtEdit;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
lbl_ItemName1: TLabel;
Label4: TLabel;
lbl_UomName1: 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;
Extedt_ItemCode: TLinkEdit;
lbl_ItemName: TEdit;
lbl_UomName: TEdit;
procedure FormCreate(Sender: TObject);
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 Extedt_ItemCodeButtonClick(Sender: TObject);
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
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_OtherIn_D:TFrm_Inv_OtherIn_D;
implementation
uses Sys_Global,Inv_OtherIn_B,Inv_OtherIn_H,Inv_Global;
{$R *.DFM}
procedure TFrm_Inv_OtherIn_D.SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,
FrmParam5,FrmParam6:String);
begin
outType:=frmParam1;
outCode:=frmParam2;
currencyCode:=frmParam3;
Vendortaxrate_Percent:=frmParam4;
if Vendortaxrate_Percent='' then
Vendortaxrate_Percent:='0';
ExchRate:=frmParam5;
fdate:=frmParam6;
end;
procedure TFrm_Inv_OtherIn_D.SetFormParam1(FrmParam1,FrmParam2:string);
begin
fwhCode:=FrmParam1;
fWhPositionCode:=FrmParam2;
end;
procedure TFrm_Inv_OtherIn_D.InitControls;
begin//根据AdoQry_Body当前值,初始化Form的控件
inherited;
with AdoQry_Body do
begin
if status='Add' then
begin
ExtEdt_ItemCode.Text:='';
Lbl_ItemName.text:='';
lbl_UomName.text:='';
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.text:=fieldbyname('ItemName').asstring;
lbl_UomName.text:=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;
lbl_ItemName.enabled:=False;
lbl_UomName.enabled:=False;
end;
procedure TFrm_Inv_OtherIn_D.SaveBodyData;
begin//把Form的控件值写入缓存,要Post
inherited;
with AdoQry_Body do
begin
if status='Add' then
fieldbyname('InvBilllineno').asinteger:=recordCount+1;
// fieldbyname('InvBillid').asinteger:=strtoint(Frm_Inv_OtherIn_B.Bill_id);
fieldbyname('ItemCode').AsString:=ExtEdt_ItemCode.Text;
fieldbyname('ItemName').AsString:=Lbl_ItemName.text;
fieldbyname('UomName').AsString:=lbl_UomName.text;
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;
//如果是人民币,则以人民币*汇率,如果是外币,则以外币/汇率
{ 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_Inv_OtherIn_D.FormCreate(Sender: TObject);
begin
inherited;
SetFocus_Control:=ExtEdt_ItemCode;//设置新增时要聚焦的控件
end;
procedure TFrm_Inv_OtherIn_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('数量不能等于零!',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;
//下面这一参数为控制运算含税价,含税金额,未税价,未税金额用。如果数据改变,则重新计算金额
if Changed then
oldPrice:='-1';
end;
procedure TFrm_Inv_OtherIn_D.SetStatus(CurrentStatus:String;var EnableControls:String);
begin
//增加时对各控件的控制,如果增加,还要对录入行进行控制
if CurrentStatus='Add' then
begin
if AdoQry_Body.RecordCount>=Frm_Inv_OtherIn_H.Billlines then
begin
EnableControls:='None';
DispInfo('本单据最多只允许输入'+inttostr(Frm_Inv_OtherIn_H.Billlines)+'条单据行',1);
end;
end
else if CurrentStatus='AllEdit' then
begin
EnableControls:='Extedt_ItemCode,Extedt_InvBillqty,Extedt_NotaxPrice,Extedt_NotaxAmount,Extedt_Price,Extedt_Amount,edt_memo,Extedt_Batchno,'
end
else
EnableControls:='None';
end;
procedure TFrm_Inv_OtherIn_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;
if outType='供应商' then
begin
with AdoQry_tmp do
begin
Close;
Sql.text:='select PmCode from Item where ItemCode='''+Trim(Extedt_ItemCode.text)+'''';
open;
if fieldbyname('PmCode').asinteger<>1 then
begin
DispInfo('物料代码的制购码必须是采购!',3);
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_UomName.text:=fieldbyname('UomName').asstring;
lbl_ItemName.text:=fieldbyname('ItemName').asstring;
end;
//如果物料与Extedt_ItemCode的值是为改变,如果没有改,则不做下面事件 ChangeD基类参数
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;
Extedt_InvBillqty.SetFocus ;
end;
procedure TFrm_Inv_OtherIn_D.Extedt_PriceExit(Sender: TObject);
var
InvBillqty,InvBillPrice,InvBillAmount,InvBillnotaxPrice,InvBillnotaxAmount:real;
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -