📄 inv_batchjournal_detail.pas
字号:
unit Inv_BatchJournal_Detail;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Outer, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls, Base_Qry, jpeg;
Type
TFrm_Inv_BatchJournal_Detail = Class(TFrm_Base_Outer)
AdoQry_tmp1: TAdoQuery;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
lbl_BatchName: TLabel;
lbl_ItemName: TLabel;
lbl_UomName: TLabel;
Label5: TLabel;
lbl_VendorCode: TLabel;
AdoQry_MainInvBilldate: TDateTimeField;
AdoQry_MaInvendorCode: TStringField;
AdoQry_Mainmopono: TStringField;
AdoQry_Mainlinenumber: TStringField;
AdoQry_MainInvBillqty: TFloatField;
AdoQry_MainInvOBillqty: TFloatField;
AdoQry_MainInvQty: TFloatField;
lbl_Batchno: TLabel;
procedure DBGridEhGetCellParams(Sender: TObject; Column: TColumnEh;
AFont: TFont; var Background: TColor; State: TGridDrawState);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
acondition:string;
aVendorCode:string;
procedure initform(AdOConnection:TAdOConnection;ReadOnly:boolean);Override;
procedure InitReport;Override;
{ Public declarations }
end;
var
Frm_Inv_BatchJournal_Detail: TFrm_Inv_BatchJournal_Detail;
implementation
uses Inv_BatchJournal,Sys_Global;
{$R *.DFM}
procedure TFrm_Inv_BatchJournal_Detail.initform(AdOConnection:TAdOConnection;ReadOnly:boolean);
begin
// inherited;
acondition:='';
Caption:='批次明细帐';
pnl_title.Caption :='批次明细帐';
OrderByFields:='InvBillcreatetime';
lbl_Order.Caption:='';
end;
procedure TFrm_Inv_BatchJournal_Detail.DBGridEhGetCellParams(Sender: TObject;
Column: TColumnEh; AFont: TFont; var Background: TColor;
State: TGridDrawState);
begin
inherited;
{if (TDBGridEh(Sender).DataSource.DataSet.fieldbyname('Orderfield').asstring='1') and
(column.FieldName='ItemCode1') then
afont.Color :=clred; }
end;
procedure TFrm_Inv_BatchJournal_Detail.InitReport;
begin
inherited;
ExtPrintReport.Subtitle2:=' '+lbl_Ordertitle.Caption+lbl_Batchno.Caption+' '+label2.Caption+lbl_Batchno.Caption+' '+label3.Caption+lbl_ItemName.Caption ;
ExtPrintReport.Subtitle3:=' '+Label4.Caption+Lbl_UomName.Caption+' '+label5.Caption+' '+lbl_VendorCode.Caption ;
end;
procedure TFrm_Inv_BatchJournal_Detail.FormCreate(Sender: TObject);
var
InvQty_H:double;
begin
inherited;
AdoQry_Main.Connection :=Frm_Inv_BatchJournal.AdoQry_Main.Connection ;
AdoQry_tmp.Connection :=AdoQry_Main.Connection ;
AdoQry_tmp1.Connection :=AdoQry_Main.Connection ;
with AdoQry_tmp do
begin
Close;
sql.Text :='drop table #Billtmp1';
try
execsql;
except
end;
end;
with AdoQry_tmp do
begin
Close;
sql.Text :='create table #Billtmp1 (id int identity ,InvBilldate smalldatetime null,'+
' VendorCode varchAr(80) null,'+
' mopono varchAr(16) null,'+
' linenumber varchAr(16) null,'+
' InvBillqty float default 0,'+
' InvOBillqty float default 0, '+
' InvQty float default 0, '+
' InvBillcreatetime smalldatetime null '+
')';
try
execsql;
except
end;
end;
lbl_Batchno.Caption :=Frm_Inv_BatchJournal.AdoQry_Main.fieldbyname('Batchno').asstring;
lbl_BatchName.Caption :=Frm_Inv_BatchJournal.AdoQry_Main.fieldbyname('BatchName').asstring;
lbl_ItemName.Caption :=Frm_Inv_BatchJournal.AdoQry_Main.fieldbyname('ItemCode').asstring;
lbl_UomName.Caption :=Frm_Inv_BatchJournal.AdoQry_Main.fieldbyname('UomName').asstring;
lbl_VendorCode.Caption :=Frm_Inv_BatchJournal.AdoQry_Main.fieldbyname('VendorCode').asstring;
// PriceFields:='InvLMAmount,InvInAmount,InvOutAmount,InvBlncAmount,InvBillNoTaxAmount';
AdoQry_tmp.Close ;
AdoQry_tmp.SQL.Text :='delete from #Billtmp1';
AdoQry_tmp.ExecSQL ;
AdoQry_Main.DisableControls;
AdoQry_Main.Close;
AdoQry_Main.SQL.clear;
SelectFromSQL:='insert #Billtmp1 (InvBilldate,VendorCode,mopono,linenumber,InvBillqty,InvBillcreatetime)'+
' select InvInBill.InvBilldate,InvInBill.VendorCode+'''+' '+'''+Vendor.VendorName VendorCode,'+
' InvInBill.pono,InvInBill.polineno,InvInBillline.InvBillqty,InvInBill.InvBillcreatetime'+
' from InvInBill join InvInBillline'+
' on InvInBill.InvBillid=InvInBillline.InvBillid'+
' join Vendor on InvInBill.VendorCode=Vendor.VendorCode'+
' where InvInBill.InvBillWHCHCK<>0 and InvInBillline.Batchno is not null and InvInBillline.Batchno='''+lbl_Batchno.Caption+'''';
AdoQry_Main.SQL.Text:=SelectFromSQL;
AdoQry_Main.ExecSQL ;
selectfromsql:='insert #Billtmp1 (InvBilldate,VendorCode,mopono,linenumber,InvOBillqty,InvBillcreatetime)'+
' select InvOutBill.InvBilldate,InvOutBill.DeptCode+'''+' '+'''+Dept.DeptName VendorCode,'+
' InvOutBill.mono,InvOutBill.MoLineno,InvOutBillline.InvBillqty,'+
' InvOutBill.InvBillcreatetime'+
' from InvOutBill join InvOutBillline'+
' on InvOutBill.InvBillid=InvOutBillline.InvBillid'+
' join Dept on InvOutBill.DeptCode=Dept.DeptCode'+
' where InvOutBill.InvBillWHCHCK<>0 and InvOutBillline.Batchno is not null and InvOutBillline.Batchno='''+lbl_Batchno.Caption+'''';
AdoQry_Main.SQL.Text:=SelectFromSQL;
AdoQry_Main.ExecSQL ;
with AdoQry_tmp do
begin
Close;
sql.Text :='select * from #Billtmp1 Order by InvBillcreatetime';
open;
First;
InvQty_H:=0;
while not eof do
begin
InvQty_H:=InvQty_H+fieldbyname('InvBillqty').Asfloat-fieldbyname('InvOBillqty').asfloat;
AdoQry_tmp1.Close;
AdoQry_tmp1.SQL.Text:='update #Billtmp1 set InvQty='+floattostr(InvQty_H)+''+
' where id='''+fieldbyname('id').asstring+'''';
AdoQry_tmp1.ExecSQL ;
next;
end;
end;
AdoQry_Main.Close;
AdoQry_Main.SQL.Text:='select a.InvBilldate,a.VendorCode,'+
' a.mopono,a.linenumber,a.InvBillqty,'+
' a.InvOBillqty,a.InvQty'+
' from #Billtmp1 a'+
' Order by InvBillcreatetime';
AdoQry_Main.Open;
AdoQry_Main.EnableControls;
end;
procedure TFrm_Inv_BatchJournal_Detail.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
with AdoQry_tmp do
begin
Close;
sql.Text :='drop table #Billtmp1';
try
execsql;
except
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -