unit u_sys_report_manage; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, dxExEdtr, dxCntner, dxTL, dxDBCtrl, dxDBGrid, DB, ADODB, bsSkinShellCtrls, bsDialogs, ppEndUsr, ppProd, ppClass, ppReport, ppDsgnDB, BusinessSkinForm, ppComm, ppRelatv, ppDB, ppDBPipe, bsSkinCtrls, dxDBTLCl, dxGrClms, ExtCtrls, DBCtrls, StdCtrls, Mask, ComCtrls, RxMemDS, TXComp,IdFTP,ShellApi, bsSkinTabs,IdFTPCommon; type Tfrm_sys_report_manage = class(TForm) dxDBGrid1: TdxDBGrid; t_sys_report_lei: TADOQuery; t_sys_report_lei1: TDataSource; one_table_1: TppDBPipeline; one_table_2: TppDBPipeline; one_table_3: TppDBPipeline; one_table_4: TppDBPipeline; all_table_1: TppDBPipeline; all_table_2: TppDBPipeline; all_table_3: TppDBPipeline; all_table_4: TppDBPipeline; all_table_5: TppDBPipeline; all_table_6: TppDBPipeline; all_table_7: TppDBPipeline; t_sys_report: TADOQuery; bsBusinessSkinForm1: TbsBusinessSkinForm; print_head: TppDBPipeline; load_employee: TppDBPipeline; ppDataDictionary1: TppDataDictionary; t_sys_report1: TDataSource; db_report: TppDBPipeline; rp: TppReport; rd: TppDesigner; bsSkinInputDialog1: TbsSkinInputDialog; t_one_table_1: TADOQuery; t_one_table_11: TDataSource; t_one_table_2: TADOQuery; t_one_table_21: TDataSource; t_one_table_31: TDataSource; t_one_table_3: TADOQuery; t_one_table_41: TDataSource; t_one_table_4: TADOQuery; t_all_table_1: TADOQuery; t_all_table_11: TDataSource; t_all_table_2: TADOQuery; t_all_table_21: TDataSource; t_all_table_3: TADOQuery; t_all_table_31: TDataSource; t_all_table_41: TDataSource; t_all_table_4: TADOQuery; t_all_table_5: TADOQuery; t_all_table_51: TDataSource; t_all_table_61: TDataSource; t_all_table_6: TADOQuery; t_all_table_71: TDataSource; t_all_table_7: TADOQuery; dxDBGrid1Column1: TdxDBGridMaskColumn; dxDBGrid1Column2: TdxDBGridColumn; bsSkinButton12: TbsSkinButton; bsSkinPanel5: TbsSkinPanel; bsSkinPanel2: TbsSkinPanel; bsSkinButton3: TbsSkinButton; bsSkinButton4: TbsSkinButton; bsSkinButton9: TbsSkinButton; bsSkinButton1: TbsSkinButton; bsSkinButton2: TbsSkinButton; bsSkinButton5: TbsSkinButton; bsSkinButton6: TbsSkinButton; bsSkinNotebook1: TbsSkinNotebook; bsSkinPanel4: TbsSkinPanel; Label13: TLabel; Panel1: TPanel; dxDBGrid2: TdxDBGrid; dxDBGrid2Column1: TdxDBGridMaskColumn; dxDBGrid2Column2: TdxDBGridCheckColumn; Panel2: TPanel; bsSkinPanel6: TbsSkinPanel; Label14: TLabel; Panel3: TPanel; bsSkinPanel1: TbsSkinPanel; Label15: TLabel; Panel4: TPanel; dxDBGrid3: TdxDBGrid; dxDBGridMaskColumn1: TdxDBGridMaskColumn; t_down_list: TRxMemoryData; t_down_list1: TDataSource; Panel5: TPanel; dxDBGrid4: TdxDBGrid; bsSkinButton7: TbsSkinButton; bsSkinButton8: TbsSkinButton; bsSkinButton10: TbsSkinButton; t_ask_report: TRxMemoryData; t_ask_report1: TDataSource; dxDBGrid4Column1: TdxDBGridMaskColumn; dxDBGrid4Column2: TdxDBGridMaskColumn; dxDBGrid4Column3: TdxDBGridMaskColumn; dxDBGrid4Column4: TdxDBGridColumn; Edit1: TEdit; Button2: TButton; Edit2: TEdit; Button3: TButton; ExtraOptions1: TExtraOptions; OpenDialog1: TOpenDialog; bsSkinButton14: TbsSkinButton; DBMemo1: TDBMemo; DBMemo3: TDBMemo; bsSkinPageControl1: TbsSkinPageControl; bsSkinTabSheet1: TbsSkinTabSheet; bsSkinTabSheet2: TbsSkinTabSheet; bsSkinPanel3: TbsSkinPanel; Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; Label10: TLabel; Label11: TLabel; Label12: TLabel; DBEdit1: TDBEdit; DBRichEdit1: TDBRichEdit; DBRichEdit2: TDBRichEdit; DBRichEdit3: TDBRichEdit; DBRichEdit4: TDBRichEdit; DBRichEdit5: TDBRichEdit; DBRichEdit6: TDBRichEdit; DBRichEdit7: TDBRichEdit; DBRichEdit8: TDBRichEdit; DBRichEdit9: TDBRichEdit; DBRichEdit10: TDBRichEdit; DBRichEdit11: TDBRichEdit; Button1: TButton; DBMemo2: TDBMemo; DBNavigator1: TDBNavigator; procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure bsSkinPanel2Resize(Sender: TObject); procedure bsSkinButton5Click(Sender: TObject); procedure bsSkinButton3Click(Sender: TObject); procedure bsSkinButton6Click(Sender: TObject); procedure bsSkinButton2Click(Sender: TObject); procedure bsSkinButton1Click(Sender: TObject); procedure bsSkinButton9Click(Sender: TObject); procedure bsSkinButton4Click(Sender: TObject); procedure FormShow(Sender: TObject); procedure Button1Click(Sender: TObject); procedure t_sys_reportAfterInsert(DataSet: TDataSet); procedure dxDBGrid1Click(Sender: TObject); procedure bsSkinButton12Click(Sender: TObject); procedure Button2Click(Sender: TObject); procedure Button3Click(Sender: TObject); procedure bsSkinButton7Click(Sender: TObject); procedure bsSkinButton10Click(Sender: TObject); procedure bsSkinButton8Click(Sender: TObject); procedure bsSkinButton14Click(Sender: TObject); procedure rdCloseQuery(Sender: TObject; var CanClose: Boolean); procedure dxDBGrid1KeyPress(Sender: TObject; var Key: Char); private { Private declarations } public { Public declarations } end; var frm_sys_report_manage: Tfrm_sys_report_manage; implementation uses u_main, u_sys_print_view, u_data_share; {$R *.dfm} procedure Tfrm_sys_report_manage.FormClose(Sender: TObject; var Action: TCloseAction); begin frm_sys_report_manage.Hide; frm_sys_report_manage.ManualFloat(frm_sys_report_manage.BoundsRect ); frm_main.freeTabs('frm_sys_report_manage'); action:=cafree; frm_sys_report_manage:=nil; end; procedure Tfrm_sys_report_manage.bsSkinPanel2Resize(Sender: TObject); var i:integer; begin i:=round(bsSkinPanel2.width/7); bsSkinButton6.width:=i; bsSkinButton3.width:=i; bsSkinButton2.width:=i; bsSkinButton1.width:=i; bsSkinButton9.width:=i; bsSkinButton4.width:=i; end; procedure Tfrm_sys_report_manage.bsSkinButton5Click(Sender: TObject); begin close; end; procedure Tfrm_sys_report_manage.bsSkinButton3Click(Sender: TObject); begin if t_sys_report.Active=false then exit; if t_sys_report.RecordCount<>0 then rp.template.DatabaseSettings.name :=''; rp.AllowPrintToFile:=true; rd.ShowModal; end; procedure Tfrm_sys_report_manage.bsSkinButton6Click(Sender: TObject); begin if t_sys_report.Active=false then exit; if t_sys_report.isempty then exit; try rp.template.DatabaseSettings.Name:=t_sys_report.fieldbyname('报表名称').AsString; rp.template.LoadFromDatabase; rp.AllowPrintToFile:=false; if not assigned(frm_sys_print_view) then frm_sys_print_view:=tfrm_sys_print_view.Create(self); frm_sys_print_view.ppViewer1.Report:=rp; rp.PrintToDevices; frm_sys_print_view.ShowModal; except showmessage('打印预览失败!'); end; end; procedure Tfrm_sys_report_manage.bsSkinButton2Click(Sender: TObject); var book1:Tbookmark; str:string; begin if t_sys_report.Active=false then exit; try t_sys_report.DisableControls; book1:=t_sys_report.GetBookmark; str:=t_sys_report.fieldbyname('报表名称').asstring; t_sys_report.First; while not t_sys_report.eof do begin if t_sys_report.fieldbyname('报表名称').asstring=str then begin t_sys_report.edit; t_sys_report['是否默认']:=1; t_sys_report.post; end else begin t_sys_report.edit; t_sys_report['是否默认']:=0; t_sys_report.post; end; t_sys_report.next; end; finally t_sys_report.GotoBookmark(book1); t_sys_report.EnableControls; end; end; procedure Tfrm_sys_report_manage.bsSkinButton1Click(Sender: TObject); begin if t_sys_report.Active=false then exit; if t_sys_report.isempty then begin showmessage('没有要更改名称的格式!'); exit; end; t_sys_report.edit; t_sys_report['报表名称']:=bsSkinInputDialog1.InputBox('更改名称','新的名称',t_sys_report.fieldbyname('报表名称').asstring); t_sys_report.post; end; procedure Tfrm_sys_report_manage.bsSkinButton9Click(Sender: TObject); begin if t_sys_report.Active=false then exit; if t_sys_report.isempty then begin showmessage('没有要删除的格式!'); exit; end; if application.MessageBox('您确定要删除格式吗?','警告:',MB_OKCANCEL)=IDOK then t_sys_report.delete; end; procedure Tfrm_sys_report_manage.bsSkinButton4Click(Sender: TObject); begin if t_sys_report.Active=false then exit; if t_sys_report.isempty then begin showmessage('没有要设计的格式!'); exit; end; try rp.template.DatabaseSettings.Name:=t_sys_report.fieldbyname('报表名称').AsString; rp.template.LoadFromDatabase; rp.AllowPrintToFile:=true; rd.ShowModal; except showmessage('格式设计失败!'); end; end; procedure Tfrm_sys_report_manage.FormShow(Sender: TObject); begin t_sys_report_lei.Open; frm_data_share.t_sys_report_head.Requery(); frm_data_share.t_load_employee.Requery(); dxdbgrid1.FullExpand; end; procedure Tfrm_sys_report_manage.Button1Click(Sender: TObject); var afield : variant; i: Integer; begin if t_sys_report_lei.IsEmpty then exit; afield := vararraycreate([0,t_sys_report_lei.fieldcount-1],varvariant); for i := 0 to (t_sys_report_lei.fieldcount-1) do begin afield[i] :=t_sys_report_lei.fields[i].value ; end; t_sys_report_lei.append; for i := 0 to (t_sys_report_lei.fieldcount-1) do begin t_sys_report_lei.fields[i].value := afield[i] ; end; end; procedure Tfrm_sys_report_manage.t_sys_reportAfterInsert( DataSet: TDataSet); begin t_sys_report['报表属性']:=t_sys_report_lei.fieldbyname('报表类别').asstring; end; procedure Tfrm_sys_report_manage.dxDBGrid1Click(Sender: TObject); begin if t_sys_report_lei.IsEmpty then exit; t_sys_report.close; t_sys_report.Parameters[0].value:=t_sys_report_lei.fieldbyname('报表类别').asstring; t_sys_report.open; if trim(t_sys_report_lei.fieldbyname('代码1').asstring)='' then begin one_table_1.Visible:=false; end else begin t_one_table_1.close; t_one_table_1.sql.clear; t_one_table_1.sql.add(t_sys_report_lei.fieldbyname('代码1').asstring); t_one_table_1.open; one_table_1.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码2').asstring)='' then begin one_table_2.Visible:=false; end else begin t_one_table_2.close; t_one_table_2.sql.clear; t_one_table_2.sql.add(t_sys_report_lei.fieldbyname('代码2').asstring); t_one_table_2.open; one_table_2.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码3').asstring)='' then begin one_table_3.Visible:=false; end else begin t_one_table_3.close; t_one_table_3.sql.clear; t_one_table_3.sql.add(t_sys_report_lei.fieldbyname('代码3').asstring); t_one_table_3.open; one_table_3.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码4').asstring)='' then begin one_table_4.Visible:=false; end else begin t_one_table_4.close; t_one_table_4.sql.clear; t_one_table_4.sql.add(t_sys_report_lei.fieldbyname('代码4').asstring); t_one_table_4.open; one_table_4.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码5').asstring)='' then begin all_table_1.Visible:=false; end else begin t_all_table_1.close; t_all_table_1.sql.clear; t_all_table_1.sql.add(t_sys_report_lei.fieldbyname('代码5').asstring); t_all_table_1.open; all_table_1.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码6').asstring)='' then begin all_table_2.Visible:=false; end else begin t_all_table_2.close; t_all_table_2.sql.clear; t_all_table_2.sql.add(t_sys_report_lei.fieldbyname('代码6').asstring); t_all_table_2.open; all_table_2.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码7').asstring)='' then begin all_table_3.Visible:=false; end else begin t_all_table_3.close; t_all_table_3.sql.clear; t_all_table_3.sql.add(t_sys_report_lei.fieldbyname('代码7').asstring); t_all_table_3.open; all_table_3.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码8').asstring)='' then begin all_table_4.Visible:=false; end else begin t_all_table_4.close; t_all_table_4.sql.clear; t_all_table_4.sql.add(t_sys_report_lei.fieldbyname('代码8').asstring); t_all_table_4.open; all_table_4.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码9').asstring)='' then begin all_table_5.Visible:=false; end else begin t_all_table_5.close; t_all_table_5.sql.clear; t_all_table_5.sql.add(t_sys_report_lei.fieldbyname('代码9').asstring); t_all_table_5.open; all_table_5.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码10').asstring)='' then begin all_table_6.Visible:=false; end else begin t_all_table_6.close; t_all_table_6.sql.clear; t_all_table_6.sql.add(t_sys_report_lei.fieldbyname('代码10').asstring); t_all_table_6.open; all_table_6.Visible:=true; end; if trim(t_sys_report_lei.fieldbyname('代码11').asstring)='' then begin all_table_7.Visible:=false; end else begin t_all_table_7.close; t_all_table_7.sql.clear; t_all_table_7.sql.add(t_sys_report_lei.fieldbyname('代码11').asstring); t_all_table_7.open; all_table_7.Visible:=true; end; end; procedure Tfrm_sys_report_manage.bsSkinButton12Click(Sender: TObject); begin if bsSkinButton12.Caption='展 开' then begin dxdbgrid1.FullExpand; bsSkinButton12.Caption:='合 并'; end else begin dxdbgrid1.FullCollapse; bsSkinButton12.Caption:='展 开'; end; end; procedure Tfrm_sys_report_manage.Button2Click(Sender: TObject); begin if Edit1.text='xhdsoft'then begin bsSkinPanel3.Enabled:=true; DBMemo2.ReadOnly:=false; end else showmessage('激活密码错误!'); end; procedure Tfrm_sys_report_manage.Button3Click(Sender: TObject); begin if Edit2.text='xhdsoft'then begin Panel4.Enabled:=true; Panel5.Enabled:=true; end else showmessage('激活密码错误!'); end; procedure Tfrm_sys_report_manage.bsSkinButton7Click(Sender: TObject); var line:string; k:integer; IdFTP1: TIdFTP; ListBox: TListBox; begin try idftp1:=tidftp.Create(application); listbox:=Tlistbox.Create(nil); listbox.Visible:=false; listbox.Parent:=frm_sys_report_manage; t_ask_report.close; t_ask_report.open; with idftp1 do begin Username:='dongsheng'; Password:='zouwenkun'; Host:='218.57.11.18'; Connect; end; IdFTP1.ChangeDir('/XHD/REPORT'); IdFTP1.TransferType := ftASCII; ListBox.Items.Clear; IdFTP1.List(ListBox.Items); //下载文件开始 if not DirectoryExists(ExtractFilePath(Application.ExeName)+'update') then CreateDir(ExtractFilePath(Application.ExeName)+'update'); for k:=0 to listbox.Count -1 do begin try Line:=ListBox.Items[k]; while pos(' ',line) <> 0 do begin delete(line,1,pos(' ',line)); end; IdFTP1.TransferType := ftBinary; IdFTP1.Get(line,ExtractFilePath(Application.ExeName)+'update\'+line,true); t_ask_report.insert; t_ask_report['公司']:=copy(line,1,pos('@',line)-1); t_ask_report['人员']:=copy(line,pos('@',line)+1,pos('%',line)-pos('@',line)-1); t_ask_report['报表类别']:=copy(line,pos('%',line)+1,pos('&',line)-pos('%',line)-1); t_ask_report['文件名称']:=line; t_ask_report.post; except ; end; //下载结束 end; finally listbox.free; idftp1.Disconnect; idftp1.Free; end; end; procedure Tfrm_sys_report_manage.bsSkinButton10Click(Sender: TObject); var IdFTP1:TIdFTP; str_rtm,do_file,str_tell:widestring; begin if t_sys_report.IsEmpty then exit; do_file:=trim(InputBox('请输入上传新报表名称', '报表名称:', '')); if do_file='' then begin showmessage('请输入上传新报表名称不能为空!!'); exit; end; str_tell:=trim(InputBox('请输入报表说明', '报表说明:', '')); if str_tell='' then begin showmessage('请输入上传新报表说明不能为空!!'); exit; end; //类别^名称#日期~说明&.rtm str_rtm:=t_sys_report_lei.fieldbyname('报表类别').asstring +'^'+do_file +'#'+datetostr(date) +'~'+str_tell +'&.rtm'; try rp.template.DatabaseSettings.Name:=t_sys_report.fieldbyname('报表名称').AsString; rp.template.LoadFromDatabase; rp.AllowPrintToFile:=true; rp.Template.FileName:=ExtractFilePath(Application.ExeName)+'update\'+str_rtm; rp.Template.SaveToFile; except showmessage('生成报表文件失败!!'); exit; end; try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:='dongsheng'; Password:='zouwenkun'; Host:='218.57.11.18'; Connect; end; idftp1.ChangeDir('/XHD/REPORT'); idftp1.TransferType:=ftBinary; idftp1.Put(ExtractFilePath(Application.ExeName)+'update\'+str_rtm,str_rtm); idftp1.Disconnect; except ; end; idftp1.Free; showmessage('上传报表成功!!'); end; procedure Tfrm_sys_report_manage.bsSkinButton8Click(Sender: TObject); var IdFTP1:TIdFTP; begin if t_ask_report.IsEmpty then exit; if application.MessageBox('您确定要将fpt服务器上的当前申请删除吗?','警告:',MB_OKCANCEL)<>IDOK then exit; try IdFTP1:=TIdFTP.Create(application); with idftp1 do begin Username:='dongsheng'; Password:='zouwenkun'; Host:='218.57.11.18'; Connect; end; IdFTP1.ChangeDir('/XHD/REPORT'); IdFTP1.Delete(t_ask_report['文件名称']); t_ask_report.delete; finally idftp1.Disconnect; idftp1.free; end; end; procedure Tfrm_sys_report_manage.bsSkinButton14Click(Sender: TObject); begin if t_ask_report.isempty then exit; ShellExecute(Application.Handle,nil,PChar(ExtractFilePath(Application.ExeName)+'update\'+t_ask_report.fieldbyname('文件名称').asstring),nil,nil,SW_NORMAL); end; procedure Tfrm_sys_report_manage.rdCloseQuery(Sender: TObject; var CanClose: Boolean); begin if rd.Report.Modified then begin case Application.MessageBox('是否要保存报表?','提示',MB_YESNOCANCEL + MB_ICONINFORMATION) of IDYES: begin rd.Report.Template.SaveToDatabase; CanClose:=True; end; IDNO: CanClose:=True; IDCANCEL: CanClose:=False; end; end; end; procedure Tfrm_sys_report_manage.dxDBGrid1KeyPress(Sender: TObject; var Key: Char); begin if key='@'then begin bsSkinNotebook1.PageIndex:=0; end; if key='#'then begin bsSkinNotebook1.PageIndex:=1; end; if key='$'then begin bsSkinNotebook1.PageIndex:=2; end; end; end.