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

📄 unit23.pas

📁 一个用DELPHI编的酒店管理系统。 其中数据库:SQL Server2000, 只需恢复 My database文件夹中 My database_Data.MDF和 My database_Log.
💻 PAS
字号:
unit Unit23;

interface

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

type
  TForm23 = class(TForm)
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    outdate: TDateTimePicker;
    DBGrid1: TDBGrid;
    print: TButton;
    checkin: TTable;
    addcustom: TTable;
    DBGrid2: TDBGrid;
    Query1: TQuery;
    DataSource1: TDataSource;
    DataSource2: TDataSource;
    Query2: TQuery;
    Button1: TButton;
    Button2: TButton;
    roomid: TEdit;
    procedure Button1Click(Sender: TObject);


  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form23: TForm23;

implementation

{$R *.dfm}

procedure TForm23.Button1Click(Sender: TObject);
var s,t:string;
    flag:boolean;
    date:integer;
    price,sum:single;
begin

   try
      {检查"房号"}
      if roomid.Text='' then
      begin
         messageDlg('"房号"输入错误,请重新输入!',mtWarning,[mbOk],0);
         activeControl:=roomid;
         abort;
      end
      else
       {验证房号的存在性}
   begin
     flag:=false;
     with checkin do
     begin
         open;
         first;
         while not eof do
         begin
             if fieldByName('房号').AsString=roomId.Text then
             begin
             flag:=true;
             break;
             end;
         next;
         end;
     if flag=false then//客户不存在
        messageDlg('房号不存在!',mtWarning,[mbOk],0)
   end;
   s:=roomid.text;
   t:=datetostr(outdate.date);
    with checkin do
   begin
      open;
      while not eof do
      begin
         if fieldByName('房号').AsString=s then
         begin
            //date:=datetoint(strtodate(t))-datetoint(fieldByName('入住日期').Asdatetime);
            price:=strtofloat(fieldByName('折扣').Asstring)*strtofloat(fieldByName('房价').Asstring);
            sum:=date*price;
            close;
            exit;
         end;
         next;
      end;
      close;
   end;
   end;
      {将客户数据填入<住宿表>}
      with checkin do
      begin
         open;
         append;
         fieldByName('退房日期').Asdatetime:=strtodate(DatetoStr(outdate.date));
         post;
         close;
      end;

   except
      on ex:EConvertError do
      begin
         messageDlg('输入有误,请重试!',mtWarning,[mbOk],0);
      end;
   end; {end of try}
   //使结账金额累加
   with checkin do
    begin
     query1.Close;
     query1.SQL.Clear;
     query1.SQL.Add('update checkin set 结账金额+'+floattostr(sum)+' where 房号='+s);
     try
       query1.Open;
     except
       query1.ExecSQL;
    end;
   end;
   {让数据控件dbGrid1同步显示}
   with query1 do
   begin
      close;
      sql.Clear;
      sql.Add('select 客户编号,客户姓名,房号,入住日期,退房日期,结账金额 from check where 房号='+s);
      open;
   end;
   {让数据控件dbGrid1同步显示}
   with query2 do
   begin
      close;
      sql.Clear;
      sql.Add('select * from addcustom where 房号='+s);
      open;
   end;
   {清屏准备输入下一位新会员}
   roomid.text:='';
   activeControl:=roomid;
end;

end.

⌨️ 快捷键说明

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