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

📄 zdxfcx.pas

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

interface

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

type
  Tzdxfcxform = class(TForm)
    Bevel1: TBevel;
    cx: TQuery;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    hz: TQuery;
    Panel3: TPanel;
    hdno: TMaskEdit;
    cxbut: TBitBtn;
    BitBtn1: TBitBtn;
    Panel1: TPanel;
    man: TRadioButton;
    woman: TRadioButton;
    dh: TComboBox;
    Panel2: TPanel;
    DBGrid2: TDBGrid;
    xf: TCheckBox;
    sh: TCheckBox;
    TabControl1: TTabControl;
    DBGrid1: TDBGrid;
    Splitter1: TSplitter;
    md: TCheckBox;
    dz: TCheckBox;
    procedure FormCreate(Sender: TObject);
    procedure hdnoExit(Sender: TObject);
    procedure cxbutClick(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure hdnoEnter(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure hdnoDblClick(Sender: TObject);
    procedure dhEnter(Sender: TObject);
    procedure hdnoKeyPress(Sender: TObject; var Key: Char);
    procedure shClick(Sender: TObject);
    procedure xfClick(Sender: TObject);
    procedure TabControl1Change(Sender: TObject);
    procedure DataSource2DataChange(Sender: TObject; Field: TField);
    procedure DBGrid2CellClick(Column: TColumn);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  zdxfcxform: Tzdxfcxform;

implementation
uses dataproc, newdj;

{$R *.DFM}
var
  fhc,lssex,acc:string; len:integer;

procedure Tzdxfcxform.FormCreate(Sender: TObject);
begin
   shortdateformat:='yyyy-MM-dd';
   dh.text:='';
   hdno.text:='';
   cx.Active :=false;
   cx.sql.clear;
   cx.sql.add('select distinct Djcode from custom where jsj='''+trim(curper.workjsj)+'''');
   cx.Prepare;
   cx.Open;
   dh.Items.Clear;
   while not cx.Eof do
   begin
      dh.Items.Add(cx.Fields[0].asstring);
      cx.Next;
   end;
   cx.sql.Clear;
   cx.Active :=false;

end;

procedure Tzdxfcxform.hdnoExit(Sender: TObject);
begin
  if length(trim(hdno.text))>0 then
  begin
    fm.Query2.Active :=false;
    fm.Query2.sql.clear;
    fm.Query2.sql.add('select accno,sex from nowin where roomno=:phandno');
    fm.Query2.ParamByName ('phandno').asstring:=trim(hdno.text);
    fm.Query2.Prepare;
    fm.Query2.Open;
    if fm.Query2.RecordCount>1 then
      Panel1.Visible:=true
    else
      Panel1.Visible:=false;
    if fm.Query2.FieldByName('sex').asstring='1' then
      man.Checked:=true;
    if fm.Query2.FieldByName('sex').asstring='0' then
      woman.Checked:=true;
    acc:=fm.Query2.fieldbyname('accno').asstring;
    fm.Query2.Active :=false;
    zdxfcxform.cxbutClick(nil);
  end;
end;

procedure Tzdxfcxform.cxbutClick(Sender: TObject);
var tj:string;
begin
    tj:='';
         if acc<>'' then
         begin
            if tj='' then tj:=' where ' else tj:=tj+' and ';
            tj:=tj+' accno='''+acc+'''';
         end
         else
         begin
            if xf.Checked then
            begin
               if tj='' then tj:=' where ' else tj:=tj+' and ';
               tj:= tj+' djcode='''+trim(dh.text)+'''';
            end;
         end;
         if md.Checked then
         begin
            if tj='' then tj:=' where ' else tj:=tj+' and ';
            tj:=tj+' ismd=1 ';
         end;
         if dz.Checked then
         begin
            if tj='' then tj:=' where ' else tj:=tj+' and ';
            tj:=tj+' welid in (select welid from nowin where zkl<>100) ';
         end;
         TabControl1.Tabs.Clear;
         fhc:='';
         cx.Active :=false;
         cx.sql.clear;
         if tj='' then tj:=' where ' else tj:=tj+' and ';
         cx.sql.add('select custom.handno,lssex.sexname,cusitem.cusname,custom.cusprice,custom.cusnum,custom.money,custom.isxj,custom.ismd,custom.regtime,custom.czy,pdid,Proid,custom.djcode,custom.zdcode as 自动单号,custom.sex  from custom,cusitem,lssex '+tj);
         cx.sql.add(' (custom.cuscode=cusitem.cuscode) and (lssex.sex=custom.sex) and jsj='''+trim(curper.workjsj)+'''');
         cx.Prepare;
         cx.Open;
         /////////
      //   len:=length(cx.sql.text);
         DataSource1.DataSet:=cx;
         chinesegrid(dbgrid1);
         cx.active:=true;
         if xf.Checked then exit;
         hz.Active :=false;
         hz.sql.clear;
         hz.sql.add('select djcode as 登记单号,handno as 手号,(select sexname from lssex where sex=nowin.sex) as 类型,(select isnull(sum(money),0) from custom where welid=nowin.welid and jsj='''+trim(curper.workjsj)+''') as 消费合计,money as 房费,istime as 钟点房,csmoney AS 超时 from nowin ');
         if acc<>'' then
            hz.sql.add(' where welid in (select welid from nowin where accno='''+acc+''')');

         hz.Prepare;
         hz.open;
//         dbgrid2.Fields[0].DisplayLabel:='登记单号';
         dbgrid2.Fields[2].DisplayWidth:=6;
         dbgrid2.Fields[3].DisplayWidth:=6;
         dbgrid2.Fields[4].DisplayWidth:=8;
         tbooleanfield(dbgrid2.Fields[5]).displayvalues:='是;否';
//         chinesegrid(dbgrid2);
         hz.Active :=true;
         if sh.Checked then
         begin
          TabControl1.Tabs.Add('全部');
          TabControl1.Tabs.Add('按手号');
          fhc:=' and custom.handno='''+hz.Fields[0].AsString+'''';
         end;
end;

procedure Tzdxfcxform.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=112 then
  begin
     if xt=1 then help(7);
     if xt=0 then help(19);
  end;
   if key=13 then
      selectnext(activecontrol,true,true);
   if key=27 then
       close;
end;
procedure Tzdxfcxform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  cx.free;
  hz.Free;
end;


procedure Tzdxfcxform.hdnoEnter(Sender: TObject);
begin
  man.enabled:=true;
  woman.enabled:=true;
  cx.Active :=false;
  hz.Active :=false;
end;

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

procedure Tzdxfcxform.hdnoDblClick(Sender: TObject);
begin
  Application.CreateForm(Tdjform, djform);
  djform.Panel1.Visible:=false;
  djform.rmnogrid.Visible:=false;
  djform.Button1.Enabled:=false;
  djform.Timer1.Free;
  djform.showmodal;
  hdno.Text:=copy(trim(djform.xfrmno.Text),1,6);
  if length(trim(djform.xfrmno.Text))>6 then
  begin
    Panel1.Visible:=true;
    if trim(copy(trim(djform.xfrmno.Text),7,6))='1' then
    begin
      man.Checked:=true;
      woman.Checked:=false;
    end
    else
    begin
      man.Checked:=false;
      woman.Checked:=true;
    end;
  end
  else Panel1.Visible:=false;
  djform.Free;

end;

procedure Tzdxfcxform.dhEnter(Sender: TObject);
begin
  dh.Text:='';
  hdno.text:='';
  cx.Close;
  hz.Close;
end;

procedure Tzdxfcxform.hdnoKeyPress(Sender: TObject; var Key: Char);
begin
//  key:=#0;
end;

procedure Tzdxfcxform.shClick(Sender: TObject);
begin
   if sh.Checked then
   begin
     xf.Checked:=false;
   end;
   hdno.Enabled:=sh.Checked;
   dh.Enabled:=xf.Checked;
   acc:='';
end;

procedure Tzdxfcxform.xfClick(Sender: TObject);
begin
   if (xf.Checked)  then
   begin
     sh.Checked:=false;
   end;
   hdno.Enabled:=sh.Checked;
   dh.Enabled:=xf.Checked;
   acc:='';
end;

procedure Tzdxfcxform.TabControl1Change(Sender: TObject);
begin
  if fhc<>'' then
  begin
    if TabControl1.TabIndex=1 then
      cx.SQL.Text:=cx.SQL.Text+fhc
    else
     // cx.SQL.Text:=copy(cx.SQL.Text,1,len);
         cx.SQL.Text:=cx.SQL.Text;
         cx.Prepare;
         cx.Open;
         chinesegrid(dbgrid1);
         cx.active:=true;

  end;
      if TabControl1.TabIndex=1 then
      DBGrid2CellClick(nil) else
      cxbutClick(nil);
end;

procedure Tzdxfcxform.DataSource2DataChange(Sender: TObject; Field: TField);
begin
if  TabControl1.TabIndex=1 then
begin
  if (fhc<>'') then
  begin
     fhc:=' and custom.handno='''+trim(hz.Fields[1].AsString)+'''';
     if (TabControl1.TabIndex=1) then
     begin
      // cx.SQL.Text:=copy(cx.SQL.Text,1,len);
       TabControl1Change(nil);
     end;
  end;
   if DataSource1.DataSet=nil then exit;
         cx.Active :=false;
         cx.sql.clear;
         cx.sql.add('select custom.handno,lssex.sexname,cusitem.cusname,custom.cusprice,custom.cusnum,custom.money,custom.isxj,custom.ismd,custom.regtime,custom.czy,pdid,Proid,custom.djcode,custom.sex  from custom,cusitem,lssex');
         cx.sql.add('  where (custom.cuscode=cusitem.cuscode) and (lssex.sex=custom.sex)  and jsj='''+trim(curper.workjsj)+''' ');
         if (sh.Checked) and (hdno.Text<>'') then
            cx.sql.add(' and custom.handno='''+trim(hdno.Text)+'''');
         if not xf.Checked then
            cx.sql.add(' and handno='''+trim(hz.Fields[1].asstring)+'''')
         else
            cx.sql.add(' and djcode='''+trim(dh.Text)+'''');
      //   cx.sql.add(' order by custom.cuscode ');
//         cx.ParamByName('pbeg').asdatetime:=strtodatetime(formatdatetime('yyyy-mm-dd',begdate.Date)+' '+formatdatetime('hh:mm:ss',begdate.Time));
//         cx.ParamByName('pend').asdatetime:=strtodatetime(formatdatetime('yyyy-mm-dd',enddate.Date)+' '+formatdatetime('hh:mm:ss',enddate.Time));
         cx.Prepare;
         cx.Open;
         chinesegrid(dbgrid1);
         cx.active:=true;
 end; 
end;

procedure Tzdxfcxform.DBGrid2CellClick(Column: TColumn);
begin
if  (TabControl1.TabIndex=1)  then
begin
   cx.Active :=false;
   cx.sql.clear;
   cx.sql.add('select custom.handno,lssex.sexname,cusitem.cusname,custom.cusprice,custom.cusnum,custom.money,custom.isxj,custom.ismd,custom.regtime,custom.czy,pdid,Proid,custom.djcode,custom.zdcode as 自动单号,custom.sex  from custom,cusitem,lssex ');
   cx.sql.add(' where  (custom.cuscode=cusitem.cuscode) and (lssex.sex=custom.sex) and custom.handno='''+dbgrid2.Fields[1].AsString+''' and jsj='''+trim(curper.workjsj)+'''');
   cx.Prepare;
   cx.Open;
   DataSource1.DataSet:=cx;
   chinesegrid(dbgrid1);
end;
end;

end.

⌨️ 快捷键说明

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