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

📄 u_zigeystzs.pas

📁 招投标软件代码,很有应用价值,请大家参考下哦,不明白的地方给我留言
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit U_ZigeysTzs;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, ExtCtrls, StdCtrls, Buttons,Unit_TopParentForm, ComCtrls,adodb,
  CELL50Lib_TLB, OleCtrls,ComObj;

type
  Tf_zigeystzs = class(tfrm_TopParentForm)
    Label2: TLabel;
    bb_Save: TBitBtn;
    listview1: TListView;
    SpeedButton2: TSpeedButton;
    SpeedButton3: TSpeedButton;
    ListView2: TListView;
    Label1: TLabel;
    Label3: TLabel;
    DateTimePicker1: TDateTimePicker;
    Label5: TLabel;
    DateTimePicker2: TDateTimePicker;
    bb_PrintPre: TBitBtn;
    Memo1: TMemo;
    BitBtn1: TBitBtn;
    Com_Leibie: TComboBox;
    Label4: TLabel;
    procedure FormCreate(Sender: TObject);
    procedure SpeedButton2Click(Sender: TObject);
    procedure Com_xmnameChange(sender:Tobject);
    procedure Com_zhaoBiaoChange(Sender:Tobject);
    procedure Com_GclxnameChange(Sender: TObject);
    procedure SpeedButton3Click(Sender: TObject);
    procedure loaddwname;
    procedure bb_SaveClick(Sender: TObject);
    //procedure Com_LeibieChange(Sender: TObject);  //一个单位可以投多个类别,多个标段,只发一通知书
    procedure bb_PrintPreClick(Sender: TObject);
    procedure GetBiaoduan;
    procedure BitBtn1Click(Sender: TObject);
    procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
  private
    { Private declarations }
    Word,Doc : variant;
    IsPrint:boolean;
    CanSave:boolean;//判断文件关闭的时候是否要进行保存
    FileName:string;//用于存储释放程序中打开的文件
  public
    { Public declarations }
  end;

var
  f_zigeystzs: Tf_zigeystzs;

implementation

uses
  DataModule,systemobject,unit_public,DataAccessCommonShell;

{$R *.dfm}


procedure Tf_zigeystzs.GetBiaoduan;
var
  adoquery:tadoquery;
  i:Integer;
begin
  {if com_zhaobiao.Text='施工' then
  begin
    com_leibie.Text:='请选择';
    GetXMleibie(com_leibie);


    {com_leibie.Items.Clear;
    com_leibie.Text:='请选择类别';
    com_leibie.Items.Add('无类别');
    com_leibie.Items.Add('第一类');
    com_leibie.Items.Add('第二类');
    com_leibie.Items.Add('第三类');
  end;
  if com_zhaobiao.Text='监理' then
  begin
    com_leibie.Items.Clear;
    label4.Caption:='标段';
    com_leibie.Text:='请选择标段';
    adoquery:=tadoquery.Create(nil);
    try
      adoquery.Close;
      adoquery.Connection:=datamodule1.ADOMainConn;
      adoquery.SQL.Text:='select bd_name 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+ ') order by bd_bianhao';
      ADOquery.Open;
      adoquery.First;
      com_leibie.Items.Clear;
      for i:=0 to adoquery.RecordCount-1 do
      begin
        com_leibie.Items.Add(adoquery.fieldbyname('bd_name').AsString);
        adoquery.Next;
      end;
    finally
      freeandnil(adoquery);
    end;
  end; }
end;

procedure Tf_zigeystzs.loaddwname;
var
  i,j:Integer;
  iPage,iRow:Integer;
  adoquery:tadoquery;
  str:string;
  top:string;
  alistitem:tlistitem;
  dwname:string;
begin
  listview1.Items.Clear;
  listview2.Items.Clear;
  if com_zhaobiao.Text='施工' then
  begin
    //文件信息
    listview1.Columns[1].Caption:='类别';
    listview2.Columns[1].Caption:='类别';
    listview1.Columns[1].Width:=200;
    listview2.Columns[1].Width:=200;
    if IsFileInUse(FileName+'yushen.Doc') or IsFileInUse(GetFilePath+'yushen.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
        begin
          Doc.save;
          Doc.CLose;
        end
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    if not DirectoryExists(GetFilePath) then
      CreateDir(GetFilePath);
    if not fileexists(GetFilePath+'yushen.Doc') then
    begin
       CopyFile(Pchar(sPath+'report\tongzhi\yushen.doc'),Pchar(GetFilePath+'yushen.Doc'),false);
    end;
    try
      word := CreateOleObject('word.application');
      word.visible:=False;
      Doc := Word.Documents.Open(GetFilePath+'yushen.doc');
    except
      showmessage('打开模板错误');
      Word.quit;
      Word:=Unassigned;
      exit;
    end;
    //

    adoquery:=tadoquery.Create(nil);
    try
      adoquery.connection:=datamodule1.ADOMainConn;

      adoquery.Close;
      adoquery.SQL.Text:='select cs_renshu from bid_canshu_SAVE 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+') ';
      adoquery.open;
      top:=adoquery.fieldbyname('cs_renshu').AsString;
      if top='' then
      begin
        freeandnil(adoquery);
        exit;
      end;
      adoquery.Close;
      {if com_leibie.ItemIndex=0 then
        adoquery.SQL.Text:='select top '+trim(top)+' b.dwbm_id,a.dw_name,(c.ys_caiwu+c.ys_jishu+c.ys_jingyan) as ys_total,b.wj2_tgduanshu '
                   +'  from bid_danwei_xinxi a '
                   +' ,bid_wenjian2 b,bid_yushen_defen c,bid_canshu_save d where b.wj2_leixing=1 and a.dw_id=b.dw_id and b.dw_id=c.dw_ID '
                   +' and b.xmgczb_id=c.xmgczb_id and c.xmgczb_id=d.xmgczb_id and c.ys_caiwu>=d.CS_CAIWU_HEGE AND '
                   +' c.ys_jishu>=d.cs_jishu_hege and c.ys_jingyan>=d.cs_jingyan_hege and '
                   +' (c.ys_caiwu+c.ys_jishu+c.ys_jingyan)>=d.cs_zuidixian 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+') '
                   +' order by b.dwbm_id '
      else}
      adoquery.SQL.Text:='select top '+trim(top)+' b.dwbm_id,a.dw_name,b.wj2_leibie,(c.ys_caiwu+c.ys_jishu+c.ys_jingyan) as ys_total,b.wj2_tgduanshu '
                   +'  from bid_danwei_xinxi a '
                   +' ,bid_wenjian2 b,bid_yushen_defen c,bid_canshu_save d where b.wj2_leixing=1 and a.dw_id=b.dw_id and b.dw_id=c.dw_ID '
                   +' and b.xmgczb_id=c.xmgczb_id and c.xmgczb_id=d.xmgczb_id and c.ys_caiwu>=d.CS_CAIWU_HEGE  '
                   //+' and b.wj2_leibie='+trim(getleibie(com_leibie.Text))
                   +' AND c.ys_jishu>=d.cs_jishu_hege and c.ys_jingyan>=d.cs_jingyan_hege and '
                   +' (c.ys_caiwu+c.ys_jishu+c.ys_jingyan)>=d.cs_zuidixian 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 b.wj2_leibie=c.bd_leibie'// and b.wj2_leibie='+getleibie(com_leibie.text)
                   +' order by b.dwbm_id,wj2_leibie ';
      adoquery.open;
      adoquery.First;
      dwname:='';
      if adoquery.FieldByName('wj2_leibie').AsInteger=0 then
      begin
        listview1.Columns[1].Width:=0;
        listview2.Columns[1].Width:=0;
      end;

      for i:=0 to adoquery.RecordCount-1 do
      begin
        if dwname=adoquery.fieldbyname('DW_name').AsString then
        begin
          if adoquery.FieldByName('wj2_leibie').AsInteger=1 then
            alistitem.SubItems.Strings[0]:=alistitem.SubItems.Strings[0]+' 第一类'
          else if adoquery.FieldByName('wj2_leibie').AsInteger=2 then
            alistitem.SubItems.Strings[0]:=alistitem.SubItems.Strings[0]+' 第二类'
          else if adoquery.FieldByName('wj2_leibie').AsInteger=3 then
            alistitem.SubItems.Strings[0]:=alistitem.SubItems.Strings[0]+' 第三类';
        end
        else
        begin
          alistitem:=listview1.items.add;
          alistitem.CAPtion:=adoquery.fieldbyname('DW_name').AsString;
          if adoquery.FieldByName('wj2_leibie').AsInteger=1 then
            alistitem.SubItems.Add('第一类')
          else if adoquery.FieldByName('wj2_leibie').AsInteger=2 then
            alistitem.SubItems.Add('第二类')
          else if adoquery.FieldByName('wj2_leibie').AsInteger=3 then
            alistitem.SubItems.Add('第三类');
          dwname:=adoquery.fieldbyname('DW_name').AsString;
        end;
        adoquery.next;
      end;
    finally
      freeandnil(adoquery);
    end;
  end;
  if com_zhaobiao.Text='监理' then
  begin
    ////文件控制
    listview1.Columns[1].Caption:='所投标段';
    listview2.Columns[1].Caption:='所投标段';
    listview1.Columns[1].Width:=200;
    listview2.Columns[1].Width:=200;
    if IsFileInUse(FileName+'yushen.Doc') or IsFileInUse(GetFilePath+'yushen.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
        begin
          Doc.save;
          Doc.CLose;
        end
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    if not DirectoryExists(GetFilePath) then
    CreateDir(GetFilePath);
    if not fileexists(GetFilePath+'yushen.Doc') then
    begin
       CopyFile(Pchar(sPath+'report\tongzhi\yushen.doc'),Pchar(GetFilePath+'yushen.Doc'),false);
    end;
    try
      word := CreateOleObject('word.application');
      word.visible:=False;
      Doc := Word.Documents.Open(GetFilePath+'yushen.doc');
    except
      showmessage('打开模板错误!');
      Word.quit;
      Word:=Unassigned;
      exit;
    end;
    ////
    adoquery:=tadoquery.Create(nil);
    try
      adoquery.Close;
      adoquery.Connection:=datamodule1.ADOMainConn;
      adoquery.SQL.Text:='select cs_renshu from bid_canshu_SAVE 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+') ';
      adoquery.Open;
      if adoquery.FieldByName('cs_renshu').AsString='' then
      begin
        freeandnil(adoquery);
        exit;
      end;
      top:=adoquery.FieldByName('cs_renshu').AsString;
      adoquery.Close;
      adoquery.SQL.Text:='select top '+trim(top)+' b.dwbm_id,a.dw_name,bd_name from bid_danwei_xinxi a,'
         +' bid_wenjian2 b,bid_ys_jl c,bid_canshu_save d,bid_biaoduan_xinxi e where b.wj2_leixing=1'
         +' and a.dw_id=b.dw_id and b.dw_id=c.dw_ID  and b.xmgczb_id=d.xmgczb_id and b.bd_isbn=c.bd_isbn'
         +' and b.bd_isbn=e.bd_isbn and c.ysjl_caiwu>=ISNULL(d.CS_CAIWU_HEGE,0) AND'
         +' c.ysjl_jishu>=ISNULL(d.cs_jishu_hege,0) and c.ysjl_jingyan>=ISNULL(d.cs_jingyan_hege,0) and'
         +' (c.ysjl_caiwu+c.ysjl_jishu+c.ysjl_jingyan)>=ISNULL(d.cs_zuidixian,0) and e. 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 e.bd_name='+quotedstr(com_leibie.Text)
         +' order by dwbm_id';
      adoquery.open;
      dwname:='';
      adoquery.First;
      for i:=0 to adoquery.RecordCount-1 do
      begin
        if dwname=adoquery.fieldbyname('DW_name').AsString then
        begin
          alistitem.SubItems.Strings[0]:=alistitem.SubItems.Strings[0]
              +' '+adoquery.fieldbyname('bd_name').AsString;
        end
        else
        begin
          alistitem:=listview1.Items.Add;
          alistitem.CAPtion:=adoquery.fieldbyname('DW_name').AsString;
          alistitem.SubItems.Add(adoquery.fieldbyname('bd_name').AsString);
          dwname:=adoquery.fieldbyname('DW_name').AsString;
        end;
        adoquery.Next;
      end;
    finally
      freeandnil(adoquery);
    end;
  end;
end;

procedure Tf_zigeystzs.FormCreate(Sender: TObject);
begin
  GetItems(com_xmname,com_zhaobiao,com_gclxname,2);
  inherited;
  IsPrint:=false;
  CanSave:=False;
  panel2.Caption:='资格预审通过通知书';
  //GetBiaoduan;
   if (com_xmname.Items.IndexOf(com_xmname.text)<0)
      or (Com_Gclxname.Items.IndexOf(Com_Gclxname.text)<0)
      or (com_zhaobiao.items.IndexOf(com_zhaobiao.text)<0) then
  else
  begin
    FileName:=GetFilePath;
    loaddwname;
  end;
end;

procedure Tf_zigeystzs.Com_xmnameChange(Sender:TObject);
begin
   inherited;
   //GetBiaoduan;
   if (com_xmname.Items.IndexOf(com_xmname.text)<0)
      or (Com_Gclxname.Items.IndexOf(Com_Gclxname.text)<0)
      or (com_zhaobiao.items.IndexOf(com_zhaobiao.text)<0) then exit;
   loaddwname;
   FileName:=GetFilePath;
end;

procedure Tf_zigeystzs.Com_zhaoBiaoChange(Sender:Tobject);
begin
   inherited;
   //GetBiaoduan;
   if (com_xmname.Items.IndexOf(com_xmname.text)<0)
      or (Com_Gclxname.Items.IndexOf(Com_Gclxname.text)<0)
      or (com_zhaobiao.items.IndexOf(com_zhaobiao.text)<0) then exit;
   loaddwname;
   FileName:=GetFilePath;

⌨️ 快捷键说明

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