📄 ctcdlr.pas
字号:
procedure Tctdcform.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=112 then
begin
if xt=0 then help(18);
end;
if key=13 then
selectnext(activecontrol,true,true);
// if key=27 then
// close;
end;
procedure Tctdcform.hdnoExit(Sender: TObject);
begin
if length(trim(hdno.text))=0 then
begin
grid.Enabled :=false;
hdno.SetFocus ;
exit;
end ;
query1.Active :=false;
query1.sql.clear;
query1.sql.add('select accno,money from ctnowin where tabno='''+trim(hdno.text)+'''');
query1.Prepare;
query1.Open;
acc:=query1.fieldbyname('accno').asstring;
if not query1.fieldbyname('money').isnull then
xf.text:=floattostr(query1.fieldbyname('money').asfloat);
Panel4.Enabled :=true;
xj.Checked :=false;
query1.Close;
query1.Active :=false;
query1.sql.clear;
end;
procedure Tctdcform.Button3Click(Sender: TObject);
begin
ctdcform.close;
end;
procedure Tctdcform.Button1Click(Sender: TObject);
var
i:integer;
begin
if length(trim(hdno.text))=0 then
begin
showmessage('桌号没有输入');
hdno.setfocus;
exit;
end;
if length(trim(djno.text))=0 then
begin
djno.text:=xdh('custom','lscustom','Djcode',10);
end;
if length(trim(pd.text))=0 then
begin
showmessage('服务员没有输入');
pd.setfocus;
exit;
end;
//********************************************//
i:=1;
while trim(xflist1.Cells[0,i])<>'' do
begin
query1.active:=false;
query1.sql.clear;
query1.sql.add('select sum(cusnum) as sl from custom where ((accno=:pacc) and (cuscode=:pbh))');
query1.ParamByName ('pacc').asstring:=acc;
query1.ParamByName ('pbh').asstring:=xfbm.Items[i-1];
query1.Prepare;
query1.open;
if not query1.IsEmpty then
if query1.FieldByName ('sl').asfloat+strtofloat(trim(xflist1.Cells[3,i]))<0 then
begin
showmessage(trim(xflist1.Cells[0,i])+' 数量不对');
exit;
end;
query1.Active:=false;
i:=i+1;
end;
if trim(xflist1.cells[0,1])='' then
begin
showmessage('此单无效');
hdno.SetFocus ;
exit;
end
else
if xj.Checked =false then
begin
query1.Active :=false;
query1.sql.clear;
query1.sql.add('update ctnowin set money=:pcustom where accno=:paccno and tabno='''+hdno.text+'''');
query1.ParamByName ('pcustom').asfloat:=strtofloat(trim(xf.text))+strtofloat(trim(edit1.text));
query1.ParamByName ('paccno').asstring:=acc;
query1.Prepare;
query1.ExecSQL;
end;
//********************************************//
i:=1;
while trim(xflist1.Cells[0,i])<>'' do
begin
query1.Active :=false;
query1.sql.clear;
query1.sql.add('insert into custom (tabno,accno,custype,cuscode,cusprice,cusnum,money,isxj,ismd,Isuse,iszk,jzfs,gzno,regtime,proid,czy,fwy,djcode)');
query1.sql.add(' values(:phandno,:paccno,:pcustype,:pcuscode,:pprice,:pnum,:pmoney,:pisxj,:pismd,0,:piszk,:pjzfs,:pgzno,:pregtime,:pproid,:pczy,:ppdid,:pdjcode)');
query1.ParamByName ('phandno').asstring:=trim(hdno.text);
query1.ParamByName ('paccno').asstring:=acc;
// query1.ParamByName ('plc').asinteger:=strtoint(lc);
query1.ParamByName ('pcustype').asstring:=copy(trim(xfbm.Items[i-1]),1,3);
query1.ParamByName ('pcuscode').asstring:=trim(xfbm.Items[i-1]);
query1.ParamByName ('pprice').asfloat:=strtofloat(trim(xflist1.Cells[1,i]));
query1.ParamByName ('pnum').asfloat:=strtofloat(trim(xflist1.Cells[3,i]));
query1.ParamByName ('pmoney').asfloat:=strtofloat(trim(xflist1.Cells[2,i]));
query1.ParamByName ('pisxj').asboolean:=xj.Checked ;
if trim(xflist1.Cells[4,i])='是' then
query1.ParamByName ('piszk').asboolean:=true
else
query1.ParamByName ('piszk').asboolean:=false;
query1.ParamByName ('pismd').asboolean:=md.Checked ;
query1.ParamByName ('pjzfs').asstring:='';
query1.ParamByName ('pgzno').asstring:='';
query1.ParamByName ('pregtime').asdatetime:=now;
query1.ParamByName ('pproid').asstring:='';
query1.ParamByName ('pczy').asstring:=copy(trim(czy.text),1,10);
query1.ParamByName ('ppdid').asstring:=trim(copy(pd.text,1,10));
query1.ParamByName ('pdjcode').asstring:=copy(trim(djno.text),1,10);
query1.Prepare;
query1.ExecSQL;
i:=i+1;
end;
showmessage('消费单录入成功');
init;
xj.SetFocus ;
end;
procedure Tctdcform.Button2Click(Sender: TObject);
begin
init;
hdno.setfocus;
end;
procedure Tctdcform.gridKeyPress(Sender: TObject; var Key: Char);
begin
if ((key<'0') or (key>'9')) then
if (key<>char(8)) and (key<>'-') and (key<>#13) then
key:=char(0);
if (key=char(13)) then
begin
grid.Col:=grid.Col+1;
// gridClick(nil);
end;
end;
procedure Tctdcform.gridEnter(Sender: TObject);
var
curxf:double;
arow,i,j:integer;
begin
arow:=grid.Row;
try
//*****************************************//
curxf:=0.00;
if length(trim(grid.cells[3,arow]))>0 then
begin
grid.Cells [2,arow]:=floattostr(strtofloat(grid.cells[1,arow])*strtofloat(grid.cells[3,arow]));
curxf:=0.00;
i:=1;
while trim(xflist1.Cells[0,i])<>'' do
begin
if trim(xflist1.Cells[0,i])=trim(grid.Cells[0,arow]) then
begin
delete(i,xflist1);
xfbm.Items.Delete(i-1);
end
else
begin
curxf:=curxf+strtofloat(trim(xflist1.Cells[2,i]));
i:=i+1;
end;
end;
if trim(grid.Cells[2,arow])<>'0' then
begin
for j:=0 to 4 do xflist1.Cells[j,i]:=grid.Cells[j,arow];
curxf:=curxf+strtofloat(trim(xflist1.Cells[2,i]));
xfbm.Items.Add(typebm.Items[arow-1]);
end;
if i>=xflist1.RowCount-1 then xflist1.RowCount:=xflist1.RowCount+1;
end
else
grid.Cells [2,arow]:='';
edit1.text:=floattostr(curxf);
//*****************************************//
//*****************************************//
except
end;
end;
procedure Tctdcform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
query1.free;
end;
procedure Tctdcform.hdnoEnter(Sender: TObject);
begin
grid.Enabled :=true;
end;
procedure Tctdcform.djnoExit(Sender: TObject);
begin
if djno.text='' then
djno.text:=xdh('ctdb.dbo.custom','ctdb.dbo.lslscustom','Djcode',10);
end;
procedure Tctdcform.xjClick(Sender: TObject);
begin
if xj.Checked =true then
md.Checked :=false
end;
procedure Tctdcform.mdClick(Sender: TObject);
begin
if md.Checked then
xj.Checked :=false
else
if not Panel4.Enabled then xj.Checked:=true;
end;
procedure Tctdcform.xflist1DblClick(Sender: TObject);
begin
if trim(xflist1.Cells[0,xflist1.row])<>'' then
begin
Edit1.Text:=floattostr(strtofloat(Edit1.text)-strtofloat(xflist1.cells[2,xflist1.row]));
delete(xflist1.row,xflist1);
xfbm.Items.Delete(xflist1.row-1);
end;
end;
procedure Tctdcform.djnoKeyPress(Sender: TObject; var Key: Char);
begin
if (key>'9') or (key<'0') then key:=#0;
end;
procedure Tctdcform.gridKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=45 then //插入
begin
GroupBox1.Visible:=true;
xlb.Caption:=xfname.Tabs[xfname.TabIndex];
xdm.Caption:=xbh('ctdb.dbo.cusitem where custype='''+xftype.Items[xfname.TabIndex]+'''','','Cuscode',4,3);
xmc.Text:='';
xdj.Text:='';
xdw.Text:='';
iszk.Checked:=false;
end;
grid.col:=3;
end;
procedure Tctdcform.hdnoDblClick(Sender: TObject);
begin
Application.CreateForm(Tycdjform, ycdjform);
ycdjform.Caption:='';
ycdjform.showmodal;
hdno.Text:=ycdjform.ydj.Text;
ycdjform.free;
end;
procedure Tctdcform.hdnoKeyPress(Sender: TObject; var Key: Char);
begin
key:=#0;
end;
procedure Tctdcform.Grid2Enter(Sender: TObject);
begin
(ActiveControl as Tstringgrid).Color:=clWhite;
(ActiveControl as Tstringgrid).Font.Color:=clBlue;
end;
procedure Tctdcform.gridMouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if y>18 then
grid.Hint:=grid.Cells[0,strtoint(floattostr(int(y/18)))]+' 单价:'+grid.Cells[1,strtoint(floattostr(int(y/18)))]+'元';
end;
procedure Tctdcform.slKeyPress(Sender: TObject; var Key: Char);
begin
if (key=char(13)) then
begin
ActiveControl:=xflist1;
end;
end;
procedure Tctdcform.xflist1MouseMove(Sender: TObject; Shift: TShiftState;
X, Y: Integer);
begin
if y>18 then
xflist1.Hint:=xflist1.Cells[0,strtoint(floattostr(int(y/18)))]+' 单价:'+xflist1.Cells[1,strtoint(floattostr(int(y/18)))]+'元';
end;
procedure Tctdcform.xfnameChange(Sender: TObject);
begin
seexfmx(xfname.TabIndex);
end;
procedure Tctdcform.xflist1KeyPress(Sender: TObject; var Key: Char);
var j:integer;
begin
if ((xflist1.Row<>1) and (trim(xflist1.cells[0,xflist1.Row-1])='')) or (trim(xflist1.cells[1,xflist1.Row])<>'') then
begin
key:=#0;
end;
if key=#13 then
begin
query1.Active :=false;
query1.sql.clear;
query1.sql.add('select cusname,price,cuscode,iszk from cusitem where cusname='''+xflist1.Cells[0,xflist1.Row]+'''');
query1.Prepare;
query1.Open;
if query1.Eof then
begin
showmessage('没有此菜名');
xflist1.Cells[0,xflist1.Row]:='';
xflist1.Cells[1,xflist1.Row]:='';
xflist1.Cells[2,xflist1.Row]:='';
xflist1.Cells[3,xflist1.Row]:='';
end
else
begin
j:=1 ;
while trim(xflist1.cells[0,j])<>'' do
begin
if trim(xflist1.cells[0,j])=trim(query1.fieldbyname('cusname').asstring) then
begin
showmessage('菜单中已有此菜名');
xflist1.cells[1,xflist1.Row]:='x';
end;
j:=j+1;
end;
if trim(xflist1.cells[1,xflist1.Row])<>'x' then
begin
xflist1.cells[0,xflist1.Row]:=query1.fieldbyname('cusname').asstring;
xflist1.cells[1,xflist1.Row]:=query1.fieldbyname('price').asstring;
if query1.fieldbyname('iszk').asboolean then
xflist1.cells[4,xflist1.Row]:='是'
else
xflist1.cells[4,xflist1.Row]:='否';
xfbm.Items.Add(query1.fieldbyname('cuscode').asstring);
xfsl.Visible:=true;
xfsl.Enabled:=true;
xfsl.Top:=26+(xflist1.row-xflist1.TopRow)*17;
ActiveControl:=xfsl;
end
else
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -