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

📄 jk.pas

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

interface

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

type
  Tjkform = class(TForm)
    q1: TQuery;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    pass1: TEdit;
    Panel1: TPanel;
    Label6: TLabel;
    curbc: TEdit;
    Label7: TLabel;
    Label8: TLabel;
    bgtime: TMaskEdit;
    Label9: TLabel;
    edtime: TMaskEdit;
    curname: TEdit;
    StringGrid1: TStringGrid;
    Regid1: TEdit;
    s1: TStoredProc;
    Query1: TQuery;
    Panel4: TPanel;
    Label4: TLabel;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    Panel2: TPanel;
    Label2: TLabel;
    Label3: TLabel;
    Regid: TEdit;
    pass: TEdit;
    Panel3: TPanel;
    Button4: TButton;
    procedure FormCreate(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Button2Click(Sender: TObject);
    procedure FormKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure StringGrid1KeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure StringGrid1KeyPress(Sender: TObject; var Key: Char);
    procedure StringGrid1Click(Sender: TObject);
    procedure curnameDblClick(Sender: TObject);
    procedure Label2DblClick(Sender: TObject);
    procedure curnameKeyPress(Sender: TObject; var Key: Char);
    procedure RegidKeyPress(Sender: TObject; var Key: Char);
    procedure passKeyPress(Sender: TObject; var Key: Char);
    procedure Button4Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  jkform: Tjkform;

implementation
uses dataproc, jkprint;

{$R *.DFM}

function hdq(dd:string;k:integer):string;
begin
   hdq:=copy(copy('                   ',1,k)+trim(dd),length(trim(dd))+1,k);

end;



procedure formini;
var
   lsdate,lsdate1,lsdate2:real;
//  lsdate,lscode:string;
  i:integer;
//  aa:array [0..1] of string;
begin
with jkform do
begin
 // lsdate:=datetostr(date());
  q1.Active :=false;
  q1.sql.clear;
  q1.sql.Add('select max(jkTime) from jkmx where GiveTime='''+trim(bgtime.Text)+''' and bc='''+trim(copy(trim(curbc.text),12,4))+'''');
  q1.Prepare;
  q1.open;
  if q1.Fields[0].isnull then
     Label4.Caption:='上次本班交款时间:'+q1.Fields[0].asstring
  else
     Label4.Caption:='本班还没有交款!';
  q1.Active :=false;
  q1.sql.clear;
  q1.sql.Add('select avg(zsbyjxj),avg(zsbyjhy),avg(zsbyjzp),avg(zsbyjcard),avg(zsbyjgz),avg(zsbyjmd),avg(zsbyjother),sum(bcjxj),sum(bcjhy),sum(bcjzp),sum(bcjcard),sum(bcjgz),sum(bcjmd),sum(bcjother) from jkmx where GiveTime='''+trim(bgtime.Text)+''' and bc='''+trim(copy(trim(curbc.text),12,4))+'''');
  q1.Prepare;
  q1.open;
  lsdate1:=0;
  lsdate2:=0;
  for i:=2 to 8 do
  begin
    if not q1.fields[i-2].isnull then
        lsdate:=q1.fields[i-2].asfloat
    else
        lsdate:=0;
    if i<>8 then StringGrid1.Cells[i,0]:=hdq(floattostr(lsdate),9)
    else StringGrid1.Cells[i,0]:=hdq(floattostr(lsdate),6);
    lsdate1:=lsdate1+lsdate;
    if not q1.fields[i+5].isnull then
        lsdate:=q1.fields[i+5].asfloat
    else
        lsdate:=0;
    if i<>8 then StringGrid1.Cells[i,1]:=hdq(floattostr(lsdate),9)
    else StringGrid1.Cells[i,1]:=hdq(floattostr(lsdate),6);
    lsdate2:=lsdate2+lsdate;

  end;
  StringGrid1.Cells[9,0]:=hdq(floattostr(lsdate1),9);
  StringGrid1.Cells[9,1]:=hdq(floattostr(lsdate2),9);
  q1.Active :=false;
  q1.sql.clear;
  q1.sql.Add('select (select sum(ysmoney) from lsjz where jzfs=''01'' and jztime>=:pbeg and jztime<=:pend),');
  q1.sql.Add('(select sum(ysmoney) from lsjz where jzfs=''06'' and jztime>=:pbeg and jztime<=:pend),');
  q1.sql.Add('(select sum(ysmoney) from lsjz where jzfs=''02'' and jztime>=:pbeg and jztime<=:pend),');
  q1.sql.Add('(select sum(ysmoney) from lsjz where jzfs>''1'' and jztime>=:pbeg and jztime<=:pend),');
  q1.sql.Add('(select sum(ysmoney) from lsjz where jzfs=''04'' and jztime>=:pbeg and jztime<=:pend),');
  q1.sql.Add('(select sum(ysmoney) from lsjz where jzfs=''05'' and jztime>=:pbeg and jztime<=:pend),0,');
  q1.sql.Add('(select sum(ysmoney) from lsjz where jztime>=:pbeg and jztime<=:pend)');
  q1.ParamByName('pbeg').asdatetime:=strtodatetime(bgtime.Text);
  q1.ParamByName('pend').asdatetime:=strtodatetime(edtime.Text);
  q1.Prepare;
  q1.open;
  for i:=0 to 7 do
  begin
    StringGrid1.Cells[i+2,2]:=hdq(floattostr(q1.Fields[i].Asfloat),9);
    StringGrid1.Cells[i+2,3]:=hdq(floattostr(strtofloat(StringGrid1.Cells[i+2,0])+q1.Fields[i].Asfloat-strtofloat(StringGrid1.Cells[i+2,1])),9);
  end;
  q1.Active :=false;
  q1.sql.clear;
  q1.sql.Add('select * from jkmoney ');
  q1.Prepare;
  q1.open;
//  q1.First;
  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:=' 免单';
  DBGrid1.fields[8].displaylabel:=' 其他';
  DBGrid1.fields[9].displaylabel:=' 小计';
  dbgrid1.Columns[1].width:=40;
  dbgrid1.Columns[2].width:=60;
  dbgrid1.Columns[3].width:=60;
  dbgrid1.Columns[4].width:=60;
  dbgrid1.Columns[5].width:=60;
  dbgrid1.Columns[6].width:=60;
  dbgrid1.Columns[7].width:=60;
  dbgrid1.Columns[0].width:=80;
  if trim(StringGrid1.Cells[9,3])='0' then
       Button2.Enabled:=false
    else
       Button2.Enabled:=true;
  end;
end;


procedure Tjkform.FormCreate(Sender: TObject);
begin
  shortdateformat:='yyyy-mm-dd';
  q1.Active :=false;
  q1.sql.Clear ;
  q1.sql.add('select GiveTime,NewBc,name,pass,NewRegid from changebc,stuff where changebc.NewRegid=stuff.code');
  q1.Open;
  q1.Last;
  if trim(q1.fields[0].asstring)<>'' then
  begin
     bgtime.Text :=q1.fields[0].asstring;
//     curbc.Text:=copy(trim(q1.fields[0].asstring),1,10)+':'+q1.fields[1].asstring;
  end
  else
  begin
     bgtime.Text :='2001-01-01 00:00';
//     curbc.Text:=curper.curbc;
  end;
  curbc.Text:=formatdatetime('yyyy-mm-dd',now)+':'+curper.curbc;
 // curbc.Text:=copy(trim(q1.fields[0].asstring),1,10)+':'+q1.fields[1].asstring;
  curname.Text:=q1.fields[2].asstring;
  pass1.Text:=q1.fields[3].asstring;
  Regid1.text:=q1.fields[4].asstring;
  q1.Close;
  edtime.text:=datetimetostr(now);

  s1.Prepare;
  s1.ParamByName ('@lsbegtime').asdatetime:=strtodatetime(bgtime.text);
  s1.ParamByName ('@lsendtime').asdatetime:=strtodatetime(edtime.text);
  s1.Prepare;
  s1.ExecProc ;
  StringGrid1.Cells[0,0]:='转上班应交';
  StringGrid1.Cells[0,1]:='本班已交合计';
  StringGrid1.Cells[0,2]:='本班应交合计';
  StringGrid1.Cells[0,3]:='本次实交合计';
//  StringGrid1.SetFocus;
  jkform.ActiveControl:=StringGrid1;
  formini;
end;


procedure Tjkform.Button1Click(Sender: TObject);
begin
//  prn;
     application.CreateForm(Tjkbprintform,jkbprintform);
     jkbprintform.hide;
     jkbprintform.qr1.print;
     //preview ;
     //
     jkbprintform.Close;
     jkbprintform.free;

  button2.Enabled :=true;
end;

procedure Tjkform.Button3Click(Sender: TObject);
begin
  jkform.Close;
end;

procedure Tjkform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  q1.Close;
//  q1.Free;
//  s1.free;
end;

procedure Tjkform.Button2Click(Sender: TObject);
begin
  if trim(stringgrid1.Cells[2,3])='' then exit;
  Panel2.Visible:=true;
  Panel3.Visible:=true;
  pass.SetFocus;
  pass.Text:='****';

end;

procedure Tjkform.FormKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
  if key=112 then
  begin
    if xt=0 then help(26);
  end;
{  if key=13 then
     selectnext(activecontrol,true,true);}
  if key=27 then
    if Panel2.Visible then Panel2.Visible:=false
    else
     jkform.close;
end;

procedure Tjkform.StringGrid1KeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
var lsdate:real;
    i:integer;
begin
  if key=13 then
  begin
    if trim(StringGrid1.Cells[StringGrid1.col,StringGrid1.row])='' then
       StringGrid1.Cells[StringGrid1.col,StringGrid1.row]:='0';
    StringGrid1.Cells[StringGrid1.col,StringGrid1.row]:=hdq(StringGrid1.Cells[StringGrid1.col,StringGrid1.row],9);
    if StringGrid1.col<8 then
    begin
      StringGrid1.col:=StringGrid1.col+1;
      StringGrid1.SetFocus;
    end
    else
      Button1.SetFocus;
    lsdate:=0;
    for i:=2 to 7 do
      lsdate:=lsdate+strtofloat(StringGrid1.Cells[i,StringGrid1.Row]);
    if StringGrid1.Row<>7 then
      StringGrid1.Cells[8,StringGrid1.Row]:=hdq(floattostr(lsdate),9)
    else
      StringGrid1.Cells[8,StringGrid1.Row]:=hdq(floattostr(lsdate),6);
    if StringGrid1.col=8 then
    begin
       Button1.SetFocus;
       StringGrid1.col:=2;
    end;
    if trim(StringGrid1.Cells[8,3])='0' then
        Button2.Enabled:=false
    else
        Button2.Enabled:=true;

  end;
end;

procedure Tjkform.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
  if (key<'0') or (key>'9') then
     if (key<>#13) and (key<>#8) then key:=#0;
end;

procedure Tjkform.StringGrid1Click(Sender: TObject);
begin
 if StringGrid1.col=8 then
    StringGrid1.col:=2;

end;

procedure Tjkform.curnameDblClick(Sender: TObject);
begin
  Panel2.Visible:=true;
  Panel3.Visible:=false;
  Regid.SetFocus;
  Regid.Text:='';
end;

procedure Tjkform.Label2DblClick(Sender: TObject);
begin
  Panel2.Visible:=false;
  StringGrid1.SetFocus;
end;

procedure Tjkform.curnameKeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then curnameDblClick(nil);
     key:=#0;
end;

procedure Tjkform.RegidKeyPress(Sender: TObject; var Key: Char);
begin
 if key=#13 then pass.SetFocus;
end;

procedure Tjkform.passKeyPress(Sender: TObject; var Key: Char);
var
  i:integer;
begin
 if key=#13 then
    if Panel3.Visible then
    begin
       if passzh(trim(pass.Text))=trim(pass1.Text) then
       begin
         Panel2.Visible:=false;
         Panel3.Visible:=false;
         fm.Query1.Active :=false;
         fm.Query1.sql.clear;
         fm.Query1.sql.add('insert into jkmx values(:pGiveTime,:pbc,:pjkregid,:p11,:p12,:p13,:p14,:p15,:p16,:p17,:p21,:p22,:p23,:p24,:p25,:p26,:p27,:pjkTime) ');
         fm.Query1.ParamByName('pGiveTime').asdatetime:=strtodatetime(bgtime.text);
         fm.Query1.ParamByName('pbc').asstring:=trim(copy(trim(curbc.text),12,4));
         fm.Query1.ParamByName('pjkregid').asstring:=trim(Regid1.text);
         for i:=1 to 7 do
         begin
           fm.Query1.ParamByName('p1'+inttostr(i)).asfloat:=strtofloat(StringGrid1.Cells[i+1,0]);
           fm.Query1.ParamByName('p2'+inttostr(i)).asfloat:=strtofloat(StringGrid1.Cells[i+1,3]);
         end;
         fm.Query1.ParamByName('pjkTime').asdatetime:=strtodatetime(edtime.text);
         fm.Query1.Prepare;
         fm.Query1.ExecSQL ;
         fm.Query1.Active :=false;
         showmessage('交款成功');
         jkform.close;
       end
       else
       begin
         showmessage('输入有误,请重新输入!');
         pass.SetFocus;
         pass.Text:='****';
       end;
    end
    else
    begin
       fm.Query2.Active :=false;
       fm.Query2.sql.clear;
       fm.Query2.sql.Add('select Name from stuff where code='''+trim(Regid.Text)+''' and pass='''+passzh(trim(pass.text))+'''');
       fm.Query2.Prepare;
       fm.Query2.open;
       if not fm.Query2.Eof then
       begin
         curname.text:=fm.Query2.Fields[0].asstring;
         pass1.text:=passzh(trim(Pass.Text));
         Regid1.text:=Regid.Text;
         Panel2.Visible:=false;
         StringGrid1.SetFocus;
       end
       else
       begin
         showmessage('输入有误,请重新输入!');
         Regid.SetFocus;
         Regid.Text:='';
       end;
       fm.Query2.Close;
       fm.Query2.Active :=false;
       fm.Query2.sql.clear;
       fm.Query2.UnPrepare;

       fm.query2.RequestLive:=false;
    end;
end;

procedure Tjkform.Button4Click(Sender: TObject);
begin
     application.CreateForm(Tjkbprintform,jkbprintform);
     jkbprintform.hide;
     jkbprintform.qr1.preview ;
     //
     //print;
     jkbprintform.Close;
     jkbprintform.free;

end;

end.

⌨️ 快捷键说明

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