You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

814 lines
23 KiB
Plaintext

11 months ago
unit u_sys_print;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
dxExEdtr, ppDB, ppProd, ppClass, ppReport, bsDialogs, bsSkinShellCtrls,
ppDsgnDB, ppRelatv, ppDBPipe, DB, ADODB, ppComm, ppEndUsr,
BusinessSkinForm, StdCtrls, Mask, bsSkinBoxCtrls, bsdbctrls, bsSkinCtrls,
dxTL, dxDBCtrl, dxDBGrid, dxCntner, dxDBTLCl, dxGrClms, DBCtrls, XPMenu,
Menus, TXComp, ExtDlgs, ImgList, IdFTP,IdFTPCommon,inifiles;
type
Tfrm_sys_print = class(TForm)
bsBusinessSkinForm1: TbsBusinessSkinForm;
dxDBGrid1: TdxDBGrid;
dxDBGrid1Column1: TdxDBGridMaskColumn;
bsSkinPanel3: TbsSkinPanel;
t_sys_report: TADOQuery;
t_sys_report1: TDataSource;
db_report: TppDBPipeline;
ppDataDictionary1: TppDataDictionary;
bsSkinInputDialog1: TbsSkinInputDialog;
bsSkinDBEdit1: TbsSkinDBEdit;
one_table_1: TppDBPipeline;
all_table_3: TppDBPipeline;
all_table_1: TppDBPipeline;
all_table_2: TppDBPipeline;
one_table_2: TppDBPipeline;
one_table_3: TppDBPipeline;
dxDBGrid1Column2: TdxDBGridCheckColumn;
one_table_4: TppDBPipeline;
all_table_4: TppDBPipeline;
all_table_5: TppDBPipeline;
all_table_6: TppDBPipeline;
all_table_7: TppDBPipeline;
print_head: TppDBPipeline;
load_employee: TppDBPipeline;
bsSkinPanel1: TbsSkinPanel;
Label1: TLabel;
DBEdit1: TDBEdit;
Label2: TLabel;
DBEdit2: TDBEdit;
Button5: TButton;
PopupMenu1: TPopupMenu;
XPMenu1: TXPMenu;
N1: TMenuItem;
N2: TMenuItem;
EXCEL1: TMenuItem;
N3: TMenuItem;
WORD1: TMenuItem;
N4: TMenuItem;
PDF1: TMenuItem;
N5: TMenuItem;
RTF1: TMenuItem;
ImageList: TImageList;
OpenDialog1: TOpenDialog;
rp: TppReport;
rd: TppDesigner;
t_sys_report_employee: TADOQuery;
bsSkinPanel2: TbsSkinPanel;
bsSkinButton12: TbsSkinButton;
bsSkinPanel4: TbsSkinPanel;
bsSkinButton6: TbsSkinButton;
bsSkinButton8: TbsSkinButton;
bsSkinButton7: TbsSkinButton;
bsSkinButton3: TbsSkinButton;
bsSkinButton4: TbsSkinButton;
bsSkinButton9: TbsSkinButton;
bsSkinButton1: TbsSkinButton;
bsSkinButton2: TbsSkinButton;
bsSkinButton10: TbsSkinButton;
bsSkinButton11: TbsSkinButton;
bsSkinButton5: TbsSkinButton;
t_sys_report_lei: TADOQuery;
t_sys_reportfile: TADOQuery;
t_sys_reportfile1: TDataSource;
bsSkinCheckRadioBox1: TbsSkinCheckRadioBox;
ExtraOptions1: TExtraOptions;
procedure bsSkinButton8Click(Sender: TObject);
procedure bsSkinButton2Click(Sender: TObject);
procedure bsSkinButton5Click(Sender: TObject);
procedure bsSkinButton3Click(Sender: TObject);
procedure bsSkinButton4Click(Sender: TObject);
procedure bsSkinButton9Click(Sender: TObject);
procedure bsSkinButton1Click(Sender: TObject);
procedure bsSkinButton6Click(Sender: TObject);
procedure rdCloseQuery(Sender: TObject; var CanClose: Boolean);
procedure FormShow(Sender: TObject);
procedure Button5Click(Sender: TObject);
procedure bsSkinButton7Click(Sender: TObject);
procedure N1Click(Sender: TObject);
procedure EXCEL1Click(Sender: TObject);
procedure WORD1Click(Sender: TObject);
procedure PDF1Click(Sender: TObject);
procedure RTF1Click(Sender: TObject);
procedure bsSkinButton10Click(Sender: TObject);
procedure bsSkinButton11Click(Sender: TObject);
procedure dxDBGrid1KeyPress(Sender: TObject; var Key: Char);
procedure t_sys_reportAfterPost(DataSet: TDataSet);
procedure bsSkinButton12Click(Sender: TObject);
procedure t_sys_reportAfterOpen(DataSet: TDataSet);
procedure t_sys_reportBeforeClose(DataSet: TDataSet);
procedure t_sys_reportfileAfterInsert(DataSet: TDataSet);
procedure t_sys_reportfileAfterPost(DataSet: TDataSet);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
{ Public declarations }
end;
var
frm_sys_print: Tfrm_sys_print;
implementation
uses u_main,u_sys_print_view, u_data_share, u_code_send_head,
my_sys_function, u_sys_print_down;
{$R *.dfm}
procedure Tfrm_sys_print.bsSkinButton8Click(Sender: TObject);
begin
if t_sys_report.isempty then
exit;
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
if t_sys_reportfile.isempty then
begin
showmessage('û<>д<EFBFBD>ӡ<EFBFBD><D3A1>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
exit;
end;
try
rp.template.DatabaseSettings.Name:=t_sys_reportfile.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
rp.template.LoadFromDatabase;
rp.AllowPrintToFile:=false;
rp.DeviceType:='Printer';
rp.Print;
except
showmessage('<27><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end;
if frm_sys_print.caption='<27><><EFBFBD>˳<EFBFBD><CBB3>ڵ<EFBFBD>֤' then
begin
if not t_sys_report_employee.Locate('CH_ID',t_sys_report.fieldbyname('CH_ID').asinteger,[])then
begin
t_sys_report_employee.insert;
t_sys_report_employee['CH_ID']:=t_sys_report['CH_ID'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=t_sys_report['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=employee;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end
else
begin
t_sys_report_employee.edit;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end;
end;
end;
procedure Tfrm_sys_print.bsSkinButton2Click(Sender: TObject);
var
book1:Tbookmark;
str:string;
begin
try
t_sys_report.DisableControls;
book1:=t_sys_report.GetBookmark;
str:=t_sys_report.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring;
t_sys_report.First;
while not t_sys_report.eof do
begin
if t_sys_report.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring=str then
begin
t_sys_report.edit;
t_sys_report['<27>Ƿ<EFBFBD>Ĭ<EFBFBD><C4AC>']:=1;
t_sys_report.post;
end
else
begin
t_sys_report.edit;
t_sys_report['<27>Ƿ<EFBFBD>Ĭ<EFBFBD><C4AC>']:=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_print.bsSkinButton5Click(Sender: TObject);
begin
close;
end;
procedure Tfrm_sys_print.bsSkinButton3Click(Sender: TObject);
begin
if t_sys_report.IsEmpty then begin
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select top 0 * from t_sys_report ');
t_sys_reportfile.Open;
end else begin
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
end;
if t_sys_reportfile.RecordCount<>0 then
rp.template.DatabaseSettings.name :='';
rp.AllowPrintToFile:=true;
rd.ShowModal;
end;
procedure Tfrm_sys_print.bsSkinButton4Click(Sender: TObject);
begin
if t_sys_report.isempty then
exit;
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
if t_sys_reportfile.isempty then
begin
showmessage('û<><C3BB>Ҫ<EFBFBD><D2AA><EFBFBD>Ƶĸ<C6B5>ʽ<EFBFBD><CABD>');
exit;
end;
try
rp.template.DatabaseSettings.Name:=t_sys_reportfile.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
rp.template.LoadFromDatabase;
rp.AllowPrintToFile:=true;
rd.ShowModal;
except
showmessage('<27><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end;
if frm_sys_print.caption='<27><><EFBFBD>˳<EFBFBD><CBB3>ڵ<EFBFBD>֤' then
begin
if not t_sys_report_employee.Locate('CH_ID',t_sys_reportfile.fieldbyname('CH_ID').asinteger,[])then
begin
t_sys_report_employee.insert;
t_sys_report_employee['CH_ID']:=t_sys_reportfile['CH_ID'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=t_sys_reportfile['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=employee;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end
else
begin
t_sys_report_employee.edit;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end;
end;
end;
procedure Tfrm_sys_print.bsSkinButton9Click(Sender: TObject);
begin
if t_sys_report.isempty then
begin
showmessage('û<><C3BB>Ҫɾ<D2AA><C9BE><EFBFBD>ĸ<EFBFBD>ʽ<EFBFBD><CABD>');
exit;
end;
if application.MessageBox('<27><>ȷ<EFBFBD><C8B7>Ҫɾ<D2AA><C9BE><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>?','<27><><EFBFBD><EFBFBD>:',MB_OKCANCEL)=IDOK then
t_sys_report.delete;
end;
procedure Tfrm_sys_print.bsSkinButton1Click(Sender: TObject);
begin
if t_sys_report.isempty then
begin
showmessage('û<><C3BB>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƶĸ<C6B5>ʽ<EFBFBD><CABD>');
exit;
end;
t_sys_report.edit;
t_sys_report['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=bsSkinInputDialog1.InputBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>','<27>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>',t_sys_report.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').asstring);
t_sys_report.post;
end;
procedure Tfrm_sys_print.bsSkinButton6Click(Sender: TObject);
begin
if t_sys_report.isempty then
exit;
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
if t_sys_reportfile.isempty then
exit;
try
rp.template.DatabaseSettings.Name:=t_sys_reportfile.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').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('<27><>ӡԤ<D3A1><D4A4>ʧ<EFBFBD>ܣ<EFBFBD>');
end;
if frm_sys_print.caption='<27><><EFBFBD>˳<EFBFBD><CBB3>ڵ<EFBFBD>֤' then
begin
if not t_sys_report_employee.Locate('CH_ID',t_sys_reportfile.fieldbyname('CH_ID').asinteger,[])then
begin
t_sys_report_employee.insert;
t_sys_report_employee['CH_ID']:=t_sys_reportfile['CH_ID'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=t_sys_reportfile['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=employee;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end
else
begin
t_sys_report_employee.edit;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end;
end;
end;
procedure Tfrm_sys_print.rdCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
if rd.Report.Modified then
begin
case Application.MessageBox('<27>Ƿ<EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><E6B1A8><EFBFBD><EFBFBD>','<27><>ʾ',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_print.FormShow(Sender: TObject);
begin
if not if_open('170') then
begin
bsSkinButton3.Enabled:=false;
bsSkinButton4.Enabled:=false;
bsSkinButton9.Enabled:=false;
bsSkinButton1.Enabled:=false;
bsSkinButton2.Enabled:=false;
bsSkinButton10.Enabled:=false;
bsSkinButton11.Enabled:=false;
end;
// frm_data_share.t_sys_report_head.Requery();
// frm_data_share.t_load_employee.Requery();
if not frm_data_share.t_sys_report_head.IsEmpty then
begin
frm_data_share.t_sys_report_head.edit;
frm_data_share.t_sys_report_head['̨ͷTO']:='';
frm_data_share.t_sys_report_head['̨ͷATTN']:='';
frm_data_share.t_sys_report_head.post;
end;
if frm_sys_print.caption='<27><><EFBFBD>˳<EFBFBD><CBB3>ڵ<EFBFBD>֤' then
bsSkinPanel2.Visible:=true;
rd.Caption:=frm_sys_print.caption;
t_sys_report_lei.close;
t_sys_report_lei.Parameters.ParamByName('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').Value:=rd.Caption;
t_sys_report_lei.open;
// rd.XHD_help:=t_sys_report_lei.fieldbyname('<27><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5>').asstring;
end;
procedure Tfrm_sys_print.Button5Click(Sender: TObject);
begin
try
frm_code_send_head:=tfrm_code_send_head.Create (self);
code_send_head_num:=2;
frm_code_send_head.ShowModal;
finally
frm_code_send_head.Free;
frm_code_send_head:=nil;
end;
end;
procedure Tfrm_sys_print.bsSkinButton7Click(Sender: TObject);
var
Pnt:Tpoint;
begin
Pnt:=bsSkinButton7.ClientToScreen(Point(0,bsSkinButton7.Height));
PopupMenu1.Popup(Pnt.x,Pnt.y);
if frm_sys_print.caption='<27><><EFBFBD>˳<EFBFBD><CBB3>ڵ<EFBFBD>֤' then
begin
if not t_sys_report_employee.Locate('CH_ID',t_sys_report.fieldbyname('CH_ID').asinteger,[])then
begin
t_sys_report_employee.insert;
t_sys_report_employee['CH_ID']:=t_sys_report['CH_ID'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=t_sys_report['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=employee;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end
else
begin
t_sys_report_employee.edit;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end;
end;
end;
procedure Tfrm_sys_print.N1Click(Sender: TObject);
begin
if t_sys_report.isempty then
exit;
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
if t_sys_reportfile.isempty then
begin
showmessage('û<>д<EFBFBD>ӡ<EFBFBD><D3A1>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>Ϊ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>');
exit;
end;
try
rp.template.DatabaseSettings.Name:=t_sys_reportfile.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
rp.template.LoadFromDatabase;
rp.DeviceType:='GraphicFile';
rp.AllowPrintToFile:=true;
rp.Print;
except
showmessage('<27><>Ϊ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end;
end;
procedure Tfrm_sys_print.EXCEL1Click(Sender: TObject);
begin
if t_sys_report.isempty then
exit;
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
if t_sys_reportfile.isempty then
begin
showmessage('û<>д<EFBFBD>ӡ<EFBFBD><D3A1>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>Ϊ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>');
exit;
end;
try
rp.template.DatabaseSettings.Name:=t_sys_reportfile.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
rp.template.LoadFromDatabase;
rp.DeviceType:='ExcelFile';
rp.AllowPrintToFile:=true;
rp.Print;
except
showmessage('<27><>Ϊ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end;
end;
procedure Tfrm_sys_print.WORD1Click(Sender: TObject);
begin
if t_sys_report.isempty then
exit;
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
if t_sys_reportfile.isempty then
begin
showmessage('û<>д<EFBFBD>ӡ<EFBFBD><D3A1>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>Ϊ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>');
exit;
end;
try
rp.template.DatabaseSettings.Name:=t_sys_reportfile.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
rp.template.LoadFromDatabase;
rp.DeviceType:='HTMLFile';
rp.AllowPrintToFile:=true;
rp.Print;
except
showmessage('<27><>Ϊ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end;
end;
procedure Tfrm_sys_print.PDF1Click(Sender: TObject);
begin
if t_sys_report.isempty then
exit;
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
if t_sys_reportfile.isempty then
begin
showmessage('û<>д<EFBFBD>ӡ<EFBFBD><D3A1>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>Ϊ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>');
exit;
end;
try
rp.template.DatabaseSettings.Name:=t_sys_reportfile.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
rp.template.LoadFromDatabase;
rp.DeviceType:='PDFFile';
rp.AllowPrintToFile:=true;
rp.Print;
except
showmessage('<27><>Ϊ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end;
end;
procedure Tfrm_sys_print.RTF1Click(Sender: TObject);
begin
if t_sys_report.isempty then
exit;
t_sys_reportfile.Close;
t_sys_reportfile.SQL.Clear;
t_sys_reportfile.SQL.Add('select * from t_sys_report where CH_ID='+inttostr(t_sys_report['CH_ID']));
t_sys_reportfile.Open;
if t_sys_reportfile.isempty then
begin
showmessage('û<>д<EFBFBD>ӡ<EFBFBD><D3A1>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD>ܴ<EFBFBD>Ϊ<EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>');
exit;
end;
try
rp.template.DatabaseSettings.Name:=t_sys_reportfile.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
rp.template.LoadFromDatabase;
rp.DeviceType:='RTFFile';
rp.AllowPrintToFile:=true;
rp.Print;
except
showmessage('<27><>Ϊ<EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD>');
end;
end;
procedure Tfrm_sys_print.bsSkinButton10Click(Sender: TObject);
var
IdFTP1:TIdFTP;
begin
// GetNewData('t_sys_report','CH_ID','',t_sys_reportfile);
{
try
IdFTP1:=TIdFTP.Create(application);
with idftp1 do
begin
Username:='dongsheng';
Password:='zouwenkun';
Host:='218.57.11.18';
Connect;
end;
idftp1.Disconnect;
update_jiandu;
try
if not assigned(frm_sys_print_down) then
frm_sys_print_down:=tfrm_sys_print_down.Create (self);
frm_sys_print_down.Caption:=frm_sys_print.Caption;
frm_sys_print_down.ShowModal;
finally
frm_sys_print_down.free;
frm_sys_print_down:=NIL;
end;
except
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD>ط<EFBFBD><D8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
end;
idftp1.free;
}
end;
procedure Tfrm_sys_print.bsSkinButton11Click(Sender: TObject);
var
IdFTP1:TIdFTP;
str:widestring;
str_file:widestring;
begin
if not OpenDialog1.Execute then
exit;
try
str:=OpenDialog1.FileName;
str_file:=frm_data_share.t_sys_company.fieldbyname('<27><><EFBFBD><EFBFBD>').AsString
+'@'+employee+'%'+frm_sys_print.caption+'&'
+FormatDateTime('yyyy',now)
+FormatDateTime('mm',now)
+FormatDateTime('dd',now)
+FormatDateTime('hh',now)
+FormatDateTime('nn',now)+'.'+copy(str,pos('.',str)+1,length(str)-pos('.',str));
IdFTP1:=TIdFTP.Create(application);
with idftp1 do
begin
Username:='dongsheng';
Password:='zouwenkun';
Host:='218.57.11.18';
Connect;
end;
con_net:=false;
idftp1.ChangeDir('/XHD');
idftp1.TransferType:=ftBinary;
idftp1.Put(str,str_file);
idftp1.Disconnect;
update_jiandu;
showmessage('<27><><EFBFBD><EFBFBD><EBB1A8><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>');
except
con_net:=true;
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB1A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
end;
idftp1.Free;
end;
procedure Tfrm_sys_print.dxDBGrid1KeyPress(Sender: TObject; var Key: Char);
var
IdFTP1:TIdFTP;
str_rtm,do_file,str_tell:widestring;
begin
if key<>'~'then
exit;
if t_sys_report.IsEmpty then
exit;
do_file:=trim(InputBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>', '<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ƣ<EFBFBD>', ''));
if do_file='' then
begin
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>±<EFBFBD><C2B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ʋ<EFBFBD><C6B2><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD>');
exit;
end;
str_tell:=trim(InputBox('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EBB1A8>˵<EFBFBD><CBB5>', '<27><><EFBFBD><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD>', ''));
if str_tell='' then
begin
showmessage('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϴ<EFBFBD><CFB4>±<EFBFBD><C2B1><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><D5A3><EFBFBD>');
exit;
end; //<2F><><EFBFBD><EFBFBD>^<5E><><EFBFBD><EFBFBD>#<23><><EFBFBD><EFBFBD><><CBB5>&.rtm
str_rtm:='$'+frm_sys_print.caption
+'^'+do_file
+'#'+datetostr(date)
+'~'+str_tell
+'&.rtm';
if not DirectoryExists(ExtractFilePath(Application.ExeName)+'update') then
CreateDir(ExtractFilePath(Application.ExeName)+'update');
try
rp.template.DatabaseSettings.Name:=t_sys_report.fieldbyname('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>').AsString;
rp.template.LoadFromDatabase;
rp.AllowPrintToFile:=true;
rp.Template.FileName:=ExtractFilePath(Application.ExeName)+'update\'+str_rtm;
rp.Template.SaveToFile;
except
showmessage('<27><><EFBFBD>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>ļ<EFBFBD>ʧ<EFBFBD>ܣ<EFBFBD><DCA3><EFBFBD>');
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('<27>ϴ<EFBFBD><CFB4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɹ<EFBFBD><C9B9><EFBFBD><EFBFBD><EFBFBD>');
end;
procedure Tfrm_sys_print.t_sys_reportAfterPost(DataSet: TDataSet);
begin
if frm_sys_print.caption='<27><><EFBFBD>˳<EFBFBD><CBB3>ڵ<EFBFBD>֤' then
begin
if not t_sys_report_employee.Locate('CH_ID',t_sys_report.fieldbyname('CH_ID').asinteger,[])then
begin
t_sys_report_employee.insert;
t_sys_report_employee['CH_ID']:=t_sys_report['CH_ID'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=t_sys_report['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=employee;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end
else
begin
t_sys_report_employee.edit;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end;
end;
end;
procedure Tfrm_sys_print.bsSkinButton12Click(Sender: TObject);
var
str:widestring;
begin
if bsSkinButton12.caption='<27><><EFBFBD>и<EFBFBD>ʽ'then
begin
bsSkinButton12.caption:='<27><><EFBFBD>ڸ<EFBFBD>ʽ';
t_sys_reportfile.close;
t_sys_report.close;
t_sys_report.sql.clear;
t_sys_report.sql.add('select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ƿ<EFBFBD>Ĭ<EFBFBD><C4AC>,CH_ID from t_sys_report where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
t_sys_report.Parameters[0].value:=frm_sys_print.caption;
t_sys_report.open;
t_sys_reportfile.Open;
end
else
begin
if not t_sys_report_employee.IsEmpty then
begin
t_sys_report_employee.first;
while not t_sys_report_employee.eof do
begin
if t_sys_report_employee.fieldbyname('<27><><EFBFBD><EFBFBD>').AsDateTime>=date-30 then
begin
if str='' then
str:=t_sys_report_employee.fieldbyname('CH_ID').asstring
else
str:=str+','+t_sys_report_employee.fieldbyname('CH_ID').asstring;
end;
t_sys_report_employee.next;
end;
str:=' and CH_ID in ('+str+')';
t_sys_reportfile.close;
t_sys_report.close;
t_sys_report.sql.clear;
t_sys_report.sql.add('select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ƿ<EFBFBD>Ĭ<EFBFBD><C4AC>,CH_ID from t_sys_report where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> '+str+' order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
t_sys_report.Parameters[0].value:=frm_sys_print.caption;
t_sys_report.open;
t_sys_reportfile.Open;
end
else
begin
t_sys_reportfile.close;
t_sys_report.close;
t_sys_report.sql.clear;
t_sys_report.sql.add('select <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,<2C>Ƿ<EFBFBD>Ĭ<EFBFBD><C4AC>,CH_ID from t_sys_report where <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>=:<3A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> order by <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>');
t_sys_report.Parameters[0].value:=frm_sys_print.caption;
t_sys_report.open;
t_sys_reportfile.Open;
end;
bsSkinButton12.caption:='<27><><EFBFBD>и<EFBFBD>ʽ';
end;
end;
procedure Tfrm_sys_print.t_sys_reportAfterOpen(DataSet: TDataSet);
begin
// t_sys_reportfile.Open;
end;
procedure Tfrm_sys_print.t_sys_reportBeforeClose(DataSet: TDataSet);
begin
// t_sys_reportfile.Close;
end;
procedure Tfrm_sys_print.t_sys_reportfileAfterInsert(DataSet: TDataSet);
begin
t_sys_reportfile['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=frm_sys_print.Caption;
end;
procedure Tfrm_sys_print.t_sys_reportfileAfterPost(DataSet: TDataSet);
begin
t_sys_report.Refresh;
if frm_sys_print.caption='<27><><EFBFBD>˳<EFBFBD><CBB3>ڵ<EFBFBD>֤' then
begin
if not t_sys_report_employee.Locate('CH_ID',t_sys_report.fieldbyname('CH_ID').asinteger,[])then
begin
t_sys_report_employee.insert;
t_sys_report_employee['CH_ID']:=t_sys_report['CH_ID'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>']:=t_sys_report['<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'];
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=employee;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end
else
begin
t_sys_report_employee.edit;
t_sys_report_employee['<27><><EFBFBD><EFBFBD>']:=date;
t_sys_report_employee.post;
end;
end;
end;
procedure Tfrm_sys_print.FormClose(Sender: TObject;
var Action: TCloseAction);
var
inifile1:Tinifile;
begin
inifile1:=Tinifile.Create(ExtractFilePath(application.ExeName)+'main.ini');
inifile1.WriteBool('RPT','NEW',bsSkinCheckRadioBox1.Checked);
inifile1.free;
end;
end.