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

📄 u_zhaobiaoyqs.pas

📁 招投标软件代码,很有应用价值,请大家参考下哦,不明白的地方给我留言
💻 PAS
📖 第 1 页 / 共 2 页
字号:
begin
  inherited;
  listitem:=listview1.Items.Add;
  listitem.Caption:=listview2.Selected.Caption;
  listitem.SubItems.Add(listview2.Selected.SubItems[0]);
  listview2.DeleteSelected;
end;

procedure Tf_zhaobiaoyqs.bb_PrintClick(Sender: TObject);
var
  i:Integer;
  FileHandle:integer;
begin
  inherited;
  if not IsExistsPath then exit;  
  if com_zhaobiao.text='施工' then
  begin
    if IsFileInUse(GetFilePath+'Toubiao.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+'toubiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;
    if not fileexists(GetFilePath+'toubiao.txt') then
    begin
       FileHandle:=filecreate(GetFilePath+'toubiao.txt');
       fileclose(FileHandle);
    end;
    memo1.Lines.LoadFromFile(GetFilePath+'toubiao.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.XM_NAME;
      Doc.FormFields.Item(3).Result := xmbdgc.XM_NAME;
      Doc.FormFields.Item(4).Result := xmbdgc.GCLX_NAME;
      Doc.FormFields.Item(5).Result :=ListView1.Items[i].SubItems[0];
      word.visible:=False;
      Doc.PrintOut;
      memo1.Lines.Add('发送单位:'+listview1.Items[i].Caption);
      memo1.lines.Add('可投合同段:'+ListView1.Items[i].SubItems[0]);
    end;

    IsPrint:=True;
    CanSave:=False;
  end
  else if com_zhaobiao.text='监理' then
  begin
    if IsFileInUse(GetFilePath+'Toubiao.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+'toubiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;

    if not fileexists(GetFilePath+'toubiao.txt') then
    begin
       FileHandle:=filecreate(GetFilePath+'toubiao.txt');
       fileclose(FileHandle);
    end;
    memo1.Lines.LoadFromFile(GetFilePath+'toubiao.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.XM_NAME;
      Doc.FormFields.Item(3).Result := xmbdgc.XM_NAME;
      Doc.FormFields.Item(4).Result := xmbdgc.GCLX_NAME;
      Doc.FormFields.Item(5).Result :=ListView1.Items[i].SubItems[0];
      word.visible:=False;
      Doc.PrintOut;
      memo1.Lines.Add('发送单位:'+listview1.Items[i].Caption);
      memo1.lines.Add('可投合同段:'+ListView1.Items[i].SubItems[0]);
    end;

    IsPrint:=True;
    CanSave:=False;
  end;
end;

procedure Tf_zhaobiaoyqs.btn_PrintPreClick(Sender: TObject);
begin
  inherited;
  if not IsExistsPath then exit;  
  if com_zhaobiao.text='施工' then
  begin
    if listview1.Selected=nil then exit;
    if IsFileInUse(GetFilePath+'Toubiao.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+'toubiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;

    Doc.FormFields.Item(1).Result := ListView1.Selected.Caption;
    Doc.FormFields.Item(2).Result := xmbdgc.XM_NAME;
    Doc.FormFields.Item(3).Result := xmbdgc.XM_NAME;
    Doc.FormFields.Item(4).Result := xmbdgc.GCLX_NAME;
    Doc.FormFields.Item(5).Result :=ListView1.Selected.SubItems[0];
    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+'Toubiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      if CanSave then
        Doc.save
      else
        Doc.saved:=True;
      Word.Quit;
      Word:=Unassigned;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=Word.Documents.open(getFilePath+'toubiao.doc');
    except
      showmessage('打开模板错误');
      word.quit;
      word:=UnAssigned;
      exit;
    end;

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


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

procedure Tf_zhaobiaoyqs.BitBtn1Click(Sender: TObject);
begin
  inherited;
  if not IsExistsPath then exit;  
  if com_zhaobiao.Text='施工' then
  begin
    if IsFileInUse(GetFilePath+'toubiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      if CanSave then
        Doc.save
      else
        Doc.saved:=True;
      Word.Quit;
      Word:=Unassigned;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=word.documents.open(GetFilePath+'toubiao.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+'toubiao.Doc') then
    begin
      if IsPrint then
      begin
        if application.MessageBox('打印通知书调用该文件,是否结束','请确定',MB_YESNO)<>Idyes then
          exit;
      end;
      if CanSave then
        Doc.save
      else
        Doc.saved:=True;
      Word.Quit;
      Word:=Unassigned;
    end;
    try
      word:=CreateOleObject('word.application');
      Doc:=word.documents.open(GetFilePath+'toubiao.Doc');
    except
      showmessage('打开模板错误!');
      Word.quit;
      WOrd:=UnAssigned;
      exit;
    end;
    word.visible:=true;
    Word.activate;
    IsPrint:=false;
    CanSave:=True;
  end;
end;

procedure Tf_zhaobiaoyqs.FormCloseQuery(Sender: TObject;
  var CanClose: Boolean);
begin
  inherited;
  if IsExistsPath then
  begin
    if com_zhaobiao.Text='施工' then
    begin
      if (IsFileInUse(GetFilePath+'toubiao.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+'toubiao.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 + -