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

📄 roombrowse.pas

📁 我自己写的一个有关酒店管理系统的代码 大家
💻 PAS
字号:
unit roombrowse;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Grids, DBGrids, StdCtrls, Buttons, DB, ADODB, DBTables;
type
  TRoomFindForm = class(TForm)
    GroupBox1: TGroupBox;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    RadioButton3: TRadioButton;
    GroupBox2: TGroupBox;
    RadioButton4: TRadioButton;
    RadioButton5: TRadioButton;
    RadioButton6: TRadioButton;
    DBGrid1: TDBGrid;
    BitBtn1: TBitBtn;
    DataSource1: TDataSource;
    GroupBox3: TGroupBox;
    Label1: TLabel;
    Edit1: TEdit;
    ComboBox1: TComboBox;
    GroupBox4: TGroupBox;
    Label2: TLabel;
    Edit2: TEdit;
    BitBtn2: TBitBtn;
    Query1: TQuery;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormActivate(Sender: TObject);
    procedure GroupBox1Click(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure initiate;
    procedure setfindrange;
  end;
var
  RoomFindForm: TRoomFindForm;
implementation
{$R *.dfm}
//退出该模块
procedure TRoomFindForm.BitBtn1Click(Sender: TObject);
begin
  query1.close;
  close;
end;
//模块启动时,执行该模块
procedure TRoomFindForm.FormActivate(Sender: TObject);
begin
  initiate;
end;
//初始化部分
procedure TRoomFindForm.initiate;
begin
  radiobutton1.checked:=true;
  radiobutton4.Checked:=true;
  label1.Caption:='客房编号';
  combobox1.Visible:=false;
  combobox1.Text:='';
  query1.SQL.clear;
  query1.SQL.add('select * from room');
  query1.open;
  combobox1.Items.Clear;
  while not query1.Eof do
  begin
         combobox1.Items.Add(query1.fieldbyname('roomclass').asstring);
         query1.Next;
  end;
  query1.Close;
  edit1.Visible:=true;
  edit1.text:='';
  dbgrid1.DataSource:=datasource1;
  dbgrid1.ReadOnly:=true;
  datasource1.DataSet:=query1;
  query1.SQL.clear;
  query1.SQL.add('select * from room_manager');
  query1.open;
  edit2.Text:=inttostr(datasource1.DataSet.RecordCount);
  edit2.Enabled:=false;
  edit2.ReadOnly:=true;
end;
//设置查询范围
procedure TRoomFindForm.setfindrange;
begin
  query1.Active:=false;
  if radiobutton1.Checked then
  begin
          if radiobutton4.checked then
          begin
              if edit1.text<>'' then
              begin
                   query1.SQL.clear;
                   query1.SQL.add('select * from room_manager where roomno=:s0');
                   query1.ParamByName('s0').asstring:=edit1.Text;
              end
              else
              begin
                    query1.SQL.Clear;
                    query1.SQL.add('select * from room_manager');
              end;
          end
          else
          begin
              if edit1.text<>'' then
              begin
                   query1.SQL.clear;
                   query1.SQL.add('select * from room_manager where roomno=:s0 and use_id=:s1');
                   query1.ParamByName('s0').AsString:=edit1.Text;
                   query1.ParamByName('s1').asboolean:=radiobutton5.checked;
              end
              else
              begin
                   query1.SQL.clear;
                   query1.SQL.add('select * from room_manager where use_id=:s0');
                   query1.ParamByName('s0').asboolean:=radiobutton5.checked;
              end
          end
    end
    else if radiobutton2.Checked then
    begin
              if radiobutton4.Checked then
              begin
                   query1.SQL.clear;
                   query1.SQL.add('select * from room_manager where roomclass=:s0');
                   query1.ParamByName('s0').asstring:=combobox1.Items[combobox1.ItemIndex];
            end
            else
            begin
                   query1.SQL.clear;
                   query1.SQL.add('select * from room_manager where roomclass=:s0 and use_id=:s1');
                   query1.ParamByName('s0').asstring:=combobox1.Items[combobox1.ItemIndex];
                   query1.ParamByName('s1').asboolean:=radiobutton5.checked;
            end
    end
    else
    begin
         if radiobutton4.Checked then
         begin
                   query1.SQL.clear;
                   query1.SQL.add('select * from room_manager where hour_id=:s1');
                   query1.ParamByName('s0').asboolean:=radiobutton3.checked;
         end
          else
          begin
                   query1.SQL.clear;
                   query1.SQL.add('select * from room_manager where hour_id=:s0 and use_id=:s1');
                   query1.ParamByName('s0').asboolean:=radiobutton3.checked;
                   query1.ParamByName('s1').asboolean:=radiobutton5.checked;
          end;
     end ;
     query1.open;
end;

procedure TRoomFindForm.GroupBox1Click(Sender: TObject);
begin
      if radiobutton1.Checked then
      begin
            label1.Visible:=true;
            label1.caption:='客房编号';
            edit1.Visible:=true;
            edit1.Text:='';
            edit1.SetFocus;
            combobox1.Visible:=false;
      end
      else if radiobutton2.Checked then
      begin
            label1.Visible:=true;
            label1.Caption:='客房等级';
            combobox1.Visible:=true;
            edit1.Visible:=false;
            combobox1.SetFocus;
      end
      else
      begin
            label1.Visible:=false;
            edit1.Visible:=false;
            combobox1.Visible:=false;
      end
end;
//按选定的查询范围进行查询
procedure TRoomFindForm.BitBtn2Click(Sender: TObject);
begin
      setfindrange
end;

end.

⌨️ 快捷键说明

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