📄 csht.~pas
字号:
procedure Tfrm_htgl.tcheckClick(Sender: TObject);
begin
if (txtshflag.text='0-未审核') and (txthtdh.Text<>'') and (memo1.text<>' ') then //(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;
aq1.close;
aq1.sql.Clear;
aq1.sql.Add('update cght set flag=:flag where htdh=:htdh');
aq1.Parameters.ParamByName('htdh').Value:=trim(txthtdh.text);
aq1.Parameters.ParamByName('flag').Value:='1';
aq1.ExecSQL;
{//写入流水帐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(txthtdh.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(txthtdh.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(txthtdh.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(txthtdh.text)+'''');
aq1.ExecSQL; }
adoc1.CommitTrans;
messagebox(frm_htgl.Handle,'此合同内容已审核','信息提示',0);
txtshflag.Text:='1-已审核';
aeanbled(2);
screen.Cursor:=crDefault;
end;
end
//如果已审核
else
if (txtshflag.text='1-未审核') or (memo1.text=' ') then //(stringgrid1.Cells[1,1]='') then
begin
showmessage('此单已审核或无数据');
end;
end;
procedure Tfrm_htgl.teditClick(Sender: TObject);
var flag:boolean;
i:integer;
begin
//flag:=false;
//if trim(tedit.Caption)='编辑' then
//begin
if (trim(txtshflag.text)='0-未审核') and (txthtdh.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_htgledit:=tfrm_htgledit.Create(application);
frm_htgledit.txtspbh.text:=frm_htgl.StringGrid1.Cells[1,cell]; //编号
frm_htgledit.txtspmc.Text:=frm_htgl.StringGrid1.Cells[2,cell]; //名称
frm_htgledit.txtspgg.text:=frm_htgl.StringGrid1.Cells[3,cell]; //地质
frm_htgledit.txtdw.text:=frm_htgl.StringGrid1.Cells[4,cell]; //电话
frm_htgledit.txtjhdj.text:=frm_htgl.StringGrid1.Cells[5,cell]; //传真
frm_htgledit.txtjhsl.text:=frm_htgl.StringGrid1.Cells[6,cell]; //状态
frm_htgledit.txtjhje.text:=frm_htgl.StringGrid1.Cells[7,cell]; //邮政编码
{
frm_htgledit.txtcbdj.text:=frm_htgl.StringGrid1.Cells[8,cell]; //电报
frm_htgledit.txtcdbh.text:=frm_htgl.StringGrid1.Cells[9,cell]; //联系人
frm_htgledit.txtqhbz.text:=frm_htgl.StringGrid1.Cells[10,cell]; //开户
frm_htgledit.txtjxcjl.text:=frm_htgl.StringGrid1.Cells[11,cell]; //开户名称
frm_htgledit.txtmax.text:=frm_htgl.StringGrid1.Cells[12,cell]; //帐号
frm_htgledit.comspxz.text:=frm_htgl.StringGrid1.Cells[13,cell]; //帐号
frm_htgledit.comspzt.text:=frm_htgl.StringGrid1.Cells[14,cell]; //帐号
frm_htgledit.comczzt.text:=frm_htgl.StringGrid1.Cells[15,cell]; //帐号
frm_htgledit.combzq.text:=frm_htgl.StringGrid1.Cells[16,cell]; //帐号
frm_htgledit.txtjhsl.text:=frm_htgl.StringGrid1.Cells[17,cell]; //帐号
frm_htgledit.txtxhsl.text:=frm_htgl.StringGrid1.Cells[18,cell]; //帐号
frm_htgledit.txtlykl.text:=frm_htgl.StringGrid1.Cells[19,cell]; //帐号
frm_htgledit.ShowModal;
end
else
showmessage('请选择纪录');
end;
end;}
end;
procedure Tfrm_htgl.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_htgl.tdelClick(Sender: TObject);
var i:integer;
begin
if (memo1.Text<>' ') and (copy(txtshflag.Text,1,1)<>'1') then
begin
if messagebox(frm_htgl.Handle,'确实要删除此单据吗','删除窗口',mb_okcancel)=idcancel then
begin
exit;
end;
with data do
begin
adoc1.BeginTrans;
aq1.Connection:=adoc1;
with aq1 do
begin
close;
sql.Clear;
sql.Add('delete from cght where htdh=:htdh');
aq1.Parameters.ParamByName('htdh').Value:=trim(txthtdh.text);
aq1.ExecSQL;
{if messagebox(frm_htgl.Handle,'确实要删除此单据吗','删除窗口',mb_okcancel)=idcancel then
begin
adoc1.RollbackTrans;
exit;
end;
adoc1.CommitTrans;
{if (stringgrid1.Cells[1,1]<>'') and (copy(txtshflag.Text,1,1)<>'1') then
begin
if messagebox(frm_htgl.Handle,'确实要删除此单据吗','删除窗口',mb_okcancel)=idcancel then
begin
exit;
end;
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(txthtdh.text);
aq1.ExecSQL;
close;
sql.Clear;
sql.Add('delete from hcrkd1 where jhdh=:jhdh');
aq1.Parameters.ParamByName('jhdh').Value:=trim(txthtdh.text);
aq1.ExecSQL;
{if messagebox(frm_htgl.Handle,'确实要删除此单据吗','删除窗口',mb_okcancel)=idcancel then
begin
adoc1.RollbackTrans;
exit;
end;}
adoc1.CommitTrans;
messagebox(frm_htgl.Handle,'删除此单据成功','提示信息',0);
aeanbled(3);
end;
end;
end;
end;
procedure Tfrm_htgl.tfindClick(Sender: TObject);
begin
csbhcreate;
frm_htglcx:=tfrm_htglcx.create(application);
frm_htglcx.showmodal;
end;
//显示单据和单据内容
procedure Tfrm_htgl.loaddata(key:string);
var i:integer;
begin
//if frm_htgl.ComboBox1.Items.Count>0 then
if frm_htgl.mainnumber>0 then
begin
with data do
begin
aq1.Connection:=adoc1;
with aq1 do
begin
close;
sql.Clear;
aq1.SQL.Add('select a.htdh,a.csbh,b.csmc,a.zdrq,a.sxrq,a.zzrq,a.czybh,a.flag, '+
'a.htnr from csda b,cght a where a.csbh=b.csbh and a.htdh=:htdh order by a.htdh,a.csbh ');
{//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('htdh').Value:=frm_htgl.number[frm_htgl.nownumber];
//frm_htgl.ComboBox1.Items[frm_htgl.ComboBox1.Items.Count-1];
aq1.Open;
if aq1.Recordset.RecordCount>0 then
begin
frm_htgl.txthtdh.Text:=aq1.Fields.Fieldbyname('htdh').Value;
frm_htgl.txtzdrq.Text:=aq1.Fields.Fieldbyname('zdrq').Value;
frm_htgl.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_htgl.txtshflag.Text:='0-未审核';///aq1.Fields.Fieldbyname('csbh').Value;
if trim(aq1.Fields.Fieldbyname('flag').Value)='1' then
frm_htgl.txtshflag.Text:='1-已审核';
txtsxrq.DateTime:=strtodatetime(aq1.Fields.Fieldbyname('sxrq').Value);
txtzzrq.DateTime:=strtodatetime(aq1.Fields.Fieldbyname('zzrq').Value);
memo1.Enabled:=false;
memo1.Text:=aq1.Fields.Fieldbyname('htnr').Value;
//aq1.First;
//frm_htgl.txtpc.Text:=aq1.Fields.Fieldbyname('pc').Value;
{while not aq1.Eof do
begin
frm_htgl.StringGrid1.RowCount:=aq1.Recordset.RecordCount+2;
for i:=1 to frm_htgl.StringGrid1.RowCount-2 do
begin
frm_htgl.StringGrid1.Cells[1,i]:=aq1.fields.fieldbyname('hcbh').value; //编号
frm_htgl.StringGrid1.Cells[2,i]:=aq1.fields.fieldbyname('hcmc').value; //名称
frm_htgl.StringGrid1.Cells[3,i]:=aq1.fields.fieldbyname('gg').value;//规格
frm_htgl.StringGrid1.Cells[4,i]:=aq1.fields.fieldbyname('jldw').value;//单位
frm_htgl.StringGrid1.Cells[5,i]:=aq1.fields.fieldbyname('jhdj').value; //进货单价
frm_htgl.StringGrid1.Cells[6,i]:=aq1.fields.fieldbyname('jhsl').value; //进货数量
frm_htgl.StringGrid1.Cells[7,i]:=aq1.fields.fieldbyname('jhje').value; // 进货金额
frm_htgl.StringGrid1.Cells[8,i]:=aq1.fields.fieldbyname('pc').value; // 批号
aq1.Next;
end;
end;}
end;
end;
end;
end;
end;
procedure Tfrm_htgl.Edit7Exit(Sender: TObject);
begin
//edit7.Color:=clwindow;
end;
procedure Tfrm_htgl.Edit9Exit(Sender: TObject);
begin
//edit9.Color:=clwindow;
end;
procedure Tfrm_htgl.Edit11Exit(Sender: TObject);
begin
//edit11.Color:=clwindow;
end;
procedure Tfrm_htgl.Edit13Exit(Sender: TObject);
begin
//if not edit13.Focused then
// edit13.Color:=clwindow;
end;
procedure Tfrm_htgl.Edit13Enter(Sender: TObject);
begin
//edit13.Color:=clskyblue;
end;
procedure Tfrm_htgl.Edit7Enter(Sender: TObject);
begin
//edit7.Color:=clskyblue;
end;
procedure Tfrm_htgl.Edit9Enter(Sender: TObject);
begin
//edit9.Color:=clskyblue;
end;
procedure Tfrm_htgl.Edit11Enter(Sender: TObject);
begin
// edit11.Color:=clskyblue;
end;
{procedure Tfrm_htgl.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_htgl.Handle,'此供应商不存在或此供应商状态不为正常状态','信息提示',0);
edit7.SetFocus;
edit7.SelectAll;
exit;
end;
edit8.Text:=aq1.Fields.Fieldbyname('csmc').value;
combobox1.SetFocus;
end;
end;
end;
end; }
procedure Tfrm_htgl.ComboBox1Change(Sender: TObject);
begin
//dit9.SetFocus;
end;
{procedure Tfrm_htgl.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_htgl.Handle,'此部门不存在','信息提示',0);
edit9.SetFocus;
edit9.SelectAll;
exit;
end;
edit10.Text:=aq1.Fields.Fieldbyname('bmmc').value;
edit11.SetFocus;
end;
end;
end;
end;
procedure Tfrm_htgl.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_htgl.Handle,'此大类不存在于此部门','信息提示',0);
edit11.SetFocus;
edit11.SelectAll;
exit;
end;
edit13.SetFocus;
end;
end;
end;
end;
procedure Tfrm_htgl.Edit13KeyPress(Sender: TObject; var Key: Char);
begin
checkinput('xlbh',trim(edit13.text));
edit14.Text:=xlmc;
end; }
procedure Tfrm_htgl.Edit7Change(Sender: TObject);
begin
{if length(edit7.Text)=4 then
begin
checkinput('csbh',trim(edit7.Text));
edit8.Text:=csmc;
end; }
end;
procedure Tfrm_htgl.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_htgl.Edit9Change(Sender: TObject);
begin
{if length(edit9.Text)=2 then
begin
checkinput('bmbh',trim(edit9.Text));
edit10.Text:=bmmc;
end; }
end;
procedure Tfrm_htgl.Edit11Change(Sender: TObject);
begin
{ if length(edit11.Text)=3 then
begin
checkinput('dlbh',trim(edit11.Text));
edit12.Text:=dlmc;
end; }
end;
procedure Tfrm_htgl.Edit13Change(Sender: TObject);
begin
{if length(edit13.Text)=3 then
begin
checkinput('xlbh',trim(edit13.Text));
edit14.Text:=xlmc;
end; }
end;
procedure Tfrm_htgl.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;
procedure Tfrm_htgl.txtcsbhChange(Sender: TObject);
begin
txtcsbh.Color:=clwindow;
txtsxrq.SetFocus;
txtsxrq.Color:=clskyblue;
end;
procedure Tfrm_htgl.txtsxrqKeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
txtzzrq.SetFocus;
end;
procedure Tfrm_htgl.txtzzrqChange(Sender: TObject);
begin
memo1.SetFocus;
memo1.Color:=clskyblue;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -