📄 u4_1.pas
字号:
unit U4_1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Buttons, StdCtrls, ExtCtrls, ComCtrls, ImgList, Grids, ValEdit;
type
TF4_1 = class(TForm)
Panel1: TPanel;
Panel2: TPanel;
Splitter1: TSplitter;
Panel3: TPanel;
Panel4: TPanel;
LBbumen: TLabel;
EDbumen: TComboBox;
LBloucheng: TLabel;
CBoxloucheng: TComboBox;
LBguige: TLabel;
CBoxguige: TComboBox;
LBzhuangtai: TLabel;
CBoxzhuangtai: TComboBox;
LBdaima: TLabel;
LBdaima1: TLabel;
LBquyu: TLabel;
LBquyu1: TLabel;
LBlou: TLabel;
LBlou1: TLabel;
LBgui: TLabel;
LBge: TLabel;
LBdanjia: TLabel;
LBdanjia1: TLabel;
Panel5: TPanel;
Panel6: TPanel;
Label15: TLabel;
Bevel1: TBevel;
Label16: TLabel;
LBheji: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
EDdaima: TEdit;
CBoxset: TComboBox;
CheckBox1: TCheckBox;
SBTsave: TSpeedButton;
SBTcancel: TSpeedButton;
SBTlook: TSpeedButton;
SBTback: TSpeedButton;
SBTbig: TSpeedButton;
SBTsmall: TSpeedButton;
SBTlist: TSpeedButton;
Bigimagelist: TImageList;
smallimagelist: TImageList;
ListView1: TListView;
ListBox1: TListBox;
ListBox2: TListBox;
procedure SBTbackClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormShow(Sender: TObject);
procedure displayInfo;
Procedure readInfo;
procedure countInfo;//房间统计
procedure listBox2info(info:string;Item: TListItem);
procedure EDbumenChange(Sender: TObject);
procedure CBoxlouchengChange(Sender: TObject);
procedure CBoxguigeChange(Sender: TObject);
procedure SBTbigClick(Sender: TObject);
procedure SBTsmallClick(Sender: TObject);
procedure SBTlistClick(Sender: TObject);
procedure CBoxzhuangtaiChange(Sender: TObject);
procedure CBoxsetChange(Sender: TObject);
procedure SBTsaveClick(Sender: TObject);
procedure ListView1Click(Sender: TObject);
procedure SBTcancelClick(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
implementation
uses UDmo;
{$R *.dfm}
procedure TF4_1.listBox2info(info:string;Item: TListItem);
begin
if info<>'有客' then
begin
if (info='清洁') or (info='待修理') or (info='有预约') then
begin
ListBox2.Items.Strings[0]:=' 无客人使用';
listBox2.Items.Strings[4]:='入住日期:';
listBox2.Items.Strings[5]:='入住时间:';
end
else begin
ListBox2.Items.Strings[0]:=' '+item.Caption;
ListBox2.Items.Strings[0]:=listBox2.Items.Strings[0]+'号清理中';
listBox2.Items.Strings[4]:='入住日期:';
listBox2.Items.Strings[5]:='入住时间:';
end;
ListBox2.Items.Strings[2]:='总 单 号:';
ListBox2.Items.Strings[3]:='客户姓名:';
listBox2.Items.Strings[6]:='单 价:';
listBox2.items.Strings[7]:='消费金额:';
end else
begin
with dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select* from Vinfo');
sql.Add('where fangjian=:fangjian');
parameters.ParamByName('fangjian').Value:=item.Caption;
open;
end;
info:=item.Caption;
info:=info+'号客人使用情况';
listBox2.Items.strings[0]:=' '+info;
listBox2.Items.Strings[2]:='总 单 号:'
+dmo.ADOQuery1.Fields.Fields[0].AsString;
listBox2.Items.Strings[3]:='客户姓名:'
+dmo.ADOQuery1.Fields.Fields[2].AsString;
info:=dmo.ADOQuery1.Fields.Fields[3].AsString;
listBox2.Items.Strings[4]:='入住日期:'+copy(info,1,10);
listBox2.Items.Strings[5]:='入住时间:'+copy(info,12,8);
listBox2.Items.Strings[6]:='单 价:'
+item.SubItems.Strings[1];
listBox2.Items.Strings[7]:='消费金额:'
+dmo.ADOQuery1.Fields.Fields[5].AsString;
dmo.ADOQuery1.Close;
end;
end;
//房间统计
procedure TF4_1.countInfo;
var
i:integer;
count:integer;
bumen:string;
begin
if EDbumen.Text='客房' then bumen:='kf'
else if EDbumen.Text='商务中心' then bumen:='sl'
else if EDbumen.Text='餐饮' then bumen:='cz'
else if EDbumen.Text='桑拿' then bumen:='xs'
else bumen:='yb';
for i:=1 to CBoxzhuangtai.Items.Count-1 do
begin
with Dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select count(zhuangtai) from Vzhuangtai');
sql.Add('where zhuangtai=:zhuangtai');
SQL.Add('and sangpinName like '''+bumen+'%''');
parameters.ParamByName('zhuangtai').Value:=CBoxzhuangtai.Items.Strings[i];
if CBoxloucheng.Text<>'全部' then
begin
sql.Add('and louceng=:louceng');
parameters.ParamByName('louceng').Value:=CBoxloucheng.Text;
end;
if CBoxguige.Text<>'全部' then
begin
sql.Add('and guige=:guige');
parameters.ParamByName('guige').Value:=CBoxguige.Text;
end;
open;
count:=fields.Fields[0].AsInteger;
end;
listbox1.Items.Strings[i-1]:=CBoxzhuangtai.Items.Strings[i]
+' ';
if (length(CBoxzhuangtai.Items.Strings[i])=4) then begin
listBox1.Items.Strings[i-1]:=listBox1.Items.Strings[i-1]+' ';
end;
listBox1.Items.Strings[i-1]:=listBox1.Items.Strings[i-1]+intTostr(count);
end;
with Dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('select count(sangpinName) from Vzhuangtai');
SQL.Add('where sangpinName like '''+bumen+'%''');
open;
LBheji.Caption:=fields.Fields[0].AsString;
end;
end;
procedure TF4_1.DisplayInfo;
var
iconindex:integer;
ID:string;
zt:string;
count:integer;
begin
count:=0;
listView1.Clear;
while Dmo.ADOQuery1.Eof=false do //当数据集没有结束时
begin
if EDbumen.Text='客房' then iconIndex:=2//判断所属部门,确定图标下标
else if EDbumen.Text='商务中心' then iconIndex:=7
else if EDbumen.Text='餐饮' then iconIndex:=5
else if EDbumen.Text='桑拿' then iconindex:=6
else iconIndex:=2;
id:=Dmo.ADOQuery1.Fields.Fields[0].DisplayText;
zt:=Dmo.ADOQuery1.Fields.Fields[11].DisplayText;
id:=trimright(id);
zt:=trimright(zt);
if zt='有客' then iconindex:=0
else if zt='清理中' then iconindex:=1
else if zt='待修理' then iconindex:=4
else if zt='有预约' then iconindex:=3;
listView1.Items.Add;
with listview1.Items.Item[count] do //向listview中添加数据
begin
Caption:=id;
ImageIndex:=iconIndex;
SubItems.Add(Dmo.ADOQuery1.Fields.Fields[1].DisplayText);
SubItems.Add(Dmo.ADOQuery1.Fields.Fields[3].displaytext);
Subitems.Add(Dmo.ADOQuery1.Fields.Fields[4].DisplayText);
Subitems.Add(Dmo.ADOQuery1.Fields.Fields[5].DisplayText);
Subitems.Add(Dmo.ADOQuery1.Fields.Fields[6].DisplayText);
Subitems.Add(Dmo.ADOQuery1.Fields.Fields[2].DisplayText);
Subitems.Add(Dmo.ADOQuery1.Fields.Fields[8].DisplayText);
Subitems.Add(Dmo.ADOQuery1.Fields.Fields[11].DisplayText);
end;
count:=count+1;
Dmo.ADOQuery1.Next;
end;
Dmo.ADOQuery1.Close;
end;
//读取数据库各部门信息
procedure TF4_1.Readinfo;
var
bumen:string;
louceng:string;
guige:string;
zhuangtai:string;
begin
//设置查询条件
if EDbumen.Text='客房' then bumen:='kf'
else if EDbumen.Text='商务中心' then bumen:='sl'
else if EDbumen.Text='餐饮' then bumen:='cz'
else if EDbumen.Text='桑拿' then bumen:='xs'
else bumen:='yb';
if CBoxloucheng.Text='全部' then louceng:='*'
else louceng:=CBoxloucheng.Text;
if CBoxguige.Text='全部' then guige:='*'
else guige:=CBoxguige.Text;
if CBoxzhuangtai.Text='全部' then zhuangtai:='*'
else zhuangtai:=CBoxzhuangtai.Text;
//添加sql语句
Dmo.ADOQuery1.Close;
Dmo.ADOQuery1.SQL.Clear;
Dmo.ADOQuery1.SQL.Add('select * from Vzhuangtai where');
Dmo.ADOQuery1.SQL.Add('sangpinName like '''+bumen+'%''');
if louceng<>'*' then
begin
Dmo.ADOQuery1.SQL.Add('and louceng=:louceng');
Dmo.ADOQuery1.Parameters.ParamByName('louceng').Value:=louceng;
end;
if guige<>'*' then
begin
Dmo.ADOQuery1.SQL.Add('and guige=:guige');
Dmo.ADOQuery1.Parameters.ParamByName('guige').Value:=guige;
end;
if zhuangtai<>'*' then
begin
Dmo.ADOQuery1.SQL.Add('and zhuangtai=:zhuangtai');
Dmo.ADOQuery1.Parameters.ParamByName('zhuangtai').Value:=zhuangtai;
end;
Dmo.ADOQuery1.Open; //生成数据集
Dmo.adoquery1.First;
end;
procedure TF4_1.SBTbackClick(Sender: TObject);
begin
Close;
end;
procedure TF4_1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action:=caFree;
end;
procedure TF4_1.FormShow(Sender: TObject);
var
info:string;
begin
readinfo;
displayinfo;
countInfo;
listview1.Items.Item[0].Selected:=true;
info:=listview1.Selected.SubItems.Strings[7];
info:=trimright(info);
listBox2info(info,listView1.Items.item[0]);
end;
procedure TF4_1.EDbumenChange(Sender: TObject);
begin
if EDBumen.Text='客房' then
begin
CBoxguige.Items.Clear;
CBoxguige.Items.Add('全部');
CBoxguige.Items.Add('标准间');
CBoxguige.Items.Add('单人间');
CBoxguige.Items.Add('豪华套间');
CBoxguige.Items.Add('普通套间');
CBoxguige.ItemIndex:=0;
CBoxloucheng.Items.Clear;
CBoxloucheng.Items.Add('全部');
CBoxloucheng.Items.Add('四楼');
CBoxloucheng.Items.Add('五楼');
CBoxloucheng.Items.Add('六楼');
CBoxloucheng.ItemIndex:=0;
end
else if (EDbumen.Text='商务中心') or (EDbumen.Text='休闲娱乐') then
begin
CBoxloucheng.Items.Clear;
CBoxloucheng.Items.Add('全部');
CBoxloucheng.ItemIndex:=0;
CBoxguige.Items.Clear;
CBoxguige.Items.Add('全部');
CBoxguige.ItemIndex:=0;
end
else if EDbumen.Text='餐饮' then
begin
CBoxloucheng.Items.Clear;
CBoxloucheng.Items.Add('全部');
CBoxloucheng.Items.Add('一楼');
CBoxloucheng.Items.Add('二楼');
CBoxloucheng.ItemIndex:=0;
CBoxguige.Items.Clear;
CBoxguige.Items.Add('全部');
CBoxguige.Items.Add('10人桌');
CBoxguige.Items.Add('8人桌');
CBoxguige.Items.Add('4人桌');
CBoxguige.Items.Add('包厢');
CBoxguige.Items.Add('贵宾包厢');
CBoxguige.ItemIndex:=0;
end
else if EDbumen.Text='桑拿' then
begin
CBoxloucheng.Items.Clear;
CBoxloucheng.Items.Add('全部');
CBoxloucheng.Items.Add('一楼');
CBoxloucheng.Items.Add('二楼');
CBoxloucheng.Items.Add('三楼');
CBoxloucheng.ItemIndex:=0;
CBoxguige.Items.Clear;
CBoxguige.Items.Add('全部');
CBoxguige.Items.Add('男包厢');
CBoxguige.Items.Add('男普通');
CBoxguige.Items.Add('女普通');
CBoxguige.ItemIndex:=0;
end;
Readinfo;
DisplayInfo;
countInfo;
end;
procedure TF4_1.CBoxlouchengChange(Sender: TObject);
begin
ReadInfo;
displayInfo;
countInfo;
end;
procedure TF4_1.CBoxguigeChange(Sender: TObject);
begin
ReadInfo;
displayInfo;
countInfo;
end;
procedure TF4_1.SBTbigClick(Sender: TObject);
begin
ListView1.ViewStyle:=vsIcon;
end;
procedure TF4_1.SBTsmallClick(Sender: TObject);
begin
listview1.ViewStyle:=vssmallIcon;
end;
procedure TF4_1.SBTlistClick(Sender: TObject);
begin
listview1.ViewStyle:=vsreport;
end;
procedure TF4_1.CBoxzhuangtaiChange(Sender: TObject);
begin
Readinfo;
displayinfo;
end;
procedure TF4_1.CBoxsetChange(Sender: TObject);
var
info:string;
begin
try
info:=CBoxset.Text;
if info='清洁' then
listview1.Selected.ImageIndex:=2
else if info='有客' then
listview1.Selected.ImageIndex:=0
else if info='清理中' then
listview1.Selected.ImageIndex:=1
else if info='待修理' then
listview1.Selected.ImageIndex:=4
else if info='有预约' then
listview1.Selected.ImageIndex:=3;
listView1.Selected.SubItems.Strings[7]:=info;
info:=LBdaima1.Caption;
listView1.Selected.Caption:=info+'*';
SBTsave.Enabled:=true;
SBTcancel.Enabled:=true;
except
//
end;
end;
procedure TF4_1.SBTsaveClick(Sender: TObject);
var
count:integer;
info:string;
begin
for count:=0 to listView1.Items.Count-1 do
begin
info:=listView1.Items.Item[count].Caption;
if copy(info,7,1)='*' then
with dmo.ADOQuery1 do
begin
try
close;
sql.Clear;
sql.Add('update zhuangtai set zhuangtai=:zhuangtai');
sql.Add('where fangjian=:fangjian');
parameters.ParamByName('zhuangtai').Value:=
listView1.Items.Item[count].SubItems.Strings[7];
parameters.ParamByName('fangjian').Value:=
copy(info,1,6);
execsql;
except
//
end;
end;
end;
if CheckBox1.Checked then
try
with dmo.ADOQuery1 do
begin
close;
sql.Clear;
sql.Add('update zhuangtai set zhuangtai=''清洁''');
sql.Add('where zhuangtai=''清理中''');
execsql;
end;
except
//
end;
MessageBox(Handle, '保存成功', '提示信息', MB_ICONASTERISK);
dmo.ADOQuery1.Close;
readinfo;
displayinfo;
countinfo;
listview1.Items.Item[0].Selected:=true;
info:=listview1.Selected.SubItems.Strings[7];
info:=trimright(info);
listBox2info(info,listView1.Items.item[0]);
end;
procedure TF4_1.ListView1Click(Sender: TObject);
var
info:string;
item:TlistItem;
begin
try
item:=listView1.Selected;
EDdaima.Text:=item.Caption;
LBdaima1.Caption:=item.Caption;
LBquyu1.Caption:=item.SubItems.Strings[2];
LBlou1.Caption:=item.SubItems.Strings[3];
LBge.Caption:=item.SubItems.Strings[4];
LBdanjia1.Caption:=item.SubItems.Strings[1];
CBoxset.ItemIndex:=Cboxset.Items.IndexOf(trimright(item.SubItems.Strings[7]));
info:=trimright(item.SubItems.Strings[7]);
listBox2info(info,item);
except
//
end;
end;
procedure TF4_1.SBTcancelClick(Sender: TObject);
begin
readinfo;
displayinfo;
countinfo;
SBTsave.Enabled:=false;
SBTcancel.Enabled:=false;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -