📄 unitroomquery.pas
字号:
unit UnitRoomQuery;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, ExtCtrls, StdCtrls, ImgList, DB, ADODB,
Buttons,strutils;
type
TfrmRoomQuery = class(TForm)
CoolBar1: TCoolBar;
StatusBar1: TStatusBar;
ToolBar1: TToolBar;
ToolButton1: TToolButton;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
Panel1: TPanel;
Splitter1: TSplitter;
Panel2: TPanel;
Panel3: TPanel;
Splitter2: TSplitter;
Panel4: TPanel;
lvwRoom: TListView;
RoomImages: TImageList;
ADOQuery: TADOQuery;
btnShowAll: TBitBtn;
btnShowNull: TBitBtn;
btnShowFull: TBitBtn;
btnEnter: TBitBtn;
Panel5: TPanel;
Splitter3: TSplitter;
Panel6: TPanel;
GroupBox1: TGroupBox;
GroupBox2: TGroupBox;
Label1: TLabel;
DateTimePicker1: TDateTimePicker;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
edtXM: TEdit;
edtSex: TEdit;
edtBirth: TEdit;
edtIDno: TEdit;
edtAddress: TEdit;
edtRegistdate: TEdit;
lblRoomState: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
edtFloor: TEdit;
edtRoom: TEdit;
edtBed: TEdit;
edtRoomtype: TEdit;
procedure ToolButton3Click(Sender: TObject);
procedure lvwRoomSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
procedure btnShowAllClick(Sender: TObject);
procedure btnEnterClick(Sender: TObject);
procedure ToolButton1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
strCon:string;
clientid:string;
procedure InitLvwRoom();
{ Private declarations }
public
procedure GetClientData();
{ Public declarations }
end;
var
frmRoomQuery: TfrmRoomQuery;
implementation
uses UnitMain, unitBebArrange;
{$R *.dfm}
procedure TfrmRoomQuery.InitLvwRoom ();
var
xx:TlistColumn;
begin
lvwRoom.ViewStyle:=vsReport;
xx:=lvwRoom.Columns.Add;
xx.Caption:='房间号';
xx:=lvwRoom.Columns.Add;
xx.Caption :='楼层';
xx:=lvwRoom.Columns.add;
xx.Caption :='床位数';
xx:=lvwRoom.Columns.add ;
xx.Caption:='已住入数';
end;
procedure TfrmRoomQuery.GetClientData();
var
strSmt:string;
begin
if ClientID<>'NONE' then //Show current client information
begin
strSmt:='select custom_name,b.Sex_name,c.Country_name,a.custom_birth, ';
strSmt:=strSmt+' a.custom_phone,a.custom_address,a.custom_idno, ';
strSmt:=strSmt+' a.regist_date,d.room_no,d.flooer_id,a.bed_no,e.bedSta_name, ';
strSmt:=strSmt+' a.bedsta_id,f.roompro_name ';
strSmt:=strSmt+' from CustomerList a left outer join SexList b ';
strSmt:=strSmt+' on a.custom_sexid=b.Sex_id ';
strSmt:=strSmt+' left outer join CountryList c ';
strSmt:=strSmt+' on a.custom_countryid=c.Country_id';
strSmt:=strSmt+' left outer join RoomList d';
strSmt:=strSmt+' on a.room_id=d.room_id ';
strSmt:=strSmt+' left outer join Bedstatus e';
strSmt:=strSmt+' on a.bedsta_id=e.BedSta_id';
strSmt:=strSmt+' left outer join RoomProperty f';
strSmt:=strSmt+' on d.roompro_id =f.Roompro_id';
strSmt:=strSmt+' where regist_id='+ClientID+'';
edtxm.Text:=strsmt;
// exit;
try
adoquery.Close;
adoquery.SQL.Clear;
adoquery.sql.Add(strSmt);
adoquery.ConnectionString:=strCon;
adoquery.Open ;
while not adoquery.Eof do
begin
edtxm.Text:=adoquery.FieldValues['custom_name'];
edtsex.Text:=adoquery.FieldValues['Sex_name'];
edtbirth.Text:=adoquery.FieldValues['custom_birth'];
edtidno.Text:=adoquery.FieldValues['custom_idno'];
edtaddress.Text:=adoquery.FieldValues['custom_address'];
edtregistdate.Text:=adoquery.FieldValues['regist_date'];
//exit;
if adoquery.FieldByName('bedsta_id').AsString='1' then //臧客当前没有设置房间
begin
lblroomstate.Caption:='没有安排房间';
edtfloor.Visible:=false;
edtroom.Visible:=false;
edtbed.Visible :=false;
edtroomtype.Visible :=false;
label9.Visible:=false;
label10.Visible :=false;
label11.Visible :=false;
label12.Visible :=false;
end
else //已安排
begin
lblroomstate.Caption:='房间设置情况';
edtfloor.Visible:=true;
edtroom.Visible:=true;
edtbed.Visible :=true;
edtroomtype.Visible :=true;
label9.Visible :=true;
label10.Visible :=true;
label11.Visible :=true;
label12.Visible :=true;
edtfloor.Text:=adoquery.FieldValues['flooer_id'];
edtroom.text:=adoquery.FieldValues['room_no'];
edtbed.Text:=adoquery.FieldValues['bed_no'];
edtroomtype.Text:=adoquery.FieldValues['roompro_name'];
end;
adoquery.Next;
end;
finally
adoquery.Close;
adoquery.SQL.Clear ;
end;
end;
end;
procedure TfrmRoomQuery.ToolButton3Click(Sender: TObject);
begin
frmRoomQuery.InitLvwRoom ;
end;
procedure TfrmRoomQuery.lvwRoomSelectItem(Sender: TObject; Item: TListItem;
Selected: Boolean);
begin
caption:=inttostr(item.Index);
end;
procedure TfrmRoomQuery.btnShowAllClick(Sender: TObject);
var
xx:TListItem;
smt:string;
strLeave:string;
begin
smt:='execute RoomLive_Status';
adoQuery.Close;
adoQuery.SQL.Clear ;
adoquery.SQL.Add(smt);
adoquery.ConnectionString:=strCon;
try
adoQuery.Open ;
lvwRoom.Items.Clear ;
while not adoquery.Eof do
begin
xx:=lvwRoom.Items.Add;
//xx.SubItems.Add(adoquery.FieldValues['room_no']);
//xx.subitems.Add(adoquery.FieldValues['flooer_no']);
//xx.SubItems.add(adoquery.FieldValues['bednum']);
//xx.sbuitems.add();
if adoquery.Fields[4].Value=0 then
begin
xx.Caption:=adoQuery.Fields[1].AsString+'/空';
xx.ImageIndex:=1;
adoquery.Next;
continue;
end;
if adoquery.Fields[3].Value=adoquery.Fields [4].Value then
begin
xx.Caption:=adoQuery.Fields[1].AsString+'/满';
xx.ImageIndex:=3;
adoquery.Next;
continue;
end;
if adoquery.Fields[3].Value-adoquery.Fields [4].Value >0 then
begin
strLeave:=inttostr(adoquery.Fields[3].Value-adoquery.Fields [4].Value);
xx.Caption:=adoQuery.Fields[1].AsString+'/余'+trim(strLeave);
xx.ImageIndex:=2;
adoquery.Next;
continue;
end;
end;
finally
adoQuery.Close;
end;
end;
procedure TfrmRoomQuery.btnEnterClick(Sender: TObject);
var
SelectNo:string;
i:integer;
begin
if lvwRoom.SelCount=0 then
begin
showmessage('请选择床位');
exit;
end;
i:= ansiPos('/',lvwRoom.Selected.Caption)-1;
SelectNo:=LeftStr(lvwRoom.Selected.Caption,i);
application.CreateForm(TfrmBedArrange,frmBedArrange);
frmBedArrange.CurrNo:= SelectNo;
frmBedArrange.Show;
end;
procedure TfrmRoomQuery.ToolButton1Click(Sender: TObject);
begin
showmessage(clientid) ;
end;
procedure TfrmRoomQuery.FormCreate(Sender: TObject);
begin
frmMain.ReadINI ;
strCon:=frmmain.strCon ;
clientid:=frmMain.clientid;
end;
procedure TfrmRoomQuery.FormShow(Sender: TObject);
begin
frmRoomQuery.GetClientData;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -