📄 skeditunit.pas
字号:
unit SKEditUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, DB, DBClient, SUIButton, StdCtrls, SUIListBox, Grids,
DBGrids, SUIImagePanel, SUIGroupBox, SUIEdit, SUIComboBox, ComCtrls,
ExtCtrls;
type
TSKEditForm = 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;
procedure suiButton2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormActivate(Sender: TObject);
procedure suiComboBox1DropDown(Sender: TObject);
procedure suiComboBox1KeyPress(Sender: TObject; var Key: Char);
procedure suiEdit1KeyPress(Sender: TObject; var Key: Char);
procedure btn3Click(Sender: TObject);
procedure btn4Click(Sender: TObject);
procedure suiButton1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
id,info:string;
roomother:string;
end;
var
SKEditForm: TSKEditForm;
implementation
uses MainUnit, LoginUnit;
{$R *.dfm}
procedure TSKEditForm.suiButton2Click(Sender: TObject);
begin
close;
end;
procedure TSKEditForm.FormCreate(Sender: TObject);
var
temp:string;
room:string;
str:string;
memozs:string;
sql:string;
begin
self.lbl2.Caption:=mainform.roomnum;
self.Label6.Caption:=mainform.typename;
self.Label2.Caption:=formatfloat('¥0.00',strtofloat(mainform.menoy));
loginform.ExecuteSQL('select room_id from room where room_num='''+mainform.roomnum+'''');
id:=LoginForm.dsQuery.Fields[0].AsString;
LoginForm.dsQuery.Close;
self.suiPanel1.Caption:='餐台【'+mainform.roomnum+'】 当前用餐单号:'+id;
loginform.ExecuteSQL('select * from house where id='''+id+'''');
suiEdit1.Text:=LoginForm.dsQuery.fieldbyname('peopelnum').AsString;
memozs:=LoginForm.dsQuery.fieldbyname('memozs').AsString;
suiComboBox1.Text:=LoginForm.dsQuery.fieldbyname('serverinfo').AsString;
LoginForm.dsQuery.Close;
suiListBox1.Items.Clear;
if memozs='' then
begin
self.suiCheckBox1.Checked:=false;
self.suiListBox1.Enabled:=false;
self.suiListBox2.Enabled:=false;
self.btn3.Enabled:=false;
self.btn4.Enabled:=false;
end
else
begin
self.suiCheckBox1.Checked:=true;
self.suiListBox1.Enabled:=true;
self.suiListBox2.Enabled:=true;
self.btn3.Enabled:=true;
self.btn4.Enabled:=true;
temp:=memozs;
suiListBox1.Items.BeginUpdate;
str:='(';
while Pos('@',memozs)>0 do
begin
room:=Copy(memozs,1,Pos('@',memozs)-1);
loginform.ExecuteSQL('select roomtype.type_mc from room,roomtype '+
'where (room.room_type=roomtype.type_xh) and (room.room_num<>'''+room+''')');
suiListBox1.Items.Add(LoginForm.dsQuery.Fields[0].AsString+':'+room);
LoginForm.dsQuery.Close;
str:=str+'(room.room_num<>'''+room+''') or';
roomother:=roomother+room+'@';
Delete(memozs,1,Pos('@',memozs));
end;
Delete(str,Length(str)-2,3);
str:=str+')';
suiListBox1.Items.BeginUpdate;
suiListBox1.Sorted:=true;
end;
sql:='select roomtype.type_mc,room.room_num from room,roomtype '+
'where (room.room_type=roomtype.type_xh) and (room.room_state=''可供'') and '+str+' '+
'order by room.room_num';
suiListBox2.Items.Clear;
suiListBox2.Items.BeginUpdate;
loginform.ExecuteSQL(sql);
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;
LoginForm.dsQuery.Close;
suiListBox2.Items.EndUpdate;
end;
procedure TSKEditForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
MainForm.RefrushRoomState(0);
mainform.Enabled:=true;
end;
procedure TSKEditForm.FormActivate(Sender: TObject);
begin
self.suiEdit1.SetFocus;
end;
procedure TSKEditForm.suiComboBox1DropDown(Sender: TObject);
begin
loginform.AddCombobox(suiComboBox1,'select name from guestsource');
end;
procedure TSKEditForm.suiComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
suiButton1.SetFocus;
end;
procedure TSKEditForm.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 TSKEditForm.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 TSKEditForm.btn4Click(Sender: TObject);
var
index:Integer;
room:string;
count:Integer;
begin
for index:=Self.suiListBox1.Items.Count-1 downto 0 do
if Self.suiListBox1.Selected[index] then
begin
room:=Self.suiListBox1.Items.Strings[index];
Delete(room,1,Pos(':',room));
LoginForm.ExecuteSQL('select count(*) from consume where Lbxf_xfbh='''+id+''' and Lbxf_sph='''+room+'''');
count:=LoginForm.dsQuery.Fields[0].AsInteger;
LoginForm.dsQuery.Close;
if count=0 then
begin
LoginForm.ExecuteSQL('update room set room_state=''可供'',room_id='''' where room_num='''+room+'''');
Self.suiListBox2.Items.Add(Self.suiListBox1.Items.Strings[index]);
self.suiListBox1.Items.Delete(index);
end;
end;
self.suiListBox1.Sorted:=true;
Self.suiListBox2.Sorted:=true;
end;
procedure TSKEditForm.suiButton1Click(Sender: TObject);
var
room:string;
peopelnum:string;
serverinfo:string;
memozs:string;
index:integer;
temp:string;
sql:string;
tempmemo,tempnum,tempinfo:string;
begin
room:=self.lbl2.Caption;
peopelnum:=self.suiEdit1.Text;
serverinfo:=self.suiComboBox1.Text;
if self.suiCheckBox1.Checked then
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;
loginform.ExecuteSQL('select memozs,peopelnum,serverinfo from house where id='''+id+''' and room='''+room+'''');
tempmemo:=LoginForm.dsQuery.Fields[0].AsString;
tempnum:=LoginForm.dsQuery.Fields[1].AsString;
tempinfo:=LoginForm.dsQuery.Fields[2].AsString;
LoginForm.dsQuery.Close;
if (tempmemo=memozs) and (tempnum=peopelnum) and (tempinfo=serverinfo) then
begin
MessageDlg('餐台【'+room+'】开单信息尚未改动!',mtConfirmation, [mbYes], 0);
exit;
end;
if tempmemo<>memozs then
loginform.ExecuteSQL('update house set memozs='''+room+'@'+memozs+''' where id='''+id+'''');
loginform.ExecuteSQL('update house set peopelnum='''+peopelnum+''',serverinfo='''+serverinfo+''' '+
'where id='''+id+''' and room='''+room+'''');
sql:='update room set room_state=''占用'',room_id='''+id+''' where room_num='''+room+'''';
if memozs='' then
while Pos('@',memozs)>0 do
begin
sql:=sql+' or room_num='''+Copy(memozs,1,Pos('@',memozs)-1)+'''';
Delete(memozs,1,Pos('@',memozs));
end;
loginform.ExecuteSQL(sql);
loginform.ExecuteSQL('insert into log '+
'values('''+formatdatetime('yyyy-mm-dd hh:nn:ss',now)+''','+
''''+loginform.userid+''','''+LoginForm.username+
''',''餐台【'+room+'】开单信息修改成功'')');
MessageDlg('餐台【'+room+'】开单信息修改成功!',mtConfirmation, [mbYes], 0);
close;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -