📄 pm_qry_informalsspoinfo_d.pas
字号:
unit Pm_Qry_InformalSsPoInfo_D;
Interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Base_Qry, Menus, ExtPrintReport, Db, ActnList, AdODB, Grids, DBGridEh,
StdCtrls, ExtCtrls, ComCtrls, ToolWin;
Type
TFrm_Pm_Qry_InformalSsPoInfo_D = Class(TFrm_Base_Qry)
AdoQry_MainItemCode: TStringField;
AdoQry_MainItemName: TStringField;
AdoQry_MainUomName: TStringField;
AdoQry_Mainldtime: TFloatField;
AdoQry_MainPmBatch: TIntegerField;
AdoQry_MainCurrentonhandInv: TFloatField;
AdoQry_Mainssdate: TDateTimeField;
AdoQry_Mainssqty: TFloatField;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormDestroy(Sender: TObject);
private
{ Private declarations }
public
procedure setconditionHint(lbl:Tlabel;cAp:string);
procedure InitForm(AdOConnection:TAdOConnection;ShowExtendColumn:Boolean);Override;
{ Public declarations }
end;
var
Frm_Pm_Qry_InformalSsPoInfo_D: TFrm_Pm_Qry_InformalSsPoInfo_D;
days:integer;
implementation
uses Pm_Qry_InformalSsPoInfo,Sys_Global;
{$R *.DFM}
{ TFrm_Pm_Qry_InformalSsPoInfo_D }
procedure TFrm_Pm_Qry_InformalSsPoInfo_D.InitForm(
AdOConnection: TAdOConnection; ShowExtendColumn: Boolean);
var sqltext:string;
begin
inherited;
try
with TFrm_Pm_Qry_InformalSsPoInfo.Create(self) do
begin
showmodal;
if modalResult<>mrok then
begin
self.Close;
exit;
end;
days:=strtoint(edtdays.text);
end;
finally
Frm_Pm_Qry_InformalSsPoInfo.Free;
end;
sqltext:=' select top 0 ItemCode,ssdate,ssqty into #tmpInformalres from Informalss '
+' select ItemCode,ssdate,ssqty '
+' into #tmpInformalss '
+' from Informalss '
+' where PmType=1 or PmType=2 '
+' Order by ItemCode,ssdate '
+' declAre @Count int, '
+' @ItemCode varchAr(16), '
+' @ssdate datetime, '
+' @date datetime, '
+' @ssqty float(8) '
+' set rowCount 1 '
+' insert into #tmpInformalres '
+' select * from #tmpInformalss '
+' select @date=(select ssdate from #tmpInformalres) '
+' delete from #tmpInformalss '
+' select @Count=(select Count(*) from #tmpInformalss) '
+' while @Count>0 '
+' begin '
+' select @ItemCode=ItemCode from #tmpInformalss '
+' select @ssdate=ssdate from #tmpInformalss '
+' select @ssqty=ssqty from #tmpInformalss '
+' if exists(select * from #tmpInformalres where ItemCode=@ItemCode)'
+' begin '
+' if dateDiff(dd,@date,@ssdate)<'+inttostr(days)
+' update #tmpInformalres '
+' set ssqty=ssqty+@ssqty '
+' where ItemCode=@ItemCode '
+' and dateDiff(dd,ssdate,@ssdate)<'+inttostr(days)
+' else '
+' begin '
+' insert into #tmpInformalres '
+' select * from #tmpInformalss '
+' select @date=@ssdate '
+' end '
+' end '
+' else '
+' begin '
+' insert into #tmpInformalres '
+' select * from #tmpInformalss '
+' select @date=@ssdate '
+' end '
+' delete from #tmpInformalss '
+' select @Count=@Count-1 '
+' end '
+' set rowCount 999999999 '
+' select #tmpInformalres.ItemCode, '
+' Item.ItemName, '
+' Uom.UomName, '
+' ldtime=Item.purchldtime, '
+' Item.PmBatch, '
+' Item.CurrentonhandInv, '
+' #tmpInformalres.ssdate, '
+' #tmpInformalres.ssqty '
+' into #tmpInformal '
+' from #tmpInformalres,Item(nolock),Uom(nolock) '
+' where #tmpInformalres.ItemCode=Item.ItemCode '
+' and Item.UomCode=Uom.UomCode '
+' Order by #tmpInformalres.ItemCode,#tmpInformalres.ssdate ';
selectfromsql:='select * from #tmpInformal';
with AdoQry_Main do
begin
Close;
sql.clear;
sql.Add(sqltext);
Prepared;
try
execsql;
except
end;
Close;
sql.clear;
sql.Add('select * from #tmpInformal');
Prepared;
try
open;
except
end;
if recordCount=0 then
begin
Application.MessageBox('无相关资料!','提示信息',mb_ok);
self.Close;
end;
end;
end;
procedure TFrm_Pm_Qry_InformalSsPoInfo_D.setconditionHint(lbl: Tlabel;
cAp: string);
begin
lbl.Caption:=cAp;
end;
procedure TFrm_Pm_Qry_InformalSsPoInfo_D.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
with AdoQry_tmp do
begin
Close;
sql.clear;
sql.Add('drop table #tmpInformalss,#tmpInformalres,#tmpInformal');
try
execsql;
except
end;
end;
inherited;
end;
procedure TFrm_Pm_Qry_InformalSsPoInfo_D.FormDestroy(Sender: TObject);
begin
inherited;
Frm_Pm_Qry_InformalSsPoInfo_D:=nil;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -