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

📄 u_zhongbiaotzs.pas

📁 招投标软件代码,很有应用价值,请大家参考下哦,不明白的地方给我留言
💻 PAS
📖 第 1 页 / 共 2 页
字号:
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=Word.Documents.open(getFilePath+'zhongbiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;

    if not fileexists(GetFilePath+'dingbiao.txt') then
    begin
      FileHandle:=filecreate(GetFilePath+'dingbiao.txt');
      fileclose(FileHandle);
    end;
    memo1.Lines.LoadFromFile(GetFilePath+'dingbiao.txt');

    for i:=0 to listview1.Items.Count-1 do
    begin
      Doc.FormFields.Item(1).Result := ListView1.Items[i].Caption;
      //Doc.FormFields.Item(2).Result := xmbdgc.GCLX_NAME;
      Doc.FormFields.Item(3).Result := ListView1.Items[i].SubItems[0];
      Doc.FormFields.Item(4).Result := NumToWstr(StrToFloat(ListView1.Items[i].SubItems[1]));
      Doc.FormFields.Item(5).Result := ListView1.Items[i].SubItems[1];
      //word.visible:=False;
      Doc.PrintOut;

      memo1.Lines.Add('发送单位:'+listview1.Items[i].Caption);
      memo1.lines.Add('中标标段:'+(listview1.Items[i].SubItems[0]));
    end;

    memo1.Lines.SaveToFile(GetFilePath+'dingbiao.txt');
    IsPrint:=True;
    CanSave:=False;
  end
  else if com_zhaobiao.Text='设计' then
  begin
    if IsFileInUse(GetFilePath+'zhongbiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=Word.Documents.open(getFilePath+'zhongbiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;

    if not fileexists(GetFilePath+'dingbiao.txt') then
    begin
      FileHandle:=filecreate(GetFilePath+'dingbiao.txt');
      fileclose(FileHandle);
    end;
    memo1.Lines.LoadFromFile(GetFilePath+'dingbiao.txt');

    for i:=0 to listview1.Items.Count-1 do
    begin
      Doc.FormFields.Item(1).Result := ListView1.Items[i].Caption;
      //Doc.FormFields.Item(2).Result := xmbdgc.GCLX_NAME;
      Doc.FormFields.Item(3).Result := ListView1.Items[i].SubItems[0];
      //Doc.FormFields.Item(4).Result := NumToWstr(StrToFloat(ListView1.Items[i].SubItems[1]));
      //Doc.FormFields.Item(5).Result := ListView1.Items[i].SubItems[1];
      //word.visible:=False;
      Doc.PrintOut;

      memo1.Lines.Add('发送单位:'+listview1.Items[i].Caption);
      memo1.lines.Add('中标标段:'+(listview1.Items[i].SubItems[0]));
    end;

    memo1.Lines.SaveToFile(GetFilePath+'dingbiao.txt');
    IsPrint:=True;
    CanSave:=False;
  end;
end;

procedure Tf_zhongbiaotzs.btn_priviewClick(Sender: TObject);
begin
  inherited;
  if not IsExistsPath then exit;
  if com_zhaobiao.text='施工' then
  begin
    if listview1.Selected=nil then exit;
    if IsFileInUse(GetFilePath+'zhongbiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=Word.Documents.open(getFilePath+'zhongbiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;

    Doc.FormFields.Item(1).Result := ListView1.Selected.Caption;
    Doc.FormFields.Item(2).Result := xmbdgc.GCLX_NAME;
    Doc.FormFields.Item(3).Result := ListView1.Selected.SubItems[0];
    Doc.FormFields.Item(4).Result := NumToWstr(StrToFloat(ListView1.Selected.SubItems[1]));
    Doc.FormFields.Item(5).Result := ListView1.Selected.SubItems[1];
    word.visible:=true;
    //Doc.PrintPreview;

    IsPrint:=false;
    CanSave:=False;
  end
  else if com_zhaobiao.text='监理' then
  begin
    if listview1.Selected=nil then exit;
    if IsFileInUse(GetFilePath+'zhongbiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=Word.Documents.open(getFilePath+'zhongbiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;

    Doc.FormFields.Item(1).Result := ListView1.Selected.Caption;
    Doc.FormFields.Item(2).Result := xmbdgc.GCLX_NAME;
    Doc.FormFields.Item(3).Result := ListView1.Selected.SubItems[0];
    Doc.FormFields.Item(4).Result := NumToWstr(StrToFloat(ListView1.Selected.SubItems[1]));
    Doc.FormFields.Item(5).Result := ListView1.Selected.SubItems[1];
    word.visible:=true;
    //Doc.PrintPreview;


    IsPrint:=false;
    CanSave:=False;
  end
  else if com_zhaobiao.text='设计' then
  begin
    if listview1.Selected=nil then exit;
    if IsFileInUse(GetFilePath+'zhongbiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=Word.Documents.open(getFilePath+'zhongbiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;

    Doc.FormFields.Item(1).Result := ListView1.Selected.Caption;
    Doc.FormFields.Item(2).Result := xmbdgc.GCLX_NAME;
    Doc.FormFields.Item(3).Result := ListView1.Selected.SubItems[0];
    //Doc.FormFields.Item(4).Result := NumToWstr(StrToFloat(ListView1.Selected.SubItems[1]));
    //Doc.FormFields.Item(5).Result := ListView1.Selected.SubItems[1];
    word.visible:=true;
    //Doc.PrintPreview;


    IsPrint:=false;
    CanSave:=False;
  end;
end;

procedure Tf_zhongbiaotzs.BitBtn1Click(Sender: TObject);
begin
  inherited;
  if not IsExistsPath then exit;
  if com_zhaobiao.Text='施工' then
  begin
    if IsFileInUse(GetFilePath+'zhongbiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=word.documents.open(GetFilePath+'zhongbiao.Doc');
    except
      showmessage('打开模板错误!');
      Word.quit;
      WOrd:=UnAssigned;
      exit;
    end;
    word.visible:=true;
    Word.activate;
    IsPrint:=false;
    CanSave:=True;
  end
  else if com_zhaobiao.Text='监理' then
  begin
    if IsFileInUse(GetFilePath+'zhongbiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=word.documents.open(GetFilePath+'zhongbiao.Doc');
    except
      showmessage('打开模板错误!');
      Word.quit;
      WOrd:=UnAssigned;
      exit;
    end;
    word.visible:=true;
    Word.activate;
    IsPrint:=false;
    CanSave:=True;
  end
  else if com_zhaobiao.Text='设计' then
  begin
    if IsFileInUse(GetFilePath+'zhongbiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
        showmessage('文件在程序外打开,请先关闭!');
        exit;
      end;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=word.documents.open(GetFilePath+'zhongbiao.Doc');
    except
      showmessage('打开模板错误!');
      Word.quit;
      WOrd:=UnAssigned;
      exit;
    end;
    word.visible:=true;
    Word.activate;
    IsPrint:=false;
    CanSave:=True;
  end;
end;

procedure Tf_zhongbiaotzs.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  inherited;
  if IsExistsPath then
  begin
    if com_zhaobiao.Text='施工' then
    begin
      if (IsFileInUse(GetFilePath+'zhongbiao.Doc')) and IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.Quit;
        Word:=Unassigned;
      except
      end;
    end
    else if com_zhaobiao.Text='监理' then
    begin
      if (IsFileInUse(GetFilePath+'zhongbiao.Doc')) and IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.quit;
        Word:=Unassigned;
      except
      end;
    end
    else if com_zhaobiao.Text='设计' then
    begin
      if (IsFileInUse(GetFilePath+'zhongbiao.Doc')) and IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      try
        if CanSave then
          Doc.save
        else
          Doc.saved:=True;
        Word.quit;
        Word:=Unassigned;
      except
      end;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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