📄 sal_enter_shiporder_d.pas
字号:
unit Sal_Enter_ShipOrder_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Entry_Detail, Db, AdODB, ExtCtrls, StdCtrls, ExtEdit, linkedit;
// SkinEngine;
Type
TFrm_Sal_Enter_ShipOrder_D = Class(TFrm_Base_Entry_Detail)
Label1: TLabel;
Label2: TLabel;
Label4: 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_SloLineNo: TEdit;
Edt_ShipQty: TEdit;
Edt_TaxPrice: TEdit;
Edt_TaxAmount: TEdit;
Edt_NoTaxPrice: TEdit;
Edt_NoTaxAmount: TEdit;
Edt_DiSCountRate: TEdit;
Edt_DiSCountAmount: TEdit;
Edt_ShipLineRemArk: TEdit;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Edt_SloNo: TEdit;
Edt_ShipLineNo: TEdit;
Edt_WhCode: TEdit;
Edt_WhPositionCode: TEdit;
Edt_BatchNo: TEdit;
Edt_WhName: TEdit;
Edt_WhPositionName: TEdit;
Edt_ItemName: TEdit;
Label3: TLabel;
ExtEdt_ItemCode: TLinkEdit;
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 ExtEdt_ItemCodeButtonClick(Sender: TObject);
procedure Edt_WhCodeKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edt_WhCodeExit(Sender: TObject);
procedure Edt_WhPositionCodeKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure Edt_WhPositionCodeExit(Sender: TObject);
private
UomName:String; //记录当前单位
LineNo:Integer;//行号
{ Private declarations }
public
procedure InitControls; Override;
procedure SaveBodyData; Override;
procedure SetStatus(CurrentStatus:String;var EnableControls:String);Override;
{ Public declarations }
end;
var
Frm_Sal_Enter_ShipOrder_D: TFrm_Sal_Enter_ShipOrder_D;
implementation
uses Sys_Global, Sal_Enter_ShipOrder;
{$R *.DFM}
{ TFrm_Sal_Enter_ShjpOrder_D }
procedure TFrm_Sal_Enter_ShipOrder_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:=RecordCount+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
Edt_ShipLineNo.Text:=fieldbyname('InvBillLineNo').AsString;
Edt_SloNo.Text:=fieldbyname('SloNo').AsString;
Edt_SloLineNo.Text:=fieldbyname('SloLineNo').AsString;
Edt_BatchNo.Text:=fieldbyname('BatchNo').AsString;
// Edt_WhCode.Text:=fieldbyname('WhCode').AsString;
// Edt_WhName.Text:=fieldbyname('WhName').AsString;
// Edt_WhPositionCode.Text:=fieldbyname('WhPositionCode').AsString;
// Edt_WhPositionName.Text:=fieldbyname('WhPositionName').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_ShipOrder_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('SloNo').AsString:=Edt_SloNo.Text;
fieldbyname('SloLineNo').AsString:=Edt_SloLineNo.Text;
fieldbyname('BatchNo').AsString:=Edt_BatchNo.Text;
// Edt_UomName.Text:=fieldbyname('UomName').AsString;
// ExtEdt_ItemCode.Text:=fieldbyname('ItemCode').AsString;
// Edt_ItemName.Text:=fieldbyname('ItemName').AsString;
// 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').AsString := fieldbyname('InvBillQty').AsString;
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_ShipOrder_D.SetStatus(CurrentStatus: String;
var EnableControls: String);
begin
inherited;
if(CurrentStatus='Add')then
EnableControls:=' ExtEdt_ItemCode,Edt_ShipQty,'
+' Edt_DiSCountRate,Edt_DiSCountAmount,Edt_WhCode,Edt_WhPositionCode,Edt_ShipLineRemArk,'
else
EnableControls:=' Edt_ShipQty,Edt_BatchNo,'
+' Edt_DiSCountRate,Edt_DiSCountAmount,Edt_WhCode,Edt_WhPositionCode,Edt_ShipLineRemArk,' ;
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_ShipOrder_D.ExtEdt_ItemCodeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
If key=120 Then
CommOnHint(Sender,AdoQry_Tmp,'ItemName','物料描述','ItemCode',
'物料代码',' Item ');
end;
procedure TFrm_Sal_Enter_ShipOrder_D.ExtEdt_ItemCodeExit(Sender: TObject);
var
sqltext:string;
begin
inherited;
If ActiveControl.Name='btn_Cancel' Then
Exit;
SqlText:=' Select * from Item where ItemUsable=1 And ItemCode=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 Item.ItemName,UomName '
+' From Item '
+' Left Outer Join Uom On Item.UomCode=Uom.UomCode '
+' Where ItemCode='+''''+Trim(ExtEdt_ItemCode.Text)+'''';
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;
end;
procedure TFrm_Sal_Enter_ShipOrder_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_ShipOrder_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('未税单价不能小于或等于0!',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_ShipOrder_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_ShipOrder_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_ShipOrder_D.ExtEdt_ItemCodeButtonClick(
Sender: TObject);
begin
inherited;
CommOnHint(Sender,AdoQry_Tmp,'ItemName','物料描述','ItemCode',
'物料代码',' Item ');
end;
procedure TFrm_Sal_Enter_ShipOrder_D.Edt_WhCodeKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
inherited;
if key =120 then
CommOnHint(Sender,AdoQry_Tmp,'WHName','仓库名称','WHCode',
'仓库代码',' Warehouse ');
end;
procedure TFrm_Sal_Enter_ShipOrder_D.Edt_WhCodeExit(Sender: TObject);
begin
inherited;
Executesql(AdoQry_tmp,'select * from Warehouse where WHCode='+quotedstr(Trim(edt_WhCode.text)),0);
edt_WhName.Text:=AdoQry_tmp.fieldbyname('whName').asstring;
end;
procedure TFrm_Sal_Enter_ShipOrder_D.Edt_WhPositionCodeKeyDown(
Sender: TObject; var Key: Word; Shift: TShiftState);
begin
inherited;
if key =120 then
CommOnHint(Sender,AdoQry_Tmp,'WhPositionName','货位名称','WhPositionCode',
'货位代码',' WhPosition ','whCode='+quotedstr(Trim(edt_WhCode.text)));
end;
procedure TFrm_Sal_Enter_ShipOrder_D.Edt_WhPositionCodeExit(
Sender: TObject);
var sqltext:string;
begin
inherited;
sqltext:='select whCode,WhPositionCode,WhPositionName from WhPosition'
+' where whCode='+quotedstr(Trim(edt_WhCode.text))
+' and WhPositionCode='+quotedstr(Trim(edt_WhPositionCode.text));
Executesql(AdoQry_tmp,sqltext,0) ;
edt_WhPositionName.Text:=AdoQry_tmp.fieldbyname('WhPositionName').asstring;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -