⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 hcrk.pas

📁 一个基于数据的药品行业管理系统,较全面,可供学习数据的开发人员参考消息
💻 PAS
📖 第 1 页 / 共 2 页
字号:
   aq1.Close;
   aq1.SQL.Clear;
   aq1.SQL.Add('delete from hcrkd where jhdh=:jhdh');
   aq1.Parameters.ParamByName('jhdh').Value:=trim(txtjhdh.text);
   mation:='确定修改此耗材入库信息吗?';
   mation1:='修改完毕';
   aq1.ExecSQL;
   end
   else
   txtjhdh.text:=jhdh;
   aq1.Close;
   aq1.SQL.Clear;
   aq1.SQL.Add('update hcda set jhdj=:jhdj,dqkc=dqkc+:q1,pc=:pc where hcbh=:hcbh');
   aq1.Parameters.ParamByName('jhdj').Value:=txtjhdj.text;
   aq1.Parameters.ParamByName('q1').Value:=txtjhsl.text;
   aq1.Parameters.ParamByName('pc').Value:=txtpc.text;
   aq1.Parameters.ParamByName('hcbh').Value:=trim(txthcbh.text);
   aq1.ExecSQL;
   aq1.Close;
   aq1.SQL.Clear;
   aq1.SQL.Add('insert into hcrkd (jhdh,csbh,hcbh,jhsl,jhrq,czybh,jhdj,jhje,zdrq,pc) '+
              ' values (:jhdh,:csbh,:hcbh,:jhsl,:jhrq,:czybh,:jhdj,:jhje,:zdrq,:pc)');
   aq1.Parameters.ParamByName('jhdh').Value:=trim(txtjhdh.text);
   aq1.Parameters.ParamByName('csbh').Value:=copy(trim(txtCSBH.text),1,4);
   aq1.Parameters.ParamByName('hcbh').Value:=trim(txthcbh.text);
   aq1.Parameters.ParamByName('jhsl').Value:=trim(txtjhsl.text);
   aq1.Parameters.ParamByName('jhrq').Value:=trim(txtjhrq.text);
   aq1.Parameters.ParamByName('czybh').Value:=trim(txtczy.text);
   aq1.Parameters.ParamByName('jhdj').Value:=trim(txtjhdj.text);
   aq1.Parameters.ParamByName('jhje').Value:=trim(txtjhje.text);
   aq1.Parameters.ParamByName('zdrq').Value:=trim(txtjhrq.Text);
    aq1.Parameters.ParamByName('pc').Value:=trim(txtpc.Text);
   aq1.ExecSQL;
   //写入流水帐hclsz
   aq1.Close;
   aq1.SQL.Clear;
   aq1.SQL.Add('insert into hclsz  (csbh,hcbh,sl,wcrq,pc,djbh,zdrq,type,jhdj,je,dqkc)'+
   ' 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)+''',''j'','''+trim(txtjhdj.Text)+''','''+trim(txtjhje.Text)+''','''+
    trim(txtdqkc.text)+''')');
   aq1.ExecSQL;
   //写入批次表pcb
   aq1.Close;
   aq1.SQL.Clear;
   {aq1.SQL.Add('insert into pcb  (csbh,hcbh,sl,jhrq,pc,djbh,zdrq,type,jhdj,je,pckc)'+
   ' 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(txtjhsl.text)+''')');  }
   aq1.SQL.Add('insert into pcb (djbh,csbh,hcbh,sl,rq,jhdj,je,zdrq,pc,pckc,type) '+
              ' values (:djbh,:csbh,:hcbh,:sl,:rq,:jhdj,:je,:zdrq,:pc,:pckc,:type)');
   aq1.Parameters.ParamByName('djbh').Value:=trim(txtjhdh.text);
   aq1.Parameters.ParamByName('csbh').Value:=copy(trim(txtCSBH.text),1,4);
   aq1.Parameters.ParamByName('hcbh').Value:=trim(txthcbh.text);
   aq1.Parameters.ParamByName('sl').Value:=trim(txtjhsl.text);
   aq1.Parameters.ParamByName('rq').Value:=trim(txtjhrq.text);
   aq1.Parameters.ParamByName('jhdj').Value:=trim(txtjhdj.text);
   aq1.Parameters.ParamByName('je').Value:=trim(txtjhje.text);
   aq1.Parameters.ParamByName('zdrq').Value:=trim(txtjhrq.Text);
   aq1.Parameters.ParamByName('pc').Value:=trim(txtpc.Text);
   aq1.Parameters.ParamByName('pckc').Value:=StrToCurr(trim(txtjhsl.text));
   aq1.Parameters.ParamByName('pc').Value:=trim(txtpc.Text);
   aq1.Parameters.ParamByName('type').Value:='J';
   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_hcRK.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.jhdh,a.hcbh,b.hcmc,b.gg,b.jldw,a.jhrq,a.zdrq,a.jhsl,'+
' a.jhdj,a.jhje,a.czybh,a.csbh,a.pc,b.dqkc,b.aqkc,c.csmc from hcda b,hcrkd a,csda c '+
' where a.hcbh=b.hcbh and a.csbh=c.csbh'+
' order by a.jhdh,a.hcbh');
aq1.Open;
if aq1.Recordset.RecordCount=0 then exit;
stringgrid1.RowCount:=aq1.Recordset.RecordCount+1;
frm_hcrk.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('jhdh').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('jhsl').Value; //进货数量
stringgrid1.Cells[5,i]:=aq1.Fields.fieldbyname('jhrq').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('jhje').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;
stringgrid1.Cells[13,i]:=aq1.Fields.fieldbyname('jldw').Value;
stringgrid1.Cells[14,i]:=aq1.Fields.fieldbyname('dqkc').Value;
stringgrid1.Cells[15,i]:=aq1.Fields.fieldbyname('aqkc').Value;
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]; //操作员
for i:=0 to txtcsbh.Items.Count-1 do
begin
if copy(txtcsbh.Items[i],1,4)=trim(stringgrid1.Cells[7,1]) then
   txtcsbh.ItemIndex:=i;
end;        // 供应商
//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];
end;


end;


procedure Tfrm_hcRK.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 hcrkd where jhdh=: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_hcRK.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];        // 批次
txtjhsl.SetFocus;
end
else
begin
showmessage('请选择纪录');
exit;
end;
end;
procedure Tfrm_hcRK.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
var i:integer;
begin
mycell:=arow;
if (stringgrid1.Focused) and (arow<>0) then
begin
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]; //操作员
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;        // 供应商
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_hcRK.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_hcRK.tfindClick(Sender: TObject);
begin
hcreflesh;
end;

procedure Tfrm_hcRK.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_hcRK.SpeedButton1Click(Sender: TObject);
begin
with data do
   begin
   screen.Cursor:=crHourGlass;
   aq1.close;
   aq1.SQL.Clear;
   aq1.SQL.Add('select hcbh as 耗材编号,hcmc as 耗材名称 from hcda'); //where csbh=:csbh');
   //aq1.Parameters.ParamByName('csbh').Value:=trim(txtcsbh.Text);
   aq1.Open;
   if aq1.Recordset.RecordCount>0 then
   begin
      aq1.FieldByName('耗材编号').DisplayWidth:=10;
      aq1.FieldByName('耗材名称').DisplayWidth:=50;
      dbgrid1.Visible:=true;
      datasource1.DataSet:=aq1;
      dbgrid1.DataSource:=datasource1;

   end;
   end;
   screen.Cursor:=crDefault;
end; 
procedure Tfrm_hcRK.DBGrid1DblClick(Sender: TObject);
begin
if dbgrid1.SelectedField.FieldName='耗材编号' then
   begin
   txthcbh.Text:=dbgrid1.SelectedField.AsString;
   with data do
   begin
   aq1.Connection:=adoc1;
   screen.Cursor:=crHourGlass;
   aq1.close;
   aq1.SQL.Clear;
   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;
   txtpc.Text:=inttostr(strtoint(trim(aq1.Fields.Fieldbyname('pc').Value))+1);
   end;
   screen.Cursor:=crDefault;
   txthcbh.color:=clwindow;
   txtjhdj.SetFocus;
   txtjhdj.SelectAll;
   txtjhdj.Color:=clskyblue;
   end;
    dbgrid1.Visible:=false;
   end;  
end;

procedure Tfrm_hcRK.txtcsbhExit(Sender: TObject);
begin
txtcsbh.Color:=clwindow;
end;

procedure Tfrm_hcRK.txtcsbhChange(Sender: TObject);
begin
txthcbh.SetFocus;
txthcbh.Color:=clskyblue;
end;

procedure Tfrm_hcRK.txtjhslKeyPress(Sender: TObject; var Key: Char);
begin
if key=#8  then key:=#8
else
if key=#13 then
  begin
  if txtjhsl.text='' then
  begin
  showmessage('数量不能为空');
  txtjhsl.SetFocus;
  exit;
  end;
  txtjhsl.Color:=clwindow;
  tsave.Click;
  end
else  
if (key>'9') or (key<'0') then
   key:=#0;
end;

procedure Tfrm_hcRK.txtjhdjKeyPress(Sender: TObject; var Key: Char);
begin
if key=#8  then key:=#8
else
if key='.' then key:='.'
else
if key=#13 then
  begin
  txtjhsl.SetFocus;
  txtjhsl.Color:=clskyblue;
  end
  {if txtjhsl.text='' then
  begin
  showmessage('数量不能为空');
  txtjhje.Text:=floattostr(strtofloat(txtjhdj.Text)*strtofloat(txtjhsl.text));
  end}
else
if (key>'9') or (key<'0') then
   key:=#0;
end;

procedure Tfrm_hcRK.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_hcRK.txtjhdjExit(Sender: TObject);
begin
txtjhdj.Color:=clwindow;
end;

procedure Tfrm_hcRK.txthcbhExit(Sender: TObject);
begin
txthcbh.Color:=clwindow;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -