📄 sal_enter_othershiporder_d.pas
字号:
unit Sal_Enter_OtherShipOrder_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Detail, Db, AdODB, ExtCtrls, StdCtrls, ExtEdit, linkedit;
Type
TFrm_Sal_Enter_OtherShipOrder_D = Class(TFrm_Base_Entry_Detail)
Label1: TLabel;
Label2: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Lab_ItemName: TLabel;
Label14: TLabel;
Label13: TLabel;
Edt_ShipQty: TEdit;
Edt_TaxPrice: TEdit;
Edt_TaxAmount: TEdit;
Edt_NoTaxPrice: TEdit;
Edt_NoTaxAmount: TEdit;
Edt_DiSCountRate: TEdit;
Edt_DiSCountAmount: TEdit;
Edt_ShipLineRemArk: TEdit;
Label16: TLabel;
Label17: TLabel;
Edt_ShipLineNo: TEdit;
Edt_WhCode: TEdit;
Edt_WhPositionCode: TEdit;
Edt_BatchNo: TEdit;
Edt_WhName: TEdit;
Edt_WhPositionName: TEdit;
Edt_ItemName: TEdit;
ExtEdt_ItemCode: TLinkEdit;
Label3: TLabel;
procedure ExtEdt_ItemCodeKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure ExtEdt_ItemCodeExit(Sender: TObject);
procedure Edt_TaxPriceExit(Sender: TObject);
procedure Edt_NoTaxPriceExit(Sender: TObject);
procedure Edt_ShipQtyExit(Sender: TObject);
procedure Edt_DiSCountRateExit(Sender: TObject);
procedure btn_okClick(Sender: TObject);
procedure ExtEdt_ItemCodeButtonClick(Sender: TObject);
private
UomName:String; //记录当前单位
{ Private declarations }
public
LineNo:Integer;//行号
procedure InitControls; Override;
procedure SaveBodyData; Override;
procedure SetStatus(CurrentStatus:String;var EnableControls:String);Override;
{ Public declarations }
end;
var
Frm_Sal_Enter_OtherShipOrder_D: TFrm_Sal_Enter_OtherShipOrder_D;
implementation
uses Sys_Global, Sal_Enter_OtherShipOrder;
{$R *.DFM}
{ TFrm_Sal_Enter_ShjpOrder_D }
procedure TFrm_Sal_Enter_OtherShipOrder_D.InitControls;
begin
inherited;
If (status='Add') Then
SetFocus_Control:=ExtEdt_ItemCode
Else
SetFocus_Control:=Edt_ShipQty;
Inherited;
with AdoQry_Body do
begin
ExtEdt_ItemCode.Text:=fieldbyname('ItemCode').AsString;
Lab_ItemName.Caption:=fieldbyname('ItemName').AsString;
Edt_ItemName.Text := fieldbyname('ItemName').AsString;
UomName:=fieldbyname('UomName').AsString;
If (Status='Add') then
begin
LineNo:=LineNo+1;
Edt_ShipLineNo.Text := IntToStr(LineNo);
Edt_ShipQty.Text:='0';
Edt_TaxPrice.Text:='0';
Edt_TaxAmount.Text:='0';
Edt_NoTaxPrice.Text:='0';
Edt_NoTaxAmount.Text:='0';
Edt_DiSCountRate.Text:='0';
Edt_DiSCountAmount.Text:='0';
Edt_ShipLineRemArk.Text:='';
end
else
begin
LineNo := fieldbyname('InvBillLineNo').AsInteger;
Edt_ShipLineNo.Text:=fieldbyname('InvBillLineNo').AsString;
Edt_BatchNo.Text:=fieldbyname('BatchNo').AsString;
Edt_ShipQty.Text:=fieldbyname('InvBillQty').AsString;
Edt_TaxPrice.Text:=fieldbyname('InvBillPrice').AsString;
Edt_TaxAmount.Text:=fieldbyname('InvBillAmount').AsString;
Edt_NoTaxPrice.Text:=fieldbyname('InvBillNoTaxPrice').AsString;
Edt_NoTaxAmount.Text:=fieldbyname('InvBillNoTaxAmount').AsString;
Edt_DiSCountRate.Text:=fieldbyname('DiSCountRate').AsString;
Edt_DiSCountAmount.Text:=fieldbyname('DiSCountAmount').AsString;
Edt_ShipLineRemArk.Text:=fieldbyname('BillLineRemArk').AsString;
end;
end;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.SaveBodyData;
begin
inherited;
If Status='Add' Then
AdoQry_Body.Append
Else
AdoQry_Body.Edit;
with AdoQry_Body do
begin
fieldbyname('InvBillLineNo').AsString:=Edt_ShipLineNo.Text;
fieldbyname('BatchNo').AsString:=Edt_BatchNo.Text;
fieldbyname('UomName').AsString:=UomName;
fieldbyname('ItemCode').AsString:=ExtEdt_ItemCode.Text;
fieldbyname('ItemName').AsString:=Edt_ItemName.Text;
{ fieldbyname('WhCode').AsString:=Edt_WhCode.Text;
fieldbyname('WhName').AsString:=Edt_WhName.Text;
fieldbyname('WhPositionCode').AsString:=Edt_WhPositionCode.Text;
fieldbyname('WhPositionName').AsString:=Edt_WhPositionName.Text;
}
fieldbyname('TmpField').AsInteger := IIFInteger(Status='Add',1,0);
fieldbyname('InvBillQty').AsString:=Edt_ShipQty.Text;
fieldbyname('InvBillPrice').AsString:=Edt_TaxPrice.Text;
fieldbyname('InvBillAmount').AsString:=Edt_TaxAmount.Text;
fieldbyname('InvBillNoTaxPrice').AsString:=Edt_NoTaxPrice.Text;
fieldbyname('InvBillNoTaxAmount').AsString:=Edt_NoTaxAmount.Text;
fieldbyname('DiSCountRate').AsString:=Edt_DiSCountRate.Text;
fieldbyname('DiSCountAmount').AsString:=Edt_DiSCountAmount.Text;
fieldbyname('BillLineRemArk').AsString:=Edt_ShipLineRemArk.Text;
fieldbyname('UomName').AsString:=UomName;
Post;
end;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.SetStatus(CurrentStatus: String;
var EnableControls: String);
begin
inherited;
if(CurrentStatus='Add')then
EnableControls:=' ExtEdt_ItemCode,Edt_ShipQty,Edt_BatchNo,Edt_WhCode,Edt_WhPositionCode,'
+' Edt_DiSCountRate,Edt_DiSCountAmount,Edt_ShipLineRemArk,Edt_BatchNo,'
else
EnableControls:=' ExtEdt_ItemCode,Edt_ShipQty,Edt_BatchNo,Edt_WhPositionCode,'
+' Edt_DiSCountRate,Edt_DiSCountAmount,Edt_ShipLineRemArk,Edt_BatchNo,' ;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select SalePriceContrl From Customer Where CustomerCode='''+CustomerCode+''' ';
AdoQry_Tmp.Open;
if AdoQry_Tmp.fieldbyname('SalePriceContrl').AsInteger =0 then
begin
EnableControls:=EnableControls+'Edt_TaxPrice,Edt_NoTaxPrice,'
end;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.ExtEdt_ItemCodeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
If key=120 Then
CommOnHint(Sender,AdoQry_Tmp,'ItemName','物料描述 |当前库存','ItemCode',
'物料代码',' (select ItemCode, convert(chAr(40),substring(ItemName,1,50)) +''|''+convert(varchAr,CurrentonhandInv) as ItemName from Item '
+' where ItemUsable=1 and ItemType=0 and canSale=1 and ItemCode in (select ItemCode from CurrentInv where WhCode='+quotedstr(WhCode)+' and WhPositionCode='+Quotedstr(WhPositionCode)+') ) as tmp ');
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.ExtEdt_ItemCodeExit(Sender: TObject);
var
sqltext:string;
begin
inherited;
If ActiveControl.Name='btn_Cancel' Then
Exit;
SqlText:=' Select Item.*,Uom.UomName from Item '
+' left join Uom on Item.UomCode=Uom.UomCode '
+' where ItemUsable=1 And ItemType=0 And ItemCode='''+Trim(ExtEdt_ItemCode.Text)+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.clear;
AdoQry_Tmp.SQL.Text :=SqlText;
AdoQry_Tmp.Open;
if AdoQry_Tmp.Eof then
begin
DispInfo('该物料无效,不能输入!',3);
TwinControl(sender).setfocus;
Abort;
end;
{ SqlText:=' Select CurrentInv.ItemCode,Item.ItemName,UomName '
+' From CurrentInv '
+' Join Item on CurrentInv.ItemCode=Item.ItemCode and Item.ItemUsable=1 and ItemType=0 and canSale=1 '
+' Left Outer Join Uom On Item.UomCode=Uom.UomCode '
+' Where CurrentInv.ItemCode='+''''+Trim(ExtEdt_ItemCode.Text)+''''
+' and CurrentInv.WhCode='+quotedstr(WhCode)
+' and CurrentInv.WhPositionCode='+quotedSTr(WhPositionCode);
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
If AdoQry_Tmp.Eof Then
begin
DispInfo('输入了错误的物料代码,请重新输入!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
}
UomName:=AdoQry_Tmp.fieldbyname('UomName').AsString;
Lab_ItemName.Caption:=AdoQry_Tmp.fieldbyname('ItemName').AsString;
Edt_ItemName.Text:=AdoQry_Tmp.fieldbyname('ItemName').AsString;
SQlText:=' Select Item.WhCode,WhName from Item '
+' Join Warehouse '
+' on Item.WhCode=Warehouse.WhCode'
+' Where ItemCode='''+Trim(ExtEdt_ItemCode.Text)+'''';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
Edt_WhCode.Text := AdoQry_Tmp.fieldbyname('WhCode').AsString;
Edt_WhName.Text:= AdoQry_Tmp.fieldbyname('WhName').AsString;
SqlText:=' Select Top 1 NoTaxPrice,TaxPrice '
+' From Sa_SaleContractLine '
+' Join Sa_SaleContract '
+' On Sa_SaleContractLine.SlcNo=Sa_SaleContract.SlcNo '
+' Where CustomerCode='''+CustomerCode+''' And StArtDate<='''+ShipDate+''' '
+' And endDate>='''+ShipDate+''' And ItemCode='''+ExtEdt_ItemCode.Text+''' '
+' Order By CreateDate DESC ';
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:=SqlText;
AdoQry_Tmp.Open;
if Not AdoQry_Tmp.Eof then
begin
Edt_TaxPrice.Text :=AdoQry_Tmp.fieldbyname('TaxPrice').AsString;
Edt_NoTaxPrice.Text :=AdoQry_Tmp.fieldbyname('NoTaxPrice').AsString;
end;
if StrToFloat(Edt_TaxPrice.text) <> 0 then
begin
Edt_TaxAmount.Text:= FloatToStr(StrToFloat(Edt_TaxPrice.text)*StrToFloat(Edt_ShipQty.text));
Edt_NoTaxAmount.Text:= FloatToStr(StrToFloat(Edt_NoTaxPrice.text)*StrToFloat(Edt_ShipQty.text));
end;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.Edt_TaxPriceExit(Sender: TObject);
begin
inherited;
if ActiveControl <> btn_Cancel then
begin
try
Edt_TaxPrice.Text := FloattoStr(StrToFloat(Edt_TaxPrice.Text));
except
DispInfo('请输入数据类型!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
if StrToFloat(Edt_TaxPrice.Text)<=0 then
begin
DispInfo('含税单价不能小于或等于0!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
if Edt_TaxPrice.Modified then
begin
Edt_NoTaxPrice.Text:=FloatToStr(StrToFloat(Edt_TaxPrice.Text)/(1+StrtoFloat(TaxRate_Percent)/100));
Edt_TaxAmount.Text:= FloatToStr(StrToFloat(Edt_TaxPrice.text)*StrToFloat(Edt_ShipQty.text));
Edt_NoTaxAmount.Text:= FloatToStr(StrToFloat(Edt_NoTaxPrice.text)*StrToFloat(Edt_ShipQty.text));
end;
end;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.Edt_NoTaxPriceExit(Sender: TObject);
begin
inherited;
if ActiveControl <> btn_Cancel then
begin
try
Edt_NoTaxPrice.Text := FloatToStr(StrToFloat(Edt_NoTaxPrice.Text));
except
DispInfo('请输入数据类型!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
if StrToFloat(Edt_NoTaxPrice.Text)<0 then
begin
DispInfo('未税单价不能小于!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
if Edt_NoTaxPrice.Modified then
begin
Edt_TaxPrice.Text:=FloatToStr(StrToFloat(Edt_NoTaxPrice.Text)*(1+StrtoFloat(TaxRate_Percent)/100));
Edt_TaxAmount.Text:= FloatToStr(StrToFloat(Edt_TaxPrice.text)*StrToFloat(Edt_ShipQty.text));
Edt_NoTaxAmount.Text:= FloatToStr(StrToFloat(Edt_NoTaxPrice.text)*StrToFloat(Edt_ShipQty.text));
end;
end;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.Edt_ShipQtyExit(Sender: TObject);
begin
inherited;
if ActiveControl <> btn_Cancel then
begin
try
Edt_ShipQty.text := floattostr(StrToFloat(Edt_ShipQty.Text));
except
DispInfo('请输入数据类型!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
{ if StrToFloat(Edt_ShipQty.Text)<=0 then
begin
DispInfo('约定交货量不能小于或等于0!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
}
if StrToFloat(Edt_TaxPrice.text) <> 0 then
begin
Edt_TaxAmount.Text:= FloatToStr(StrToFloat(Edt_TaxPrice.text)*StrToFloat(Edt_ShipQty.text));
Edt_NoTaxAmount.Text:= FloatToStr(StrToFloat(Edt_NoTaxPrice.text)*StrToFloat(Edt_ShipQty.text));
end;
end;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.Edt_DiSCountRateExit(Sender: TObject);
begin
inherited;
if ActiveControl <> btn_Cancel then
begin
try
Edt_DiSCountRate.Text := FloatToStr(StrToFloat(Edt_DiSCountRate.Text));
except
DispInfo('请输入数据类型!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
if StrToFloat(Edt_DiSCountRate.Text)<0 then
begin
DispInfo('未税单价不能小于0!',3);
TWincontrol(Sender).SetFocus;
Abort;
end;
if Edt_DiSCountRate.Modified then
Edt_DiSCountAmount.Text:= FloatToStr(StrToFloat(Edt_TaxAmount.text)*StrToFloat(Edt_DiSCountRate.text)/100);
end;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.btn_okClick(Sender: TObject);
begin
try
Edt_TaxPrice.Text := FloattoStr(StrToFloat(Edt_TaxPrice.Text));
except
DispInfo('请输入数据类型!',3);
if Edt_TaxPrice.CanFocus then
Edt_TaxPrice.SetFocus;
Abort;
end;
if StrToFloat(Edt_TaxPrice.Text)<=0 then
begin
DispInfo('含税单价不能小于或等于0!',3);
if Edt_TaxPrice.CanFocus then
Edt_TaxPrice.SetFocus;
Abort;
end;
try
Edt_NoTaxPrice.Text := FloatToStr(StrToFloat(Edt_NoTaxPrice.Text));
except
DispInfo('请输入数据类型!',3);
if Edt_NoTaxPrice.CanFocus then
Edt_NoTaxPrice.SetFocus;
Abort;
end;
if StrToFloat(Edt_NoTaxPrice.Text)<=0 then
begin
DispInfo('未税单价不能小于或等于0!',3);
if Edt_NoTaxPrice.CanFocus then
Edt_NoTaxPrice.SetFocus;
Abort;
end;
inherited;
end;
procedure TFrm_Sal_Enter_OtherShipOrder_D.ExtEdt_ItemCodeButtonClick(
Sender: TObject);
begin
inherited;
CommOnHint(Sender,AdoQry_Tmp,'ItemName','物料描述 |当前库存','ItemCode',
'物料代码',' (select ItemCode, convert(chAr(40),substring(ItemName,1,50)) +''|''+convert(varchAr,CurrentonhandInv) as ItemName from Item '
+' where ItemUsable=1 and ItemType=0 and canSale=1 and ItemCode in (select ItemCode from CurrentInv where WhCode='+quotedstr(WhCode)+' and WhPositionCode='+Quotedstr(WhPositionCode)+') ) as tmp ');
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -