📄 u_zhaobiaoyqs.pas
字号:
unit U_ZhaoBiaoyqs;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons,Unit_TopParentForm, ComCtrls,
OleCtrls, CELL50Lib_TLB,adodb,ComObj;
type
Tf_zhaobiaoyqs = class(Tfrm_TopParentForm)
listview1: TListView;
Com_Leibie: TComboBox;
Label1: TLabel;
Label4: TLabel;
SpeedButton3: TSpeedButton;
SpeedButton2: TSpeedButton;
Label6: TLabel;
btn_PrintPre: TBitBtn;
bb_Print: TBitBtn;
ListView2: TListView;
Memo1: TMemo;
BitBtn1: TBitBtn;
Memo2: TMemo;
procedure FormCreate(Sender: TObject);
procedure GetInfor;
procedure Com_LeibieChange(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 bb_PrintClick(Sender: TObject);
procedure btn_PrintPreClick(Sender: TObject);
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_zhaobiaoyqs: Tf_zhaobiaoyqs;
implementation
uses
systemobject,datamodule,unit_public,DataAccessCommonShell;
{$R *.dfm}
procedure Tf_zhaobiaoyqs.GetInfor;
var
adoquery:tadoquery;
str:string;
i:integer;
dwname:string;
listitem:tlistitem;
begin
listview1.Items.Clear;
listview2.Items.Clear;
if com_zhaobiao.Text='施工' then
begin
if IsFileInUse(FileName+'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;
if not DirectoryExists(GetFilePath) then
CreateDir(GetFilePath);
if not fileexists(GetFilePath+'Toubiao.Doc') then
begin
CopyFile(Pchar(sPath+'report\tongzhi\Toubiao.doc'),Pchar(GetFilePath+'toubiao.Doc'),false);
end;
try
word:=CreateOleObject('word.application');
Word.visible:=False;
Doc:=word.documents.open(GetFilePath+'toubiao.Doc');
except
showmessage('打开模板错误!');
Word.quit;
WOrd:=UnAssigned;
exit;
end;
adoquery:=tadoquery.Create(nil);
try
adoquery.Close;
adoquery.Connection:=datamodule1.ADOMainConn;
adoquery.SQL.Text:='select a.dw_name,b.bd_name from bid_danwei_xinxi a,bid_biaoduan_xinxi b,bid_wenjian2 c '
+' where c.wj2_leixing=2 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 a.dw_id=c.dw_id and c.bd_isbn=b.bd_isbn '
+' and c.wj2_leibie='+trim(getleibie(com_leibie.Text))
+' order by a.dw_name';
adoquery.Open;
dwname:='';
adoquery.First;
for i:=0 to adoquery.RecordCount-1 do
begin
if dwname=adoquery.fieldbyname('dw_name').AsString then
listitem.SubItems.Strings[0]:=listitem.SubItems.Strings[0]
+' '+adoquery.fieldbyname('bd_name').AsString
else
begin
listitem:=listview1.Items.Add;
listitem.Caption:=adoquery.fieldbyname('dw_name').AsString;
listitem.SubItems.Add(adoquery.fieldbyname('bd_name').AsString);
dwname:=adoquery.fieldbyname('bd_name').AsString;
end;
adoquery.Next;
end;
except
freeandnil(adoquery);
end;
end
else if com_zhaobiao.Text='监理' then
begin
if IsFileInUse(FileName+'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;
if not DirectoryExists(GetFilePath) then
CreateDir(GetFilePath);
if not fileexists(GetFilePath+'Toubiao.Doc') then
begin
CopyFile(Pchar(sPath+'report\tongzhi\Toubiao.doc'),Pchar(GetFilePath+'toubiao.Doc'),false);
end;
try
word:=CreateOleObject('word.application');
Word.visible:=False;
Doc:=word.documents.open(GetFilePath+'toubiao.Doc');
except
showmessage('打开模板错误!');
Word.quit;
WOrd:=UnAssigned;
exit;
end;
adoquery:=tadoquery.Create(nil);
try
adoquery.Close;
adoquery.Connection:=datamodule1.ADOMainConn;
adoquery.SQL.Text:='select a.dw_name,b.bd_name from bid_danwei_xinxi a,bid_biaoduan_xinxi b,bid_wenjian2 c '
+' where c.wj2_leixing=2 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 a.dw_id=c.dw_id and c.bd_isbn=b.bd_isbn ';
adoquery.Open;
dwname:='';
adoquery.First;
for i:=0 to adoquery.RecordCount-1 do
begin
if dwname=adoquery.fieldbyname('dw_name').AsString then
listitem.SubItems.Strings[0]:=listitem.SubItems.Strings[0]
+' '+adoquery.fieldbyname('bd_name').AsString
else
begin
listitem:=listview1.Items.Add;
listitem.Caption:=adoquery.fieldbyname('dw_name').AsString;
listitem.SubItems.Add(adoquery.fieldbyname('bd_name').AsString);
dwname:=adoquery.fieldbyname('dw_name').AsString;
end;
adoquery.Next;
end;
except
freeandnil(adoquery);
end;
end;
end;
procedure Tf_zhaobiaoyqs.FormCreate(Sender: TObject);
begin
GetItems(com_xmname,com_zhaobiao,com_gclxname,1);
inherited;
panel2.Caption:='中标邀请书';
IsPrint:=false;
CanSave:=False;
{if com_zhaobiao.Text='施工' then
begin
com_leibie.ItemIndex:=0;
label4.Visible:=true;
com_leibie.Visible:=true;
end
else if com_zhaobiao.Text='监理' then
begin
com_leibie.ItemIndex:=0;
label4.Visible:=false;
com_leibie.Visible:=false;
GetInfor;
end;}
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;
GetInfor;
end;
end;
procedure Tf_zhaobiaoyqs.Com_LeibieChange(Sender: TObject);
begin
inherited;
//GetInfor;
end;
procedure Tf_zhaobiaoyqs.Com_xmnameChange(Sender:TObject);
begin
inherited;
{if com_zhaobiao.Text='施工' then
begin
Getxmleibie(com_leibie);
if com_leibie.Items[0]='无类别' then
begin
com_leibie.ItemIndex:=0;
com_leibie.Enabled:=false;
end
else
com_leibie.Enabled:=true;
end
else if com_zhaobiao.Text='监理' then }
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;
GetInfor;
FileName:=GetFilePath;
end;
procedure Tf_zhaobiaoyqs.Com_zhaoBiaoChange(Sender:Tobject);
begin
inherited;
{if com_zhaobiao.Text='施工' then
begin
com_leibie.ItemIndex:=0;
label4.Visible:=true;
com_leibie.Visible:=true;
GetXmLeiBie(com_Leibie);
if com_leibie.Items[0]='无类别' then
begin
com_leibie.ItemIndex:=0;
com_leibie.Enabled:=false;
end
else
com_leibie.Enabled:=true;
end
else if com_zhaobiao.Text='监理' then
begin
com_leibie.ItemIndex:=0;
label4.Visible:=false;
com_leibie.Visible:=false;
GetInfor;
end; }
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;
GetInfor;
FileName:=GetFilePath;
end;
procedure Tf_zhaobiaoyqs.Com_GclxnameChange(Sender: TObject);
begin
inherited;
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;
getinfor;
FileName:=GetFilePath;
end;
procedure Tf_zhaobiaoyqs.SpeedButton2Click(Sender: TObject);
var
listitem:tlistitem;
begin
inherited;
listitem:=listview2.Items.Add;
listitem.Caption:=listview1.Selected.Caption;
listitem.SubItems.Add(listview1.Selected.SubItems[0]);
listview1.DeleteSelected;
end;
procedure Tf_zhaobiaoyqs.SpeedButton3Click(Sender: TObject);
var
listitem:tlistitem;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -