📄 zdxffltj.pas
字号:
unit zdxffltj;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Buttons, Grids, DBGrids, Mask, Db, DBTables, ExtCtrls, ComCtrls,
ImgList;
type
Tzdxffltjform = class(TForm)
q1: TQuery;
DataSource1: TDataSource;
Panel2: TPanel;
Panel1: TPanel;
cx: TCheckBox;
begdate: TDateTimePicker;
begtime: TDateTimePicker;
Label7: TLabel;
enddate: TDateTimePicker;
endtime: TDateTimePicker;
SpeedButton1: TSpeedButton;
Panel4: TPanel;
SpeedButton2: TSpeedButton;
SpeedButton3: TSpeedButton;
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
mxname: TTabControl;
DBGrid1: TDBGrid;
Panel3: TPanel;
Label2: TLabel;
wjzhj: TLabel;
TabControl1: TTabControl;
DBGrid2: TDBGrid;
Panel5: TPanel;
SpeedButton4: TSpeedButton;
ImageList1: TImageList;
q2: TQuery;
DataSource2: TDataSource;
Label1: TLabel;
yjzhj: TLabel;
Label3: TLabel;
mdhj: TLabel;
q3: TQuery;
TabSheet3: TTabSheet;
DBGrid3: TDBGrid;
DataSource3: TDataSource;
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure begdateChange(Sender: TObject);
procedure cxClick(Sender: TObject);
procedure xfnameChange(Sender: TObject);
procedure SpeedButton1Click(Sender: TObject);
procedure SpeedButton2Click(Sender: TObject);
procedure SpeedButton3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
zdxffltjform: Tzdxffltjform;
implementation
uses dataproc, xftjprin, xftj;
{$R *.DFM}
procedure formini(dd:string);
begin
with zdxffltjform do
begin
DataSource1.DataSet:=nil;
DataSource2.DataSet:=nil;
DataSource3.DataSet:=nil;
q1.Active :=false;
q1.sql.clear;
if PageControl1.ActivePage=TabSheet1 then
begin //where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and substring(custype,1,2)='''+xflb.Items[xfname.ItemIndex]+'''');
q1.sql.add('select sum(Money) from custom where (Regtime>=:pbgtm1) and (Regtime<=:pedtm1) and jsj=:pzdh');
q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
q1.ParamByName ('pzdh').asstring:=curper.workjsj;
q1.Prepare;
q1.open;
if (q1.Fields[0].isnull) or (trim(q1.Fields[0].asstring)='') then
wjzhj.Caption:='0'
else
wjzhj.Caption:=q1.Fields[0].asstring;
q1.Active :=false;
q1.sql.clear; //isxj,ismd
q1.SQL.Add('select distinct cuscode,(select cusname from cusitem where cusitem.cuscode=t.cuscode) as 消费名称,');
q1.SQL.Add('(select CusPrice from cusitem where cusitem.cuscode=t.cuscode) as 消费单价,');
q1.SQL.Add('(select sum(CusNum) from custom where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh and t.cuscode=custom.cuscode) as 数量,');
q1.SQL.Add('(select sum(Money) from custom where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh and t.cuscode=custom.cuscode) as 金额');
q1.SQL.Add(' from custom as t ');
q1.sql.Add(' where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh ');
q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
q1.ParamByName ('pzdh').asstring:=curper.workjsj;
q1.Prepare;
q1.open;
DataSource1.DataSet:=q1;
chinesegrid(dbgrid1);
// DBGrid1.fields[1].displaylabel:='类型';
end;
if PageControl1.ActivePage=TabSheet2 then
begin
q2.Active:=false;
q2.SQL.clear; //是现金或免单的 moditime 值为null
q2.sql.add('select sum(Money) from lscustom where (regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh');
q2.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
q2.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
q2.ParamByName ('pzdh').asstring:=curper.workjsj;
q2.Prepare;
q2.open;
if (q2.Fields[0].isnull) or (trim(q2.Fields[0].asstring)='') then
yjzhj.Caption:='0'
else
yjzhj.Caption:=q2.Fields[0].asstring;
q3.Active:=false;
q3.SQL.clear; //是现金或免单的 moditime 值为null
q3.sql.add('select sum(Money) from lscustom where (regtime>=:pbgtm1) and (regtime<=:pedtm1) and ismd=1 and jsj=:pzdh');
q3.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
q3.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
q3.ParamByName ('pzdh').asstring:=curper.workjsj;
q3.Prepare;
q3.open;
if (q3.Fields[0].isnull) or (trim(q3.Fields[0].asstring)='') then
mdhj.Caption:='0'
else
mdhj.Caption:=q3.Fields[0].asstring;
q2.Active :=false;
q2.sql.clear;
q2.SQL.Add('select distinct cuscode,(select cusname from cusitem where cusitem.cuscode=t.cuscode) as 消费名称,');
q2.SQL.Add('(select CusPrice from cusitem where cusitem.cuscode=t.cuscode) as 消费单价,');
q2.SQL.Add('(select sum(CusNum) from lscustom where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh and t.cuscode=lscustom.cuscode) as 数量,');
q2.SQL.Add('(select sum(Money) from lscustom where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh and t.cuscode=lscustom.cuscode) as 金额');
q2.SQL.Add(' from lscustom as t ');
q2.sql.Add(' where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh ');
q2.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
q2.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
q2.ParamByName ('pzdh').asstring:=curper.workjsj;
q2.Prepare;
q2.open;
DataSource2.DataSet:=q2;
chinesegrid(dbgrid2);
DBGrid2.fields[1].displaylabel:='类型';
end;
if PageControl1.ActivePage=TabSheet3 then
begin
{q2.Active:=false;
q2.SQL.clear; //是现金或免单的 moditime 值为null
q2.sql.add('select sum(Money) from custom where (regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh');
q2.sql.add('union(select sum(Money) from lscustom where (regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh)');
q2.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
q2.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
q2.ParamByName ('pzdh').asstring:=curper.workjsj;
q2.Prepare;
q2.open;
if (q2.Fields[0].isnull) or (trim(q2.Fields[0].asstring)='') then
yjzhj.Caption:='0'
else
yjzhj.Caption:=q2.Fields[0].asstring;
q3.Active:=false;
q3.SQL.clear; //是现金或免单的 moditime 值为null
q3.sql.add('select sum(Money) from lscustom where (regtime>=:pbgtm1) and (regtime<=:pedtm1) and ismd=1 and jsj=:pzdh');
q3.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
q3.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
q13.ParamByName ('pzdh').asstring:=curper.workjsj;
q3.Prepare;
q3.open;
if (q3.Fields[0].isnull) or (trim(q3.Fields[0].asstring)='') then
mdhj.Caption:='0'
else
mdhj.Caption:=q3.Fields[0].asstring;}
q2.Active :=false;
q2.sql.clear;
q2.SQL.Add('select distinct cuscode,(select cusname from cusitem where cusitem.cuscode=t.cuscode) as 消费名称,');
q2.SQL.Add('(select CusPrice from cusitem where cusitem.cuscode=t.cuscode) as 消费单价,');
q2.SQL.Add('(select sum(CusNum) from custom where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh and t.cuscode=custom.cuscode) as 数量,');
q2.SQL.Add('(select sum(Money) from custom where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh and t.cuscode=custom.cuscode) as 金额');
q2.SQL.Add(' from custom as t ');
q2.sql.Add(' where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh ');
q2.SQL.Add('union(select distinct cuscode,(select cusname from cusitem where cusitem.cuscode=t.cuscode) as 消费名称,');
q2.SQL.Add('(select CusPrice from cusitem where cusitem.cuscode=t.cuscode) as 消费单价,');
q2.SQL.Add('(select sum(CusNum) from lscustom where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh and t.cuscode=lscustom.cuscode) as 数量,');
q2.SQL.Add('(select sum(Money) from lscustom where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh and t.cuscode=lscustom.cuscode) as 金额');
q2.SQL.Add(' from lscustom as t ');
q2.sql.Add(' where (Regtime>=:pbgtm1) and (regtime<=:pedtm1) and jsj=:pzdh )');
q2.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
q2.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
q2.ParamByName ('pzdh').asstring:=curper.workjsj;
q2.Prepare;
q2.open;
DataSource3.DataSet:=q2;
chinesegrid(dbgrid3);
DBGrid3.fields[1].displaylabel:='类型';
end;
end;
end;
procedure xflbini;
begin
with zdxffltjform do
begin
DataSource1.DataSet:=nil;
DataSource2.DataSet:=nil;
DataSource3.DataSet:=nil;
TabControl1.Tabs.Clear;
formini('cuscode');
end;
end;
procedure Tzdxffltjform.FormCreate(Sender: TObject);
begin
shortdateformat:='yyyy-mm-dd';
begdate.date:=now;
begtime.Time:=strtotime('00:00');
enddate.datetime:=now;
endtime.time:=strtotime('23:59');
DataSource1.DataSet:=nil;
DataSource2.DataSet:=nil;
DataSource3.DataSet:=nil;
q1.sql.clear;
Q1.active:=false;
q1.sql.text:='select UnitName from syssetup';
q1.Prepare;
q1.Open;
Panel4.Caption:=unpassname(Q1.Fields[0].asstring)+'消费收入统计表';
xflbini;
end;
procedure Tzdxffltjform.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=112 then
begin
if xt=1 then help(3);
if xt=0 then help(5);
end;
if key=13 then
selectnext(activecontrol,true,true);
if key=27 then
zdxffltjform.close;
end;
procedure Tzdxffltjform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
{ q1.Active :=false;
q1.sql.clear;
q1.SQL.Add('delete from customls');
q1.ExecSQL;
q1.Active :=false;
q1.sql.clear;
q1.free; }
end;
procedure Tzdxffltjform.begdateChange(Sender: TObject);
begin
cx.Checked:=false;
Panel1.Enabled:=true;
q1.Close;
end;
procedure Tzdxffltjform.cxClick(Sender: TObject);
begin
formini('cuscode');
Panel1.Enabled:=false;
end;
procedure Tzdxffltjform.xfnameChange(Sender: TObject);
begin
xflbini;
end;
procedure Tzdxffltjform.SpeedButton1Click(Sender: TObject);
begin
{ if (DataSource1.DataSet=q1) and (q1.Active) then
begin
application.CreateForm(Txftjprinform,xftjprinform);
xftjprinform.hide;
xftjprinform.qr1.Print;
xftjprinform.Close;
xftjprinform.free;
end;
}
end;
procedure Tzdxffltjform.SpeedButton2Click(Sender: TObject);
begin
{ if (DataSource1.DataSet=q1) and (q1.Active) then
begin
application.CreateForm(Txftjprinform,xftjprinform);
xftjprinform.hide;
xftjprinform.qr1.preview;
xftjprinform.Close;
xftjprinform.free;
end;}
end;
procedure Tzdxffltjform.SpeedButton3Click(Sender: TObject);
begin
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -