⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dhftj.pas

📁 集成酒店桑拿食管管理的完整程序
💻 PAS
字号:
unit dhftj;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, Grids, DBGrids, Mask, Db, DBTables, ExtCtrls, ComCtrls;

type
  Tdhftjform = class(TForm)
    q1: TQuery;
    DataSource1: TDataSource;
    mxname: TTabControl;
    DBGrid1: TDBGrid;
    Panel2: TPanel;
    Panel1: TPanel;
    cx: TCheckBox;
    begdate: TDateTimePicker;
    Label7: TLabel;
    enddate: TDateTimePicker;
    Panel3: TPanel;
    Label1: TLabel;
    yjzhj: TLabel;
    Label2: TLabel;
    wjzhj: TLabel;
    Label3: TLabel;
    hj: TLabel;
    SpeedButton1: TSpeedButton;
    Panel4: TPanel;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    begtime: TDateTimePicker;
    endtime: TDateTimePicker;
    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 mxnameChange(Sender: TObject);
    procedure DBGrid1TitleClick(Column: TColumn);
    procedure SpeedButton1Click(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  dhftjform: Tdhftjform;

implementation
uses dataproc, dhftjprin;
//, dhftjprin;

{$R *.DFM}


procedure formini(dd:string);
begin
  with dhftjform do
  begin
      DataSource1.DataSet:=nil;
      q1.Active :=false;
      q1.sql.clear;
      if mxname.tabIndex=0 then
      begin
         q1.sql.add('select sum(hjMoney) from phonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         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;
         q1.sql.add('select sum(hjMoney) from qtphonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         q1.Prepare;
         q1.open;
         if (not q1.Fields[0].isnull) and (trim(q1.Fields[0].asstring)<>'') then
            wjzhj.Caption:=floattostr(strtofloat(wjzhj.Caption)+q1.Fields[0].asfloat);
         q1.Active :=false;
         q1.sql.clear;
         q1.sql.add('select sum(hjMoney) from lsphonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         q1.Prepare;
         q1.open;
         if (q1.Fields[0].isnull) or (trim(q1.Fields[0].asstring)='') then
            yjzhj.Caption:='0'
         else
            yjzhj.Caption:=q1.Fields[0].asstring;
         hj.Caption:=floattostr(strtofloat(wjzhj.Caption)+strtofloat(yjzhj.Caption));
         q1.Active :=false;
         q1.sql.clear;
         q1.SQL.Add('delete from phonedbls');
         q1.sql.add('insert into phonedbls select '''',''  '',* from phonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.sql.add('insert into phonedbls select '''',''  '',* from qtphonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.sql.add('insert into phonedbls select * from lsphonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         q1.Prepare;
         q1.ExecSQL;
         q1.Active :=false;
         q1.sql.clear;
      end;
      if mxname.tabIndex=1 then
      begin
         q1.sql.add('select sum(hjMoney) from phonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         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;
         q1.sql.add('select sum(hjMoney) from lsphonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         q1.Prepare;
         q1.open;
         if (q1.Fields[0].isnull) or (trim(q1.Fields[0].asstring)='') then
            yjzhj.Caption:='0'
         else
            yjzhj.Caption:=q1.Fields[0].asstring;
         hj.Caption:=floattostr(strtofloat(wjzhj.Caption)+strtofloat(yjzhj.Caption));
         q1.Active :=false;
         q1.sql.clear;
         q1.SQL.Add('delete from phonedbls');
         q1.sql.add('insert into phonedbls select '''',''  '',* from phonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.sql.add('insert into phonedbls select * from lsphonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         q1.Prepare;
         q1.ExecSQL;
         q1.Active :=false;
         q1.sql.clear;
      end;
      if mxname.tabIndex=2 then
      begin
         yjzhj.Caption:='0';
         q1.Active :=false;
         q1.sql.clear;
         q1.sql.add('select sum(hjMoney) from qtphonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         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;
         hj.Caption:=wjzhj.Caption;
         q1.Active :=false;
         q1.sql.clear;
         q1.SQL.Add('delete from phonedbls');
         q1.sql.add('insert into phonedbls select '''',''  '',* from qtphonedb where (begtime>=:pbgtm1) and (begtime<=:pedtm1)');
         q1.ParamByName ('pbgtm1').asstring:=datetostr(begdate.Date)+' '+timetostr(begtime.time);
         q1.ParamByName ('pedtm1').asstring:=datetostr(enddate.Date)+' '+timetostr(endtime.time);
         q1.Prepare;
         q1.ExecSQL;
         q1.Active :=false;
         q1.sql.clear;
      end;
      q1.Active :=false;
      q1.sql.clear;
      q1.SQL.Add('select roomno,extension,dftel,begtime,address,phmoney,agnomen,fwf,hjmoney from phonedbls order by '+dd);
      q1.open;
      DataSource1.DataSet:=q1;
      chinesegrid(dbgrid1);
      DBGrid1.fields[4].displaylabel:='通话时长';
      dbgrid1.Columns[4].width:=60;
      dbgrid1.Columns[5].width:=40;
      dbgrid1.Columns[6].width:=40;
      dbgrid1.Columns[7].width:=40;
      dbgrid1.Columns[1].width:=40;
//      DBGrid1.fields[7].displaylabel:=' 结帐时间';
//         dbgrid1.Columns[2].width:=dbgrid1.Columns[2].width+5;
      q1.Active :=true;
  end;
end;



procedure Tdhftjform.FormCreate(Sender: TObject);
begin
   shortdateformat:='yyyy-mm-dd';
   begdate.date:=now;
   begtime.Time:=strtotime('00:00');
   enddate.datetime:=now;
   endtime.time:=strtotime('23:59');
   q1.sql.clear;
   Q1.active:=false;
   q1.sql.text:='select UnitName from syssetup';
   q1.Prepare;
   q1.Open;
   Panel4.Caption:=unpassname(Q1.Fields[0].asstring)+'电话费统计表';
   q1.sql.clear;
   Q1.active:=false;
   mxname.Tabs.Clear;
   mxname.Tabs.Add('全部电话');
   mxname.Tabs.Add('宾客电话');
   mxname.Tabs.Add('非宾客电话');

   formini('roomNo');
end;


procedure Tdhftjform.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
     dhftjform.close;
end;

procedure Tdhftjform.FormClose(Sender: TObject; var Action: TCloseAction);
begin

         q1.Active :=false;
         q1.sql.clear;
         q1.SQL.Add('delete from phonedbls');
         q1.ExecSQL;
         q1.Active :=false;
         q1.sql.clear;
         q1.free;
end;

procedure Tdhftjform.begdateChange(Sender: TObject);
begin
   cx.Checked:=false;
   Panel1.Enabled:=true;
   q1.Close;

end;

procedure Tdhftjform.cxClick(Sender: TObject);
begin
   formini('roomNo');
   Panel1.Enabled:=false;

end;

procedure Tdhftjform.mxnameChange(Sender: TObject);
begin
   formini('roomNo');
end;

procedure Tdhftjform.DBGrid1TitleClick(Column: TColumn);
begin
      formini(Column.DisplayName);

end;

procedure Tdhftjform.SpeedButton1Click(Sender: TObject);
begin
  if (DataSource1.DataSet=q1) and (q1.Active) then
  begin
     application.CreateForm(Tdhftjprinform,dhftjprinform);
     dhftjprinform.hide;
     dhftjprinform.qr1.Print;
     dhftjprinform.Close;
     dhftjprinform.free;
  end;


end;

procedure Tdhftjform.SpeedButton2Click(Sender: TObject);
begin
  if (DataSource1.DataSet=q1) and (q1.Active) then
  begin
     application.CreateForm(Tdhftjprinform,dhftjprinform);
     dhftjprinform.hide;
     dhftjprinform.qr1.preview;
     dhftjprinform.Close;
     dhftjprinform.free;
  end;
end;

procedure Tdhftjform.SpeedButton3Click(Sender: TObject);
begin
   close;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -