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

📄 ryyjtj.pas

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

interface

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

type
  TryyjtjForm = class(TForm)
    TabControl1: TTabControl;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    ComboBox1: TComboBox;
    Panel1: TPanel;
    Label7: TLabel;
    Label2: TLabel;
    begdate: TDateTimePicker;
    enddate: TDateTimePicker;
    BitBtn1: TBitBtn;
    begtime: TDateTimePicker;
    endtime: TDateTimePicker;
    bm: TCheckBox;
    Query1: TQuery;
    bmmc: TComboBox;
    bmbh: TComboBox;
    Q2: TQuery;
    xgh: TCheckBox;
    gh: TEdit;
    xsm: TCheckBox;
    xm: TEdit;
    BitBtn2: TBitBtn;
    PopupMenu1: TPopupMenu;
    N1: TMenuItem;
    Query2: TQuery;
    zy: TCheckBox;
    fw: TCheckBox;
    BitBtn3: TBitBtn;
    procedure FormCreate(Sender: TObject);
    procedure DBGrid1Enter(Sender: TObject);
    procedure begdateChange(Sender: TObject);
    procedure TabControl1Change(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure BitBtn1Click(Sender: TObject);
    procedure bmmcChange(Sender: TObject);
    procedure FormShow(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure N1Click(Sender: TObject);
    procedure BitBtn3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  ryyjtjForm: TryyjtjForm;

implementation

{$R *.DFM}
uses yjmxtj,hyzytcprin;
procedure init(ry:integer);
begin
{with ryyjForm do
  begin
    Query1.Active:=false;
    Query1.SQL.Clear;
    Query1.sql.Text:='delete nowinls';
    Query1.sql.add('insert into nowinls select * from nowin where BegTime<='''+datetostr(enddate.date)+' 23:59'+''' and BegTime>='''+datetostr(begdate.date)+'''');
    Query1.sql.add('insert into nowinls select * from lsnowin where BegTime<='''+datetostr(enddate.date)+' 23:59'+''' and BegTime>='''+datetostr(begdate.date)+'''');
    Query1.sql.add('delete customls');
    Query1.sql.add('insert into customls select * from custom where Regtime<='''+datetostr(enddate.date)+' 23:59'+''' and Regtime>='''+datetostr(begdate.date)+'''');
    Query1.sql.add('insert into customls select * from lscustom where Regtime<='''+datetostr(enddate.date)+' 23:59'+''' and Regtime>='''+datetostr(begdate.date)+'''');
    Query1.Prepare;
    Query1.ExecSQL;
    Query1.Active:=false;
    Query1.SQL.Clear;
    Query1.SQL.Text:='select code,Name,dj=(select count(DISTINCT AccNo) from nowinls where czy=stuff.name) ,';
    Query1.SQL.Add('jz=(select count(DISTINCT AccNo) from lsjz where czy=stuff.name and jztime<='''+datetostr(enddate.date)+' 23:59'+''' and jztime>='''+datetostr(begdate.date)+'''),');
    Query1.SQL.Add('xf=(select count(DISTINCT Djcode) from customls where czy=stuff.name),');
    Query1.SQL.Add('pd=(select count(DISTINCT Djcode) from customls where pdid=stuff.name),');
    Query1.SQL.Add('zy=(select count(AccNo) from customls where Proid=stuff.name),money=(select sum(Money) from customls where Proid=stuff.name)');
    Query1.SQL.Add(' from stuff where deptcode='''+ComboBox1.Items[ry]+'''');
    Query1.Prepare;
    Query1.Open;
    DBGrid1.fields[0].displaylabel:=' 工号';
    DBGrid1.fields[1].displaylabel:='  姓名';
    DBGrid1.fields[2].displaylabel:=' 登记次数';
    DBGrid1.fields[3].displaylabel:=' 结帐次数';
    DBGrid1.fields[4].displaylabel:=' 消费单录入';
    DBGrid1.fields[5].displaylabel:=' 跑单次数';
    DBGrid1.fields[6].displaylabel:=' 专业服务次数';
    DBGrid1.fields[7].displaylabel:=' 专业服务收入';

  end;}

end;


procedure TryyjtjForm.FormCreate(Sender: TObject);
begin
    q2.Active :=false;
    q2.sql.Clear ;
    q2.sql.add('select * from dept');
    q2.Prepare;
    q2.open;
    bmmc.Items.Clear;
    bmbh.Items.Clear;
    while not q2.Eof do
    begin
      bmbh.Items.Add(q2.FieldByName('Code').asstring);
      bmmc.Items.Add(q2.FieldByName('deptname').asstring);
      q2.Next;
    end;
    q2.Close;
    q2.UnPrepare;
 { Query1.sql.Text:='select code,deptname from dept';
  Query1.Open;
  TabControl1.Tabs.Clear;
  ComboBox1.Items.Clear;
  while not Query1.Eof do
  begin
    TabControl1.Tabs.Add(Query1.Fields[1].asstring);
    ComboBox1.Items.Add(Query1.Fields[0].asstring);
    Query1.Next;
  end;
  Query1.sql.Clear;
  query1.Active :=false;}
 { enddate.date:=now;
  begdate.date:=now;
  init(0); }

end;

procedure TryyjtjForm.DBGrid1Enter(Sender: TObject);
begin
 //init(TabControl1.TabIndex);

end;

procedure TryyjtjForm.begdateChange(Sender: TObject);
begin
    //ActiveControl:=DBGrid1;

end;

procedure TryyjtjForm.TabControl1Change(Sender: TObject);
begin
 //init(TabControl1.TabIndex);

end;

procedure TryyjtjForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
    Query1.Active:=false;
    Query1.SQL.Clear;
    Query1.sql.Text:='delete nowinls';
    Query1.sql.add('delete customls');
    Query1.Prepare;
    Query1.ExecSQL;
    Query1.Active:=false;
    Query1.SQL.Clear;

end;

procedure TryyjtjForm.BitBtn1Click(Sender: TObject);
begin
 close;
end;

procedure TryyjtjForm.bmmcChange(Sender: TObject);
begin
   bmbh.ItemIndex:=bmmc.ItemIndex;
end;

procedure TryyjtjForm.FormShow(Sender: TObject);
begin
    gh.Text:='';xm.Text:='';bmmc.Text:='';bmbh.Text:='';
   begdate.DateTime:=now-1;
   enddate.DateTime:=now;
   begtime.Time:=strtotime('00:00:00');
   endtime.Time:=strtotime('00:00:00');

end;

procedure TryyjtjForm.BitBtn2Click(Sender: TObject);
 var tj:string;
begin             
  tj:='';
  if (zy.Checked)and (not fw.Checked)  then
    tj:=' customls.proid=stuff.Name and  ';
  if (not zy.Checked)and ( fw.Checked) then
    tj:=' customls.pdid=stuff.Name and  ';
  if ((zy.Checked)and (fw.Checked))or((not zy.Checked)and (not fw.Checked)) then
  tj:=' (customls.proid=stuff.Name or customls.pdid=stuff.Name) and ' ;
    Query1.Active:=false;
    Query1.SQL.Clear;
    Query1.sql.Text:='delete nowinls';
    Query1.sql.add('insert into nowinls select * from nowin where BegTime<=:pend and BegTime>=:pbeg ');
    Query1.sql.add('insert into nowinls select * from lsnowin where BegTime<=:pend and BegTime>=:pbeg');
    Query1.sql.add('delete customls');
    Query1.sql.add('insert into customls select * from custom where Regtime<=:pend and Regtime>=:pbeg ');
    Query1.sql.add('insert into customls select * from lscustom where Regtime<=:pend and Regtime>=:pbeg ');
    Query1.ParamByName('pbeg').asdatetime:=strtodatetime(formatdatetime('yyyy-MM-dd',begdate.Date)+' '+formatdatetime('hh:mm:ss',begtime.Time));
    Query1.ParamByName('pend').asdatetime:=strtodatetime(formatdatetime('yyyy-MM-dd',enddate.Date)+' '+formatdatetime('hh:mm:ss',endtime.Time));
   { Query1.sql.add('insert into nowinls select * from nowin where BegTime<='''+datetostr(enddate.date)+' formatdatetime('hh:mm:ss',begtime.Time+'+''' and BegTime>='''+datetostr(begdate.date)+'''');
    Query1.sql.add('insert into nowinls select * from lsnowin where BegTime<='''+datetostr(enddate.date)+' 23:59'+''' and BegTime>='''+datetostr(begdate.date)+'''');
    Query1.sql.add('delete customls');
    Query1.sql.add('insert into customls select * from custom where Regtime<='''+datetostr(enddate.date)+' 23:59'+''' and Regtime>='''+datetostr(begdate.date)+'''');
    Query1.sql.add('insert into customls select * from lscustom where Regtime<='''+datetostr(enddate.date)+' 23:59'+''' and Regtime>='''+datetostr(begdate.date)+''''); }
    Query1.Prepare;
    Query1.ExecSQL;
    Query1.Active:=false;
    Query1.SQL.Clear;
    Query1.SQL.Text:='select distinct code,Name,(select sum(cusnum) from customls  where  '+tj+' regtime>=:pbeg and regtime<=:pend and ismd<>1 ) as 数量,';
    Query1.SQL.Add('(select sum(money) from customls  where   '+tj+'   regtime>=:pbeg and regtime<=:pend and ismd<>1 ) as 金额,');
    Query1.SQL.Add('(select sum(tcje) from customls  where   '+tj+'    regtime>=:pbeg and regtime<=:pend and ismd<>1 ) as 提成金额');
    if (zy.Checked)and (not fw.Checked)  then
    Query1.SQL.Add(' from stuff where iszy=1 ' );
    if (not zy.Checked)and (fw.Checked)  then
    Query1.SQL.Add(' from stuff where isfwy=1 ' );
    if ((zy.Checked)and (fw.Checked))or((not zy.Checked)and (not fw.Checked)) then
    Query1.SQL.Add(' from stuff where (iszy=1 or isfwy=1)' );
    if (bm.Checked) and (bmmc.Text<>'') then
    Query1.sql.add(' and deptcode='''+trim(bmbh.Text)+'''');
    if (xgh.Checked) and (gh.Text<>'') then
    Query1.sql.add(' and code='''+trim(gh.Text)+'''');
    if (xsm.Checked) and (xm.Text<>'') then
    Query1.sql.add(' and name='''+trim(xm.Text)+'''');
    Query1.ParamByName('pbeg').asdatetime:=strtodatetime(formatdatetime('yyyy-mm-dd',begdate.Date)+' '+formatdatetime('hh:mm:ss',begtime.Time));
    Query1.ParamByName('pend').asdatetime:=strtodatetime(formatdatetime('yyyy-mm-dd',enddate.Date)+' '+formatdatetime('hh:mm:ss',endtime.Time));
    Query1.Prepare;
    Query1.Open;
    DBGrid1.fields[0].displaylabel:=' 工号';
    DBGrid1.fields[1].displaylabel:='  姓名';
    DBGrid1.fields[2].displaylabel:=' 消费次数';
    DBGrid1.fields[3].displaylabel:=' 消费总金额';
    DBGrid1.fields[4].displaylabel:=' 提成合计';

end;

procedure TryyjtjForm.N1Click(Sender: TObject);
begin
 if (query1.Active)and (query1.RecordCount<>0) then
 begin
  query2.Active:=false;
  query2.SQL.Clear;
  query2.SQL.Add('select distinct  cuscode as 商品编号,(select cusname from cusitem where cusitem.cuscode=t.cuscode) 项目名称,');
 // query2.SQL.Add('(select cusprice from cusitem where cusitem.cuscode=t.cuscode) as 项目单价,');
  query2.SQL.Add('(select sum(cusnum) from customls where (customls.proid=:pzyry or customls.pdid=:pzyry) and  regtime>=:pbeg and regtime<=:pend and ismd<>1 and customls.cuscode=t.cuscode ) as 数量,');
  query2.SQL.Add('(select tcje from cusitem where cusitem.cuscode=t.cuscode) as 提成单价,');
  query2.SQL.Add('(select sum(cusnum) from customls where (customls.proid=:pzyry or customls.pdid=:pzyry) and  regtime>=:pbeg and regtime<=:pend and ismd<>1 and customls.cuscode=t.cuscode )* ');
  query2.SQL.Add('(select tcje from cusitem where cusitem.cuscode=t.cuscode) as 提成小计 ');
//  query2.SQL.Add('(select sum(money) from customls where (customls.proid=:pzyry or customls.pdid=:pzyry) and  regtime>=:pbeg and regtime<=:pend and ismd<>1 and customls.cuscode=t.cuscode ) as 金额 from customls as t where ');
  query2.SQL.Add('  from customls as t where ');
  query2.SQL.Add('(t.proid=:pzyry or t.pdid=:pzyry) and  regtime>=:pbeg and regtime<=:pend and ismd<>1 ');
  query2.ParamByName('pbeg').asdatetime:=strtodatetime(formatdatetime('yyyy-mm-dd',begdate.Date)+' '+formatdatetime('hh:mm:ss',begtime.Time));
  query2.ParamByName('pend').asdatetime:=strtodatetime(formatdatetime('yyyy-mm-dd',enddate.Date)+' '+formatdatetime('hh:mm:ss',endtime.Time));
  query2.ParamByName('pzyry').asstring:=query1.fieldbyname('Name').asstring;
  query2.Open;
  Application.CreateForm(TyjmxtjForm, yjmxtjForm);
  yjmxtjForm.showmodal;
  yjmxtjForm.free;
  end ;
end;

procedure TryyjtjForm.BitBtn3Click(Sender: TObject);
begin
 if (query1.Active)and (query1.RecordCount<>0) then
 begin
     application.CreateForm(Tzytcpnform,zytcpnform);
     zytcpnform.QRLabel6.Caption:=' '+formatdatetime('yyyy''年''MM''月''dd''日''',begdate.date)+' '+formatdatetime('hh''时''mm''分''ss''秒''',begtime.time)
              +' 到 '+formatdatetime('yyyy''年''MM''月''dd''日''',enddate.date)+' '+formatdatetime('hh''时''mm''分''ss''秒''',endtime.time);
     zytcpnform.hide;
     zytcpnform.qr1.Preview;
     zytcpnform.Close;
     zytcpnform.free;
 end;
end;

end.

⌨️ 快捷键说明

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