📄 inv_otherout_d.pas
字号:
unit Inv_OtherOut_D;
//其它出库的明细单元
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Detail, Db, AdODB, ExtCtrls, StdCtrls, ExtEdit;
Type
TFrm_Inv_OtherOut_D = Class(TFrm_Base_Entry_Detail)
Label1: TLabel;
Label2: TLabel;
ExtEdt_ItemCode: TExtEdit;
Lbl_ItemName: TLabel;
Label4: TLabel;
edt_NotaxPrice: TEdit;
Label5: TLabel;
edt_NotaxAmount: TEdit;
Label3: TLabel;
Edt_Qty: TEdit;
Label6: TLabel;
edt_memo: TEdit;
Label7: TLabel;
lbl_Uom: TLabel;
Label8: TLabel;
Edt_BatchNo: TEdit;
procedure Edt_QtyExit(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure edt_NotaxPriceExit(Sender: TObject);
procedure edt_NotaxAmountExit(Sender: TObject);
procedure ExtEdt_ItemCodeExit(Sender: TObject);
procedure Edt_BatchNoKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edt_BatchNoExit(Sender: TObject);
procedure btn_okClick(Sender: TObject);
procedure ExtEdt_ItemCodeChange(Sender: TObject);
private
WhCode,Position,HasNegative,InvBillMonth,BillDate,QryMonth: String;
IsPlanPrice,Lc_Changed:boolean;
oldPrice,oldAmount:real;
{ Private declarations }
public
Added:boolean;
procedure InitControls; Override;
procedure SaveBodyData; Override;
procedure SetWhPosition(PWhCode,PPosition,Qry_Month:String);
procedure SetStatus(CurrentStatus:String;var EnableControls:String);Override;
procedure SetFormParam(FrmParam1,FrmParam2,FrmParam3,FrmParam4,FrmParam5,FrmParam6:string);OverRide;
{ Public declarations }
end;
var
Frm_Inv_OtherOut_D: TFrm_Inv_OtherOut_D;
implementation
uses Inv_OtherOut_H,Sys_Global,Inv_Global, Inv_OtherOut_B;
{$R *.DFM}
procedure TFrm_Inv_OtherOut_D.InitControls;
begin
inherited;
//初始化明细窗体的各组件
with AdoQry_Body do
begin
ExtEdt_ItemCode.Text:=fieldbyname('ItemCode').AsString;
Lbl_ItemName.Caption:=fieldbyname('ItemName').AsString;
Edt_Qty.Text:=fieldbyname('InvBillQty').AsString;
Edt_BatchNo.Text:=fieldbyname('BatchNo').asString;
InvBillMonth:=fieldbyname('InvBillMonth').asstring;
edt_NotaxPrice.text:=fieldbyname('InvBillNoTaxPrice').asString;
edt_NotaxAmount.text:=fieldbyname('InvBillNoTaxAmount').asstring;
lbl_Uom.Caption:=fieldbyname('UomName').asstring;
end;
if Pnl_Add.Caption='增加' then
begin
Edt_Qty.Text:='0';
Edt_NotaxPrice.text:='0';
Edt_NotaxAmount.text:='0';
end
else
begin
if not BatchCtrl(AdoQry_Tmp,ExtEdt_ItemCode.Text) then
begin
Edt_BatchNo.clear;
Edt_BatchNo.Color:=clmenu;
Edt_BatchNo.Enabled:=False;
end
else
begin
Edt_BatchNo.Color:=clwindow;
Edt_BatchNo.Enabled:=True;
end;
end;
end;
procedure TFrm_Inv_OtherOut_D.SaveBodyData;
var
mypost:TDataSetNotifyEvent;
begin
//对Qry_BODY中的记录给值
mypost:=AdoQry_Body.AfterScroll;
AdoQry_Body.AfterScroll:=nil;
inherited;
if AdoQry_Body.RecordCount>=Frm_Inv_OtherOut_H.Billlines then
begin
DispInfo('本单据最多只允许输入'+inttostr(Frm_Inv_OtherOut_H.Billlines)+'条单据行',1);
abort;
end
else
with AdoQry_Body do
begin
if status='Add' then
begin
// Added:=True;
Insert;
fieldbyname('InvBilllineno').asinteger:=recordCount+1;
fieldbyname('ItemCode').AsString:=ExtEdt_ItemCode.Text;
fieldbyname('ItemName').AsString:=Lbl_ItemName.Caption;
fieldbyname('InvBillNotaxPrice').asstring:=edt_NotaxPrice.text;
fieldbyname('InvBillNoTaxAmount').asstring:=edt_NotaxAmount.text;
fieldbyname('InvBillqty').AsString:=Edt_qty.Text;
fieldbyname('BatchNo').asstring:=Edt_BatchNo.text;
fieldbyname('UomName').asstring:=lbl_Uom.Caption;
fieldbyname('BillLineRemArk').asstring:=Edt_Memo.Text;
Post;
end
else
begin
edit;
fieldbyname('InvBillNotaxPrice').asstring:=edt_NotaxPrice.text;
fieldbyname('InvBillNoTaxAmount').asstring:=edt_NotaxAmount.text;
fieldbyname('InvBillqty').AsString:=Edt_qty.Text;
fieldbyname('BatchNo').asstring:=Edt_BatchNo.text;
fieldbyname('UomName').asstring:=lbl_Uom.Caption;
fieldbyname('BillLineRemArk').asstring:=Edt_Memo.Text;
post;
end;
end;
AdoQry_Body.AfterScroll:=mypost;
end;
procedure TFrm_Inv_OtherOut_D.Edt_QtyExit(Sender: TObject);
var
i:integer;
Book1:TBookMArk;
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
//对数量进行有效性检查
Floatcheck(Sender);
If StrToFloat(Edt_Qty.Text)=0 then
begin
DispInfo('出库数量不能等于零',1);
Edt_Qty.SetFocus;
Abort;
end;
if not InvQtyCheck
(False,
AdoQry_Body,
AdoQry_tmp,
WhCode,
Position,
ExtEdt_ItemCode.Text,
'InvBillQty',
StrToFloat(Trim(Edt_Qty.Text)),
False) then
begin
Edt_Qty.SetFocus;
abort;
end;
Book1:=AdoQry_Body.GetBookmArk;
AdoQry_Body.First;
for i:=0 to AdoQry_Body.RecordCount-1 do
begin
if (strtofloat(Edt_Qty.text)*AdoQry_Body.fieldbyname('InvBillQty').asfloat<0) and
(AdoQry_Body.fieldbyname('ItemCode').asstring<>Trim(ExtEdt_ItemCode.text))
then
begin
DispInfo('同一次出库,不能出现正负数混合的情况!',1);
Edt_Qty.setfocus;
abort;
end;
AdoQry_Body.next;
end;
AdoQry_Body.GotoBookmArk(Book1);
AdoQry_Body.FreeBookmArk(Book1);
If StrToFloat(Edt_Qty.Text)=0 then
begin
DispInfo('出库数量不能等于零',1);
Edt_Qty.SetFocus;
Abort;
end;
if not Changed then exit;
try
if edt_NotaxPrice.text='' then edt_NotaxPrice.text:='0';
edt_NotaxAmount.Text:=formatfloat('0.00',(strtofloat(edt_NotaxPrice.text)*strtofloat(Edt_Qty.Text)));
except
DispInfo('数量输入错误,请检查!',1);
edt_qty.setfocus;
abort;
end;
end;
procedure TFrm_Inv_OtherOut_D.SetWhPosition(PWhCode, PPosition,Qry_Month: String);
begin
WhCode:=PWhCode;
Position:=PPosition;
QryMonth:=Qry_Month;
end;
procedure TFrm_Inv_OtherOut_D.SetStatus(CurrentStatus: String;
var EnableControls: String);
begin
inherited;
if Status='Add' then
SetFocus_Control:=ExtEdt_ItemCode
else
SetFocus_Control:=Edt_Qty;
EnableControls:='ExtEdt_ItemCode,Edt_Qty,edt_NotaxPrice,edt_NotaxAmount,edt_memo,Edt_BatchNo,';
end;
procedure TFrm_Inv_OtherOut_D.FormActivate(Sender: TObject);
begin
inherited;
//窗体激活时的某些控件的初始化
if Pnl_Add.Caption='增加' then
begin
ExtEdt_ItemCode.Color:=clwindow;
ExtEdt_ItemCode.Enabled:=True;
ExtEdt_ItemCode.SetFocus;
edt_NotaxPrice.text:='';
edt_NotaxPrice.Color:=clwindow;
edt_NotaxAmount.text:='';
edt_NotaxAmount.Color:=clwindow;
end
else
begin
ExtEdt_ItemCode.Color:=clmenu;
Edt_Qty.SetFocus;
ExtEdt_ItemCode.Enabled:=False;
end;
end;
procedure TFrm_Inv_OtherOut_D.edt_NotaxPriceExit(Sender: TObject);
var
a1,a2:real;
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
//未税价的有效性检查
if not Changed then exit;
If StrToFloat(Edt_Qty.Text)=0 then
begin
DispInfo('出库数量不能等于零',1);
Edt_Qty.SetFocus;
Abort;
end;
a1:=round(strtofloat(Trim(edt_NotaxPrice.text))*strtofloat(Trim(edt_qty.text))*100)/100;
{
if (not IsPlanPrice) and (a1>oldAmount) then
// (formatfloat('0.000000',strtofloat(edt_NotaxPrice.text)*strtofloat(edt_qty.text))>
// formatfloat('0.000000',oldAmount)) then
begin
DispInfo('出库价格过大,将导致负的库存金额出现!',1);
edt_NotaxPrice.SetFocus;
abort;
end;
}
try
edt_NotaxAmount.text:=formatfloat('0.00',strtofloat(edt_NotaxPrice.text)*strtofloat(edt_qty.text));
except
DispInfo('未税价输入有误,请检查!',1);
edt_NotaxPrice.setfocus;
abort;
end;
end;
procedure TFrm_Inv_OtherOut_D.edt_NotaxAmountExit(Sender: TObject);
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
//未税金额的有效性检查
if not Changed then
exit;
try
edt_NotaxPrice.text:=floattostr(
strtofloat(edt_NotaxAmount.text)/strtofloat(edt_qty.text));
except
DispInfo('金额输入有误,请检查!',1);
edt_NotaxAmount.setfocus;
abort;
end;
end;
procedure TFrm_Inv_OtherOut_D.ExtEdt_ItemCodeExit(Sender: TObject);
var
Book1:TBookMArk;
begin
inherited;
if ActiveControl.Name='btn_Cancel' then
exit;
//该物料出入库的有效性检查
InOutItemCodeCheck(sender);
Book1:=AdoQry_Body.GetBookmArk;
AdoQry_Body.First;
if AdoQry_Body.locate('ItemCode',ExtEdt_ItemCode.text,[]) then
begin
DispInfo('该物料在本单据中已经存在,不允许增加或修改!',1);
TWinControl(Sender).SetFocus;
Abort;
end;
AdoQry_Body.GotoBookmArk(Book1);
AdoQry_Body.FreeBookmArk(Book1);
if not DefaultWHCheck(AdoQry_tmp,getCode(WhCode),Extedt_ItemCode.text) then
begin
ExtEdt_ItemCode.setfocus;
abort;
end;
if not BatchCtrl(AdoQry_Tmp,ExtEdt_ItemCode.Text) then
begin
Edt_BatchNo.clear;
Edt_BatchNo.Color:=clmenu;
Edt_BatchNo.Enabled:=False;
end
else
begin
Edt_BatchNo.Color:=clwindow;
Edt_BatchNo.Enabled:=True;
end;
with AdoQry_Tmp do
begin
//取是否计划价
Close;
sql.text:='select PriceType '+
' from Warehouse '+
' where whCode='''+whCode+''' ';
Prepared;
open;
if (not eof) and (fieldbyname('PriceType').asinteger=1) then
IsPlanPrice:=True
else IsPlanPrice:=False;
//是否需要计划价的判断
Close;
if IsPlanPrice then
begin
sql.text:='select spPrice '+
' from StandardPrice '+
' where ItemCode='''+Trim(ExtEdt_ItemCode.Text)+''' '+
' and SPStArtMonth='''+QryMonth+'''';
open;
If IsEmpty then
begin
DispInfo('该物料还没有定义计划价!',1);
ExtEdt_ItemCode.setfocus;
exit;
end;
if not Changed then exit;
if not Lc_Changed then exit;
edt_NotaxPrice.Text:=floattostr(fieldbyname('spPrice').asfloat);
edt_NotaxPrice.enabled:=False;
edt_NotaxPrice.color:=clmenu;
edt_NotaxAmount.enabled:=False;
edt_NotaxAmount.color:=clmenu;
end
else
begin
if not Changed then exit;
if not Lc_Changed then exit;
sql.text:='Select '+
' case when Ap.Apqty=0 then Ap.AveragePrice '+
' else Ap.ApAmount/Ap.Apqty end as AveragePrice'+
' ,Ap.ApAmount as ApAmount'+
' from '+
' AveragePrice Ap'+
' where Ap.whCode='''+whCode+''''+
' and Ap.ItemCode='''+ExtEdt_ItemCode.Text+''' ';
open;
if not eof then
begin
edt_NotaxPrice.Text:=floattostr(fieldbyname('AveragePrice').asfloat);
edt_NotaxAmount.Text:='0';
oldPrice:=strtofloat(formatfloat('0.000000',fieldbyname('AveragePrice').asfloat));
oldAmount:=strtofloat(formatfloat('0.00',fieldbyname('ApAmount').asfloat));
edt_NotaxPrice.enabled:=True;
edt_NotaxAmount.enabled:=True;
edt_NotaxAmount.color:=clwindow;
edt_NotaxPrice.color:=clwindow;
end
else
begin
edt_NotaxAmount.Text:='0';
edt_NotaxPrice.Text:='0';
end;
end;
end;
with AdoQry_Tmp do
begin
Close;
sql.clear;
sql.Add('select U.UomName '+
' from Item I'+
' Left Join Uom U'+
' on U.UomCode=I.UomCode'+
' where I.ItemCode='''+Trim(ExtEdt_ItemCode.text)+'''');
open;
if not eof then lbl_Uom.Caption:=fieldbyname('UomName').asstring;
end;
edt_NotaxAmount.text:='0';
Lc_Changed:=False;
end;
procedure TFrm_Inv_OtherOut_D.Edt_BatchNoKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
If Key=VK_F9 then //批次信息提示
Edt_BatchNo.text:=BatchHint(AdoQry_Tmp.Connection,ExtEdt_ItemCode.Text,
'',WhCode,Position);
end;
procedure TFrm_Inv_OtherOut_D.Edt_BatchNoExit(Sender: TObject);
begin
inherited;
If ActiveControl.Name='btn_Cancel' then exit;
//批次号的检测
if not BatchNoCheck(AdoQry_Tmp,Edt_BatchNo.Text,ExtEdt_ItemCode.text,'',
BillDate)then
begin
Edt_BatchNo.setfocus;
Abort;
end;
if not BatchInvCheck(AdoQry_Tmp,Edt_BatchNo.text,'c',WhCode,Position,strtofloat(Edt_Qty.text)) then
begin
Edt_BatchNo.setfocus;
Abort;
end;
end;
procedure TFrm_Inv_OtherOut_D.btn_okClick(Sender: TObject);
begin
If StrToFloat(Edt_Qty.Text)=0 then
begin
DispInfo('出库数量不能等于零',1);
Edt_Qty.SetFocus;
Abort;
end;
if strtofloat(edt_NotaxPrice.text)=0 then
begin
DispInfo('未税价不能等于零!',1);
edt_NotaxPrice.setfocus;
abort;
end;
inherited;
//
end;
procedure TFrm_Inv_OtherOut_D.ExtEdt_ItemCodeChange(Sender: TObject);
begin
inherited;
Lc_Changed:=True;
end;
procedure TFrm_Inv_OtherOut_D.SetFormParam(FrmParam1, FrmParam2, FrmParam3,
FrmParam4, FrmParam5, FrmParam6: string);
begin
inherited;
// Billdate:=frmParam1;
// QryMonth:=copy(Billdate,1,7);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -