📄 hcckd.pas
字号:
end;
end;
with data do
begin
adoc1.BeginTrans;
aq1.Connection:=adoc1;
screen.Cursor:=crHourGlass;
//编辑时
if editflag=1 then
begin
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('delete from hcckd0 where lydh=:lydh');
aq1.Parameters.ParamByName('lydh').Value:=trim(txtjhdh.text);
aq1.ExecSQL;
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('delete from hcckd1 where lydh=:lydh');
aq1.Parameters.ParamByName('lydh').Value:=trim(txtjhdh.text);
aq1.ExecSQL;
end
else
begin
txtjhdh.text:=xsdh;
end;
//写入入库单一
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add(sqlinsert1);
aq1.Parameters.ParamByName('lydh').Value:=trim(txtjhdh.text);
aq1.Parameters.ParamByName('csbh').Value:=copy(trim(frm_HCCKD.txtcsbh.items[frm_HCCKD.txtcsbh.itemindex]),1,4);
//aq1.Parameters.ParamByName('pc').Value:=trim(txtpc.text);
aq1.Parameters.ParamByName('zdrq').Value:=formatdatetime('yyyy-mm-dd',now);
aq1.Parameters.ParamByName('czybh').Value:=trim(txtczybh.text);
aq1.Parameters.ParamByName('flag').Value:=copy(trim(txtshflag.text),1,1);
aq1.Parameters.ParamByName('bmbh').Value:=copy(trim(frm_HCCKD.txtbm.items[frm_HCCKD.txtbm.itemindex]),1,2);
aq1.Parameters.ParamByName('ygbh').Value:=copy(trim(frm_HCCKD.txtyg.items[frm_HCCKD.txtyg.itemindex]),1,3);
aq1.ExecSQL;
//写入入库单二
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add(sqlinsert2);
for i:=1 to stringgrid1.rowcount-1 do
begin
if stringgrid1.cells[1,i]<>'' then
begin
aq1.Parameters.ParamByName('lydh').Value:=trim(txtjhdh.text);
aq1.Parameters.ParamByName('hcbh').Value:=stringgrid1.cells[1,i];
aq1.Parameters.ParamByName('lysl').Value:=stringgrid1.cells[6,i];
aq1.Parameters.ParamByName('jhdj').Value:=StrToCurr(stringgrid1.cells[5,i]);
aq1.Parameters.ParamByName('lyje').Value:=StrToCurr(stringgrid1.cells[7,i]);
//if editflag=0 then
// stringgrid1.cells[8,i]:=inttostr(strtoint(pccreate(stringgrid1.Cells[1,i]))+1);
aq1.Parameters.ParamByName('pc').Value:=stringgrid1.cells[8,i];
aq1.ExecSQL;
end;
end;
adoc1.CommitTrans;
messagedlg(mation1,mtinformation,[mbyes],1);
screen.Cursor:=crDefault;
end;
editflag:=0;
//hcreflesh;
aeanbled(2);
end
else
if (trim(tup.Caption))='前页' then
begin
nownumber:=nownumber-1;
if frm_HCCKD.nownumber=0 then
begin
loaddata(number[nownumber]);
showmessage('这是满足条件的第一条纪录');
exit;
end
else if frm_HCCKD.nownumber>0 then
loaddata(number[nownumber])
else
begin
nownumber:=0;
showmessage('这是满足条件的第一条纪录');
exit;
end;
end;
end;
procedure Tfrm_HCCKD.FormCreate(Sender: TObject);
begin
stringgrid1.ColCount:=9;
stringgrid1.rowcount:=2;
stringgrid1.ColWidths[0]:=10;
stringgrid1.ColWidths[1]:=60;
stringgrid1.ColWidths[2]:=150;
stringgrid1.ColWidths[3]:=80 ;
stringgrid1.ColWidths[4]:=80;
stringgrid1.ColWidths[5]:=80;
stringgrid1.ColWidths[6]:=80;
stringgrid1.ColWidths[7]:=80;
stringgrid1.ColWidths[8]:=80;
stringgrid1.cells[1,0]:= '耗材编号';
stringgrid1.cells[2,0]:= '耗材名称';
stringgrid1.cells[3,0]:= '耗材规格';
stringgrid1.cells[4,0]:= '单位';
stringgrid1.cells[5,0]:= '进货单价';
stringgrid1.cells[6,0]:= '领用数量';
stringgrid1.cells[7,0]:= '领用金额';
stringgrid1.cells[8,0]:= '批号';
{ stringgrid1.cells[8,0]:= '成本单价';
stringgrid1.cells[9, 0]:= '产地号';
stringgrid1.cells[10,0]:='缺货指标';
stringgrid1.cells[11,0]:= '进销差价率';
stringgrid1.cells[12,0]:= '大包量';
stringgrid1.cells[13,0]:= '商品性质';
stringgrid1.cells[14,0]:= '商品状态';
stringgrid1.cells[15,0]:= '称重商品';
stringgrid1.cells[16,0]:= '保质期属性';
stringgrid1.cells[17,0]:= '进货税率';
stringgrid1.cells[18,0]:= '销售税率';
stringgrid1.cells[19,0]:= '联营扣率';
stringgrid1.Cells[2,0]:='地址 ';
stringgrid1.Cells[3,0]:='联系人';
stringgrid1.Cells[4,0]:='电话';
stringgrid1.Cells[5,0]:='传真';
stringgrid1.Cells[6,0]:='银行帐户';
stringgrid1.Cells[7,0]:='帐户名称';
stringgrid1.Cells[8,0]:='电子邮件';
stringgrid1.Cells[9,0]:='邮编';
stringgrid1.Cells[10,0]:='起初应收';
stringgrid1.Cells[11,0]:='起初应付'; }
stringgrid1.FixedCols:=1;
stringgrid1.FixedRows:=1;
aeanbled(2);
end;
//审核
procedure Tfrm_HCCKD.tcheckClick(Sender: TObject);
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('update hcckd0 set flag=:flag where lydh=: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.lysl,a.zdrq,b.pc,a.lydh,a.zdrq,''L'',b.jhdj,b.lyje from'+
' hcckd0 a,hcckd1 b where a.lydh=b.lydh and a.lydh='''+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('update pcb set pckc=pckc-hcckd1.lysl from hcckd1,hcckd0'+
' where pcb.pc=hcckd1.pc and pcb.hcbh=hcckd1.hcbh and hcckd1.lydh=hcckd0.lydh and'+
' hcckd0.lydh='''+trim(txtjhdh.Text)+'''');
aq1.ExecSQL;
//更改耗材档案
aq1.Close;
aq1.SQL.Clear;
aq1.SQL.Add('update hcda set jhdj=hcckd1.jhdj,dqkc=dqkc-hcckd1.lysl,pc=hcckd1.pc '+
' from hcckd0,hcckd1 where hcckd0.lydh=hcckd1.lydh and hcda.hcbh=hcckd1.hcbh and '+
' hcda.csbh=hcckd0.csbh and hcckd0.lydh='''+trim(txtjhdh.text)+'''');
aq1.ExecSQL;
adoc1.CommitTrans;
messagebox(frm_HCCKD.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_HCCKD.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_hcckedit:=tFRM_hcckedit.Create(application);
FRM_hcckedit.txtspbh.text:=frm_HCCKD.StringGrid1.Cells[1,cell]; //编号
FRM_hcckedit.txtspmc.Text:=frm_HCCKD.StringGrid1.Cells[2,cell]; //名称
FRM_hcckedit.txtspgg.text:=frm_HCCKD.StringGrid1.Cells[3,cell]; //地质
FRM_hcckedit.txtdw.text:=frm_HCCKD.StringGrid1.Cells[4,cell]; //电话
FRM_hcckedit.txtjhdj.text:=frm_HCCKD.StringGrid1.Cells[5,cell]; //传真
FRM_hcckedit.txtjhsl.text:=frm_HCCKD.StringGrid1.Cells[6,cell]; //状态
FRM_hcckedit.txtjhje.text:=frm_HCCKD.StringGrid1.Cells[7,cell]; //邮政编码
{
FRM_hcckedit.txtcbdj.text:=frm_HCCKD.StringGrid1.Cells[8,cell]; //电报
FRM_hcckedit.txtcdbh.text:=frm_HCCKD.StringGrid1.Cells[9,cell]; //联系人
FRM_hcckedit.txtqhbz.text:=frm_HCCKD.StringGrid1.Cells[10,cell]; //开户
FRM_hcckedit.txtjxcjl.text:=frm_HCCKD.StringGrid1.Cells[11,cell]; //开户名称
FRM_hcckedit.txtmax.text:=frm_HCCKD.StringGrid1.Cells[12,cell]; //帐号
FRM_hcckedit.comspxz.text:=frm_HCCKD.StringGrid1.Cells[13,cell]; //帐号
FRM_hcckedit.comspzt.text:=frm_HCCKD.StringGrid1.Cells[14,cell]; //帐号
FRM_hcckedit.comczzt.text:=frm_HCCKD.StringGrid1.Cells[15,cell]; //帐号
FRM_hcckedit.combzq.text:=frm_HCCKD.StringGrid1.Cells[16,cell]; //帐号
FRM_hcckedit.txtjhsl.text:=frm_HCCKD.StringGrid1.Cells[17,cell]; //帐号
FRM_hcckedit.txtxhsl.text:=frm_HCCKD.StringGrid1.Cells[18,cell]; //帐号
FRM_hcckedit.txtlykl.text:=frm_HCCKD.StringGrid1.Cells[19,cell]; } //帐号
FRM_hcckedit.ShowModal;
end
else
showmessage('请选择纪录');
end;
end;
end;
procedure Tfrm_HCCKD.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_HCCKD.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_HCCKD.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 hcckd0 where lydh=:jhdh');
aq1.Parameters.ParamByName('jhdh').Value:=trim(txtjhdh.text);
aq1.ExecSQL;
close;
sql.Clear;
sql.Add('delete from hcckd1 where lydh=: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_HCCKD.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_HCCKD.tfindClick(Sender: TObject);
begin
csbhcreate;
bmcreate;
ygcreate;
frm_hcckdcx:=tfrm_hcckdcx.create(application);
frm_hcckdcx.showmodal;
end;
//显示单据和单据内容
procedure Tfrm_HCCKD.loaddata(key:string);
var i:integer;
begin
//if frm_HCCKD.ComboBox1.Items.Count>0 then
if frm_HCCKD.mainnumber>0 then
begin
with data do
begin
aq1.Connection:=adoc1;
with aq1 do
begin
close;
sql.Clear;
aq1.SQL.Add('select a.lydh,b.hcbh,b.hcmc,b.gg,b.jldw,a.zdrq,t1.lysl,'+
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -