📄 unit_yaohao.pas
字号:
if com_project.ItemIndex=1 then
begin
cell1.SaveFile(GetFilePath+GetLeibie(com_leibie.text)+'_yhbd.cll',1);
end;
if com_project.ItemIndex=2 then
begin
getcellXuhao(cell1,7,27);
cell1.SaveFile(GetFilePath+GetLeibie(com_leibie.text)+'_zbsqr.cll',1);
cell1.OpenFile(GetFilePath+GetLeibie(com_leibie.text)+'_zbsqr.cll','');
end;
end;
procedure TFrm_YaoHao.getcol;
const
str:widestring='ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩⅪⅫ';
var
adoquery:tadoquery;
i:integer;
str1:string;
begin
if StrToInt(GetLeiBie(Com_Leibie.Text))>0 then
cell1.SetCellString(1,4,0,com_leibie.text)
else
cell1.SetCellString(1,4,0,' ');
if com_project.ItemIndex=1 then
begin
cell1.OpenFile(SPATH+'\report\Others\yhbd.cll','');
adoquery:=tadoquery.Create(nil);
try
adoquery.Connection:=datamodule1.ADOMainConn;
adoquery.close;
adoquery.SQL.Text:='select yaohao_cs from bid_xmgczb where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID;
adoquery.Open;
edit1.Text:='';
edit1.Text:=adoquery.fieldbyname('yaohao_cs').AsString;
finally
freeandnil(adoquery);
end;
if edit1.text='' then exit;
if strtoint(edit1.Text)<10 then
begin
cell1.DeleteCol(strtoint(edit1.Text)+2,10-strtoint(edit1.Text),0);
end
else if strtoint(edit1.Text)>10 then
begin
cell1.InsertCol(11,strtoint(edit1.Text)-10,0);
cell1.DeleteCol(strtoint(edit1.Text)+2,cell1.GetCols(0)-(strtoint(edit1.Text)+1),0);
end;
for I:=2 to cell1.GetCols(0) do
begin
cell1.SetCellString(i,5,0,str[i-1]);
end;
end
else if com_project.ItemIndex=2 then
begin
cell1.OpenFile(SPATH+'\report\Others\zbsqr.cll','');
adoquery:=tadoquery.Create(nil);
try
adoquery.Connection:=datamodule1.ADOMainConn;
adoquery.Close;
{if com_leibie.ITEMS.IndexOf(COM_LEIBIE.Text)=0 then
begin
adoquery.sql.Text:='select bd_bianhao from bid_biaoduan_xinxi where xmgczb_id in '
+' (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+')';
end;}
adoquery.sql.Text:='select bd_bianhao from bid_biaoduan_xinxi where xmgczb_id in '
+' (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and bd_leibie='
+getleibie(com_leibie.Text);
adoquery.Open;
if adoquery.RecordCount<15 then
begin
cell1.DeleteCol(adoquery.RecordCount+3,15-adoquery.RecordCount,0);
end
else if adoquery.RecordCount>15 then
begin
cell1.InsertCol(17,adoquery.RecordCount-15,0);
end;
adoquery.First;
for i:=3 to cell1.GetCols(0) do
begin
cell1.SetCellString(i,6,0,adoquery.fieldbyname('bd_bianhao').asstring);
adoquery.Next;
end;
finally
freeandnil(adoquery);
end;
end;
btn_xiangxi.Enabled:=true;
end;
procedure TFrm_YaoHao.Cell1EditFinish(Sender: TObject;var text: WideString; var approve: Integer);
var
adoquery:tadoquery;
ssql:string;
nowrow,nowsheet,nowtext,nowcol:integer;
duanshu,sl:string;
begin
if com_project.ItemIndex=0 then
begin
if trim(cell1.getcellstring(cell1.GetCurrentCol,cell1.GetCurrentRow,cell1.GetCurSheet))='' then exit;
if (cell1.GetCurrentCol<>1) or (cell1.GetCurrentRow<6) then exit;
try
strtoint(cell1.GetCellString(1,cell1.GetCurrentRow,cell1.GetCurSheet));
except
showmessage('你输入的不是有效数字');
exit;
end;
if (strtoint(cell1.GetCellString(1,cell1.GetCurrentRow,cell1.GetCurSheet))<=0)
or (cell1.GetCellString(1,cell1.GetCurrentRow,cell1.GetCurSheet)=ecol) then exit;
nowrow:=cell1.GetCurrentRow;
nowsheet:=cell1.GetCurSheet;
nowtext:=strtoint(cell1.GetCellString(1,nowrow,nowsheet));
adoquery:=tadoquery.Create(nil);
try
adoquery.Connection:=DATAmodule1.ADOMainConn;;
adoquery.Close;
DATAmodule1.ADOMainConn.BeginTrans;
try
ssql:=' if (select count(*) from bid_shenqingrhm where sqrhm='+trim(cell1.getcellstring(1,nowrow,nowsheet))
+' and xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+'))>0 begin ';
if nowtext>strtoint(ecol) then
ssql:=ssql+' update bid_shenqingrhm set sqrhm=sqrhm-1 where xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and sqrhm>'+trim(ecol)+' and sqrhm<='+trim(inttostr(nowtext))
else if nowtext<strtoint(ecol) then
ssql:=ssql+' update bid_shenqingrhm set sqrhm=sqrhm+1 where xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and sqrhm<'+trim(ecol)+' and sqrhm>='+trim(inttostr(nowtext));
ssql:=ssql+' update bid_shenqingrhm set sqrhm='+trim(inttostr(nowtext))+' where xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and dw_id in (select dw_id from bid_danwei_xinxi where dw_name='''
+trim(cell1.GetCellString(2,nowrow,nowsheet))+''')'
+' end else begin '
+ ' update bid_shenqingrhm set sqrhm='+trim(inttostr(nowtext))+' where xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and dw_id in (select dw_id from bid_danwei_xinxi where dw_name='''
+trim(cell1.GetCellString(2,nowrow,nowsheet))+''') end';
adoquery.SQL.Text:=ssql;
adoquery.ExecSQL;
DATAmodule1.ADOMainConn.CommitTrans;
except
DATAmodule1.ADOMainConn.RollbackTrans;
end;
finally
freeandnil(adoquery);
end;
end;
if com_project.ItemIndex=1 then
begin
nowcol:=cell1.GetCurrentCol;
nowrow:=cell1.GetCurrentRow;
nowsheet:=cell1.GetCurSheet;
if (nowcol<2) or (nowrow<6) then exit;
if (trim(cell1.GetCellString(nowcol,nowrow,nowsheet))='') and (ecol='') then exit;
if (trim(cell1.GetCellString(nowcol,nowrow,nowsheet))<>'') then
try
strtoint(cell1.GetCellString(nowcol,nowrow,nowsheet));
except
showmessage('你输入的不是有效数字');
//[[[[[cell1.SetCellString(nowcol,nowrow,nowsheet,'');
exit;
end;
if trim(cell1.getcellstring(1,nowrow,nowsheet))='' then exit;
adoquery:=tadoquery.Create(nil);
try
adoquery.Connection:=datamodule1.ADOMainConn;
adoquery.Close;
if (trim(cell1.GetCellString(nowcol,nowrow,nowsheet))<>'') then
begin
adoquery.Close;
adoquery.SQL.Text:='select dw_id,wj2_tgduanshu,wj2_leibie from bid_wenjian2 a where wj2_leixing=1'
+' and dw_id In (select dw_Id from bid_shenqingrhm where xmgczb_Id=a.xmgczb_id and sqrhm='
+trim(cell1.GetCellString(nowcol,nowrow,nowsheet))+' and bd_leibie=a.wj2_leibie) and xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and wj2_leibie='+getleibie(com_leibie.text);
adoquery.Open;
if (adoquery.RecordCount=0) or (adoquery.fieldbyname('wj2_tgduanshu').AsString='') then
begin
freeandnil(adoquery);
showmessage('该单位未申请该类别,或者未设置该单位的通过合同段数');
cell1.SetCellString(nowcol,nowrow,nowsheet,'');
exit;
end;
duanshu:=adoquery.fieldbyname('wj2_tgduanshu').AsString;
adoquery.close;
adoquery.sql.Text:='select * from bid_yaohao_Jieguo a,bid_shenqingrhm b where bd_isbn in (select bd_isbn from bid_biaoduan_xinxi'
+' where xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and bd_name='+quotedstr(trim(cell1.GetCellString(1,nowrow,nowsheet)))
+') and a.dw_id=b.dw_id and a.xmgczb_id=b.xmgczb_id and b.sqrhm='+quotedstr(trim(cell1.GetCellString(nowcol,nowrow,nowsheet)));
adoquery.Open;
if adoquery.RecordCount>0 then
begin
freeandnil(adoquery);
showmessage('该单位已申请该合同段');
cell1.SetCellString(nowcol,nowrow,nowsheet,'');
exit;
end;
adoquery.close;
adoquery.sql.Text:='select count(*) sl from bid_yaohao_jieguo a,bid_shenqingrhm b where'
+' a.xmgczb_id=b.xmgczb_id and a.dw_Id=b.dw_id and a.bd_leibie=b.bd_leibie and'
+' b.bd_leibie='+getleibie(com_leibie.text)+' and a.xmgczb_id in'
+'(select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and sqrhm='+trim(cell1.GetCellString(nowcol,nowrow,nowsheet));
adoquery.Open;
if strtoint(duanshu)<=adoquery.fieldbyname('sl').asinteger then
begin
freeandnil(adoquery);
showmessage('超过该单位在该类别的申请段数');
cell1.SetCellString(nowcol,nowrow,nowsheet,'');
exit;
end;
adoquery.Close;
adoquery.SQL.Text:=' if (select count(*) from bid_yaohao_jieguo where '
+' bd_leibie='+getleibie(com_leibie.text)+' and xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and bd_isbn in (select bd_isbn from bid_biaoduan_xinxi where '
+' xmgczb_id=bid_yaohao_jieguo.xmgczb_id and bd_name='''+trim(cell1.GetCellString(1,nowrow,nowsheet))+''')'
+' and yh_xuhao='+trim(inttostr(nowcol-1))+')> 0 '
+' begin '
+' update bid_yaohao_jieguo set DW_ID=A.DW_ID FROM BID_DANWEI_XINXI A,BID_SHENQINGRHM B,BID_YAOHAO_JIEGUO C '
+' WHERE B.SQRHM='+trim(cell1.GetCellString(nowcol,nowrow,nowsheet))
+' AND B.DW_ID=A.DW_ID AND C.XMGCZB_ID=B.XMGCZB_iD AND b.bd_leibie=c.bd_leibie and b.bd_leibie='+getleibie(com_leibie.text)
+' and C.xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and C.bd_isbn in (select bd_isbn from bid_biaoduan_xinxi where '
+' xmgczb_id=C.xmgczb_id and bd_name='''+trim(cell1.GetCellString(1,nowrow,nowsheet))+''')'
+' and yh_xuhao='+trim(inttostr(nowcol-1))
+' end else begin '
+' insert into bid_yaohao_jieguo(bd_isbn,xmgczb_id,DW_ID,yh_xuhao,bd_leibie) select A.bd_isbn,A.xmgczb_id,B.DW_ID,'
+triM(inttostr(nowcol-1))+',a.bd_leibie from bid_biaoduan_xinxi A,BID_SHENQINGRHM B'
+' WHERE A.XMGCZB_ID=B.XMGCZB_ID AND B.SQRHM='+trim(cell1.GetCellString(nowcol,nowrow,nowsheet))
+' AND b.bd_leibie='+getleibie(com_leibie.text)+' and A.xmgczb_id in (select xmgczb_id from bid_xmgczb '
+' where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='+xmbdgc.gCLX_ID
+' and zblx_id='+xmbdgc.BDLX_ID+') and A.bd_name='''+trim(cell1.GetCellString(1,nowrow,nowsheet))+''' END ';
end
else if (trim(cell1.GetCellString(nowcol,nowrow,nowsheet))='') then
adoquery.SQL.Text:='delete from bid_yaohao_jieguo where bd_isbn in (select bd_isbn from bid_biaoduan_xinxi'
+' where xmgczb_id in (select xmgczb_id from bid_xmgczb where xm_isbn='''+trim(xmbdgc.XM_ISBn)+''' and gclx_id='
+xmbdgc.gCLX_ID+' and zblx_id='+xmbdgc.BDLX_ID+') and bd_name='''+trim(cell1.GetCellString(1,nowrow,nowsheet))
+''') and yh_xuhao='+trim(inttostr(nowcol-1))+' and bd_leibie='+getleibie(com_leibie.text);
datamodule1.ADOMainConn.BeginTrans;
try
adoquery.ExecSQL;
datamodule1.ADOMainConn.CommitTrans;
except
datamodule1.ADOMainConn.RollbackTrans;
end;
finally
freeandnil(adoquery);
END;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -