📄 mrwx_bjrk.~pas
字号:
stringgrid1.Col:=stringgrid1.Col+1;
end;
// key:=#0;
end;
9:begin
if key=#13 then
stringgrid1.Col:=stringgrid1.Col+1;
if key='.' then begin
for stri:=1 to length(stringgrid1.cells[9,y]) do begin
if stringgrid1.Cells[9,y][stri]='.' then key:=#0;
end;
end else begin
if (key>'9') or (key<'0') then key:=#0;
end;
end;
10:begin
if key=#13 then
stringgrid1.Col:=stringgrid1.Col+1;
end;
11:begin
if key=#13 then begin
stringgrid1.Col:=1;
stringgrid1.row:=stringgrid1.Row+1;
end;
end;
end;
end else begin
key:=#0;
end; }
end;
procedure TMR_WXBJ_RK.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case x of
{ 1:begin
if dbgrid4.Visible then begin
if key=$26 then begin
key:=$0;
adotable8.Prior;
stringgrid1.cells[1,y]:=adotable8.fieldbyname('备件名').asstring;
end;
if key=$28 then begin
key:=$0;
adotable8.Next;
stringgrid1.cells[1,y]:=adotable8.fieldbyname('备件名').asstring;
end;
if key=$27 then begin
dbgrid4.Visible:=false;
stringgrid1.Cells[1,y]:='';
end;
end;
end;
1:begin
if dbgrid3.Visible then begin
if key=$26 then begin
key:=$0;
adotable4.Prior;
stringgrid1.cells[1,y]:=adotable4.fieldbyname('备件名称').asstring;
end;
if key=$28 then begin
key:=$0;
adotable4.Next;
stringgrid1.cells[1,y]:=adotable4.fieldbyname('备件名称').asstring;
end;
if key=$27 then begin
dbgrid3.Visible:=false;
stringgrid1.Cells[1,y]:='';
end;
end;
end;
end; }
end;
procedure TMR_WXBJ_RK.StringGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case x of
1:begin
if dbgrid3.Visible then begin
if length(stringgrid1.Cells[1,y])<>0 then begin
if (key<>$26) and (key<>$28) then begin
adotable4.Locate('备件名称',stringgrid1.Cells[1,y],[loPartialKey]);
end;
end;
end;
end;
end;
end;
procedure TMR_WXBJ_RK.DBGrid3DblClick(Sender: TObject);
begin
stringgrid1.Cells[1,y]:=adotable4.fieldbyname('备件名称').asstring;
stringgrid1.Cells[2,y]:=adotable4.fieldbyname('备件型号').asstring;
stringgrid1.Cells[3,y]:=adotable4.fieldbyname('备件规格').asstring;
stringgrid1.cells[4,y]:=adotable4.fieldbyname('单位').asstring;
stringgrid1.Cells[6,y]:='0';
stringgrid1.cells[7,y]:='0';
stringgrid1.cells[9,y]:='0';
stringgrid1.cells[10,y]:='0';
dbgrid3.Visible:=false;
// adotable4.Close;
stringgrid1.Col:=5;
end;
procedure TMR_WXBJ_RK.StringGrid1GetEditMask(Sender: TObject; ACol,
ARow: Integer; var Value: String);
begin
if acol=5 then begin
combobox1.left:=stringgrid1.CellRect(5,arow).left;
combobox1.top:=stringgrid1.cellrect(5,arow).top;
combobox1.Visible:=true;
combobox1.SetFocus;
end else begin
combobox1.visible:=false;
end;
if acol=8 then begin
combobox2.Left:=stringgrid1.cellrect(8,arow).left;
combobox2.Top:=stringgrid1.cellrect(8,arow).top;
combobox2.Visible:=true;
combobox2.SetFocus;
end else begin
combobox2.visible:=false;
end;
if (y=arow-1) and (stringgrid1.Cells[1,y]<>'') and (stringgrid1.Cells[1,arow]='') and
(stringgrid1.cells[9,arow]='') then begin
if stringgrid1.cells[9,y]='' then stringgrid1.cells[9,y]:='0';
if strtofloat(stringgrid1.Cells[9,y])=0 then begin
stringgrid1.row:=y;
messagedlg('请输入单价和数量.',mterror,[mbok],0);
exit;
end else begin
jin:=jin-strtofloat(stringgrid1.cells[9,y]);
stringgrid1.Cells[6,arow]:='0';
stringgrid1.cells[7,arow]:='0';
stringgrid1.cells[9,arow]:='0';
end;
{ if jin<adotable5.FieldByName('提示下限').asfloat then begin
messagedlg('公司的['+combobox2.text+']以超出了资产下限,请三思。',}
end;
x:=acol;
y:=arow;
end;
procedure TMR_WXBJ_RK.StringGrid1DblClick(Sender: TObject);
begin
if length(stringgrid1.cells[1,y-1])<>0 then begin
case x of
1:begin
dbgrid3.visible:=true;
end;
end;
end;
end;
procedure TMR_WXBJ_RK.StringGrid1Click(Sender: TObject);
begin
dbgrid3.Visible:=false;
dbgrid4.visible:=false;
end;
procedure TMR_WXBJ_RK.BitBtn2Click(Sender: TObject);
begin
if bitbtn2.caption='取消添加[&C]' then begin
bitbtn1.caption:='批量入库登记[&R]';
bitbtn2.caption:='备件入库登记[&C]';
bitbtn3.Caption:='领料单入库[&P]';
tabsheet1.show;
bitbtn4.Enabled:=true;
bitbtn6.enabled:=true;
end else begin
adotable3.Insert;
adotable3.FieldByName('日期').asdatetime:=date;
MR_WXBJRK_TJ.showmodal;
end;
end;
procedure TMR_WXBJ_RK.BitBtn3Click(Sender: TObject);
var jilu:integer; bian:string; bian1:integer;
begin
{if tbitbtn(sender).caption='保存信息[&P]' then begin
for jilu:=1 to 100 do begin
if (stringgrid1.Cells[1,jilu]<>'') and (strtofloat(stringgrid1.cells[7,stringgrid1.Row])<>0) then begin
if adotable1.locate('物品名称;型号;规格;部门',
vararrayof([stringgrid1.cells[1,jilu],stringgrid1.cells[2,jilu],stringgrid1.Cells[3,jilu],combobox3.text]),
[loCaseInsensitive]) then begin
adotable1.Edit;
adotable1.FieldByName('数量').asinteger:=
adotable1.FieldByName('数量').asinteger+
strtoint(stringgrid1.cells[7,jilu])-
strtoint(stringgrid1.cells[10,jilu]);
adotable1.FieldByName('库存金额').asfloat:=
adotable1.FieldByName('库存金额').asfloat+
strtofloat(stringgrid1.Cells[9,jilu]);
adotable1.fieldbyname('平均单价').asfloat:=
adotable1.fieldbyname('库存金额').asfloat/
adotable1.fieldbyname('数量').asfloat;
adotable1.Post;
end else begin
adotable1.Last;
bian:=adotable1.fieldbyname('编号').asstring;
if bian='' then begin
bian:='000001';
end else begin
bian:=inttostr(strtoint(bian)+1);
for bian1:=1 to 6-length(bian) do begin
bian:='0'+bian;
end;
end;
adotable1.InsertRecord([bian,stringgrid1.cells[1,jilu],
stringgrid1.cells[2,jilu],stringgrid1.cells[3,jilu],
stringgrid1.cells[4,jilu],strtoint(stringgrid1.cells[7,jilu])-
strtoint(stringgrid1.cells[10,jilu]),
stringgrid1.cells[6,jilu],stringgrid1.cells[9,jilu],
mr_wxform.adotable2.fieldbyname('库存上限').asinteger,
mr_wxform.adotable2.fieldbyname('库存下限').asinteger,combobox3.text]);
end;
adotable3.insertRecord([date,stringgrid1.cells[1,jilu],
stringgrid1.cells[2,jilu],stringgrid1.cells[3,jilu],
stringgrid1.cells[4,jilu],stringgrid1.cells[5,jilu],
'买入',stringgrid1.cells[7,jilu],stringgrid1.cells[6,jilu],
stringgrid1.cells[9,jilu],
stringgrid1.cells[10,jilu],stringgrid1.cells[8,jilu],
stringgrid1.cells[11,jilu],combobox3.text]);
adotable2.InsertRecord([date,stringgrid1.cells[1,jilu],
stringgrid1.cells[2,jilu],stringgrid1.cells[3,jilu],
stringgrid1.cells[4,jilu],stringgrid1.cells[5,jilu],
stringgrid1.cells[7,jilu],nil,stringgrid1.cells[6,jilu],nil,
stringgrid1.cells[9,jilu],
adotable1.fieldbyname('数量').asinteger,stringgrid1.cells[10,jilu],
stringgrid1.cells[8,jilu],stringgrid1.cells[11,jilu],combobox3.text]);
end;
end;
bitbtn1.Click;
bitbtn1.caption:='批量入库登记[&R]';
bitbtn2.caption:='备件入库登记[&C]';
bitbtn3.Caption:='领料单入库[&P]';
tabsheet1.show;
bitbtn4.Enabled:=true;
bitbtn6.enabled:=true;
end else begin
if mr_wxform.ADOQuery2.fieldbyname('领料单入库管理').asboolean=false then begin
showmessage('对不起,您没有这个系统权限.');
exit;
end;
if not assigned(mr_wxlldrk) then begin
mr_wxlldrk:=tmr_wxlldrk.create(self);
end;
mr_wxlldrk.Top:=top;
mr_wxlldrk.Left:=left;
mr_wxlldrk.show;
end; }
end;
procedure TMR_WXBJ_RK.BitBtn4Click(Sender: TObject);
begin
if tbitbtn(sender).caption='刷 新[&S]' then begin
tbitbtn(sender).caption:='入库记录查询[&S]';
adotable3.filtered:=false;
end else begin
mr_wxbjrkxx_xx.showmodal;
end;
end;
procedure TMR_WXBJ_RK.DBGrid3KeyPress(Sender: TObject; var Key: Char);
begin
if key=#27 then begin
dbgrid3.Visible:=false;
stringgrid1.cells[1,y]:='';
stringgrid1.cells[2,y]:='';
stringgrid1.cells[3,y]:='';
stringgrid1.cells[4,y]:='';
stringgrid1.cells[5,y]:='';
stringgrid1.cells[6,y]:='';
stringgrid1.cells[7,y]:='';
stringgrid1.cells[8,y]:='';
stringgrid1.cells[9,y]:='';
stringgrid1.cells[10,y]:='';
end;
if key=#13 then begin
stringgrid1.Cells[1,y]:=adotable4.fieldbyname('备件名称').asstring;
stringgrid1.Cells[2,y]:=adotable4.fieldbyname('备件型号').asstring;
stringgrid1.Cells[3,y]:=adotable4.fieldbyname('备件规格').asstring;
stringgrid1.cells[4,y]:=adotable4.fieldbyname('单位').asstring;
stringgrid1.Cells[6,y]:='0';
stringgrid1.cells[7,y]:='0';
stringgrid1.cells[9,y]:='0';
stringgrid1.cells[10,y]:='0';
dbgrid3.Visible:=false;
// adotable4.Close;
stringgrid1.Col:=5;
end;
end;
procedure TMR_WXBJ_RK.ComboBox1Exit(Sender: TObject);
begin
stringgrid1.Cells[5,y]:=combobox1.text;
combobox1.Visible:=false;
//stringgrid1.Col:=6;
//stringgrid1.setfocus;
end;
procedure TMR_WXBJ_RK.ComboBox2Exit(Sender: TObject);
begin
stringgrid1.Cells[8,y]:=combobox2.text;
combobox2.Visible:=false;
//stringgrid1.Col:=9;
//stringgrid1.setfocus;
end;
procedure TMR_WXBJ_RK.ComboBox3Click(Sender: TObject);
begin
adotable1.filter:=format('部门'+'='+'''%S''',[combobox3.text]);
adotable2.Filter:=adotable1.Filter;
adotable3.Filter:=adotable1.Filter;
end;
procedure TMR_WXBJ_RK.ComboBox2Enter(Sender: TObject);
begin
if stringgrid1.Cells[6,y]='' then stringgrid1.Cells[6,y]:='0';
if stringgrid1.cells[7,y]='' then stringgrid1.Cells[7,y]:='0';
stringgrid1.Cells[9,y]:=floattostr(strtofloat(stringgrid1.cells[6,y])*
strtofloat(stringgrid1.Cells[7,y]));
end;
procedure TMR_WXBJ_RK.SpeedButton1Click(Sender: TObject);
begin
if strtofloat(stringgrid1.cells[7,stringgrid1.Row])<>0 then
showmessage(stringgrid1.cells[7,stringgrid1.Row]);
end;
procedure TMR_WXBJ_RK.DataSource3DataChange(Sender: TObject;
Field: TField);
begin
if dbgrid3.Visible then begin
stringgrid1.cells[1,y]:=adotable4.fieldbyname('备件名称').asstring;
end;
end;
procedure TMR_WXBJ_RK.ComboBox1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then begin
stringgrid1.Col:=6;
stringgrid1.SetFocus;
end;
end;
procedure TMR_WXBJ_RK.ComboBox1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=$25 then begin
stringgrid1.Col:=4;
stringgrid1.SetFocus;
end;
if key=$27 then begin
stringgrid1.Col:=6;
stringgrid1.SetFocus;
end;
end;
procedure TMR_WXBJ_RK.ComboBox2KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=$25 then begin
stringgrid1.Col:=7;
stringgrid1.SetFocus;
end;
if key=$27 then begin
stringgrid1.Col:=9;
stringgrid1.SetFocus;
end;
end;
procedure TMR_WXBJ_RK.ComboBox2KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then begin
stringgrid1.Col:=9;
stringgrid1.SetFocus;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -