📄 bas_batchclose.pas
字号:
unit Bas_BatchClose;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Check, Menus, Db, ActnList, AdODB, Grids, DBGridEh, StdCtrls,
ExtCtrls, ComCtrls, ToolWin, DBCtrls, ExtPrintReport, jpeg;
Type
TFrm_Bas_BatchClose = Class(TFrm_Base_Check)
DBText2: TDBText;
Label2: TLabel;
AdoQry_HeadItemCode: TStringField;
AdoQry_HeadBatchno: TStringField;
AdoQry_HeadBatchName: TStringField;
AdoQry_HeadUomName: TStringField;
AdoQry_HeadBackflush: TIntegerField;
AdoQry_HeadusefulCtrl: TIntegerField;
AdoQry_Headusefuldate: TIntegerField;
AdoQry_HeadBatchstatus: TIntegerField;
AdoQry_HeadVendorCode: TStringField;
AdoQry_HeadVendorBatchno: TStringField;
AdoQry_HeadBatchlineremArk: TStringField;
AdoQry_HeadFirstindate: TDateTimeField;
AdoQry_HeadCurrentindate: TDateTimeField;
AdoQry_HeadFirstoutdate: TDateTimeField;
AdoQry_HeadCurrentoutdate: TDateTimeField;
AdoQry_HeadBatchInv: TFloatField;
AdoQry_HeadInvQty: TFloatField;
AdoQry_Headtmpflag: TIntegerField;
AdoQry_Headusedate: TIntegerField;
procedure Act_CheckExecute(Sender: TObject);
procedure Act_CancelCheckExecute(Sender: TObject);
procedure AdoQry_HeadCalcFields(DataSet: TDataSet);
procedure Act_FilterExecute(Sender: TObject);
procedure DBGridEhTitleBtnClick(Sender: TObject; ACol: Integer;
Column: TColumnEh);
private
checktmp:boolean;
{ Private declarations }
public
{ Public declarations }
procedure InitForm(AdOConnection:TAdOConnection;ReadOnly:Boolean);Override;
end;
var
Frm_Bas_BatchClose: TFrm_Bas_BatchClose;
implementation
uses Sys_Global,Bas_BatchClose_C;
{$R *.DFM}
{ TFrm_Pm_Pc_Check }
procedure TFrm_Bas_BatchClose.InitForm(AdOConnection: TAdOConnection;
ReadOnly: Boolean);
begin
inherited;
checktmp:=False;
// PriceFields:='PcNoTaxPrice,PcTaxPrice,';
SelectFromSQL:='select Batch.ItemCode+'''+' '+'''+Item.ItemName ItemCode,Batchline.Batchno'+
',Batchline.BatchName,Item.UomName,Batch.Backflush,'+
'Batchline.usefulCtrl,Batchline.usefuldate,Batchline.Batchstatus,'+
'Batchline.VendorCode+'''+' '+'''+Vendor.VendorName VendorCode,'+
'Batchline.VendorBatchno,Batchline.BatchlineremArk,'+
'Batchline.Firstindate,Currentindate,Firstoutdate,'+
'Currentoutdate,BatchInv,BatchCurrentInv.InvQty,Batchline.Batchstatus tmpflag '+
'from Batch join Batchline on Batch.Batchid=Batchline.Batchid '+
'left join (select Batchno,sum(InvQty) InvQty from BatchCurrentInv group by Batchno) BatchCurrentInv'+
' on BatchCurrentInv.Batchno=Batchline.Batchno'+
' join Vendor on Batchline.VendorCode=Vendor.VendorCode'+
' join (select Item.*,Uom.UomName from Item join Uom on'+
' Item.UomCode=Uom.UomCode) Item on Item.ItemCode=Batch.ItemCode';
OrderByFields:='ItemCode';
Frm_Sys_Condition:=TFrm_Bas_BatchClose_C.Create(Self);
TFrm_Bas_BatchClose_C(Frm_Sys_Condition).InitForm(AdoQry_Head.Connection,UserCode,LoginDate);
Condition:='Batchline.BatchStatus=0';
getdata;
// Act_Filter.Execute;
end;
procedure TFrm_Bas_BatchClose.Act_CheckExecute(Sender: TObject);
var
BookmArk:TBookmArk;
begin
inherited;
if DispInfo('确定关闭选定的批次项?',2)='n' then
Exit;
AdoQry_Head.DisableControls;
BookmArk:=AdoQry_Head.GetBookmArk;
AdoQry_Head.First;
while not AdoQry_Head.Eof do
begin
if AdoQry_Head.fieldbyname('TmpFlag').AsString='1' then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Update Batchline Set Batchstatus=1'
+' Where Batchno='''+AdoQry_Head.fieldbyname('Batchno').AsString+'''';
AdoQry_Tmp.ExecSQL;
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('BatchStatus').AsString:='1';
AdoQry_Head.fieldbyname('TmpFlag').AsString:='0';
AdoQry_Head.Post;
end;
AdoQry_Head.Next;
end;
AdoQry_Head.GotoBookmArk(BookmArk);
AdoQry_Head.FreeBookmArk(BookmArk);
AdoQry_Head.EnableControls;
end;
procedure TFrm_Bas_BatchClose.Act_CancelCheckExecute(Sender: TObject);
var
BookmArk:TBookmArk;
begin
inherited;
if DispInfo('确定打开选定的批次项?',2)='n' then
Exit;
AdoQry_Head.DisableControls;
BookmArk:=AdoQry_Head.GetBookmArk;
AdoQry_Head.First;
while not AdoQry_Head.Eof do
begin
if AdoQry_Head.fieldbyname('TmpFlag').AsString='1' then
begin
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Update Batchline Set BatchStatus=0'
+' Where Batchno='''+AdoQry_Head.fieldbyname('Batchno').AsString+'''';
AdoQry_Tmp.ExecSQL;
AdoQry_Head.Edit;
AdoQry_Head.fieldbyname('BatchStatus').AsString:='0';
AdoQry_Head.fieldbyname('TmpFlag').AsString:='0';
AdoQry_Head.Post;
end;
AdoQry_Head.Next;
end;
AdoQry_Head.GotoBookmArk(BookmArk);
AdoQry_Head.FreeBookmArk(BookmArk);
AdoQry_Head.EnableControls;
end;
procedure TFrm_Bas_BatchClose.AdoQry_HeadCalcFields(DataSet: TDataSet);
begin
inherited;
if (AdoQry_Head.fieldbyname('usefulCtrl').asstring='1') and
(not AdoQry_Head.fieldbyname('Firstindate').IsNull) then
AdoQry_Head.fieldbyname('usedate').asinteger:=DateTimeToTimeStamp(now).date-DateTimeToTimeStamp(AdoQry_Head.fieldbyname('Firstindate').asdatetime).date;
end;
procedure TFrm_Bas_BatchClose.Act_FilterExecute(Sender: TObject);
var
condstr:string;
begin
if Frm_Sys_Condition.ShowModal=mrOk then
begin
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).cmbx_Batchstatus.Text='打开') then
begin
condstr:='where Batchline.Batchstatus=0 ';
lbl_Condition.Caption :='批次状态:打开';
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text<>'') then
begin
condstr:=condstr+'and Item.ItemCode='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text+'''';
lbl_Condition.Caption:=lbl_Condition.Caption+'/物料代码='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text+'''';
end;
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text<>'') then
begin
condstr:=condstr+' and Batchline.Batchno='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text+'''';
lbl_Condition.Caption:=lbl_Condition.Caption+'/批次号='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text+'''';
end;
end;
if TFrm_Bas_BatchClose_C(Frm_Sys_Condition).cmbx_Batchstatus.Text='关闭' then
begin
condstr:='where Batchline.Batchstatus=1 ';
lbl_Condition.Caption:='批次状态:关闭';
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text<>'') then
begin
condstr:=condstr+'and Item.ItemCode='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text+'''';
lbl_Condition.Caption:=lbl_Condition.Caption+'/物料代码='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text+'''';
end;
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text<>'') then
begin
condstr:=condstr+' and Batchline.Batchno='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text+'''';
lbl_Condition.Caption:=lbl_Condition.Caption+'/批次号='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text+'''';
end;
end;
if TFrm_Bas_BatchClose_C(Frm_Sys_Condition).cmbx_Batchstatus.Text='全部' then
begin
condstr:='where (Batchline.Batchstatus=0 or Batchline.Batchstatus=1) ';
lbl_Condition.Caption:='批次状态:全部';
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text<>'') then
begin
condstr:=condstr+'and Item.ItemCode='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text+'''';
lbl_Condition.Caption:=lbl_Condition.Caption+'/物料代码='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text+'''';
end;
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text<>'') then
begin
condstr:=condstr+' and Batchline.Batchno='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text+'''';
lbl_Condition.Caption:=lbl_Condition.Caption+'/批次号='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text+'''';
end;
end;
if TFrm_Bas_BatchClose_C(Frm_Sys_Condition).cmbx_Batchstatus.Text='' then
begin
condstr:='where (Batchline.Batchstatus=0 or Batchline.Batchstatus=1) ';
lbl_Condition.Caption:='批次状态:全部';
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text<>'') then
begin
condstr:=condstr+'and Item.ItemCode='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text+'''';
lbl_Condition.Caption:=lbl_Condition.Caption+'/物料代码='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).Extedt_ItemCode.Text+'''';
end;
if (TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text<>'') then
begin
condstr:=condstr+' and Batchline.Batchno='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text+'''';
lbl_Condition.Caption:=lbl_Condition.Caption+'/批次号='''+TFrm_Bas_BatchClose_C(Frm_Sys_Condition).edt_Batchno.Text+'''';
end;
end;
// Lbl_Condition.Caption:=Frm_Sys_Condition.ConditionHint;
AdoQry_Head.DisableControls;
AdoQry_Head.Close;
AdoQry_Head.SQL.clear;
SelectFromSQL:='select Batch.ItemCode+'''+' '+'''+Item.ItemName ItemCode,Batchline.Batchno'+
',Batchline.BatchName,Item.UomName,Batch.Backflush,'+
'Batchline.usefulCtrl,Batchline.usefuldate,Batchline.Batchstatus,'+
'Batchline.VendorCode+'''+' '+'''+Vendor.VendorName VendorCode,'+
'Batchline.VendorBatchno,Batchline.BatchlineremArk,'+
'Batchline.Firstindate,Currentindate,Firstoutdate,'+
'Currentoutdate,BatchInv,BatchCurrentInv.InvQty,Batchline.Batchstatus tmpflag '+
'from Batch join Batchline on Batch.Batchid=Batchline.Batchid '+
'left join (select Batchno,sum(InvQty) InvQty from BatchCurrentInv group by Batchno) BatchCurrentInv'+
' on BatchCurrentInv.Batchno=Batchline.Batchno'+
' join Vendor on Batchline.VendorCode=Vendor.VendorCode'+
' join (select Item.*,Uom.UomName from Item join Uom on'+
' Item.UomCode=Uom.UomCode) Item on Item.ItemCode=Batch.ItemCode ';
AdoQry_Head.SQL.Text:=SelectFromSQL+condstr;
AdoQry_Head.Open;
AdoQry_Head.Sort:=OrderByFields;
AdoQry_Head.EnableControls;
end;
end;
procedure TFrm_Bas_BatchClose.DBGridEhTitleBtnClick(Sender: TObject;
ACol: Integer; Column: TColumnEh);
var
BookmArk1:tBookmArk;
begin
inherited;
if AdoQry_Head.RecordCount=0 then
exit;
AdoQry_Head.Edit ;
if checktmp then
checktmp:=False
else
checktmp:=True;
if column.FieldName='tmpflag' then
begin
BookmArk1:=AdoQry_Head.GetBookmArk;
AdoQry_Head.DisableControls ;
AdoQry_Head.First ;
if checktmp then
begin
while not AdoQry_Head.Eof do
begin
AdoQry_Head.Edit ;
AdoQry_Head.fieldbyname('tmpflag').Asstring:='1';
AdoQry_Head.Next;
end;
end
else
begin
while not AdoQry_Head.Eof do
begin
AdoQry_Head.Edit ;
AdoQry_Head.fieldbyname('tmpflag').Asstring:='0';
AdoQry_Head.Next;
end;
end;
AdoQry_Head.EnableControls ;
AdoQry_Head.GotoBookmArk(BookmArk1);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -