📄 inv_batchhint_add.pas
字号:
unit Inv_BatchHint_Add;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Dialog, ExtEdit, StdCtrls, Db, AdODB;
Type
TFrm_Inv_BatchHint_Add = Class(TFrm_Base_Dialog)
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label10: TLabel;
Label12: TLabel;
Label7: TLabel;
Label8: TLabel;
Lbl_Vendor: TLabel;
Lbl_Item: TLabel;
Edt_VendorBatchNo: TEdit;
Edt_UsefulDate: TEdit;
Edt_BatchName: TEdit;
Edt_RemArk: TEdit;
CmBx_UsefulCtrl: TComboBox;
CmBx_BackFlush: TComboBox;
procedure TextCheck(Sender: TObject);
procedure Edt_UsefulDateExit(Sender: TObject);
procedure btn_okClick(Sender: TObject);
procedure CmBx_UsefulCtrlChange(Sender: TObject);
private
{ Private declarations }
ItemCode,VendorCode:String;
public
{ Public declarations }
procedure InitForm(AdOConnection:TAdOConnection;ItemCode,VendorCode:String);
end;
var
Frm_Inv_BatchHint_Add: TFrm_Inv_BatchHint_Add;
implementation
uses Sys_Global;
{$R *.DFM}
procedure TFrm_Inv_BatchHint_Add.InitForm(AdOConnection:TAdOConnection;ItemCode,VendorCode:String);
begin
inherited;
SetDBConnect(AdOConnection);
AdoQry_Tmp.Close;
AdoQry_Tmp.Connection:=AdOConnection;
AdoQry_Tmp.SQL.Text:='Select ItemCode+'' ''+ItemName As ItemCodeName'
+' From Item'
+' Where ItemCode='''+ItemCode+'''';
AdoQry_Tmp.Open;
Lbl_Item.Caption:=AdoQry_Tmp.fieldbyname('ItemCodeName').AsString;
CmBx_BackFlush.ItemIndex:=1;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select VendorCode+'' ''+VendorName As VendorCodeName'
+' From Vendor'
+' Where VendorCode='''+VendorCode+'''';
AdoQry_Tmp.Open;
Lbl_Vendor.Caption:=AdoQry_Tmp.fieldbyname('VendorCodeName').AsString;
Edt_BatchName.Text:='';
Edt_VendorBatchNo.Text:='';
CmBx_UsefulCtrl.ItemIndex:=0;
Edt_UsefulDate.Enabled:=False;
Edt_UsefulDate.Text:='0';
Edt_RemArk.Text:='';
Self.ItemCode:=ItemCode;
Self.VendorCode:=VendorCode;
end;
procedure TFrm_Inv_BatchHint_Add.TextCheck(Sender: TObject);
begin
inherited;
if TEdit(Sender).Text='' then
begin
DispInfo('批次描述不能为空',3);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Inv_BatchHint_Add.Edt_UsefulDateExit(Sender: TObject);
begin
inherited;
IntegerCheck(Sender);
if (CmBx_UsefulCtrl.Text='否') then
begin
TEdit(Sender).Text:='0';
end;
if (CmBx_UsefulCtrl.Text='是')and(StrToInt(TEdit(Sender).Text)<=0) then
begin
DispInfo('有效天数必须大于0',3);
TWinControl(Sender).SetFocus;
Abort;
end;
end;
procedure TFrm_Inv_BatchHint_Add.btn_okClick(Sender: TObject);
var
BatchId,BatchNo:String;
begin
inherited;
DBConnect.beginTrans;
try
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select BatchId'
+' From Batch'
+' Where ItemCode='''+ItemCode+'''';
AdoQry_Tmp.Open;
if AdoQry_Tmp.fieldbyname('BatchId').AsString<>'' then
begin
BatchId:=AdoQry_Tmp.fieldbyname('BatchId').AsString;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Update Batch Set'
+' BackFlush='+IntToStr(CmBx_BackFlush.ItemIndex)+''
+' Where BatchId='''+BatchId+'''';
AdoQry_Tmp.ExecSQL;
end
else
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert Batch (ItemCode,BackFlush)'
+' Values ('
+' '''+ItemCode+''''
+','+IntToStr(CmBx_BackFlush.ItemIndex)+')';
AdoQry_Tmp.ExecSQL;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Select @@identity as BatchId';
AdoQry_Tmp.Open;
BatchId:=AdoQry_Tmp.fieldbyname('BatchId').AsString;
end;
BatchNo:=GetNo(DBConnect,FormatDateTime('yyyy-mm-',Now),'BT');
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Insert BatchLine (BatchId,BatchNo,BatchName,VendorCode'
+',VendorBatchNo,UsefulCtrl,UsefulDate,BatchLineRemArk)'
+' Values ('
+' '+BatchId+''
+','''+BatchNo+''''
+','''+Edt_BatchName.Text+''''
+','''+VendorCode+''''
+','''+Edt_VendorBatchNo.Text+''''
+','+IntToStr(CmBx_UsefulCtrl.ItemIndex)+''
+','+Edt_UsefulDate.Text+''
+','''+Edt_RemArk.Text+''''
+')';
AdoQry_Tmp.ExecSQL;
DBConnect.CommitTrans;
except
DBConnect.RollBackTrans;
DispInfo('增加批次失败',3);
Abort;
end;
ModalResult:=mrOk;
end;
procedure TFrm_Inv_BatchHint_Add.CmBx_UsefulCtrlChange(Sender: TObject);
begin
inherited;
if (CmBx_UsefulCtrl.Text='否') then
Edt_UsefulDate.Enabled:=False
else
Edt_UsefulDate.Enabled:=True;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -