📄 c_ydcysk.pas
字号:
Result := Copy(s,1,p-1);
end;
//获取餐厅名称
function TYdcyskForm.GetCtmc(const s: string): string;
var
p: Integer;
begin
p := Pos('|',s);
Result := Copy(s,p+1,Length(s));
end;
//更新预定餐厅
procedure TYdcyskForm.UpdateCtbh(const ACtbh,ACtmc: string);
begin
//如果有删除
//if not tblYdcy.FindKey([FYdbh,ACtbh]) then
//tblYdcy.Delete
//else
//begin
tblYdcy.Insert;
tblYdcyD_YDBH.Value := FYdbh;
tblYdcyD_CTBH.Value := ACtbh;
tblYdcyD_CTMC.Value := ACtmc;
//tblYdcyD_XFJE.Value := FXfje;
tblYdcyD_YCBZ.Value := FYcbz;
tblYdcyD_RZBZ.Value := FRzbz;
tblYdcy.Post;
//end;
end;
//判断用餐标准的有效性
function TYdcyskForm.IsValid: Boolean;
begin
Result := False;
tblYdcyD_YCLX.Value := RadioGroup1.ItemIndex;
case RadioGroup1.ItemIndex of
0:
begin
{if (tblYdcyD_XFSL.IsNull)
or(tblYdcyD_DJ.IsNull)
or(tblYdcyD_XFSL.Value<=0)
or(tblYdcyD_DJ.Value<=0) then}
if (tblYdcyD_XFSL.IsNull)
or(tblYdcyD_XFSL.Value<=0) then
begin
ShowWarning('请输入用餐标准!');
Exit;
end;
if tblYdcyD_DJ.IsNull then
tblYdcyD_DJ.Value := 0;
tblYdcyD_XFJE.Value := tblYdcyD_DJ.Value*tblYdcyD_XFSL.Value;
if tblYdcyD_XFJE.Value <> 0 then
tblYdcyD_YCBZ.Value := tblYdcyD_XFSL.AsString+' 桌 × '+tblYdcyD_DJ.AsString+' 元'
else
tblYdcyD_YCBZ.Value := tblYdcyD_XFSL.AsString+' 桌';
Result := True;
end;
1:
begin
{if (tblYdcyD_XFSL.IsNull)
or(tblYdcyD_DJ.IsNull)
or(tblYdcyD_XFSL.Value<=0)
or(tblYdcyD_DJ.Value<=0) then}
if (tblYdcyD_XFSL.IsNull)
or(tblYdcyD_XFSL.Value<=0) then
begin
ShowWarning('请输入用餐标准!');
Exit;
end;
if tblYdcyD_DJ.IsNull then
tblYdcyD_DJ.Value := 0;
tblYdcyD_XFJE.Value := tblYdcyD_XFSL.Value*tblYdcyD_DJ.Value;
if tblYdcyD_XFJE.Value<>0 then
tblYdcyD_YCBZ.Value := tblYdcyD_XFSL.AsString +'人 × '+tblYDcyD_DJ.AsString+' 元'
else
tblYdcyD_YCBZ.Value := tblYdcyD_XFSL.AsString +'人';
Result := True;
end;
2:
begin
if (tblYdcyD_XFSL.IsNull)or(tblYdcyD_XFSL.Value<=0) then
begin
ShowWarning('请输入用餐标准!');
Exit;
end;
tblYdcyD_DJ.Value := 0;
tblYdcyD_XFJE.Value := 0;
tblYdcyD_YCBZ.Value := tblYdcyD_XFSL.AsString+' 桌 × 点菜';
Result := True;
end;
end;
end;
//确认
procedure TYdcyskForm.btnOKClick(Sender: TObject);
var
ACtbh,ACtmc,s: string;
i : Integer;
//CanPost : Boolean;
begin
inherited;
if not HotelData.CheckYgqx(CZY.CzyBh,'预定修改') then Exit;
//CanPost := False;
//如果
if not IsValid then Exit;
//清空子单
//s := 'select * from YDCY where (D_YDBH="'+FYdbh+'")and(D_CTBH<>"0")';
s := 'delete from YDCY where (D_YDBH="'+FYdbh+'")and(D_KRBH="'+FKrbh+'")and(D_CTBH<>"0")';
HotelData.EmptyData(s);
//判断有效性
for i:=0 to ListView1.Items.Count - 1 do
begin
if ListView1.Items[i].Checked then
begin
//CanPost := True;//有餐厅被选择
ACtbh := GetCtbh(ListView1.Items[i].Caption);
ACtmc := GetCtmc(ListView1.Items[i].Caption);
//判断是否被预定
if not HotelData.IsValidCyyd(ACtbh,tblYdcyD_SJDM.Value,tblYdcyD_SYRQ.Value) then
begin
ShowWarning('该餐厅台号已经被预定!');
Exit;
end;
end;
end;
{//如果没有选择餐厅
if not CanPost then
begin
ShowWarning('请选择餐厅台号!');
Exit;
end;
}
tblYdcyD_CTBH.Value := '0';
tblYdcyD_CTMC.Value := '0';
FXfje := tblYdcyD_XFJE.Value;
FYcbz := tblYdcyD_YCBZ.Value;
FYdrq := tblYdcyD_YDRQ.Value;
FSyrq := tblYdcyD_SYRQ.Value;
FSysj := tblYdcyD_SYSJ.Value;
FSjdm := tblYdcyD_SJDM.Value;
//FRzbz := tblYdcyD_RZBZ.Value;
HotelData.DatabaseUser.StartTransaction;
try
//保存总单
tblYdcy.Post;
//重新添加子单
IsAppend := False;
for i:=0 to ListView1.Items.Count - 1 do
begin
if ListView1.Items[i].Checked then
begin
ACtbh := GetCtbh(ListView1.Items[i].Caption);
ACtmc := GetCtmc(ListView1.Items[i].Caption);
UpdateCtbh(ACtbh,ACtmc);
end;
end;
HotelData.DatabaseUser.Commit;
except
HotelData.DatabaseUser.Rollback;
raise;
end;
Close;
end;
procedure TYdcyskForm.tblYdcyBeforePost(DataSet: TDataSet);
begin
inherited;
if IsAppend then
begin
FYdbh := HotelData.GetBh('D_YDBH',PREV_YDBH);
tblYdcyD_YDBH.Value := FYdbh;
end;
end;
procedure TYdcyskForm.btnCancClick(Sender: TObject);
begin
inherited;
tblYdcy.Cancel;
end;
procedure TYdcyskForm.DBEdit3Exit(Sender: TObject);
begin
inherited;
tblYdcyD_SJDM.Value := GetSjdm(tblYdcyD_SYSJ.Value);
end;
procedure TYdcyskForm.btnYdqrClick(Sender: TObject);
begin
inherited;
if not HotelData.CheckYgqx(CZY.CzyBh,'预定确认') then Exit;
if Confirm('你确认该餐饮的预定吗?') then
begin
tblYdcyD_RZBZ.Value := 'T';
//ShowState;
FRzbz := 'T';
btnOkClick(nil);
end;
end;
procedure TYdcyskForm.RadioGroup1Click(Sender: TObject);
var
i: Integer;
begin
inherited;
i := RadioGroup1.ItemIndex;
case i of
0:
begin
DBEdit6.Visible := True;
Label13.Visible := True;
Label11.Caption := '桌';
end;
1:
begin
DBEdit6.Visible := True;
Label13.Visible := True;
Label11.Caption := '人';
end;
2:
begin
DBEdit6.Visible := False;
Label13.Visible := False;
Label11.Caption := '桌';
end;
end;
{ DBEdit4.Visible := (i=0)and(i<>2);
Label5.Visible := (i=0)and(i<>2);
DBEdit5.Visible := (i=1)and(i<>2);
DBEdit6.Visible := (i=1)and(i<>2);
Label11.Visible := (i=1)and(i<>2);
Label13.Visible := (i=1)and(i<>2);}
end;
//手工录入餐厅
procedure TYdcyskForm.btnSelectClick(Sender: TObject);
var
s,ACtbh: string;
i,j,Len: Integer;
begin
inherited;
s := edtCtbh.Text;
Len := Length(s);
while (Len>0) do
begin
i := Pos(' ',s);
if i=0 then Break;
ACtbh := Copy(s,1,i-1);
for j:=0 to ListView1.Items.Count - 1 do
if GetCtbh(ListView1.Items[j].Caption)=ACtbh then
begin
ListView1.Items[j].Checked := True;
Break;
end;
s := Copy(s,i+1,Len-i);
Len := Len - i;
end;
end;
procedure TYdcyskForm.btnPrintClick(Sender: TObject);
var
i : Integer;
ACtmc : string;
begin
if not HotelData.CheckYgqx(CZY.CzyBh,'预定确认') then Exit;
if Confirm('你确认该餐饮的预定吗?') then
begin
tblYdcyD_RZBZ.Value := 'T';
FRzbz := 'T';
//ShowState;
FBz := TStringList.Create;
FBz.AddStrings(DBMemo1.Lines);
btnOkClick(nil);
end
else
Exit;
YdcyskPrintForm := TYdcyskPrintForm.Create(Application);
try
with YdcyskPrintForm do
begin
qrlSub.Caption := '打印时间:'+DateTimeToStr(Now)+' '+'通知人:'+CZY.CzyXm;
qrlKrxm.Caption := lblKrxm.Caption;
qrlLxr.Caption := lblLxr.Caption;
qrlLxdh.Caption := lblLxdh.Caption;
qrlYcsj.Caption := tblYdcyD_SYRQ.AsString + ' '
+ tblYdcyD_SJDM.AsString + FormatDateTime('hh:nn',tblYdcyD_SYSJ.AsDateTime);
qrlYcbz.Caption := tblYdcyD_YCBZ.Value;
ACtmc := '';
for i:=0 to ListView1.Items.Count - 1 do
if ListView1.Items[i].Checked then
ACtmc := ACtmc + GetCtmc(ListView1.Items[i].Caption)+' ';
qrlCtmc.Caption := ACtmc;
//qrlBz.DataSet := tblYdcy;
//qrlBz.DataField := 'D_BZ';
//qrlBz.Lines.AddStrings(DBMemo1.Lines);
qrlBz.Lines.AddStrings(FBz);
QRLabel14.Caption := qrlSub.Caption;
QRLabel15.Caption := qrlKrxm.Caption;
QRLabel16.Caption := qrlLxr.Caption;
QRLabel23.Caption := qrlLxdh.Caption;
QRLabel17.Caption := qrlYcsj.Caption;
QRLabel19.Caption := qrlYcbz.Caption;
QRLabel20.Caption := qrlCtmc.Caption;
QRMemo1.Lines.AddStrings(FBz);
//QRMemo1.Lines := qrlBz.Lines;
YdcyskPrint;
end;
finally
YdcyskPrintForm.Free;
end;
//btnOkClick(nil);
end;
procedure TYdcyskForm.btnYdqxClick(Sender: TObject);
begin
inherited;
if not HotelData.CheckYgqx(CZY.CzyBh,'预定确认') then Exit;
if Confirm('你取消该餐饮的确认吗?') then
begin
tblYdcyD_RZBZ.Value := 'F';
ShowState;
//btnOkClick(nil);
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -