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

📄 roomstatusut.~pas

📁 宾馆客房管理系统,功能强大,界面美观,全部delphi源代码
💻 ~PAS
字号:
unit RoomStatusUt;

interface

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

type
  TRoomStatusFm = class(TForm)
    PageControl1: TPageControl;
    TabSheet1: TTabSheet;
    Panel1: TPanel;
    Panel2: TPanel;
    rsgd: TStringGrid;
    RoomStatusAdo: TADOQuery;
    ImageList1: TImageList;
    roomstatusedit: TEdit;
    RoomStatusAdo1: TADOQuery;
    Label1: TLabel;
    GroupBox1: TGroupBox;
    Image1: TImage;
    Label2: TLabel;
    Image3: TImage;
    Label3: TLabel;
    Image2: TImage;
    Label4: TLabel;
    Image4: TImage;
    Label5: TLabel;
    Image5: TImage;
    Label6: TLabel;
    Image6: TImage;
    Label7: TLabel;
    Image7: TImage;
    procedure FormCreate(Sender: TObject);
    procedure rsgdDrawCell(Sender: TObject; ACol, ARow: Integer;
      Rect: TRect; State: TGridDrawState);
    procedure rsgdSelectCell(Sender: TObject; ACol, ARow: Integer;
      var CanSelect: Boolean);
    procedure rsgdDblClick(Sender: TObject);
    procedure typeboxChange(Sender: TObject);
    procedure floorboxChange(Sender: TObject);
  private
    { Private declarations }
  public
  procedure SetIco(index,cellcol,cellrow:integer);
  procedure SetText(number,cellcol,cellrow:integer;typename:string);
  procedure ShowStatus;
    { Public declarations }
  end;

var
  RoomStatusFm: TRoomStatusFm;
  str,str1:string;
  roomnum:integer;//选种的房间编号
  ischosen:bool;//判断是否选种了一个有效的房间
  chosenindex:integer;//选种的
  typenumber,floornumber:integer;
implementation

uses hotelmis;

{$R *.dfm}
procedure TRoomStatusFm.SetIco(index,cellcol,cellrow:integer);
var
 bitmap:Tbitmap;
 rt:Trect;
begin
  rt:=rsgd.cellRect(cellcol,cellrow);
  bitmap:=TBitMap.create;
  imagelist1.GetBitmap(index,bitmap);
  rsgd.canvas.draw(rt.Left,rt.Top,bitmap);
  bitmap.Free;
end;
procedure TRoomStatusFm.SetText(number,cellcol,cellrow:integer;typename:string);
var

 rt:Trect;
begin
   rt:=rsgd.cellRect(cellcol,cellrow);
   rsgd.canvas.brush.style:=bsclear;
   rsgd.canvas.font.Color:=clblue;
   // rsgd.canvas.brush.Color:=clblue;
   rsgd.canvas.textout(rt.Left+5,rt.top+32,inttostr(number));
    rsgd.canvas.font.Color:=clred;
    rsgd.canvas.textout(rt.Left+5,rt.top+46,typename);
end;
procedure TRoomStatusFm.ShowStatus;
var
  i,floor,room,num,index:integer;
  status:string;
  typenum:integer;
  typename:string;
  begin
  with RoomStatusAdo do
     begin
       close;
       sql.Clear;
       //sql.Add('select * from 客房信息表');
       sql.add(str1);
       open;
       first;
       i:=1;
       while not eof do
         begin
           num:=fieldbyname('客房编号').asinteger;
           status:=fieldbyname('状态').AsString;
           typenum:=fieldbyname('类型编号').AsInteger;
          with RoomStatusAdo1 do
          begin
          close;
          sql.Clear;
          sql.Add('select 类型名称 from 客房类型表 where 类型编号='+inttostr(typenum)) ;
           open;
          typename:=fieldbyname('类型名称').AsString;
         end;
           floor:=round(num/100);
           room:=num mod (100*floor);
           if status='空房' then
            index:=0;
            if status='住房' then
            index:=1;
            if status='自用' then
            index:=2;
            if status='维修' then
            index:=3;
            if status='将到' then
            index:=4;
            if status='将离' then
            index:=5;
            SetIco(index,room,floor);
            SetText(num,room,floor,typename);
            next;
           end;
        end;
end;
procedure TRoomStatusFm.FormCreate(Sender: TObject);
var
i,j:integer;
totlefloodnum:integer;
vroommnum,index:integer;
begin
i:=0;
str:='select count(楼层编号) as totle from 楼层编号表';
totlefloodnum:=hotelfm.DataTotle(RoomStatusAdo,str); //获取记录总数
rsgd.RowCount:=totlefloodnum+1;
rsgd.ColCount:=10;
rsgd.Cells[0,0]:='房间号';
 with RoomStatusAdo do
   begin
    close;
    sql.Clear;
    sql.Add('select * from 楼层编号表');
    open;
    first;
      while not eof do
       begin
         rsgd.Cells[0,i+1]:=fieldbyname('楼层名称').AsString;
          inc(i);
         next;
       end;
   end;
   for i:=0 to 20 do
   rsgd.Cells[i+1,0]:=inttostr(i+1)+'号';
 
    str1:='select * from 客房信息表 where id=""';
end;

procedure TRoomStatusFm.rsgdDrawCell(Sender: TObject; ACol, ARow: Integer;
  Rect: TRect; State: TGridDrawState);
begin
ShowStatus();
end;

procedure TRoomStatusFm.rsgdSelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
  var
  status:string;
  typenum:integer;
  typename:string;
  begin
   if (ARow>0) and (ACol>0) then
   begin
     roomnum:=100*(ARow)+ACol;
     with RoomStatusAdo do
      begin
        close;
        sql.Clear;
        sql.Add('select 状态,类型编号,楼层编号 from 客房信息表 where 客房编号='+inttostr(roomnum));
        open;
        status:=trim(fieldbyname('状态').AsString);
        typenum:=fieldbyname('类型编号').AsInteger;
         with RoomStatusAdo1 do
         begin
          close;
          sql.Clear;
          sql.Add('select 类型名称 from 客房类型表 where 类型编号='+inttostr(typenum)) ;
          open;
          typename:=fieldbyname('类型名称').AsString;
         end;
        if status<>'' then
        ischosen:=true
        else
        ischosen:=false;
         roomstatusedit.Text:=inttostr(roomnum)+typename+status;
        rsgd.Hint:=inttostr(roomnum)+chr(13)+typename+chr(13)+status;
        end;
   end;
end;

procedure TRoomStatusFm.rsgdDblClick(Sender: TObject);
begin
 if (ischosen=true) then
  begin
      with RoomStatusAdo do
      begin
        close;
        sql.Clear;
        sql.Add('select 状态 from 客房信息表 where 客房编号='+inttostr(roomnum));
        open;
        if fieldbyname('状态').AsString='空房' then
        begin
         inroomFm:=TinroomFm.create(self);
         inroomFm.showmodal;
         inroomFm.free;
        end;
        end;
  end;
end;

procedure TRoomStatusFm.typeboxChange(Sender: TObject);
var
vtypenum:integer;
begin

end;

procedure TRoomStatusFm.floorboxChange(Sender: TObject);
var
vfloornum:integer;
begin

end;

end.

⌨️ 快捷键说明

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