📄 sfc_bcpmonthsumqry.pas
字号:
unit Sfc_BcPMonthSumQry;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin, DBCtrls;
Type
TFrm_Sfc_MonthSumQry = Class(TFrm_Base_Qry)
DBText1: TDBText;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure AdoQueryAfterOpen(DataSet: TDataSet);
private
{ Private declarations }
public
{ Public declarations }
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
procedure GetData; Override;
end;
var
Frm_Sfc_MonthSumQry: TFrm_Sfc_MonthSumQry;
implementation
uses Sfc_MonthSumQry_C;
{$R *.DFM}
procedure TFrm_Sfc_MonthSumQry.InitForm(AdOConnection: TAdOConnection;
ShowExtendColumn: Boolean);
begin
inherited;
AmountFields:='aInvBlncQty,aInvOutQty,aInvInQty,aInvLMQty,';
PriceFields:='Price1,Price2,Price3,Price4,';
try
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Drop TABLE #MonthSumQry';
AdoQry_Tmp.ExecSQL;
except
end;
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='CREATE TABLE #MonthSumQry ('
+' [JournalQryId] [numeric](18, 0) IDENTITY (1, 1) NOT NULL'
+',[ItemCode] [varchAr] (16) NULL'
+',[DeptCode] [varchAr] (8) NULL'
+',[whCode] [varchAr] (8) NULL'
+',[InvLMQty] [float] default 0'
+',[InvLMAmount] [float] default 0'
+',[InvInQty] [float] default 0'
+',[InvInAmount] [float] default 0'
+',[InvBlncQty] [float] default 0'
+',[InvBlncAmount] [float] default 0'
+',[Dept] [varchAr](8) NULL'
+' )'
+' CREATE TABLE #MonthSumQry1 ('
+' [JournalQryId] [numeric](18, 0) IDENTITY (1, 1) NOT NULL'
+',[DeptCode] [varchAr] (8) NULL'
+',[ItemCode] [varchAr] (16) NULL'
+',[InvLMQty] [float] default 0'
+',[InvLMAmount] [float] default 0'
+',[InvInQty] [float] default 0'
+',[InvInAmount] [float] default 0'
+',[InvBlncQty] [float] default 0'
+',[InvBlncAmount] [float] default 0'
+' )';
AdoQry_Tmp.ExecSQL;
OrderByFields:='DeptCodeName,ItemCode';
Frm_Sys_Condition:=TFrm_Sfc_MonthSumQry_C.Create(Self);
Act_Filter.Execute;
end;
procedure TFrm_Sfc_MonthSumQry.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
try
AdoQry_Tmp.Close;
AdoQry_Tmp.SQL.Text:='Drop TABLE #MonthSumQry,#MonthSumQry1';
AdoQry_Tmp.ExecSQL;
except
end;
end;
procedure TFrm_Sfc_MonthSumQry.GetData;
begin
SelectFromSQL:=Condition;
Condition:='';
inherited;
end;
procedure TFrm_Sfc_MonthSumQry.AdoQueryAfterOpen(DataSet: TDataSet);
var
sql_txt:string;
i:integer;
sumAmounts,sumAmountr,sumAmountc,sumAmountb:real;
begin
inherited;
sumAmounts:=0;
sumAmountr:=0;
sumAmountc:=0;
sumAmountb:=0;
//计算汇总金额
If Not AdoQry_Main.IsEmpty then
begin
AdoQry_Main.DisableControls;
AdoQry_Main.First;
for I:=0 to AdoQry_Main.RecordCount-1 do
begin
SumAmounts:=SumAmounts+AdoQry_Main.fieldbyname('aInvLMQty').asFloat;
SumAmountr:=SumAmountr+AdoQry_Main.fieldbyname('aInvInQty').asFloat;
SumAmountc:=SumAmountc+AdoQry_Main.fieldbyname('aInvOutQty').asFloat;
SumAmountb:=SumAmountb+AdoQry_Main.fieldbyname('aInvBlncQty').asFloat;
AdoQry_Main.next;
end;
AdoQry_Main.First;
AdoQry_Main.enableControls;
end;
edit1.text:=FormatFloat('#.##',SumAmounts);
edit2.text:=FormatFloat('#.##',SumAmountr);
edit3.text:=FormatFloat('#.##',SumAmountc);
edit4.text:=FormatFloat('#.##',SumAmountb);
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -