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

📄 sprcd.~pas

📁 一个基于数据的药品行业管理系统,较全面,可供学习数据的开发人员参考消息
💻 ~PAS
📖 第 1 页 / 共 2 页
字号:
begin
 if (txtshflag.text='0-未审核') and (txtjhdh.Text<>'')  and (stringgrid1.Cells[1,1]<>'') then
    begin
      if messagedlg('确定审核吗?',mtinformation,[mbyes,mbno],0)=mrno then
                  begin
                    screen.Cursor:=crDefault;
                    exit;
                  end;
       with data do
        begin
          adoc1.BeginTrans;
          screen.Cursor:=crHourGlass;
          aq1.Connection :=adoc1;
          with aq1 do
             begin
               {close;
               sql.Clear;
               sql.Add('select * from hcrkd0 ');
               open;
               if aq1.Recordset.RecordCount>=30 then
               begin
               showmessage('你的使用期限已到,请于通友科技联系,电话:13793190541 徐东');
               adoc1.RollbackTrans;
               screen.Cursor:=crDefault;
               aeanbled(2);
               exit;
               end;}
               close;
               sql.Clear;
               sql.Add('update hcrkd0 set flag=:flag where jhdh=:djbh');
               aq1.Parameters.ParamByName('djbh').Value:=trim(txtjhdh.text);
               aq1.Parameters.ParamByName('flag').Value:='1';
               aq1.ExecSQL;
               close;
               //写入流水帐hclsz
   aq1.Close;
   aq1.SQL.Clear;
   aq1.SQL.Add('insert into hclsz  (csbh,hcbh,sl,wcrq,pc,djbh,zdrq,type,jhdj,je)'+
   ' select a.csbh,b.hcbh,b.jhsl,a.zdrq,b.pc,a.jhdh,a.zdrq,''J'',b.jhdj,b.jhje from'+
   ' hcrkd0 a,hcrkd1 b where a.jhdh=b.jhdh and a.jhdh='''+trim(txtjhdh.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) '+
              ' select a.jhdh,a.csbh,b.hcbh,b.jhsl,a.zdrq,b.jhdj,b.jhje,a.zdrq,b.pc,'+
              'b.jhsl,''J'' from hcrkd0 a,hcrkd1 b where a.jhdh=b.jhdh and a.jhdh='''+trim(txtjhdh.Text)+'''');
   aq1.ExecSQL;
  //更改耗材档案
   aq1.Close;
   aq1.SQL.Clear;
   aq1.SQL.Add('update hcda set jhdj=hcrkd1.jhdj,dqkc=dqkc+hcrkd1.jhsl,pc=hcrkd1.pc '+
   ' from hcrkd0,hcrkd1 where hcrkd0.jhdh=hcrkd1.jhdh and hcda.hcbh=hcrkd1.hcbh and '+
   ' hcda.csbh=hcrkd0.csbh and hcrkd0.jhdh='''+trim(txtjhdh.text)+'''');
   aq1.ExecSQL;

               adoc1.CommitTrans;
               messagebox(frm_sprcd.Handle,'此商品信息已添加完毕','信息提示',0);
               txtshflag.Text:='1-已审核';
               aeanbled(2);
               screen.Cursor:=crDefault;
             end;
        end;
    end
    //如果已审核
    else
    if (txtshflag.text='1-未审核')  or (stringgrid1.Cells[1,1]='') then
        begin
         showmessage('此单已审核或无数据');
        end;
end;
procedure Tfrm_sprcd.teditClick(Sender: TObject);
var flag:boolean;
    i:integer;
begin
 flag:=false;
 if trim(tedit.Caption)='编辑' then
  begin
   if (trim(txtshflag.text)='0-未审核') and (txtjhdh.Text<>'') then
      begin
       aeanbled(1);
       editflag:=1;
      end
   else
      showmessage('此单已审核,不能编辑');
  end
  else
    begin
      if (not flag) and (trim(tedit.Caption)='编辑栏目') then
         begin
           If (stringgrid1.Focused) and ( stringgrid1.RowCount>=2) and (cell<>0) then
              begin
              frm_sprcdedit:=tfrm_sprcdedit.Create(application);
              frm_sprcdedit.txtspbh.text:=frm_sprcd.StringGrid1.Cells[1,cell]; //编号
      frm_sprcdedit.txtspmc.Text:=frm_sprcd.StringGrid1.Cells[2,cell]; //名称
      frm_sprcdedit.txtspgg.text:=frm_sprcd.StringGrid1.Cells[3,cell]; //地质
      frm_sprcdedit.txtdw.text:=frm_sprcd.StringGrid1.Cells[4,cell];   //电话
      frm_sprcdedit.txtjhdj.text:=frm_sprcd.StringGrid1.Cells[5,cell]; //传真
      frm_sprcdedit.txtjhsl.text:=frm_sprcd.StringGrid1.Cells[6,cell]; //状态
      frm_sprcdedit.txtjhje.text:=frm_sprcd.StringGrid1.Cells[7,cell]; //邮政编码
      {
      frm_sprcdedit.txtcbdj.text:=frm_sprcd.StringGrid1.Cells[8,cell];   //电报
      frm_sprcdedit.txtcdbh.text:=frm_sprcd.StringGrid1.Cells[9,cell];   //联系人
      frm_sprcdedit.txtqhbz.text:=frm_sprcd.StringGrid1.Cells[10,cell];  //开户
      frm_sprcdedit.txtjxcjl.text:=frm_sprcd.StringGrid1.Cells[11,cell]; //开户名称
      frm_sprcdedit.txtmax.text:=frm_sprcd.StringGrid1.Cells[12,cell];  //帐号
      frm_sprcdedit.comspxz.text:=frm_sprcd.StringGrid1.Cells[13,cell]; //帐号
      frm_sprcdedit.comspzt.text:=frm_sprcd.StringGrid1.Cells[14,cell]; //帐号
      frm_sprcdedit.comczzt.text:=frm_sprcd.StringGrid1.Cells[15,cell]; //帐号
      frm_sprcdedit.combzq.text:=frm_sprcd.StringGrid1.Cells[16,cell];  //帐号
      frm_sprcdedit.txtjhsl.text:=frm_sprcd.StringGrid1.Cells[17,cell]; //帐号
      frm_sprcdedit.txtxhsl.text:=frm_sprcd.StringGrid1.Cells[18,cell]; //帐号
      frm_sprcdedit.txtlykl.text:=frm_sprcd.StringGrid1.Cells[19,cell]; } //帐号
      frm_sprcdedit.ShowModal;
              end
              else
      showmessage('请选择纪录');
         end;
    end;
end;
procedure Tfrm_sprcd.StringGrid1SelectCell(Sender: TObject; ACol,
  ARow: Integer; var CanSelect: Boolean);
begin
      cell:=0;
   if (stringgrid1.Cells[1,arow]<>'') and (arow<>0) then
      cell:=arow;
end;

procedure Tfrm_sprcd.tdelClick(Sender: TObject);
var flag:boolean;
    i:integer;
begin
 flag:=false;
 if trim(tdel.Caption)='删除' then
  begin
   if (stringgrid1.Cells[1,1]<>'') and (copy(txtshflag.Text,1,1)<>'1') then
   begin
    if messagebox(frm_sprcd.Handle,'确实要删除此单据吗','删除窗口',mb_okcancel)=idcancel then
      exit;
    with data do
    begin
     adoc1.BeginTrans;
     aq1.Connection:=adoc1;
     with aq1 do
     begin
      close;
      sql.Clear;
      sql.Add('delete from hcrkd0 where jhdh=:jhdh');
      aq1.Parameters.ParamByName('jhdh').Value:=trim(txtjhdh.text);
      aq1.ExecSQL;
      close;
      sql.Clear;
      sql.Add('delete from hcrkd1 where jhdh=:jhdh');
      aq1.Parameters.ParamByName('jhdh').Value:=trim(txtjhdh.text);
      aq1.ExecSQL;
      adoc1.CommitTrans;
      for i:=1 to stringgrid1.RowCount-1 do
      stringgrid1.Rows[i].Clear;
      stringgrid1.RowCount:=2;
      messagebox(frm_sprcd.Handle,'删除此单据成功','提示信息',0);
      aeanbled(3);
      end;
   end;
  end
  else
      showmessage('此单已审核,不能编辑');
  end
  else
    begin
      if (not flag) and (trim(tdel.Caption)='删除栏目') then
         begin
           If (stringgrid1.Focused) and ( stringgrid1.RowCount>=2) and (cell<>0) then
           begin
               for i:=cell to stringgrid1.RowCount-1 do
               begin
               if i<stringgrid1.RowCount-1 then
                 stringgrid1.Rows[i]:=stringgrid1.Rows[i+1];
               end;
               stringgrid1.RowCount:=stringgrid1.RowCount-1;
           end;
         end;
    end;
  end;

procedure Tfrm_sprcd.tfindClick(Sender: TObject);
begin
csbhcreate;
frm_sprcdcx:=tfrm_sprcdcx.create(application);
frm_sprcdcx.showmodal; 
end;
//显示单据和单据内容
procedure Tfrm_sprcd.loaddata(key:string);
var i:integer;
begin
//if frm_sprcd.ComboBox1.Items.Count>0 then
if frm_sprcd.mainnumber>0 then
begin
with data do
begin
aq1.Connection:=adoc1;
with aq1 do
begin
close;
sql.Clear;
aq1.SQL.Add('select a.jhdh,t1.hcbh,b.hcmc,b.gg,b.jldw,a.zdrq,t1.jhsl,'+
' t1.jhdj,t1.jhje,a.czybh,a.csbh,t1.pc,c.csbh,a.flag from hcda b,hcrkd0 a,csda c,hcrkd1 t1 '+
' where t1.hcbh=b.hcbh and a.csbh=c.csbh and a.jhdh=:jhdh and a.jhdh=t1.jhdh '+
' order by a.jhdh,t1.hcbh');
{//sql.Add(' select a.djbh,a.mcbh,a.bmbh,a.dlbh,a.xlbh,a.czybh,c.czymc,a.zdrq,a.flag,'+
        ' b.csbh,b.csmc,t1.spbh,t1.spmc,t1.spgg,t1.jldw,t1.shdj,t1.hydj,'+
        ' t1.jhdj,t1.cbdj,t1.cdbh,t1.aqcl,t1.jxcjl,t1.mxsl,t1.spxz,t1.state,'+
        ' t1.czsp,t1.bzsx,t1.jhtax,t1.xstax,t1.lykl,a.xzbh from sprcd01 a,sprcd02 t1, '+
        ' czyda c,csda b where a.csbh=b.csbh and a.djbh=:djbh and c.czybh=a.czybh'+
        ' and t1.djbh=a.djbh');  }
aq1.Parameters.ParamByName('jhdh').Value:=frm_sprcd.number[frm_sprcd.nownumber];
//frm_sprcd.ComboBox1.Items[frm_sprcd.ComboBox1.Items.Count-1];
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
frm_sprcd.txtjhdh.Text:=aq1.Fields.Fieldbyname('jhdh').Value;
frm_sprcd.txtzdrq.Text:=aq1.Fields.Fieldbyname('zdrq').Value;
frm_sprcd.txtczybh.Text:=aq1.Fields.Fieldbyname('czybh').Value;
for i:=0 to txtcsbh.items.count-1 do
begin
if copy(txtcsbh.items[i],1,4)=aq1.Fields.Fieldbyname('csbh').Value then
   txtcsbh.itemindex:=i;
end;
if trim(aq1.Fields.Fieldbyname('flag').Value)='0' then
frm_sprcd.txtshflag.Text:='0-未审核';///aq1.Fields.Fieldbyname('csbh').Value;
if trim(aq1.Fields.Fieldbyname('flag').Value)='1' then
frm_sprcd.txtshflag.Text:='1-已审核';
aq1.First;
frm_sprcd.txtpc.Text:=aq1.Fields.Fieldbyname('pc').Value;
while not aq1.Eof do
begin
for i:=1 to StringGrid1.RowCount-2 do
    stringgrid1.Rows[i].Clear;
frm_sprcd.StringGrid1.RowCount:=aq1.Recordset.RecordCount+2;
for i:=1 to frm_sprcd.StringGrid1.RowCount-2 do
    begin
     frm_sprcd.StringGrid1.Cells[1,i]:=aq1.fields.fieldbyname('hcbh').value; //编号
     frm_sprcd.StringGrid1.Cells[2,i]:=aq1.fields.fieldbyname('hcmc').value; //名称
     frm_sprcd.StringGrid1.Cells[3,i]:=aq1.fields.fieldbyname('gg').value;//规格
     frm_sprcd.StringGrid1.Cells[4,i]:=aq1.fields.fieldbyname('jldw').value;//单位
     frm_sprcd.StringGrid1.Cells[5,i]:=aq1.fields.fieldbyname('jhdj').value; //进货单价
     frm_sprcd.StringGrid1.Cells[6,i]:=aq1.fields.fieldbyname('jhsl').value; //进货数量
     frm_sprcd.StringGrid1.Cells[7,i]:=aq1.fields.fieldbyname('jhje').value; // 进货金额
     frm_sprcd.StringGrid1.Cells[8,i]:=aq1.fields.fieldbyname('pc').value; // 批号
     aq1.Next;
     end;
 end;
 end;
end;
end;
end;
end;

procedure Tfrm_sprcd.Edit7Exit(Sender: TObject);
begin
//edit7.Color:=clwindow;
end;

procedure Tfrm_sprcd.Edit9Exit(Sender: TObject);
begin
//edit9.Color:=clwindow;
end;

procedure Tfrm_sprcd.Edit11Exit(Sender: TObject);
begin
//edit11.Color:=clwindow;
end;

procedure Tfrm_sprcd.Edit13Exit(Sender: TObject);
begin
//if not edit13.Focused then
// edit13.Color:=clwindow;
end;

procedure Tfrm_sprcd.Edit13Enter(Sender: TObject);
begin
//edit13.Color:=clskyblue;
end;

procedure Tfrm_sprcd.Edit7Enter(Sender: TObject);
begin
//edit7.Color:=clskyblue;
end;

procedure Tfrm_sprcd.Edit9Enter(Sender: TObject);
begin
//edit9.Color:=clskyblue;
end;

procedure Tfrm_sprcd.Edit11Enter(Sender: TObject);
begin
//  edit11.Color:=clskyblue;
end;

{procedure Tfrm_sprcd.Edit7KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
     begin
       with data do
         begin
           aq1.Connection:=adoc1;
           with aq1 do
              begin
                close;
                sql.Clear;
                sql.Add('select * from csda where csbh=:csbh and state=:state');
                aq1.Parameters.ParamByName('csbh').value:=trim(edit7.Text);
                aq1.Parameters.ParamByName('state').value:='0';
                aq1.Open;
                if aq1.Recordset.RecordCount=0 then
                  begin
                    messagebox(frm_sprcd.Handle,'此供应商不存在或此供应商状态不为正常状态','信息提示',0);
                    edit7.SetFocus;
                    edit7.SelectAll;
                    exit;
                  end;
                edit8.Text:=aq1.Fields.Fieldbyname('csmc').value;
                combobox1.SetFocus;
              end;
         end;
     end;
end; }
procedure Tfrm_sprcd.ComboBox1Change(Sender: TObject);
begin
//dit9.SetFocus;
end;
{procedure Tfrm_sprcd.Edit9KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
     begin
       with data do
         begin
           aq1.Connection:=adoc1;
           with aq1 do
              begin
                close;
                sql.Clear;
                sql.Add('select * from bm where bmbh=:bmbh ');
                aq1.Parameters.ParamByName('bmbh').value:=trim(edit9.Text);
                aq1.Open;
                if aq1.Recordset.RecordCount=0 then
                  begin
                    messagebox(frm_sprcd.Handle,'此部门不存在','信息提示',0);
                    edit9.SetFocus;
                    edit9.SelectAll;
                    exit;
                  end;
                edit10.Text:=aq1.Fields.Fieldbyname('bmmc').value;
                edit11.SetFocus;
              end;
         end;
     end;
end;
procedure Tfrm_sprcd.Edit11KeyPress(Sender: TObject; var Key: Char);
begin
  if key=#13 then
     begin
        checkinput('dlbh',trim(edit11.Text));
        edit12.Text:=dlmc;
     with data do
         begin
           aq1.Connection:=adoc1;
           with aq1 do
              begin
                close;
                sql.Clear;
                sql.Add('select * from dl where bmbh=:bmbh  and dlbh=:dlbh ');
                aq1.Parameters.ParamByName('bmbh').value:=trim(edit9.Text);
                aq1.Parameters.ParamByName('dlbh').value:=trim(edit11.Text);
                aq1.Open;
                if aq1.Recordset.RecordCount=0 then
                  begin
                    messagebox(frm_sprcd.Handle,'此大类不存在于此部门','信息提示',0);
                    edit11.SetFocus;
                    edit11.SelectAll;
                    exit;
                  end;
                edit13.SetFocus;
              end;
         end;
     end;
end;

procedure Tfrm_sprcd.Edit13KeyPress(Sender: TObject; var Key: Char);
begin
checkinput('xlbh',trim(edit13.text));
edit14.Text:=xlmc;
end; }

procedure Tfrm_sprcd.Edit7Change(Sender: TObject);
begin
{if length(edit7.Text)=4 then
   begin
     checkinput('csbh',trim(edit7.Text));
     edit8.Text:=csmc;
   end; }
end;

procedure Tfrm_sprcd.txtczybhChange(Sender: TObject);
begin
begin
if length(txtczybh.Text)=4 then
   begin
     checkinput('czybh',trim(txtczybh.Text));
     txtczymc.Text:=czymc;
   end;
end;
end;

procedure Tfrm_sprcd.Edit9Change(Sender: TObject);
begin
{if length(edit9.Text)=2 then
   begin
     checkinput('bmbh',trim(edit9.Text));
     edit10.Text:=bmmc;
   end; }
end;

procedure Tfrm_sprcd.Edit11Change(Sender: TObject);
begin
 { if length(edit11.Text)=3 then
   begin
     checkinput('dlbh',trim(edit11.Text));
     edit12.Text:=dlmc;
   end; }
end;

procedure Tfrm_sprcd.Edit13Change(Sender: TObject);
begin
{if length(edit13.Text)=3 then
   begin
     checkinput('xlbh',trim(edit13.Text));
     edit14.Text:=xlmc;
   end; }
end;

procedure Tfrm_sprcd.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 + -