📄 newxf.pas
字号:
sl.Value:=1;
sl.Visible:=False;
sl.Enabled:=false;
ActiveControl:=grid;
end;
procedure Txfform.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
if Panel7.Visible then Panel7.Visible:=false else close;
end;
procedure Txfform.hdnoExit(Sender: TObject);
var
aa:array [0..1] of string;
begin
if length(trim(hdno.text))=0 then
begin
grid.Enabled :=false;
if activecontrol<>Button3 then
hdno.SetFocus ;
exit;
end ;
query1.Active :=false;
query1.sql.clear;
if (Panel3.Visible) then
begin
if (man.Checked) then
begin
lssex:='1';
end;
if (woman.Checked) then
begin
lssex:='0';
end;
end
else
begin
if copy(hdno.Text,1,1)>'9' then
lssex:='3'
else
lssex:='2';
end; // and sex='''+lssex+'''
query1.sql.add('select accno,isleft,welid from nowin where handno='''+trim(hdno.text)+'''');
query1.Prepare;
query1.Open;
acc:=query1.fieldbyname('accno').asstring;
welno:=query1.fieldbyname('welid').asstring;
if query1.fieldbyname('isleft').asboolean=true then
showmessage('此房是结帐留房');
query2.Active :=false;
query2.sql.clear;
query2.sql.add('select handno as 手号,s.sexname as 类型,roomprice as 房价 from nowin,lssex s where ((accno=:paccno) and (nowin.sex=s.sex)) ');
query2.ParamByName('paccno').asstring:=trim(acc);
query2.Prepare;
query2.open;
dbgrid2.Fields[2].DisplayWidth:=4;
query3.Active :=false;
query3.sql.clear;
query3.sql.add('select (select max(cusname) from cusitem where cusitem.cuscode=custom.cuscode) as 项目,sum(cusnum) as 数量,ismd as 免单,cuscode from custom where accno=:paccno and jsj='''+trim(curper.workjsj)+'''');
query3.sql.add(' group by cuscode,ismd order by cuscode');
query3.ParamByName('paccno').asstring:=trim(acc);
query3.Prepare;
query3.open;
dbgrid3.Fields[0].DisplayWidth:=10;
dbgrid3.Fields[1].DisplayWidth:=4;
tbooleanfield(dbgrid3.Fields[2]).displayvalues:='是;否';
{ Panel4.Enabled :=false;
xj.Checked :=true;
end
else
begin
Panel4.Enabled :=true;
xj.Checked :=false;
end;}
locka;
query1.Close;
query1.Active :=false;
query1.sql.clear;
query1.UnPrepare;
getvalue(aa,'select Deposit,Custom from account where accno='''+trim(acc)+'''');
yj.text:=trim(aa[0]);
xf.text:=trim(aa[1]);
sumroom(trim(hdno.text),lssex);
query1.Active :=false;
query1.sql.clear;
query1.sql.add('select isnull(sum(money),0),isnull(sum(csmoney),0) from nowin ');
if trim(acc)<>'' then
query1.sql.add(' where welid in (select welid from nowin where accno='''+trim(acc)+''')');
query1.Prepare;
query1.open;
MaskEdit1.text:=floattostr(query1.fields[0].asfloat+query1.fields[1].asfloat);
MaskEdit2.text:=floattostr(strtofloat(MaskEdit1.text) + strtofloat(xf.text));
MaskEdit3.text:=floattostr(strtofloat(yj.text)-strtofloat(MaskEdit2.text));
end;
procedure Txfform.Button3Click(Sender: TObject);
begin
xfform.close;
end;
procedure Txfform.Button1Click(Sender: TObject);
var sphj:Currency;zddh,jzfsm:string;
i,j,xsdh:integer;
begin
servertime(NIL);
if length(trim(hdno.text))=0 then
begin
showmessage('手号不能为空');
hdno.setfocus;
exit;
end;
if length(trim(acc))=0 then
begin
showmessage('帐号不能为空');
hdno.setfocus;
exit;
end;
if length(trim(djno.Text))=0 then
begin
showmessage('单号不能为空');
djno.setfocus;
exit;
end;
if trim(MaskEdit3.Text)='' then MaskEdit3.Text:='0';
{ if (strtofloat(MaskEdit3.Text)-strtofloat(edit1.Text))<0 then
if messagedlg('客人押金不足,请核对能否消费!',mtInformation, [mbYes], 0) = mrno then
exit; }
query1.Close;
// query1.Prepare;
query1.SQL.Clear;
query1.sql.Add('select * from qbcustom where djcode='''+trim(djno.Text)+'''');
query1.Prepare;
query1.Open;
if query1.RecordCount<>0 then
begin
showmessage('单号重复,请核对后再录入');
exit;
end;
query1.Close;
{ 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:=xflist1.Cells[7,i];
query1.Prepare;
query1.open;
if not query1.IsEmpty then
try
if query1.FieldByName ('sl').asfloat+strtofloat(trim(xflist1.Cells[3,i]))<0 then
begin
showmessage(trim(xflist1.Cells[0,i])+' 数量不对');
exit;
end;
except
end;
query1.Active:=false;
query1.UnPrepare;
i:=i+1;
end;
if trim(xflist1.cells[0,1])='' then
begin
showmessage('消费单无效');
hdno.SetFocus ;
exit;
end
else
if xj.Checked =false then
begin
if trim(xf.text)='' then xf.text:='0';
query1.Active :=false;
query1.sql.clear;
query1.sql.add('update account set custom=:pcustom where accno=:paccno');
query1.ParamByName ('pcustom').asfloat:=strtofloat(trim(xf.text))+strtofloat(trim(edit1.text));
query1.ParamByName ('paccno').asstring:=acc;
query1.Prepare;
query1.ExecSQL;
end;
//********************************************//
query1.Active :=false;
query1.sql.clear;
query1.sql.add('select max(jzfs) as fs from nowin where accno=:paccno');
query1.ParamByName ('paccno').asstring:=acc;
query1.Prepare;
query1.Open;
jzfsm:=query1.Fieldbyname('fs').AsString;
query1.Active :=false;
query1.sql.clear;
query1.sql.add('select ismxf as fs from nowin where accno=:paccno');
query1.ParamByName ('paccno').asstring:=acc;
query1.Prepare;
query1.Open;
if query1.Fields[0].AsBoolean then
jzfsm:='05';
// zddh:=xdh('custom','lscustom','zdcode',10);
i:=1;xsdh:=0;sphj:=0;
while trim(xflist1.Cells[0,i])<>'' do
begin
query1.Active :=false;
query1.sql.clear;
query1.sql.add('insert into custom (handno,sex,accno,welid,custype,cuscode,cusprice,cusnum,money,isxj,ismd,jzfs,gzno,regtime,proid,czy,pdid,djcode,jsj,zdcode,tcje)');
query1.sql.add(' values(:phandno,:psex,:paccno,:pwelid,:pcustype,:pcuscode,:pprice,:pnum,:pmoney,:pisxj,:pismd,:pjzfs,:pgzno,:pregtime,:pproid,:pczy,:ppdid,:pdjcode,:pjsj,:pzdcode,:ptcje)');
query1.sql.add('insert into gzCustom (handno,sex,accno,welid,custype,cuscode,cusprice,cusnum,money,isxj,ismd,jzfs,gzno,regtime,proid,czy,pdid,djcode,jsj,zdcode,tcje)');
query1.sql.add(' values(:phandno,:psex,:paccno,:pwelid,:pcustype,:pcuscode,:pprice,:pnum,:pmoney,:pisxj,:pismd,:pjzfs,:pgzno,:pregtime,:pproid,:pczy,:ppdid,:pdjcode,:pjsj,:pzdcode,:ptcje)');
query1.ParamByName ('phandno').asstring:=trim(hdno.text);
query1.ParamByName ('psex').asstring:=lssex;
query1.ParamByName ('paccno').asstring:=acc;
query1.ParamByName ('pwelid').asstring:=welno;
query1.ParamByName ('pcustype').asstring:=trim(xflist1.Cells[8,i]);
query1.ParamByName ('pcuscode').asstring:=trim(xflist1.Cells[7,i]);
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 ;
query1.ParamByName ('pismd').asboolean:=md.Checked ;
query1.ParamByName ('pjzfs').asstring:=jzfsm;
query1.ParamByName ('pgzno').asstring:='';
query1.ParamByName ('pregtime').asdatetime:=now;
query1.ParamByName ('pproid').asstring:=trim(xflist1.Cells[4,i]);//copy(trim(xflist1.Cells[4,i]),1,10);
query1.ParamByName ('pczy').asstring:=copy(trim(czy.text),1,10);
query1.ParamByName ('ppdid').asstring:=trim(copy(pd.text,1,10));
query1.ParamByName ('pdjcode').asstring:=trim(copy(trim(djno.text),1,10));
query1.ParamByName ('pjsj').asstring:=trim(curper.workjsj);
query1.ParamByName ('pzdcode').asstring:=zddh;
query1.ParamByName ('ptcje').asfloat:=strtofloat(trim(xflist1.Cells[3,i]))*strtofloat(trim(xflist1.Cells[10,i]));
query1.Prepare;
query1.ExecSQL;
{ if zdsz.Items.Count>0 then
begin
for j:=1 to zdsz.Items.Count-1 do
if (trim(copy(zdsz.Items[j],1,4))=copy(trim(xflist1.Cells[8,i]),1,2)) and (trim(copy(zdsz.Items[j],5,10))<>'') and (trim(xflist1.Cells[9,i])<>'')then
begin
fm.Query3.Active:=false;
if xsdh=0 then
begin
fm.Query3.SQL.Clear;
fm.Query3.SQL.Add('insert into 销售单(原始单号,a,b) values(:dh,:p,:x)');
fm.Query3.ParamByName('dh').asstring:=zddh;
fm.Query3.ParamByName('p').asstring:=curper.workjsj;
fm.Query3.ParamByName('x').asstring:=curper.code+curper.workjsj;
fm.Query3.ExecSQL;
fm.Query3.SQL.Clear;
fm.Query3.SQL.Add('select max(id) from 销售单 where a='''+curper.workjsj+'''');
fm.Query3.Open;
xsdh:=fm.Query3.Fields[0].asinteger;
end;
fm.Query3.SQL.Clear;
fm.Query3.SQL.Add('insert into 销售明细(销售单ID,商品ID,商品名称,仓库,数量,单位,单价,[折扣%],合计,记帐)');
fm.Query3.SQL.Add('values(:id,:pspid,:sp,:pk,:count,:pdw,:pdj,:pzk,:phj,0)');
fm.Query3.SQL.Add('update 数量表 set 现有数量=现有数量-:count,出库金额=出库金额+:phj,修改日期=:prq where 商品编号=:pspid and 仓库编号='''+trim(copy(zdsz.Items[j],5,10))+'''');
fm.Query3.ParamByName('id').AsInteger:=xsdh;
fm.Query3.ParamByName('pspid').asstring:=trim(xflist1.Cells[9,i]);
fm.Query3.ParamByName('sp').asstring:=trim(xflist1.Cells[0,i]) ;
fm.Query3.ParamByName('pk').asstring:=trim(copy(zdsz.Items[j],5,10));
fm.Query3.ParamByName('pzk').asinteger:=zkl.Value;
if trim(xflist1.Cells[3,i])='' then
fm.Query3.ParamByName('count').AsFloat:=0
else
fm.Query3.ParamByName('count').AsFloat:=strtofloat(trim(xflist1.Cells[3,i]));
fm.Query3.ParamByName('pdw').asstring:='';
if trim(xflist1.Cells[1,i])='' then
fm.Query3.ParamByName('pdj').AsFloat:=0
else
fm.Query3.ParamByName('pdj').AsFloat:=strtofloat(trim(xflist1.Cells[1,i]));
if trim(xflist1.Cells[2,i])='' then
fm.Query3.ParamByName('phj').AsFloat:=0
else
fm.Query3.ParamByName('phj').AsFloat:=strtofloat(trim(xflist1.Cells[2,i])) ;
fm.Query3.ParamByName('prq').Asdatetime:=now;
fm.Query3.ExecSQL;
sphj:=sphj+strtofloat(trim(xflist1.Cells[2,i]));
end;
end; }
i:=i+1;
end;
{ if xsdh<>0 then
begin
fm.Query3.SQL.Clear;
fm.Query3.SQL.Add('update 销售单 set 销售日期=:pdate,业务员=:pywy,客户代码=1,');
fm.Query3.SQL.Add('原始单号=:pdh,结帐方式=:pfk,金额合计=:phj,操作员=:czy,b=''0'' where rtrim(id)=:pid and rtrim(a)='''+curper.workjsj+'''');
fm.Query3.ParamByName('pid').asinteger:=xsdh;
fm.Query3.ParamByName('pdate').asdatetime:=now;
fm.Query3.ParamByName('pywy').asstring:=trim(pd.Text);
fm.Query3.ParamByName('pdh').asstring:=zddh;
fm.Query3.ParamByName('phj').AsFloat:=sphj;
fm.Query3.ParamByName('pfk').asstring:=curper.workjsj+'销售';
fm.Query3.ParamByName('czy').asstring:=trim(czy.Text);
fm.Query3.ExecSQL;
end;}
fm.Query3.Active:=false;
query1.Active :=false;
query1.UnPrepare;
query1.sql.clear;
addlogo(curper.code,datetimetostr(now),trim(copy(trim(djno.text),1,10))+'入帐'+trim(hdno.text));
showmessage('消费单录入成功');
unlocka;
query3.Active :=false;
query3.sql.clear;
query3.sql.add('select (select max(cusname) from cusitem where cusitem.cuscode=custom.cuscode) as 项目,sum(cusnum) as 数量,ismd as 免单,cuscode from custom where accno=:paccno ');
query3.sql.add(' group by cuscode,ismd order by cuscode');
query3.ParamByName('paccno').asstring:=trim(acc);
query3.Prepare;
query3.open;
dbgrid3.Fields[0].DisplayWidth:=10;
dbgrid3.Fields[1].DisplayWidth:=4;
tbooleanfield(dbgrid3.Fields[2]).displayvalues:='是;否';
init;
// xj.SetFocus ;
end;
procedure Txfform.Button2Click(Sender: TObject);
begin
if length(trim(hdno.text))>0 then
begin
unlocka;
end;
init;
hdno.setfocus;
end;
procedure Txfform.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 Txfform.gridEnter(Sender: TObject);
var
curxf:double;
arow,i,j:integer;
begin
arow:=grid.Row;
grid.Color:=clWhite;
grid.Font.Color:=clBlue;
try
//*****************************************//
if length(trim(grid.cells[3,arow]))>0 then
begin
if trim(grid.Cells [5,arow])='True' then
grid.Cells [2,arow]:=floattostr(strtofloat(grid.cells[1,arow])*strtofloat(grid.cells[3,arow])*zkl.Value/100)
else
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[7,i])=trim(grid.Cells[7,arow]) then
begin
delete(i,xflist1);
// xfbm.Items.Delete(i-1);
end
else
begin
// if xflist1.RowCount<i-1 then xflist1.RowCount:=xflist1.RowCount+1;
curxf:=curxf+strtofloat(trim(xflist1.Cells[2,i]));
i:=i+1;
end;
end;
xflist1.RowCount:=xflist1.RowCount+1;
if trim(grid.Cells[2,arow])<>'0' then
begin
for j:=0 to 10 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;
edit1.text:=floattostr(curxf);
end
else
grid.Cells [2,arow]:='';
//*****************************************//
//*****************************************//
except
end;
end;
procedure Txfform.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if length(trim(hdno.text))>0 then
begin
unlocka;
end;
query1.free;
s1.free;
s2.free;
end;
procedure Txfform.hdnoEnter(Sender: TObject);
begin
grid.Enabled :=true;
if acc<>'' then
unlocka;
end;
procedure Txfform.xjClick(Sender: TObject);
begin
if xj.Checked =true then
md.Checked :=false
end;
procedure Txfform.mdClick(Sender: TObject);
begin
if md.Checked then
xj.Checked :=false
else
if not Panel4.Enabled then xj.Checked:=true;
end;
procedure Txfform.xfnameChange(Sender: TObject);
begin
if not zyry.Visible then
begin
xftype.ItemIndex:=xfname.TabIndex;
seexftype(xfname.TabIndex);
end;
end;
procedure Txfform.Grid3DblClick(Sender: TObject);
begin
seexfmx(grid2.col,grid2.row);
end;
procedure Txfform.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);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -