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

📄 u2_2.pas

📁 前言 随着旅游业的发展
💻 PAS
字号:
unit U2_2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, StdCtrls, Buttons, ComCtrls, ExtCtrls, ImgList;

type
  TF2_2 = class(TForm)
    Panel3: TPanel;
    Splitter2: TSplitter;
    TreeView1: TTreeView;
    Panel4: TPanel;
    SBTadd: TSpeedButton;
    SBTdazhe: TSpeedButton;
    SBTsave: TSpeedButton;
    SBTchudan: TSpeedButton;
    SBTback: TSpeedButton;
    Label1: TLabel;
    Edit1: TEdit;
    DBGrid1: TDBGrid;
    Panel1: TPanel;
    LBzhangdan: TLabel;
    EDzhangdan: TEdit;
    LBheji: TLabel;
    EDheji: TEdit;
    LByuan: TLabel;
    Eddazhe: TEdit;
    LByingshou: TLabel;
    EDyingshou: TEdit;
    Panel2: TPanel;
    LBfukuan: TLabel;
    LBbizhong: TLabel;
    LByinghang: TLabel;
    LBzhanghao: TLabel;
    LBbeizhu: TLabel;
    EDbeizhu: TEdit;
    EDzhanghao: TEdit;
    CBoxfukuan: TComboBox;
    CBoxbizhong: TComboBox;
    EDyinghang: TEdit;
    DBGrid2: TDBGrid;
    ImageList1: TImageList;
    function zhanghao:string;
    procedure readInfo(info:string);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure CBoxfukuanChange(Sender: TObject);
    procedure TreeView1Change(Sender: TObject; Node: TTreeNode);
    procedure FormShow(Sender: TObject);
    procedure DBGrid1DblClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure SBTchudanClick(Sender: TObject);
    procedure SBTbackClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

implementation

uses UDmo;

{$R *.dfm}
var
  count:real;

procedure TF2_2.readinfo(info:string);
begin
  with dmo.ADOQuery3 do
  begin
    Close;
    sql.Clear;
    sql.add('select xfID as ''ID'',zhanghaoID as ''顾客账号'','
            +'shangpinName as ''编号'',mingcheng as ''名称'','
            +'danwei as ''单位'',danjia as ''单价'','
            +'xiaofei as ''消费额'',time as ''消费时间''');
    sql.Add('from mingxi');
    sql.Add('where zhanghaoID=:zhanghaoID');
    parameters.ParamByName('zhanghaoID').Value:=info;
    open;
  end;
end;

function TF2_2.zhanghao:string;
var
  str:string;
begin
  with DMo.ADOQuery2 do
  begin
    close;
    sql.Clear;
    sql.Add('select zhanghaoID from mingxi');
    sql.add('where zhanghaoID like(''L%'')');
    open;
    if fields.Fields[0].AsString='' then str:='1000'
    else begin
      Last;
      str:=fields.Fields[0].asstring;
      str:=copy(str,2,length(str)-1);
      str:=trimRight(str);
      str:=intTostr(strToint(str)+1);
    end;
  end;
  str:='L'+str;
  zhanghao:=str;
end;

procedure TF2_2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Action:=caFree;
end;

procedure TF2_2.CBoxfukuanChange(Sender: TObject);
begin
  if CBoxFukuan.Text='现金' then
  begin
    EDyinghang.Enabled:=false;
    EDyinghang.Color:=clScrollBar;
    EDzhanghao.Enabled:=false;
    EDzhanghao.Color:=clScrollBar;
    Cboxbizhong.Enabled:=true;
    CBoxbizhong.Color:=clWindow;
    CBoxbizhong.Items.Clear;
    CBoxbizhong.Items.Add('人民币');
    CBoxbizhong.Items.Add('美元');
    CBoxbizhong.ItemIndex:=0;
  end else if CBoxFukuan.Text='信用卡' then
  begin
    EDzhanghao.Enabled:=true;
    EDzhanghao.Color:=clWindow;
    EDyinghang.Enabled:=false;
    EDyinghang.Color:=clScrollBar;
    CBoxbizhong.Enabled:=true;
    CBoxbizhong.Color:=clWindow;
    CBoxbizhong.Items.Clear;
    CBoxbizhong.Items.Add('牡丹卡');
    CBoxbizhong.Items.Add('灵通卡');
    CBoxbizhong.Items.Add('龙卡');
    CBoxbizhong.ItemIndex:=0;
  end else if CBoxFukuan.Text='支票' then
  begin
    EDyinghang.Enabled:=true;
    EDyinghang.Color:=clWindow;
    EDzhanghao.Enabled:=true;
    EDzhanghao.Color:=clWindow;
    CBoxbizhong.Enabled:=true;
    CBoxbizhong.Color:=clWindow;
    CBoxbizhong.Items.Clear;
    CBoxbizhong.Text:='';
  end else
  begin
    CBoxbizhong.Enabled:=false;
    CBoxbizhong.Color:=clScrollBar;
    EDyinghang.Enabled:=false;
    EDyinghang.Color:=clScrollBar;
    EDzhanghao.Enabled:=false;
    EDzhanghao.Color:=clScrollBar;
  end;
end;

procedure TF2_2.TreeView1Change(Sender: TObject; Node: TTreeNode);
var
  str:string;
  info:string;
begin
  str:=TreeView1.selected.Text;
  if str='菜肴' then info:='cy'
  else if str='餐桌号' then info:='cz'
  else if str='酒类' then info:='cj'
  else if str='会议室' then info:='kh'
  else if str='加床费' then info:='kj'
  else if str='其他商品' then info:='kq'
  else if str='手牌号' then info:='xs'
  else if str='消费及服务' then info:='xx'
  else if str='通信' then info:='st'
  else if str='网络室' then info:='sl'
  else if str='文字处理' then info:='sw'
  else if str='包厢费' then info:='yb'
  else info:='*';
  with dmo.ADOQuery1 do
  begin
    close;
    sql.Clear;
    sql.Add('select sangpinName as ''代码'',mingcheng as ''名称'','
            +'yushe as ''预设单价'',danwei as ''单位'' from jichu');
    sql.Add('where sangpinName like('''+info+'%'')');
    open;
  end;
    DBGrid1.Columns.Items[0].Width:=50;
    DBgrid1.Columns.Items[1].Width:=120;
    DBGrid1.Columns.Items[2].Width:=50;
    DBGrid1.Columns.Items[3].Width:=40;
end;
procedure TF2_2.FormShow(Sender: TObject);
begin
  EDzhangdan.Text:=zhanghao;
  readInfo(EDzhangdan.text);
end;

procedure TF2_2.DBGrid1DblClick(Sender: TObject);
var
  dm:string;
  ID:string;
  mc:string;
  zh:string;
  dw:string;
  dj:string;
  xf:string;
begin
    SBTchudan.Enabled:=true;
    SBTsave.Enabled:=true;
    Dmo.ADOQuery2.Close;
    Dmo.ADOQuery2.SQL.Clear;
    Dmo.ADOQuery2.SQL.Add('select max(xfID) from mingxi');
    Dmo.ADOQuery2.Open;
    if Dmo.ADOQuery2.Fields.Fields[0].DisplayText='' then
       ID:='0'
    else ID:=Dmo.ADOQuery2.Fields.Fields[0].AsString;
    zh:=EDzhangdan.Text;
    dm:=DBGrid1.Fields[0].AsString;
    mc:=DBGrid1.Fields[1].AsString;
    dw:=DBGrid1.Fields[3].AsString;
    dj:=DBGrid1.Fields[2].AsString;
    xf:=dj;
    count:=count+strTofloat(xf);
    ID:=intTostr(strToint(ID)+1);
    dmo.ADOQuery3.InsertRecord([id,zh,dm,mc,dw,strTofloat(dj),strTofloat(xf),NOW]);
    with DMo.ADOQuery2 do
    begin
      close;
      sql.clear;
      sql.Add('update mingxi set ld=''y''');
      sql.Add('where xfid=:xfid');
      parameters.ParamByName('xfid').Value:=strToint(id);
      execsql;
      close;
      sql.clear;
      sql.Add('update mingxi set beizhu=:beizhu');
      sql.Add('where xfid=:xfid');
      parameters.ParamByName('beizhu').Value:=EDbeizhu.Text;
      parameters.ParamByName('xfid').Value:=strToint(id);
      execsql;
    end;
    EDheji.Text:=floatTostr(count);
    EDyingshou.Text:=floatTostr(strTofloat(EDheji.Text)+strTofloat(EDdazhe.Text))
end;

procedure TF2_2.FormCreate(Sender: TObject);
begin
  count:=0.00;
end;

procedure TF2_2.SBTchudanClick(Sender: TObject);
begin
  MessageBox(Handle, '消费和收银记录已经保存', '结账',
              MB_ICONASTERISK);
  with dmo.ADOQuery2 do
  begin
    close;
    sql.Clear;
    sql.Add('update mingxi set fk=''y''');
    sql.Add('where zhanghaoID=:zhanghaoID');
    parameters.ParamByName('zhanghaoID').Value:=EDzhangdan.Text;
    execsql;
  end;
  DBGrid2.Columns.Clear;
  EDzhangdan.Text:=zhanghao;
  readInfo(EDzhangdan.Text);

end;

procedure TF2_2.SBTbackClick(Sender: TObject);
begin
  Close;
end;

end.

⌨️ 快捷键说明

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