📄 main_query_scjhtj.pas
字号:
unit MAIN_QUERY_SCJHTJ;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, MAIN_QUERY, DB, DBTables, ComCtrls, StdCtrls, TFlatComboBoxUnit,
TFlatSpeedButtonUnit, Grids, DBGrids, DsFancyButton, ExtCtrls,myself,frmmain;
type
TFrm_main_query_scjhtj = class(TFrm_main_query)
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure SB_queryClick(Sender: TObject);
procedure SB_printClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Frm_main_query_scjhtj: TFrm_main_query_scjhtj;
implementation
uses PRINT_TEMP, PRINT_SCJHTJ;
{$R *.dfm}
procedure TFrm_main_query_scjhtj.FormCreate(Sender: TObject);
begin
inherited;
self.Caption :='商场进货统计';
with query_temp do
begin
close;
sql.Clear ;
sql.Text :='select name from depot where setid=999 and type="外部"';
open;
CB_depot.Items.Clear ;
CB_depot.Style :=csDropDownList;
CB_depot.Items.Add('所有');
while not eof do
begin
CB_depot.Items.add(fieldbyname('name').asstring);
next;
end;
close;
end;
end;
procedure TFrm_main_query_scjhtj.FormShow(Sender: TObject);
begin
inherited;
SB_query.Click ;
end;
procedure TFrm_main_query_scjhtj.SB_queryClick(Sender: TObject);
begin
inherited;
if not Checkrights(USERRIGHTS,'查看') then
begin
messagedlg(Errormsg0006+'0007',mterror,[mbok],0);
exit;
end;
with query_data do
begin
close;
sql.Clear ;
if (cb_depot.Text ='') or (CB_depot.Text ='所有') then
sql.Text :=' SELECT Depot.NAME Depotname, Goodsmessage.NAME goodsname,'
+' Goodsmessage.TYPE, Goodsmessage.UNIT, sum(Stockrecord.NUMBER) NUMBER,'
+' SUM( Stockrecord.NUMBER * Stockrecord.PRICE ) PRICE'
+' FROM Stockrecord'
+' INNER JOIN Depot ON (Stockrecord.DEPOTID = Depot.ID)'
+' INNER JOIN Goodsmessage'
+' ON (Stockrecord.GOODSID = Goodsmessage.ID)'
+' WHERE (DEPOT.type="外部")'
+' AND (Stockrecord.mydate>="'+formatdatetime('yyyy-mm-dd',DTP_begin.DateTime)+'")'
+' AND (Stockrecord.mydate<="'+formatdatetime('yyyy-mm-dd',dtp_end.DateTime)+'")'
+' GROUP BY Depot.NAME, Goodsmessage.NAME,'
+' Goodsmessage.TYPE, Goodsmessage.UNIT'
+' UNION ALL'
+' SELECT Depot.NAME Depotname, Goodsmessage.name GOODSNAME,'
+' Goodsmessage.TYPE, Goodsmessage.UNIT, SUM( 0 - Threcord.NUMBER ) NUMBER,'
+' SUM((0 - Threcord.NUMBER) * Threcord.PRICE ) PRICE'
+' FROM Threcord'
+' INNER JOIN Depot ON (Threcord.DEPOTID = Depot.ID)'
+' INNER JOIN Goodsmessage'
+' ON (Threcord.GOODSID = Goodsmessage.ID)'
+' WHERE (DEPOT.type="外部")'
+' AND (Threcord.mydate>="'+formatdatetime('yyyy-mm-dd',DTP_begin.DateTime)+'")'
+' AND (Threcord.mydate<="'+formatdatetime('yyyy-mm-dd',dtp_end.DateTime)+'")'
+' GROUP BY Depot.NAME,Goodsmessage.NAME,'
+' Goodsmessage.TYPE, Goodsmessage.UNIT'
+' ORDER BY Depot.NAME'
else
sql.Text :=' SELECT Depot.NAME Depotname, Goodsmessage.name GOODSNAME,'
+' Goodsmessage.TYPE, Goodsmessage.UNIT, sum(Stockrecord.NUMBER) NUMBER,'
+' SUM( Stockrecord.NUMBER * Stockrecord.PRICE ) PRICE'
+' FROM Stockrecord'
+' INNER JOIN Depot ON (Stockrecord.DEPOTID = Depot.ID)'
+' INNER JOIN Goodsmessage'
+' ON (Stockrecord.GOODSID = Goodsmessage.ID)'
+' WHERE (DEPOT.name="'+cb_DEPOT.Text +'")'
+' And (Stockrecord.mydate>="'+formatdatetime('yyyy-mm-dd',DTP_begin.DateTime)+'")'
+' AND (Stockrecord.mydate<="'+formatdatetime('yyyy-mm-dd',dtp_end.DateTime)+'")'
+' GROUP BY Depot.NAME, Goodsmessage.NAME,'
+' Goodsmessage.TYPE, Goodsmessage.UNIT'
+' UNION ALL'
+' SELECT Depot.NAME Depotname, Goodsmessage.name GOODSNAME,'
+' Goodsmessage.TYPE, Goodsmessage.UNIT, SUM(0 - Threcord.NUMBER ) NUMBER,'
+' SUM( (0 - Threcord.NUMBER) * Threcord.PRICE ) PRICE'
+' FROM Threcord'
+' INNER JOIN Depot ON (Threcord.DEPOTID = Depot.ID)'
+' INNER JOIN Goodsmessage'
+' ON (Threcord.GOODSID = Goodsmessage.ID)'
+' WHERE (DEPOT.name="'+cb_DEPOT.Text +'")'
+' And (Threcord.mydate>="'+formatdatetime('yyyy-mm-dd',DTP_begin.DateTime)+'")'
+' AND (Threcord.mydate<="'+formatdatetime('yyyy-mm-dd',dtp_end.DateTime)+'")'
+' GROUP BY Depot.NAME, Goodsmessage.NAME,'
+' Goodsmessage.TYPE, Goodsmessage.UNIT'
+' ORDER BY Depot.NAME';
try
open;
except
messagedlg(Errormsg0001+'0010+0012+0020+0025',mtError,[mbok],0);
close;
end;
end;
end;
procedure TFrm_main_query_scjhtj.SB_printClick(Sender: TObject);
begin
inherited;
try
Application.CreateForm(TFrm_print_scjhtj, Frm_print_scjhtj);
Application.CreateForm(TFrm_print_temp, Frm_print_temp);
except
messagedlg(Errormsg0011,mtError,[mbok],0);
exit;
end;
Frm_print_scjhtj.QuickRep_scjhtj.preview;
Frm_print_scjhtj.Free ;
Frm_print_temp.Free ;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -