?? 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 + -