📄 hcck.~pas
字号:
' values ('''+copy(trim(txtcsbh.text),1,4)+''','''+trim(txthcbh.text)+''','''+
trim(txtjhsl.Text)+''','''+trim(txtjhrq.Text)+''','''+trim(txtpc.text)+''','''+
trim(txtjhdh.Text)+''','''+trim(txtjhrq.Text)+''',''L'','''+trim(txtjhdj.Text)+''','''+trim(txtjhje.Text)+''','''+
trim(txtdqkc.text)+''')');
aq1.ExecSQL;
//更新批次表
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('update pcb set pckc=pckc-:pckc where pc=:pc and hcbh=:hcbh');
{aq2.Close;
aq2.SQL.Clear;
aq2.SQL.add('select * from pcb where pckc>0');
aq2.Open;
if aq2.Recordset.RecordCount>0 then
begin
sumber:=aq2.Recordset.RecordCount;
setlength(setpckc,sumber);
while not aq2.Eof do
begin
for i:=0 to sumber-1 do
begin
setpckc[i]:=aq2.Fields.Fieldbyname('pckc').AsCurrency;
pc[i]:=StrToCurr(aq2.Fields.Fieldbyname('pc').Value);
aq2.Next;
end;
end;
for i:=0 to sumber-1 do
begin
setpckc[i]:=setpckc[i]-StrToCurr(trim(txtjhsl.Text));
if setpckc[i]>=0 then
break
else
setpckc[i]:=setpckc[i]
end
else
if }
aq1.Parameters.ParamByName('pckc').Value:=trim(txtjhsl.Text);
aq1.Parameters.ParamByName('pc').Value:=trim(txtpc.Text);
aq1.Parameters.ParamByName('hcbh').Value:=trim(txthcbh.Text);
aq1.ExecSQL;
if messagedlg(mation,mtinformation,[mbyes,mbno],0)=mrno then
begin
adoc1.RollbackTrans;
screen.Cursor:=crDefault;
exit;
end;
adoc1.CommitTrans;
messagedlg(mation1,mtinformation,[mbyes],1);
editflag:=0;
hcreflesh;
screen.Cursor:=crDefault;
end;
aenabeld(3);
end;
procedure Tfrm_hccK.hcreflesh;
var i:integer;
begin
for i:=1 to stringgrid1.RowCount-1 do
begin
stringgrid1.Rows[i].Clear;
end;
with data do
begin
aq1.Connection:=adoc1;
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('select a.LYdh,a.hcbh,b.hcmc,b.gg,b.jldw,a.LYrq,a.zdrq,a.LYsl,'+
' a.jhdj,a.LYje,a.czybh,a.csbh,a.pc,b.dqkc,b.aqkc,a.bmbh,a.ygbh from hcda b,hcckd a where a.hcbh=b.hcbh'+
' order by a.lydh,a.hcbh');
aq1.Open;
if aq1.Recordset.RecordCount=0 then exit;
stringgrid1.RowCount:=aq1.Recordset.RecordCount+1;
frm_hcck.StatusBar1.Panels[1].Text:=inttostr(aq1.Recordset.RecordCount);
stringgrid1.Font.Color:=clblack;
while not aq1.Eof do
begin
for i:=1 to stringgrid1.RowCount do
begin
stringgrid1.Cells[1,i]:=aq1.Fields.fieldbyname('lydh').Value;// 进货单号
stringgrid1.Cells[2,i]:=aq1.Fields.fieldbyname('hcbh').Value; //耗材编号
stringgrid1.Cells[3,i]:=aq1.Fields.fieldbyname('hcmc').Value; //耗材名称
stringgrid1.Cells[4,i]:=aq1.Fields.fieldbyname('lysl').Value; //进货数量
stringgrid1.Cells[5,i]:=aq1.Fields.fieldbyname('lyrq').Value; //进货日期
stringgrid1.Cells[6,i]:=aq1.Fields.fieldbyname('czybh').Value; //操作员
stringgrid1.Cells[7,i]:=aq1.Fields.fieldbyname('csbh').Value; // 供应商
stringgrid1.Cells[8,i]:=aq1.Fields.fieldbyname('jhdj').Value; // 进货价格
stringgrid1.Cells[9,i]:=aq1.Fields.fieldbyname('lyje').Value;// 进货金额
stringgrid1.Cells[10,i]:=aq1.Fields.fieldbyname('pc').Value; //批次
stringgrid1.Cells[11,i]:=aq1.Fields.fieldbyname('zdrq').Value;//制单日期
stringgrid1.Cells[12,i]:=aq1.Fields.fieldbyname('gg').Value; //gg
stringgrid1.Cells[13,i]:=aq1.Fields.fieldbyname('jldw').Value;//jldw
stringgrid1.Cells[14,i]:=aq1.Fields.fieldbyname('dqkc').Value;//dqkc
stringgrid1.Cells[15,i]:=aq1.Fields.fieldbyname('aqkc').Value;// aqkc
stringgrid1.Cells[16,i]:=aq1.Fields.fieldbyname('bmbh').Value; //bmbh
stringgrid1.Cells[17,i]:=aq1.Fields.fieldbyname('ygbh').Value; //ygbh
aq1.Next;
end;
end;
txtjhdh.Text:=stringgrid1.Cells[1,1]; // 进货单号
txthcbh.Text:=stringgrid1.Cells[2,1]; //耗材编号
txthcmc.text:=stringgrid1.Cells[3,1];
txtjhsl.Text:=stringgrid1.Cells[4,1]; // 进货数量
txtjhrq.Text:=stringgrid1.Cells[5,1]; // 进货日期
txtczy.Text:=stringgrid1.Cells[6,1]; //操作员
txtcsbh.Text:=stringgrid1.Cells[7,1]; // 供应商
txtjhdj.Text:=stringgrid1.Cells[8,1]; //进货价格
txtjhje.Text:=stringgrid1.Cells[9,1]; //进货金额
txtpc.Text:=stringgrid1.Cells[10,1]; //批次
txtjhrq.Text:=stringgrid1.Cells[11,1]; // 制单日期
txtgg.text:=stringgrid1.Cells[12,1];
txtdw.text:=stringgrid1.Cells[13,1];
txtdqkc.text:=stringgrid1.Cells[14,1];
txtaqkc.text:=stringgrid1.Cells[15,1];
txtbm.text:=stringgrid1.Cells[16,1];
txtyg.text:=stringgrid1.Cells[17,1];
end;
end;
procedure Tfrm_hccK.tdelClick(Sender: TObject);
begin
if (stringgrid1.Focused) and (stringgrid1.Cells[1,mycell]<>'') and (mycell<>0) then
begin
with data do
begin
adoc1.BeginTrans;
aq1.Connection:=adoc1;
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('delete from hcckd where lydh=:jhdh');
aq1.Parameters.ParamByName('jhdh').Value:=stringgrid1.Cells[1,mycell];
try
if messagedlg('确定删除此耗材入库信息吗?',mtinformation,[mbyes,mbno],0)=mrno then
begin
adoc1.RollbackTrans;
exit;
end;
aq1.ExecSQL;
adoc1.CommitTrans;
messagedlg('此耗材耗材入库已删除库',mtinformation,[mbyes],1);
hcreflesh;
except
showmessage('数据库连接错误');
end;
end;
end
else
begin
showmessage('请选择纪录');
exit;
end;
end;
procedure Tfrm_hccK.teditClick(Sender: TObject);
begin
if (stringgrid1.Focused) and (stringgrid1.Cells[1,mycell]<>'') and (mycell<>0) then
begin
aenabeld(1);
editflag:=1;
txtjhdh.Text:=stringgrid1.Cells[1,mycell]; // 进货单号
txthcbh.Text:=stringgrid1.Cells[2,mycell]; //耗材编号
txthcmc.text:=stringgrid1.Cells[3,mycell];
txtjhsl.Text:=stringgrid1.Cells[4,mycell]; // 进货数量
txtjhrq.Text:=stringgrid1.Cells[5,mycell]; // 进货日期
txtczy.Text:=stringgrid1.Cells[6,mycell]; //操作员
txtcsbh.Text:=stringgrid1.Cells[7,mycell]; // 供应商
txtjhdj.Text:=stringgrid1.Cells[8,mycell]; //进货价格
txtjhje.Text:=stringgrid1.Cells[9,mycell]; //进货金额
txtpc.Text:=stringgrid1.Cells[10,mycell]; //批次
txtjhrq.Text:=stringgrid1.Cells[11,mycell]; // 制单日期
txtgg.text:=stringgrid1.Cells[12,mycell];
txtdw.text:=stringgrid1.Cells[13,mycell];
txtdqkc.text:=stringgrid1.Cells[14,mycell];
txtaqkc.text:=stringgrid1.Cells[15,mycell];
txtbm.Text:=stringgrid1.Cells[16,mycell];
txtyg.Text:=stringgrid1.Cells[17,mycell]; // 批次
txtjhsl.SetFocus;
end
else
begin
showmessage('请选择纪录');
exit;
end;
end;
procedure Tfrm_hccK.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer; var CanSelect: Boolean);
var i:integer;
begin
mycell:=arow;
if (stringgrid1.Focused) and (arow<>0) then
begin
for i:=0 to txtcsbh.Items.Count-1 do
begin
if copy(txtcsbh.Items[i],1,4)=trim(stringgrid1.Cells[7,mycell]) then
txtcsbh.ItemIndex:=i;
end; // 供应商
txtjhdh.Text:=stringgrid1.Cells[1,mycell]; // 进货单号
txthcbh.Text:=stringgrid1.Cells[2,mycell]; //耗材编号
txthcmc.text:=stringgrid1.Cells[3,mycell];
txtjhsl.Text:=stringgrid1.Cells[4,mycell]; // 进货数量
txtjhrq.Text:=stringgrid1.Cells[5,mycell]; // 进货日期
txtczy.Text:=stringgrid1.Cells[6,mycell]; //操作员
//txtcsbh.Text:=stringgrid1.Cells[7,mycell]; // 供应商
txtjhdj.Text:=stringgrid1.Cells[8,mycell]; //进货价格
txtjhje.Text:=stringgrid1.Cells[9,mycell]; //进货金额
txtpc.Text:=stringgrid1.Cells[10,mycell]; //批次
txtjhrq.Text:=stringgrid1.Cells[11,mycell]; // 制单日期
txtgg.text:=stringgrid1.Cells[12,mycell];
txtdw.text:=stringgrid1.Cells[13,mycell];
txtdqkc.text:=stringgrid1.Cells[14,mycell];
txtaqkc.text:=stringgrid1.Cells[15,mycell]; // 批次
end;
end;
{procedure Tfrm_hcxx.txtaqkcExit(Sender: TObject);
begin
if not txtfax.Focused then
txtfax.Color:=clwindow;
end;
procedure Tfrm_hcxx.txtemailExit(Sender: TObject);
begin
if not txtemail.Focused then
txtemail.Color:=clwindow;
end;
procedure Tfrm_hcxx.txtjhdjExit(Sender: TObject);
begin
if not txthttp.Focused then
txthttp.Color:=clwindow;
end;
procedure Tfrm_hcxx.txthcmcMouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
txtkhbh.Color:=clskyblue;
end;
procedure Tfrm_hcxx.TXTsfzKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
txtsfz.Color:=clskyblue;
tsave.Click;
end;
end;
procedure Tfrm_hcxx.TXTsfzExit(Sender: TObject);
begin
if not txtsfz.Focused then
txtsfz.Color:=clwindow;
end;
procedure Tfrm_hcxx.txtcsrqKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
txtphone.SetFocus;
txtphone.Color:=clskyblue;
end;
end;
procedure Tfrm_hcxx.txtaqkcKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
txtemail.SetFocus;
txtemail.Color:=clskyblue;
end;
end;
procedure Tfrm_hcxx.txtemailKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
txthttp.SetFocus;
txthttp.Color:=clskyblue;
end;
end; }
procedure Tfrm_hccK.tcancelClick(Sender: TObject);
begin
aenabeld(3);
end;
{procedure Tfrm_hcxx.txtjhdjKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
txtsfz.SetFocus;
txtsfz.Color:=clskyblue;
end;
end; }
procedure Tfrm_hccK.tfindClick(Sender: TObject);
begin
frm_ckcx:=tfrm_ckcx.create(application);
frm_ckcx.showmodal;
hcreflesh;
end;
procedure Tfrm_hccK.FormShow(Sender: TObject);
begin
txtcsbh.Clear;
txtcsbh.Items.Add(' ');
with data do
begin
aq1.Connection:=adoc1;
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('select * from csda');
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
while not aq1.Eof do
begin
txtcsbh.Items.Add(aq1.Fields.Fieldbyname('csbh').Value+'-'+aq1.Fields.Fieldbyname('csmc').Value);
aq1.Next;
end;
end;
end;
end;
procedure Tfrm_hccK.SpeedButton1Click(Sender: TObject);
begin
with data do
begin
screen.Cursor:=crHourGlass;
aq1.close;
aq1.SQL.Clear;
aq1.SQL.Add('select a.hcbh as 耗材编号,a.hcmc as 耗材名称,b.pc as 批次 from hcda a,pcb b where '+
' a.hcbh=b.hcbh and b.csbh=:csbh and b.pckc>0 order by b.pc,a.hcbh ');
//where csbh=:csbh'
aq1.Parameters.ParamByName('csbh').Value:=copy(trim(txtcsbh.Text),1,4);
//aq1.SQL.Add('select hcbh as 耗材编号,hcmc as 耗材名称 from hcda');
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
//while not aq1.Eof do
//begin
//if strtoint(trim(aq1.FieldByName('pckc').Value))>0 then
//begin
aq1.First;
aq1.FieldByName('耗材编号').DisplayWidth:=10;
aq1.FieldByName('耗材名称').DisplayWidth:=50;
aq1.FieldByName('批次').DisplayWidth:=50;
txtpc.Text:=aq1.Fields.Fieldbyname('批次').Value;
dbgrid1.Visible:=true;
datasource1.DataSet:=aq1;
dbgrid1.DataSource:=datasource1;
//break;
//end;
//aq1.Next;
end;
screen.Cursor:=crDefault;
end;
end;
procedure Tfrm_hccK.DBGrid1DblClick(Sender: TObject);
begin
if dbgrid1.SelectedField.FieldName='耗材编号' then
txthcbh.Text:=dbgrid1.SelectedField.AsString;
with data do
begin
aq1.Connection:=adoc1;
screen.Cursor:=crHourGlass;
aq1.close;
aq1.SQL.Clear;
aq1.SQL.Add('select a.hcmc,a.hcbh,a.gg,a.JLdw,a.dqkc ,a.aqkc,b.pckc,b.jhdj from hcda a,pcb b'+
' where a.hcbh='''+trim(txthcbh.text)+''' and b.pc='''+trim(txtpc.text)+''' ');
//aq1.SQL.Add('select * from hcda where hcbh=:hcbh');
//aq1.Parameters.ParamByName('hcbh').Value:=copy(trim(txthcbh.Text),1,4);
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
txthcmc.Text:=aq1.Fields.Fieldbyname('hcmc').Value;
txtdw.Text:=aq1.Fields.Fieldbyname('jldw').Value;
txtgg.Text:=aq1.Fields.Fieldbyname('gg').Value;
txtjhdj.Text:=aq1.Fields.Fieldbyname('jhdj').Value;
txtdqkc.Text:=aq1.Fields.Fieldbyname('dqkc').Value;
txtaqkc.Text:=aq1.Fields.Fieldbyname('aqkc').Value;
txtpckc.Text:=aq1.Fields.Fieldbyname('pckc').Value;
//txtpc.Text:=aq1.Fields.Fieldbyname('pc').Value;
end;
screen.Cursor:=crDefault;
txthcbh.color:=clwindow;
txtjhdj.SetFocus;
txtjhdj.SelectAll;
txtjhdj.Color:=clskyblue;
end;
dbgrid1.Visible:=false;
end;
procedure Tfrm_hccK.txtcsbhExit(Sender: TObject);
begin
txtcsbh.Color:=clwindow;
end;
procedure Tfrm_hccK.txtcsbhChange(Sender: TObject);
begin
txthcbh.SetFocus;
txthcbh.Color:=clskyblue;
end;
procedure Tfrm_hccK.txtjhslKeyPress(Sender: TObject; var Key: Char);
begin
//txtjhsl.Text:=key;
if key=#8 then key:=#8
else
if key=#13 then
begin
if txtjhsl.text='' then
begin
showmessage('数量不能为空');
txtjhsl.SetFocus;
exit;
end;
IF txtjhsl.text>txtpckc.text then
begin
showmessage('领用数量不能大于当前批次数量');
exit;
end;
end
else
if (key>'9') or (key<'0') then
key:=#0
{if trim(txtjhsl.text)>trim(txtpckc.Text) then
begin
showmessage('数量大于当前批次数量');
txtjhsl.Text:=txtpckc.Text;
end; }
else
//txtjhje.Text:=floattostr(strtofloat(txtjhdj.Text)*strtofloat(txtjhsl.text));
end;
procedure Tfrm_hccK.txtjhdjKeyPress(Sender: TObject; var Key: Char);
begin
if key=#8 then key:=#8
else
if key='.' then key:='.'
else
if key=#13 then
begin
txtjhdj.Color:=clwindow;
txtjhsl.SetFocus;
txtjhsl.Color:=clskyblue;
if txtjhsl.text='' then
begin
showmessage('数量不能为空');
exit;
end;
end
else
if (key>'9') or (key<'0') then
key:=#0;
end;
procedure Tfrm_hccK.txtjhslKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var i:integer;
begin
i:=strtoint(txtjhsl.Text);
txtjhje.Text:=floattostr(strtofloat(txtjhdj.Text)*strtofloat(txtjhsl.text));
end;
procedure Tfrm_hccK.txtjhslChange(Sender: TObject);
begin
//txtjhje.Text:=floattostr(strtofloat(txtjhdj.Text)*strtofloat(txtjhsl.text));
end;
procedure Tfrm_hccK.txtjhslKeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key=8 then key:=8
else
if key=13 then key:=0
else
if (key>105) or (key>57) and (key<96) or (key<48) then key:=0
else
//[/formatfloat('0.00',(StrTo1int(stringgrid1.Cells[6,X])*StrToFloat(stringgrid1.Cells[5,X]))); //计算合计金额
// label7.Caption:=stringgrid1.Cells[7,X];}
txtjhje.Text:=formatfloat('0.00',strtofloat(txtjhdj.Text)*strtofloat(txtjhsl.text));
end;
procedure Tfrm_hccK.txtbmChange(Sender: TObject);
begin
with data do
begin
txtyg.Clear;
txtyg.Items.Add(' ');
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('select * from ygzl where bmbh='''+copy(trim(txtbm.items[txtbm.ItemIndex]),1,2)+'''');
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
while not aq1.Eof do
begin
txtyg.Items.Add(trim(aq1.Fieldbyname('ygbh').Value)+'-'+trim(aq1.Fieldbyname('ygmc').Value));
aq1.Next;
end;
end;
end;
end;
procedure Tfrm_hccK.csbhcreate;
begin
txtcsbh.Clear;
txtcsbh.Items.Add(' ');
with data do
begin
aq1.Connection:=adoc1;
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('select * from csda');
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
while not aq1.Eof do
begin
txtcsbh.Items.Add(aq1.Fields.Fieldbyname('csbh').Value+'-'+aq1.Fields.Fieldbyname('csmc').Value);
aq1.Next;
end;
end;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -