unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ppEndUsr, ppProd, ppClass, ppReport, ppComm, ppRelatv, ppCache, ppDB, ppDBPipe, Db, ADODB, StdCtrls, Grids, DBGrids, CheckLst,ShellApi; type TForm1 = class(TForm) CheckListBox1: TCheckListBox; Button1: TButton; Button2: TButton; DBGrid1: TDBGrid; Button3: TButton; Label1: TLabel; Edit1: TEdit; Edit2: TEdit; Label2: TLabel; Button4: TButton; Button5: TButton; db_old: TADOConnection; ADOQuery1: TADOQuery; DataSource1: TDataSource; ppDBPipeline1: TppDBPipeline; ppReport1: TppReport; ppDesigner1: TppDesigner; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure Button5Click(Sender: TObject); procedure Button4Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.DFM} procedure TForm1.Button1Click(Sender: TObject); begin ShellExecute(Application.Handle,nil,PChar(ExtractFilePath(Application.ExeName)+'\sql.udl'),nil,nil,SW_NORMAL); end; procedure TForm1.Button2Click(Sender: TObject); begin try db_old.ConnectionString:='FILE NAME='+ExtractFilePath(ParamStr(0))+'sql.udl'; db_old.Connected:=true; except showmessage('数据库连接错误!'); exit; end; db_old.GetTableNames(CheckListBox1.Items); end; procedure TForm1.Button3Click(Sender: TObject); begin if CheckListBox1.Items.Count<1 then exit; ADOQuery1.Close; ADOQuery1.SQL.text:='select * from '+CheckListBox1.Items[CheckListBox1.ItemIndex]; ADOQuery1.open; end; procedure TForm1.Button5Click(Sender: TObject); begin close; end; procedure TForm1.Button4Click(Sender: TObject); begin if ADOQuery1.isempty then exit; if ADOQuery1.isempty then begin showmessage('没有要设计的格式!'); exit; end; ppReport1.template.DatabaseSettings.NameField:=edit1.text; ppReport1.template.DatabaseSettings.TemplateField:=edit2.text; try ppReport1.template.DatabaseSettings.Name:=ADOQuery1.fieldbyname(Edit1.text).AsString; ppReport1.template.LoadFromDatabase; ppReport1.AllowPrintToFile:=true; ppDesigner1.ShowModal; except showmessage('格式设计失败!'); end; end; end.