📄 ydkdunit.pas
字号:
unit YDKDUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, DB, DBClient, SUIButton, StdCtrls, SUIListBox, Grids,
DBGrids, SUIImagePanel, SUIGroupBox, SUIEdit, SUIComboBox, ExtCtrls,
DateUtils, ComCtrls;
type
TYDKDForm = class(TForm)
suiPanel1: TsuiPanel;
lbl1: TLabel;
lbl2: TLabel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label5: TLabel;
Label4: TLabel;
Label6: TLabel;
suiButton1: TsuiButton;
suiButton2: TsuiButton;
suiEdit1: TsuiEdit;
suiGroupBox1: TsuiGroupBox;
suiListBox2: TsuiListBox;
btn3: TsuiButton;
btn4: TsuiButton;
suiListBox1: TsuiListBox;
suiCheckBox1: TsuiCheckBox;
suiComboBox1: TsuiComboBox;
Label7: TLabel;
procedure suiButton1Click(Sender: TObject);
procedure suiButton2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormActivate(Sender: TObject);
procedure suiListBox1Click(Sender: TObject);
procedure suiEdit1KeyPress(Sender: TObject; var Key: Char);
procedure suiComboBox1KeyPress(Sender: TObject; var Key: Char);
procedure suiComboBox1DropDown(Sender: TObject);
procedure btn3Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
id:string;
end;
var
YDKDForm: TYDKDForm;
implementation
uses MainUnit, LoginUnit, YDGLUnit, YLGLUnit;
{$R *.dfm}
procedure TYDKDForm.suiButton2Click(Sender: TObject);
begin
close;
end;
procedure TYDKDForm.FormCreate(Sender: TObject);
var
temp:string;
begin
suiEdit1.Clear;
self.suiComboBox1.Clear;
suiPanel1.Caption:='用餐单号:YC'+FormatDateTime('yyyymmddhhnnss',now);
id:=suiPanel1.Caption;
delete(id,1,10);
self.lbl2.Caption:='无';
self.Label6.Caption:='无';
self.Label2.Caption:='¥0.00';
loginform.ExecuteSQL('select * from reserve where id='''+YDGLForm.ClientDataSet1.FieldByName('id').AsString+'''');
loginform.dsQuery.First;
self.suiListBox1.Items.Clear;
self.suiListBox1.Items.BeginUpdate;
temp:='(';
while not LoginForm.dsQuery.Eof do
begin
Self.suiListBox1.Items.Add(loginform.dsQuery.fieldbyname('roomtype').AsString+':'+
loginform.dsQuery.fieldbyname('roomnum').AsString);
temp:=temp+'(room.room_num<>'''+loginform.dsQuery.fieldbyname('roomnum').AsString+''') or ';
LoginForm.dsQuery.Next;
end;
Self.suiListBox1.Items.EndUpdate;
LoginForm.dsQuery.Close;
delete(temp,Length(temp)-3,4);
temp:=temp+')';
suiListBox2.Items.Clear;
suiListBox2.Items.BeginUpdate;
loginform.ExecuteSQL('select roomtype.type_mc,room.room_num from room,roomtype '+
'where (room.room_type=roomtype.type_xh) and '+
'((room.room_state=''可供'') or (room.room_state=''预订'')) and '+temp+' '+
'order by room.room_num');
LoginForm.dsQuery.First;
while not LoginForm.dsQuery.Eof do
begin
suiListBox2.Items.Add(LoginForm.dsQuery.Fields[0].AsString+':'+LoginForm.dsQuery.Fields[1].AsString);
LoginForm.dsQuery.Next;
end;
suiListBox2.Items.EndUpdate;
end;
procedure TYDKDForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
YDGLForm.ClientDataSet1.Close;
YDGLForm.ClientDataSet1.CommandText:='select * from Reserve order by id,roomnum';
YDGLForm.ClientDataSet1.Open;
YDGLForm.Enabled:=true;
end;
procedure TYDKDForm.FormActivate(Sender: TObject);
begin
self.suiEdit1.Text:='1';
self.suiEdit1.SetFocus;
end;
procedure TYDKDForm.suiEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if not (key in [#48..#57,#13,#8]) then
key:=#0
else
if key=#13 then
self.suiComboBox1.SetFocus;
end;
procedure TYDKDForm.suiComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
self.suiButton1.SetFocus;
end;
procedure TYDKDForm.suiComboBox1DropDown(Sender: TObject);
begin
suiComboBox1.Items.Clear;
suiComboBox1.Items.BeginUpdate;
loginform.ExecuteSQL('select id,name from server');
loginform.dsQuery.First;
while not loginform.dsQuery.Eof do
begin
suiComboBox1.Items.Add('【'+loginform.dsQuery.Fields[0].AsString+'】'+loginform.dsQuery.Fields[1].AsString);
loginform.dsQuery.Next;
end;
loginform.dsQuery.Close;
suiComboBox1.Items.EndUpdate;
end;
procedure TYDKDForm.btn3Click(Sender: TObject);
var
index:Integer;
begin
for index:=Self.suiListBox2.Items.Count-1 downto 0 do
if Self.suiListBox2.Selected[index] then
begin
Self.suiListBox1.Items.Add(Self.suiListBox2.Items.Strings[index]);
self.suiListBox2.Items.Delete(index);
end;
self.suiListBox2.Sorted:=true;
Self.suiListBox1.Sorted:=true;
end;
procedure TYDKDForm.btn4Click(Sender: TObject);
var
index:Integer;
begin
for index:=Self.suiListBox1.Items.Count-1 downto 0 do
if Self.suiListBox1.Selected[index] then
begin
Self.suiListBox2.Items.Add(Self.suiListBox1.Items.Strings[index]);
self.suiListBox1.Items.Delete(index);
end;
self.suiListBox1.Sorted:=true;
Self.suiListBox2.Sorted:=true;
end;
procedure TYDKDForm.suiButton1Click(Sender: TObject);
var
room:string;
peopelnum:string;
serverinfo:string;
memozs:string;
entertime:string;
index:integer;
temp:string;
sql:string;
begin
room:=self.lbl2.Caption;
if (self.lbl2.Caption='无') then
begin
MessageDlg('预订单号【'+id+'】尚未选择主餐台信息!',mtConfirmation, [mbYes], 0);
exit;
end;
peopelnum:=self.suiEdit1.Text;
serverinfo:=self.suiComboBox1.Text;
for index:=0 to self.suiListBox1.Items.Count-1 do
begin
temp:=self.suiListBox1.Items.Strings[index];
delete(temp,1,pos(':',temp));
memozs:=memozs+temp+'@';
end;
if (memozs='') then
begin
MessageDlg('预订单号【'+id+'】餐台信息为空!',mtConfirmation, [mbYes], 0);
exit;
end;
entertime:=FormatDateTime('yyyy-mm-dd hh:nn:ss',now);
sql:='update room set room_state=''占用'',room_id='''+id+''' where ';
temp:=memozs;
while Pos('@',temp)>0 do
begin
sql:=sql+'room_num='''+Copy(temp,1,Pos('@',temp)-1)+''' or ';
loginform.ExecuteSQL('insert into house '+
'values('''+id+''','''','''+peopelnum+''','''+memozs+''','+
''''+Copy(temp,1,Pos('@',temp)-1)+''','+
''''+entertime+''','''','''+serverinfo+''')');
Delete(temp,1,Pos('@',temp));
end;
Delete(sql,Length(sql)-3,4);
loginform.ExecuteSQL(sql);
LoginForm.ExecuteSQL('update Reserve set state=''已用餐'' '+
'where id='''+YDGLForm.ClientDataSet1.FieldByName('id').AsString+'''');
loginform.ExecuteSQL('insert into log '+
'values('''+entertime+''','''+loginform.userid+''','''+LoginForm.username+''','+
'''预订单号【'+YDGLForm.ClientDataSet1.FieldByName('id').AsString+'】'+
'主餐台【'+room+'】于'+entertime+'开单成功'')');
MessageDlg('预订单号【'+YDGLForm.ClientDataSet1.FieldByName('id').AsString+'】'+
'主餐台【'+room+'】于'+entertime+'开单成功!',mtConfirmation, [mbYes], 0);
close;
end;
procedure TYDKDForm.suiListBox1Click(Sender: TObject);
var
temp:string;
begin
temp:=self.suiListBox1.Items.Strings[Self.suiListBox1.itemindex];
self.Label6.Caption:=Copy(temp,1,Pos(':',temp)-1);
Delete(temp,1,Pos(':',temp));
self.lbl2.Caption:=temp;
loginform.ExecuteSQL('select type_menoy from roomtype where type_mc='''+self.Label6.Caption+'''');
self.Label2.Caption:=FormatDateTime('¥0.00',LoginForm.dsQuery.Fields[0].AsFloat);
LoginForm.dsQuery.Close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -