📄 djdhcx.pas
字号:
unit djdhcx;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, DBTables, Grids, DBGrids, ExtCtrls, Buttons, StdCtrls, Mask, ComCtrls;
type
Tdjdhcxform = class(TForm)
Bevel1: TBevel;
cx: TQuery;
DataSource1: TDataSource;
DataSource2: TDataSource;
dhcx: TQuery;
Panel3: TPanel;
cxbut: TBitBtn;
BitBtn1: TBitBtn;
Panel2: TPanel;
DBGrid1: TDBGrid;
DBGrid2: TDBGrid;
Label1: TLabel;
Label3: TLabel;
begdate: TDateTimePicker;
begtime: TDateTimePicker;
enddate: TDateTimePicker;
endtime: TDateTimePicker;
dh: TEdit;
Splitter1: TSplitter;
Label2: TLabel;
Edit1: TEdit;
xf: TCheckBox;
BitBtn2: TBitBtn;
print: TQuery;
procedure FormCreate(Sender: TObject);
procedure cxbutClick(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure DataSource2DataChange(Sender: TObject; Field: TField);
procedure BitBtn2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
djdhcxform: Tdjdhcxform;
implementation
uses dataproc;
{$R *.DFM}
var
acc:string;
procedure Tdjdhcxform.FormCreate(Sender: TObject);
begin
shortdateformat:='yyyy-MM-dd';
dh.text:='';
edit1.text:='';
begdate.DateTime:=now-1;
enddate.DateTime:=now;
begtime.Time:=strtotime('00:00:00');
endtime.Time:=strtotime('23:59:00');
end;
procedure Tdjdhcxform.cxbutClick(Sender: TObject);
var tj:string;
begin
tj:='';
if xf.Checked then
begin
if tj='' then
begin
if trim(dh.Text)<>'' then tj:=' and CAST(djcode AS decimal(25,8))>='+trim(dh.Text)+'' ;
end
else
if trim(dh.Text)<>'' then tj:=tj+' and CAST(djcode AS decimal(25,8))>='+trim(dh.Text)+'';
if tj='' then
begin
if trim(edit1.Text)<>'' then tj:=' and CAST(djcode AS decimal(25,8))<='+trim(edit1.Text)+'' ;
end
else
if trim(edit1.Text)<>'' then tj:=tj+' and CAST(djcode AS decimal(25,8))<='+trim(edit1.Text)+'';
end;
dhcx.Active:=false;
dhcx.SQL.Clear;
dhcx.SQL.Add('select CAST(djcode AS decimal(25,8)) as 登记单号,(select sum(ysmoney) from lsjz where lsjz.accno=lsnowin.accno) as 合计,accno as 记录号 from lsnowin where endtime>=:pbegtime and endtime<=:pendtime '+tj+'group by CAST(djcode AS decimal(25,8)),accno order by CAST(djcode AS decimal(25,8))');
dhcx.ParamByName('pbegtime').asstring:=formatdatetime('yyyy-MM-dd',begdate.date)+' '+formatdatetime('hh:mm:ss',begtime.time);
dhcx.ParamByName('pendtime').asstring:=formatdatetime('yyyy-MM-dd',enddate.date)+' '+formatdatetime('hh:mm:ss',endtime.time);
dhcx.Prepare;
dhcx.Open;
dbgrid2.Fields[0].DisplayLabel:='登记单号';
dbgrid2.Fields[1].DisplayLabel:='合计';
dbgrid2.Fields[2].DisplayLabel:='记录号';
end;
procedure Tdjdhcxform.BitBtn1Click(Sender: TObject);
begin
close;
end;
procedure Tdjdhcxform.DataSource2DataChange(Sender: TObject;
Field: TField);
begin
if DataSource1.DataSet=nil then exit;
cx.Active :=false;
cx.sql.clear;
cx.sql.add('select lsnowin.handno as 手号,(select name from room where roomno=handno) as 类型,roomprice,(money+csmoney) as 房费,');
cx.sql.add('(select isnull(sum(money),0) from lscustom where isxj<>1 and ismd<>1 and lscustom.handno=lsnowin.handno and lscustom.accno=lsnowin.accno) as 消费,');
cx.sql.add('(isnull((money+csmoney),0)+(select isnull(sum(money),0) from lscustom where isxj<>1 and ismd<>1 and lscustom.handno=lsnowin.handno and lscustom.accno=lsnowin.accno)) as 合计,');
cx.sql.add(' djcode as 入住单号,ismff 免房费,ismxf 免消费,accno,begtime,isnull((select cal from lschangeroom where lschangeroom.handno=lsnowin.handno and lschangeroom.accno=lsnowin.accno),1) as 计算 ');
cx.sql.add(' from lsnowin where accno=:paccno '); //and CAST(lsnowin.djcode AS decimal(25,8))=:pcode
// if dhcx.Fields[0].asstring='' then
// cx.ParamByName('pcode').asinteger:=0 else
// cx.ParamByName('pcode').asinteger:=dhcx.Fields[0].asinteger;
cx.ParamByName('paccno').asstring:=dhcx.Fields[2].asstring;
cx.Prepare;
cx.Open;
chinesegrid(dbgrid1);
cx.active:=true;
end;
procedure Tdjdhcxform.BitBtn2Click(Sender: TObject);
begin
{ print.Active;
print.SQL.Clear;
print.SQL.Add('delete from xfdhprint');
print.Prepare;
print.ExecSQL;
while not dhcx.Eof do
begin
print.SQL.Clear;
print.SQL.Add('insert into xfdhprint values(:code1,:money1,:accno1,:code2,:money2,:accno2,:code3,:money3,:accno3) ');
print.ParamByName('code1').asstring:=dhcx.fieldbyname('消费单号').asstring;
print.ParamByName('money1').asstring:=dhcx.fieldbyname('合计').asstring;
print.ParamByName('accno1').asfloat:=dhcx.fieldbyname('记录号').asfloat;
dhcx.Next;
if dhcx.Eof then
begin
print.ParamByName('code2').asstring:='';
print.ParamByName('money2').asstring:='';
print.ParamByName('accno2').asstring:='';
print.ParamByName('code3').asstring:='';
print.ParamByName('money3').asstring:='';
print.ParamByName('accno3').asstring:='';
end else
begin
print.ParamByName('code2').asstring:=dhcx.fieldbyname('消费单号').asstring;
print.ParamByName('money2').asstring:=dhcx.fieldbyname('合计').asstring;
print.ParamByName('accno2').asfloat:=dhcx.fieldbyname('记录号').asfloat;
dhcx.Next;
if dhcx.Eof then
begin
print.ParamByName('code3').asstring:='';
print.ParamByName('money3').asstring:='';
print.ParamByName('accno3').asfloat:=0;
end else
begin
print.ParamByName('code3').asstring:=dhcx.fieldbyname('消费单号').asstring;
print.ParamByName('money3').asstring:=dhcx.fieldbyname('合计').asstring;
print.ParamByName('accno3').asfloat:=dhcx.fieldbyname('记录号').asfloat;
end;
dhcx.Next;
end;
print.Prepare;
print.ExecSQL;
end;
print.Active:=false;
print.SQL.Clear;
print.SQL.Add('select * from xfdhprint order by CAST(code1 AS int(15,8))');
print.Prepare;
print.Open;
application.CreateForm(Trzdhprintform,rzdhprintform);
rzdhprintform.QRLabel6.Caption:=formatdatetime('yyyy''年''MM''月''d''日'' hh:mm',begdate.Datetime)+'至'+formatdatetime('yyyy''年''MM''月''d''日'' hh:mm',enddate.Datetime);
rzdhprintform.hide;
// if RadioButton2.Checked then
rzdhprintform.qr1.Preview;// else
// xfdhprintform.qr1.Print;
rzdhprintform.free; }
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -