📄 ctcdlr.pas
字号:
xflist1.cells[0,xflist1.Row]:='';
xflist1.cells[1,xflist1.Row]:='';
xflist1.cells[1,xflist1.Row]:='';
xflist1.cells[3,xflist1.Row]:='';
xflist1.cells[4,xflist1.Row]:='';
end;
end;
end;
end;
procedure Tctdcform.xflist1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if xflist1.Col<>0 then xflist1.Col:=0;
end;
procedure Tctdcform.xflist1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var i,j:integer;
begin
if length(trim(xflist1.cells[xflist1.Col,xflist1.Row]))=3 then
for i:=0 to xftype.Items.Count-1 do
if trim(xflist1.cells[xflist1.Col,xflist1.Row])=xftype.Items[i] then
begin
xfname.TabIndex:=i;
seexfmx(xfname.TabIndex);
end;
if length(trim(xflist1.cells[xflist1.Col,xflist1.Row]))=6 then
begin
for i:=0 to typebm.Items.Count-1 do
if trim(xflist1.cells[xflist1.Col,xflist1.Row])=typebm.Items[i] then
begin
j:=1 ;
while trim(xflist1.cells[0,j])<>'' do
begin
if trim(xflist1.cells[0,j])=trim(grid.Cells[0,i+1]) then
begin
showmessage('菜单中已有此菜名');
xflist1.cells[1,xflist1.Row]:='x';
end;
j:=j+1;
end;
if trim(xflist1.cells[1,xflist1.Row])<>'x' then
begin
xfbm.Items.Add(trim(xflist1.cells[xflist1.Col,xflist1.Row]));
xflist1.cells[xflist1.Col,xflist1.Row]:=grid.Cells[0,i+1];
xflist1.cells[1,xflist1.Row]:=grid.Cells[1,i+1];
xflist1.cells[4,xflist1.Row]:=grid.Cells[4,i+1];
xfsl.Visible:=true;
xfsl.Enabled:=true;
xfsl.Top:=26+(xflist1.row-xflist1.TopRow)*17;
ActiveControl:=xfsl;
end
else
begin
xflist1.cells[0,xflist1.Row]:='';
xflist1.cells[1,xflist1.Row]:='';
xflist1.cells[1,xflist1.Row]:='';
xflist1.cells[3,xflist1.Row]:='';
end;
end;
end;
end;
procedure Tctdcform.xfslExit(Sender: TObject);
var i:integer;
begin
if (trim(xfsl.Text)<>'') then
begin
try
if trim(xfsl.text)<>'' then i:=strtoint(xfsl.text);
xflist1.Cells[3,xflist1.Row]:=inttostr(xfsl.value);
except
xflist1.Cells[3,xflist1.Row]:=trim(xfsl.text);
end;
xflist1.Cells[2,xflist1.Row]:=floattostr(strtofloat(xflist1.Cells[1,xflist1.Row])*strtofloat(xflist1.Cells[3,xflist1.Row]));
edit1.text:=floattostr(strtofloat(edit1.text)+strtofloat(xflist1.Cells[2,xflist1.Row]));
end
else
begin
xflist1.Cells[2,xflist1.Row]:='0';
xflist1DblClick(nil);
end;
xfsl.Value:=1;
xfsl.Visible:=False;
xfsl.Enabled:=false;
if xflist1.Row>=xflist1.RowCount-1 then xflist1.RowCount:=xflist1.RowCount+1;
xflist1.Row:=xflist1.Row+1;
ActiveControl:=xflist1;
{
var i:integer;
curxf:double;
begin
curxf:=0.00;
i:=1;
while trim(xflist1.Cells[0,i])<>'' do
begin
if trim(xflist1.Cells[7,i])=bbb[0] then
begin
delete(i,xflist1);
end
else
begin
if xflist1.RowCount<=i then xflist1.RowCount:=xflist1.RowCount+1;
curxf:=curxf+strtofloat(trim(xflist1.Cells[2,i]));
i:=i+1;
end;
end;
if bbb[2]<>'0' then
begin
xflist1.Cells[0,i]:=bbb[1];
xflist1.Cells[1,i]:=bbb[3];
xflist1.Cells[7,i]:=bbb[0];
xflist1.Cells[8,i]:=bbb[4];
xflist1.Cells[3,i]:=floattostr(xfsl.Value);
xflist1.Cells[4,i]:=zyry1.Text;
xflist1.Cells[2,i]:=floattostr(strtofloat(bbb[3])*xfsl.Value);
curxf:=curxf+strtofloat(trim(xflist1.Cells[2,i]));
// xfbm.Items.Add(bbb[0]);
end;
edit1.text:=floattostr(curxf);
mc.Text:='';
zyry1.Text:='';
mc.SetFocus;
xfsl.Enabled:=false;
xfsl.Value:=1; }
end;
procedure Tctdcform.Button5Click(Sender: TObject);
begin
GroupBox1.Visible:=false;
end;
procedure Tctdcform.Button4Click(Sender: TObject);
begin
query2.Active :=false;
query2.sql.clear;
query2.sql.add('insert into cusitem values('''+xdm.Caption+''','''+trim(xmc.Text)+''','''+xftype.Items[xfname.TabIndex]+''','+xdj.Text+','''+xdw.Text+''',:piszk)');
query2.ParamByName ('piszk').asboolean:=iszk.Checked;
query2.Prepare;
query2.ExecSQL;
query2.Active :=false;
query2.sql.clear;
seexfmx(xfname.TabIndex);
GroupBox1.Visible:=false;
end;
procedure Tctdcform.xmcChange(Sender: TObject);
begin
if (trim(xmc.text)<>'') and (trim(xdj.text)<>'') and (trim(xdw.text)<>'') then
Button4.Enabled:=true
else
Button4.Enabled:=false;
end;
procedure Tctdcform.gridDblClick(Sender: TObject);
begin
if (grid.Col=3) and (trim(grid.Cells[0,grid.row])<>'') then
begin
sl.Visible:=true;
sl.Enabled:=true;
sl.Top:=26+(grid.row-grid.TopRow)*19;
ActiveControl:=sl;
end;
end;
///////////////////////////////////////////////////////////////
procedure Tctdcform.mcExit(Sender: TObject);
begin
if trim(mc.text)='' then exit;
getvalue(bbb,'select cuscode,cusname,unit,price,custype,iszy from cusitem where cuscode='''+trim(mc.Text)+''' or cusname='''+trim(mc.Text)+'''');
if bbb[0]='' then
begin
showmessage('项目错误!');
mc.Text:='';
mc.SetFocus;
exit;
end;
if bbb[5]='1' then
begin
zyry1.Enabled:=true;
zyry1.SetFocus;
exit;
end;
xfsl.Enabled:=true;
xfsl.SetFocus;
xfsl.Value:=1;
mc.Text:=bbb[1];
end;
procedure Tctdcform.mcKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then mcExit(nil);
end;
procedure Tctdcform.SpinEdit1Exit(Sender: TObject);
var i:integer;
curxf:double;
begin
curxf:=0.00;
i:=1;
while trim(xflist1.Cells[0,i])<>'' do
begin
if trim(xflist1.Cells[7,i])=bbb[0] then
begin
delete(i,xflist1);
end
else
begin
if xflist1.RowCount<=i then xflist1.RowCount:=xflist1.RowCount+1;
curxf:=curxf+strtofloat(trim(xflist1.Cells[2,i]));
i:=i+1;
end;
end;
if bbb[2]<>'0' then
begin
xflist1.Cells[0,i]:=bbb[1];
xflist1.Cells[1,i]:=bbb[3];
xflist1.Cells[7,i]:=bbb[0];
xflist1.Cells[8,i]:=bbb[4];
xflist1.Cells[3,i]:=floattostr(xfsl.Value);
xflist1.Cells[4,i]:=zyry1.Text;
xflist1.Cells[2,i]:=floattostr(strtofloat(bbb[3])*xfsl.Value);
curxf:=curxf+strtofloat(trim(xflist1.Cells[2,i]));
// xfbm.Items.Add(bbb[0]);
end;
edit1.text:=floattostr(curxf);
mc.Text:='';
zyry1.Text:='';
mc.SetFocus;
xfsl.Enabled:=false;
xfsl.Value:=1;
end;
procedure Tctdcform.SpinEdit1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then xfslExit(nil);
end;
procedure Tctdcform.zyry1Exit(Sender: TObject);
begin
xfsl.Enabled:=true;
zyry1.Enabled:=false;
xfsl.SetFocus;
end;
procedure Tctdcform.zyry1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then zyry1Exit(nil);
end;
procedure Tctdcform.mcKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if bx.Checked then exit;
if (key>=47) and (key<>45) then
begin
Panel7.Visible:=true;
jc.Text:=chr(key);
ActiveControl:=jc;
jc.SelStart:=1;
jcKeyUp(jc,key,shift);
end;
end;
procedure Tctdcform.jcExit(Sender: TObject);
begin
if Panel7.Visible then
jc.SetFocus;
end;
procedure Tctdcform.jcKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var i:integer;
begin
if (key>=49) and (key<58) AND (shift=[ssCtrl]) then
begin
Query1.First;
for i:=1 to strtoint(CHR(key))-1 do Query1.Next;
DBGrid1DblClick(NIL);
end;
if (key>32) and (key<=40) then dbgrid1.SetFocus;
if key=27 then
begin
Query1.Active:=false;
Panel7.Visible:=false;
DataSource1.DataSet:=nil;
mc.SetFocus;
end;
end;
procedure Tctdcform.jcKeyPress(Sender: TObject; var Key: Char);
begin
key:=upcase(key);
if key=#13 then
begin
if trim(jc.text)<>'' then
DBGrid1DblClick(NIL);
Query1.Active:=false;
Panel7.Visible:=false;
DataSource1.DataSet:=nil;
mc.SetFocus;
end;
end;
procedure Tctdcform.jcKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var tj:string;
begin
if jc1.Checked =true then
begin
tj:=' where cusjc>='''+trim(jc.Text)+''' and cusjc<'''+trim(jc.Text)+chr(255)+'''';
Label22.Caption:='项目简称';
end
else
begin
tj:=' where cuscode>='''+trim(jc.Text)+''' and cuscode<'''+trim(jc.Text)+chr(255)+'''';
Label22.Caption:='项目编号';
end;
Query1.Active:=false;
Query1.SQL.Clear;
Query1.SQL.Add('select * from cusitem ' +tj) ;
Query1.Prepare;
Query1.Open;
DataSource1.DataSet:=Query1;
ChineseGrid(DBGrid1);
end;
procedure Tctdcform.DBGrid1DblClick(Sender: TObject);
begin
bbb[0]:=Query1.fieldbyname('cuscode').asstring;
bbb[1]:=Query1.fieldbyname('cusname').asstring;
bbb[2]:=Query1.fieldbyname('unit').asstring;
bbb[3]:=Query1.fieldbyname('price').asstring;
bbb[4]:=Query1.fieldbyname('custype').asstring;
bbb[5]:=Query1.fieldbyname('iszy').asstring;
xfsl.Enabled:=true;
xfsl.SetFocus;
xfsl.Value:=1;
mc.Text:=bbb[1];
Query1.Active:=false;
Panel7.Visible:=false;
DataSource1.DataSet:=nil;
xfsl.SetFocus;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -