unit U_LabelPrintSql; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, cxStyles, cxCustomData, cxGraphics, cxFilter, cxData, cxDataStorage, cxEdit, DB, cxDBData, ToolWin, ComCtrls, U_BaseHelp, cxGridCustomTableView, cxGridTableView, cxGridDBTableView, cxGridLevel, cxClasses, cxControls, cxGridCustomView, cxGrid, DBClient, ADODB, ImgList, StdCtrls, ExtCtrls, cxTextEdit, cxGridCustomPopupMenu, cxGridPopupMenu, cxLookAndFeels, cxLookAndFeelPainters, dxSkinsCore, dxSkinsDefaultPainters, cxNavigator, dxDateRanges, dxBarBuiltInMenu, System.ImageList, U_BaseInput, RM_Common, RM_Class, RM_GridReport, RM_Dataset, Vcl.Buttons, RM_E_llPDF, RM_BarCode, RM_e_Graphic, RM_e_Jpeg, RM_e_Xls, cxContainer, cxMaskEdit, cxDropDownEdit, cxMRUEdit; type TfrmLabelPrintSql = class(TfrmBaseHelp) ADOQueryTemp: TADOQuery; ADOConnection1: TADOConnection; Panel1: TPanel; ImageList1: TImageList; RMDB_1: TRMDBDataSet; RM1: TRMGridReport; RMDB_2: TRMDBDataSet; ADO_1: TADOQuery; btnPrint: TSpeedButton; btnShow: TSpeedButton; ADO_2: TADOQuery; RMDB_3: TRMDBDataSet; ADO_3: TADOQuery; RMXLSExport1: TRMXLSExport; RMJPEGExport1: TRMJPEGExport; RMBarCodeObject1: TRMBarCodeObject; RMllPDFExport1: TRMllPDFExport; CheckBox1: TCheckBox; ComboBox1: TComboBox; Label1: TLabel; CheckBox2: TCheckBox; procedure FormCreate(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormShow(Sender: TObject); procedure FormDestroy(Sender: TObject); procedure TV1DblClick(Sender: TObject); procedure btnPrintClick(Sender: TObject); procedure btnShowClick(Sender: TObject); private procedure PrintLabel(MIsShow: Boolean); { Private declarations } public FPreviewPrint, IsWhile: Boolean; MSQLS: TStringList; { Public declarations } end; var frmLabelPrintSql: TfrmLabelPrintSql; implementation uses U_DataLink, U_RTFun, U_LabelPrint; {$R *.dfm} procedure TfrmLabelPrintSql.PrintLabel(MIsShow: Boolean); var fPrintFile, fPrintFile10, FMainID, LBName: string; i: Integer; begin RMllPDFExport1.ShowDialog := CheckBox2.Checked; RMJPEGExport1.ShowDialog := CheckBox2.Checked; RMXLSExport1.ShowDialog := CheckBox2.Checked; RM1.ShowPrintDialog := CheckBox1.Checked; for i := 1 to MSQLS.Count do begin with ADO_1 do begin Close; sql.Clear; sql.add(MSQLS[i - 1]); Open; end; LBName := Trim(ADO_1.FieldByName('LBName').AsString); if LBName <> '' then begin ExportFtErpFile(LBName + '.rmf', ADOQueryTemp); fPrintFile := ExtractFilePath(Application.ExeName) + 'Report\' + LBName + '.rmf'; if FileExists(fPrintFile) then begin RM1.LoadFromFile(fPrintFile); RM1.DefaultCopies := StrToIntDef(ComboBox1.Text, 1); RMVariables['LBPrtCode'] := dcode; RMVariables['LBPrtName'] := dname; if MIsShow then RM1.ShowReport else RM1.PrintReport; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end else begin Application.MessageBox(PChar('没有找' + fPrintFile), '提示', 0); Exit; end; end; end; procedure TfrmLabelPrintSql.FormCreate(Sender: TObject); begin inherited; FPreviewPrint := True; try with ADOConnection1 do begin Connected := false; ConnectionString := DConString; Connected := true; end; ADOQueryBaseCmd.Connection := ADOConnection1; ADOQueryBaseTemp.Connection := ADOConnection1; except {if Application.MessageBox('网络连接失败,是否要再次连接?','提示',32+4)=IDYES then begin try with ADOConnection1 do begin Connected:=false; ConnectionString:=DConString; //ConnectionString:='23242'; Connected:=true; end; except end; end; } end; end; procedure TfrmLabelPrintSql.btnPrintClick(Sender: TObject); var i: Integer; begin PrintLabel(False); ModalResult := 1; end; procedure TfrmLabelPrintSql.btnShowClick(Sender: TObject); begin PrintLabel(true); end; procedure TfrmLabelPrintSql.FormClose(Sender: TObject; var Action: TCloseAction); begin inherited; Action := cahide; end; procedure TfrmLabelPrintSql.FormShow(Sender: TObject); begin inherited; if FPreviewPrint then RM1.PreviewButtons := [rmpbZoom, rmpbLoad, rmpbSave, rmpbPrint, rmpbFind, rmpbPageSetup, rmpbExit, rmpbSaveToXLS, rmpbExport, rmpbNavigator] else RM1.PreviewButtons := [rmpbZoom, rmpbLoad, rmpbSave, rmpbFind, rmpbPageSetup, rmpbExit, rmpbSaveToXLS, rmpbExport, rmpbNavigator]; end; procedure TfrmLabelPrintSql.TV1DblClick(Sender: TObject); begin ModalResult := 1; end; procedure TfrmLabelPrintSql.FormDestroy(Sender: TObject); begin inherited; frmLabelPrint := nil; end; end.