📄 mc_dcfy_lr.~pas
字号:
End
Else
begin
for a:=1 to 51 do
begin
if Length(DCGrid.Cells[1,a])=0 then //如果该行首单元格为空
begin
b:=a;
Break; //结束循环
End
Else
begin
if Length(DCGrid.Cells[2,a])=0 then //如果该行第二单元格为空
begin
ShowMessage('数据有误,请修改.');
DCGrid.Col:=2;
DCGrid.Row:=a;
DCGrid.SetFocus; //光标移到该单元格
Abort;
end;
if Length(DCGrid.Cells[3,a])=0 then //如果该行第三单元格为空
begin
ShowMessage('数据有误,请修改.');
DCGrid.Col:=3;
DCGrid.Row:=a;
DCGrid.SetFocus; //光标移到该单元格
Abort;
end;
if Length(DCGrid.Cells[4,a])=0 then //如果该行第四单元格为空
begin
ShowMessage('数据有误,请修改.');
DCGrid.Col:=4;
DCGrid.Row:=a;
DCGrid.SetFocus; //光标移到该单元格
Abort;
end;
if Length(DCGrid.Cells[5,a])=0 then //如果该行第五单元格为空
begin
ShowMessage('数据有误,请修改.');
DCGrid.Col:=5;
DCGrid.Row:=a;
DCGrid.SetFocus; //光标移到该单元格
Abort;
end;
if Length(DCGrid.Cells[6,a])=0 then //如果该行第六单元格为空
begin
ShowMessage('数据有误,请修改.');
DCGrid.Col:=6;
DCGrid.Row:=a;
DCGrid.SetFocus; //光标移到该单元格
Abort;
end;
if Length(DCGrid.Cells[7,a])=0 then //如果该行第七单元格为空
begin
ShowMessage('数据有误,请修改.');
DCGrid.Col:=7;
DCGrid.Row:=a;
DCGrid.SetFocus; //光标移到该单元格
Abort;
end;
if Length(DCGrid.Cells[8,a])=0 then //如果该行第八单元格为空
begin
ShowMessage('数据有误,请修改.');
DCGrid.Col:=8;
DCGrid.Row:=a;
DCGrid.SetFocus; //光标移到该单元格
Abort;
end;
end;
end;
Query2.Close;
Query2.SQL.Clear;
Query2.SQL.Add('Insert 点菜临时表 (房间台号,编号,名称,类型,单位,数量,价格,合计,服务员编号,服务员姓名,状态,点单日期,结帐编号,是否结单)');
Query2.SQl.Add('Values(:房间台号,:编号,:名称,:类型,:单位,:数量,:价格,:合计,:服务员编号,:服务员名称,:状态,:点单日期,:结帐编号,:是否结单)');
For a:=1 to b-1 do
begin //将点菜信息保存到点菜临时表
Query2.Params[0].AsInteger:=StrToInt(TLCYGLXT.KT_FJTHXXB.FieldByName('编号').AsString);
Query2.Params[1].AsInteger:=StrToInt(DCGrid.Cells[1,a]);
Query2.Params[2].AsString:=DCGrid.Cells[2,a];
Query2.Params[3].AsString:=DCGrid.Cells[3,a];
Query2.Params[4].AsString:=DCGrid.Cells[4,a];
Query2.Params[5].AsInteger:=StrToInt(DCGrid.Cells[5,a]);
Query2.Params[6].AsFloat:=StrToFloat(DCGrid.Cells[6,a]);
Query2.Params[7].AsFloat:=StrToFloat(DCGrid.Cells[8,a]);
Query2.Params[8].AsInteger:=TLCYGLXT.YGXXB.FieldByName('员工编号').AsInteger;
Query2.Params[9].AsString:=TLCYGLXT.YGXXB.FieldByName('姓名').AsString;
Query2.Params[10].AsString:=DCGrid.Cells[7,a];
Query2.Params[11].AsDateTime:=StrToDateTime(Label17.Caption);
Query2.Params[12].AsInteger:=StrToInt(Label18.Caption);
Query2.Params[13].Asstring:='否';
Query2.ExecSQL;
end;
TLCYGLXT.KT_FJTHXXB.Edit; //编辑房台信息
TLCYGLXT.KT_FJTHXXB.FieldByName('状态').AsString:='营业';
TLCYGLXT.KT_FJTHXXB.Post; //保存该房台为营业
end; //结束判断点菜的信息是否为空.
End
Else
Abort;
end;
//
{procedure TDCFY_LR.DCGridKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState); //在 DCGrid控件中的按键操作
begin
x:=DCGrid.Row;
Y:=DCGrid.Col;
end;}
{procedure TDCFY_LR.DCGridKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If DCGrid.Col = 5 Then //当光标在第五列时
begin
if Length(DCGrid.Cells[1,X])<>0 then //当光标所在行的首单元格不为空
if Length(DCGrid.Cells[5,X])=0 then //当光标所在行的第五单元格为空
begin
Exit; //结束
End
Else
begin
Try
DCGrid.Cells[8,X]:=IntToStr(Round(StrToint(DCGrid.Cells[5,X])*StrToFloat(DCGrid.Cells[6,X]))); //计算合计金额
Except
End;
end;
end;
end;}
//
procedure TDCFY_LR.FormClose(Sender: TObject; var Action: TCloseAction); //关闭窗体
begin
KTGL.Button1.Click;
TLCYGLXT.CPFYXXB.Close; //关闭菜谱费用信息表;
TLCYGLXT.CJFYXXB.Close; //关闭餐具费用信息表;
TLCYGLXT.SJFYXXB.CLose; //关闭水酒信息表
TLCYGLXT.KT_FJTHXXB.CLose;
TLCYGLXT.JZBH.Close;
Query2.Close;
QUery1.Close;
DCFY_LR.Release;
DCFY_LR:=nil;
end;
procedure TDCFY_LR.DCGridKeyPress(Sender: TObject; var Key: Char);
var zjje:Real;
aa:integer;
begin
X:=DCGrid.Row;
Y:=DCGrid.Col;
if key=#13 then //回车
begin
If DCGrid.Col = 8 Then //当光标移到表格第八列时计算消费合计
begin
zjje:=0;
for aa:=1 to 51 do
begin
if Length(DCGrid.Cells[8,aa])<>0 then
begin
if DCGrid.Cells[7,aa]<>'赠单' then
begin
zjje:=StrToFloat(DCGrid.Cells[8,aa])+zjje; //计算总计消费
Label14.Caption:=FloatToStr(zjje);
End
Else
begin
Label14.Caption:=FloatToStr(zjje);
end;
End
Else
Break; //结束循环
end;
end;
If DCGrid.Col = 5 Then
begin
if Length(DCGrid.Cells[1,X])<>0 then
begin
if StrToInt(DCGrid.Cells[5,X])=0 then //输入数量为零
begin
ShowMessage('数量不正确');
Exit;
End
Else
begin
Try
DCGrid.Cells[8,X]:=IntToStr(Round(StrToint(DCGrid.Cells[5,X])*StrToFloat(DCGrid.Cells[6,X]))); //计算金额
Except
End;
DCGrid.Col:=7;
end;
end;
if Length(DCGrid.Cells[1,x])<>0 then
if StrToInt(Copy(DCGrid.Cells[1,x],0,1))=1 then
begin
if PJ[DCGrid.row]-StrToInt(DCGrid.Cells[5,x])<=0 then //超出库存
begin
ShowMessage('库存不足');
end;
end;
end;
If DCGrid.Col = 1 Then //光标在第一列时
if Length(DCGrid.Cells[1,x])<>0 then
begin
case StrToInt(Copy(DCGrid.Cells[1,x],0,1)) of //copy: 获取指定数量的字符串
1: begin //首字符为1 点酒水
if TLCYGLXT.SJFYXXB.Locate('编号',DCGrid.Cells[1,x],[locaseInsensitive]) then
begin
if query1.Locate('编号',TLCYGLXT.SJFYXXB.FieldByName('货存编号').AsInteger,[locaseInsensitive]) then //查找商品
begin
PJ[DCGrid.row]:=Query1.FieldByName('数量').AsInteger;
DCGrid.Cells[2,X]:=TLCYGLXT.SJFYXXB.FieldByName('酒水名称').AsString;
DCGrid.Cells[4,x]:=TLCYGLXT.SJFYXXB.FieldByName('单位').AsString;
DCGrid.Cells[3,x]:=TLCYGLXT.SJFYXXB.FieldByName('酒水类别').AsString;
DCGrid.Cells[6,x]:=TLCYGLXT.SJFYXXB.FieldByName('价格').AsString;
DCGrid.Cells[7,x]:='点单';
DCGrid.Cells[5,x]:='1';
DCGrid.Cells[8,x]:=TLCYGLXT.SJFYXXB.FieldByName('价格').AsString;
DCGrid.Col:=4;
End
Else
begin
ShowMessage('对不起,已没有库存.');
Abort;
end;
End
Else
begin
ShowMessage('没有此编号水酒信息');
Abort;
end;
end;
3: begin //首字符为3 点餐具
if TLCYGLXT.CJFYXXB.Locate('编号',DCGrid.Cells[1,X],[loCaseInsensitive]) then
begin
DCGrid.Cells[2,X]:=TLCYGLXT.CJFYXXB.FieldByName('餐具名称').AsString;
DCGrid.Cells[4,x]:=TLCYGLXT.CJFYXXB.FieldByName('单位').AsString;
DCGrid.Cells[3,x]:=TLCYGLXT.CJFYXXB.FieldByName('餐具类别').AsString;
DCGrid.Cells[6,x]:=TLCYGLXT.CJFYXXB.FieldByName('价格').AsString;
DCGrid.Cells[7,x]:='点单';
DCGrid.Cells[5,x]:='1';
DCGrid.Cells[8,x]:=TLCYGLXT.CJFYXXB.FieldByName('价格').AsString;
DCGrid.Col:=4;
End
Else
begin
ShowMessage('没有此编号餐具信息');
Abort;
end;
end;
Else //首字符为其他点菜
begin
if TLCYGLXT.CPFYXXB.Locate('编号',DCGrid.Cells[1,X],[loCaseInsensitive]) then
begin
DCGrid.Cells[2,X]:=TLCYGLXT.CPFYXXB.FieldByName('菜名').AsString;
DCGrid.Cells[4,x]:=TLCYGLXT.CPFYXXB.FieldByName('单位').AsString;
DCGrid.Cells[3,x]:=TLCYGLXT.CPFYXXB.FieldByName('菜系类别').AsString;
DCGrid.Cells[6,x]:=TLCYGLXT.CPFYXXB.FieldByName('价格').AsString;
DCGrid.Cells[7,x]:='点单';
DCGrid.Cells[5,x]:='1';
DCGrid.Cells[8,x]:=TLCYGLXT.CPFYXXB.FieldByName('价格').AsString;
DCGrid.Col:=4;
End
Else
begin
ShowMessage('没有此编号菜谱信息');
Abort;
end;
end;
end;
end;
if DCGrid.Col<8 then DCGrid.Col:=DCGrid.Col+1 //光标向后移动
Else
If DCGrid.Row <> 50 Then
begin
DCGrid.row:=DCGrid.row+1; //光标移到下一行
DCGrid.Col:=1;
end;
End
Else
If (DCGrid.Col = 1) Or (DCGrid.Col = 5) Then
begin
If DCGrid.Col = 5 Then
begin
if key=#8 then key:=#8 else //退格键
if (key<'0') or (Key>'9') then key:=#0; //如果输入大于0小于9,则输入空字符
if Length(DCGrid.Cells[2,x])=0 then
begin
Key:=#0; // 空字符
end;
end;
If DCGrid.Col = 1 Then
if Length(DCGrid.Cells[2,X-1])=0 then
begin
Key:=#0;
End
Else
begin
if key=#8 then key:=#8 else
if (key<'0') or (Key>'9') then key:=#0; //如果输入大于0小于9,则输入空字符
end;
End
Else
If DCGrid.Col = 7 Then //如果光标在第7列时
begin
if Length(DcGrid.Cells[1,x])=0 then key:=#0 //如果DcGrid.Cells[1,x]单元格无输入值,输入空字符
Else
begin
Listbox2.Visible:=True; //显示点单赠单列表
Listbox2.ItemIndex:=0; //移到点单
ListBox2.SetFocus;
end;
End
Else
if (DCGrid.Col=1) or (DCGrid.Col=2) or (DCGrid.Col=3) or (DCGrid.Col=4)
or (DCGrid.Col=6) or (DCGrid.Col=7) or (DCGrid.Col=8) then Key:=#0;
end;
procedure TDCFY_LR.DCGridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
x:=DCGrid.Row;
Y:=DCGrid.Col;
end;
procedure TDCFY_LR.DCGridKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
If DCGrid.Col = 5 Then //当光标在第五列时
begin
if Length(DCGrid.Cells[1,X])<>0 then //当光标所在行的首单元格不为空
if Length(DCGrid.Cells[5,X])=0 then //当光标所在行的第五单元格为空
begin
Exit; //结束
End
Else
begin
Try
DCGrid.Cells[8,X]:=IntToStr(Round(StrToint(DCGrid.Cells[5,X])*StrToFloat(DCGrid.Cells[6,X]))); //计算合计金额
Except
End;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -