private void GenerateGrid() { CompositeLink composLink = new CompositeLink(new PrintingSystem()); PrintableComponentLink pcLink1 = new PrintableComponentLink(); Link linkMainReport = new Link(); Link linkGrid1Report = new Link(); linkGrid1Report.CreateDetailArea += new CreateAreaEventHandler(linkGrid1Report_CreateDetailArea); // Assign the controls to the printing links. pcLink1.Component = this.ThirdGridIncomeAnalysis; // Populate the collection of links in the composite link. // The order of operations corresponds to the document structure. composLink.Links.Add(linkGrid1Report); composLink.Links.Add(pcLink1); composLink.Links.Add(linkMainReport); // Create the report and show the preview window. //composLink.PrintingSystem.PreviewFormEx.AutoScale = true; composLink.PrintingSystem.PageSettings.Landscape = true; composLink.CreateDocument(printingSystem1); printingSystem1.PreviewFormEx.PrintingSystem.PageSettings.LeftMargin = 0; printingSystem1.PreviewFormEx.PrintingSystem.PageSettings.TopMargin = 30; //printingSystem1.PreviewFormEx.AutoScale = true; printingSystem1.PageSettings.Landscape = true; printingSystem1.PreviewFormEx.ForeColor = System.Drawing.Color.Black; printingSystem1.PreviewFormEx.Owner = this; printingSystem1.PreviewFormEx.PrintingSystem.Print(); }
private void barPrint_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()) { Component = this.gridControl1, Landscape = true, PaperKind = System.Drawing.Printing.PaperKind.A3 }; link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea); link.CreateDocument(); link.ShowPreview(); }
void m_cmd_xuat_pdf_Click(object sender, EventArgs e) { try { // Check whether the ChartControl can be previewed. if (!chartControl1.IsPrintingAvailable) { CHRM_BaseMessages.MsgBox_Error("The 'DevExpress.XtraPrinting' is not found"); return; } // Open the Preview window. PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()); link.Component = chartControl1; chartControl1.OptionsPrint.SizeMode = PrintSizeMode.Stretch; //chartControl1.Legend.MaxVerticalPercentage = 100; link.Landscape = true; link.PaperKind = System.Drawing.Printing.PaperKind.A4; link.ShowPreview(); // Specify the paper kind and page orientation. //chartControl1.Legend.MaxVerticalPercentage = 100; //chartControl1.Legend.Direction = DevExpress.XtraCharts.LegendDirection.TopToBottom; //chartControl1.ShowPrintPreview(DevExpress.XtraCharts.Printing.PrintSizeMode.Zoom); } catch (Exception v_e) { CSystemLog_301.ExceptionHandle(v_e); } }
private void galleryControlGallery1_ItemClick(object sender, DevExpress.XtraBars.Ribbon.GalleryItemClickEventArgs e) { string index = string.Format("{0}", e.Item.Tag); frmMain frm = BackstageView.Ribbon.FindForm() as frmMain; if(frm == null) return; if(index.Contains("PDF")) saveFileDialog1.Filter = Properties.Resources.PDFFilter; else if(index.Contains("HTML")) saveFileDialog1.Filter = Properties.Resources.HTMLFilter; else if(index.Contains("MHT")) saveFileDialog1.Filter = Properties.Resources.MHTFilter; else if(index.Contains("RTF")) saveFileDialog1.Filter = Properties.Resources.RTFFilter; else if(index.Contains("XLS")) saveFileDialog1.Filter = Properties.Resources.XLSFilter; else if(index.Contains("XLSX")) saveFileDialog1.Filter = Properties.Resources.XLSXFilter; else if(index.Contains("CSV")) saveFileDialog1.Filter = Properties.Resources.CSVFilter; else if(index.Contains("Text")) saveFileDialog1.Filter = Properties.Resources.TextFilter; else if(index.Contains("Image")) saveFileDialog1.Filter = Properties.Resources.ImageFilter; saveFileDialog1.Filter += "|" + Properties.Resources.AllFilesFilter; saveFileDialog1.FilterIndex = 0; saveFileDialog1.FileName = frm.CurrentModuleName; if(saveFileDialog1.ShowDialog() != DialogResult.OK) return; Cursor.Current = Cursors.WaitCursor; PrintingSystem ps = new PrintingSystem(); PrintableComponentLink link = new PrintableComponentLink(ps); link.Component = frm.CurrentExportComponent; link.CreateDocument(); ExportTo(index, saveFileDialog1.FileName, ps); }
private void btnPrint_Click(object sender, EventArgs e) { grdViewSTVForChecking.OptionsPrint.AutoWidth = true; var pcLink = new PrintableComponentLink(new PrintingSystem()) {Component = grdSTVs, Landscape = true}; pcLink.CreateDocument(); pcLink.ShowPreviewDialog(); }
private void btnYazdir_Click(object sender, EventArgs e) { PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()); link.Component = grid; link.Landscape = true; link.PaperKind = System.Drawing.Printing.PaperKind.A4; link.ShowPreview(); }
public PrintableComponentLink GetPrintLink() { advBandedGridViewData.CheckLoaded(); var printLink = new PrintableComponentLink() { Landscape = true, PaperKind = PaperKind.A4, Component = gridControlData }; return printLink; }
private void CustomizePrintingSystem(PrintableComponentLink link) { link.PrintingSystem.PrintProgress += delegate(object send, PrintProgressEventArgs prArgs) { lastPrinterName = prArgs.PageSettings.PrinterSettings.PrinterName; using (System.IO.StreamWriter file = new System.IO.StreamWriter("PrintInfo")) { file.WriteLine(lastPrinterName); } }; }
public PrintableComponentLink GetPrintLink() { gridViewData.CheckLoaded(); var printLink = new PrintableComponentLink() { Landscape = true, PaperKind = PaperKind.A4, Component = gridControlData }; printLink.CreateReportHeaderArea += OnCreateReportHeaderArea; return printLink; }
public void DoPivoitPrint(PivotGridControl pivotGridControl, bool landscape = true) { var link = new PrintableComponentLink(new PrintingSystem()) { Margins = { Left = 10, Right = 10, Top = 110, Bottom = 90 }, Landscape = landscape, PaperKind = PaperKind.A4, Component = pivotGridControl }; var footer = new PageFooterArea(); footer.Content.Add("Printed on " + "[Date Printed]" + " by " + Utils.Username); footer.Content.Add("Page " + "[Page #]"); footer.LineAlignment = BrickAlignment.Near; var header = new PageHeaderArea(); link.CreateMarginalHeaderArea += CreateMarginalDetailHeaderArea; link.CreateMarginalFooterArea += CreateMarginalFooterArea; link.PageHeaderFooter = new PageHeaderFooter(header, footer); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Save, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Watermark, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.FillBackground, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.HandTool, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Customize, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Scale, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Parameters, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SubmitParameters, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Background, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.None, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.None); link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Document"].Visible = false; link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Background"].Visible = false; link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Zoom"].Visible = false; link.CreateDocument(); link.PrintingSystem.Document.AutoFitToPagesWidth = 1; link.ShowRibbonPreview(UserLookAndFeel.Default); }
public override void LoadPrintingSettings(PrintableComponentLink printableComponentLink) { base.LoadPrintingSettings(printableComponentLink); if (File.Exists("PrintInfo") && new FileInfo("PrintInfo").Length != 0) { printableComponentLink.PrintingSystem.PageSettings.PrinterName = File.ReadAllLines("PrintInfo")[0]; printableComponentLink.PrintingSystem.PageSettings.Landscape = PrintingSettings.Landscape; printableComponentLink.PrintingSystem.PageSettings.PageSettings.Margins = PrintingSettings.Margins; printableComponentLink.PrintingSystem.PageSettings.PageSettings.Landscape = PrintingSettings.Landscape; } else { printableComponentLink.PrintingSystem.PageSettings.Landscape = PrintingSettings.Landscape; printableComponentLink.PrintingSystem.PageSettings.PageSettings.Landscape = PrintingSettings.Landscape; printableComponentLink.PrintingSystem.PageSettings.PageSettings.Margins = PrintingSettings.Margins; printableComponentLink.PrintingSystem.PageSettings.PrinterName = lastPrinterName; } }
protected void ASPxButton2_Click(object sender, EventArgs e) { using (MemoryStream ms = new MemoryStream()) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = ASPxGridViewExporter3; pcl.Margins.Left = pcl.Margins.Right = 0; pcl.Margins.Top = 50; pcl.Landscape = true; pcl.CreateDocument(true); pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1; PageHeaderFooter phf = pcl.PageHeaderFooter as PageHeaderFooter; phf.Header.Content.Clear(); //phf.Header.Content.AddRange(new string[] { leftColumn, middleColumn, rightColumn }); phf.Header.LineAlignment = BrickAlignment.Far; pcl.ExportToPdf(ms); WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Attachment.ToString()); } }
/// <summary> /// Initializes a new instance of the <see cref="XtraPrintService"/> class. /// </summary> /// <param name="printable">The printable.</param> public XtraPrintService(IPrintable printable) { printSystem = new PrintingSystem(); printSystem.ShowMarginsWarning = false; PrintableComponentLink pcl = new PrintableComponentLink(printSystem); pcl.CreateMarginalHeaderArea += new CreateAreaEventHandler(pcl_CreateMarginalHeaderArea); pcl.CreateMarginalFooterArea += new CreateAreaEventHandler(pcl_CreateMarginalFooterArea); pcl.Component = printable; printSystem.Links.Add(pcl); PrinterSettingsUsing pst = new PrinterSettingsUsing(); pst.UseMargins = false; pst.UsePaperKind = false; printSystem.PageSettings.PaperKind = PaperKind.A4; printSystem.PageSettings.PaperName = "A4"; printSystem.PageSettings.LeftMargin = 5; printSystem.PageSettings.RightMargin = 5; printSystem.PageSettings.AssignDefaultPrinterSettings(pst); }
public static void DevPrint(GridControl gc,String printHeader) { var ps = new PrintingSystem(); var link = new PrintableComponentLink(ps); ps.Links.Add(link); link.Component = gc;//这里可以是可打印的部件 var phf = link.PageHeaderFooter as PageHeaderFooter; if (phf != null) { phf.Header.Content.Clear(); phf.Header.Content.AddRange(new[] { "", printHeader, "" }); phf.Header.Font = new System.Drawing.Font("宋体", 14, System.Drawing.FontStyle.Bold); phf.Header.LineAlignment = BrickAlignment.Center; } link.CreateDocument(); //建立文档 ps.PreviewFormEx.Show(); }
public ReportCenter(IPrintable Printable, string ReportName, string Condition) { printSystem = new PrintingSystem(); mReportName = ReportName; mCondition = Condition; PrintableComponentLink pcl = new PrintableComponentLink(); pcl.CreateMarginalHeaderArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalHeaderArea); pcl.CreateMarginalFooterArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalFooterArea); pcl.Component = Printable; printSystem.Links.Add(pcl); pcl.CreateDocument(); PrinterSettingsUsing pst = new PrinterSettingsUsing(); pst.UseMargins = true; //pst.UsePaperKind = false; printSystem.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4; printSystem.PageSettings.PaperName = "A4"; printSystem.PageSettings.LeftMargin = 30; printSystem.PageSettings.RightMargin = 30; printSystem.PageSettings.AssignDefaultPrinterSettings(pst); }
public static void exportaPreviewGrid(GridControl grid) { //Modo de chamar = Utilidades.exportaPreviewGrid(gcGrid); #region 'Configuração Margem' const Int16 esquerda = 30; const Int16 direita = 30; const Int16 superior = 40; const Int16 inferior = 40; #endregion PrintingSystem PS = new PrintingSystem(); PrintableComponentLink PCL = new PrintableComponentLink(PS); PCL.Component = grid; PCL.Landscape = true; PCL.PaperKind = System.Drawing.Printing.PaperKind.A4; PCL.EnablePageDialog = true; PCL.CreateReportHeaderArea += gridPreviewTextoCabecalho; PCL.CreateMarginalHeaderArea += gridPreviewPaginacao; PCL.Margins = new System.Drawing.Printing.Margins(esquerda, direita, superior, inferior); PCL.ShowPreview(); }
public ReportCenter(IPrintable Printable, string ReportName, string Condition, PaperKind paperKind) { printSystem = new PrintingSystem(); mReportName = ReportName; mCondition = Condition; PrintableComponentLink pcl = new PrintableComponentLink(); pcl.CreateMarginalHeaderArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalHeaderArea); pcl.CreateMarginalFooterArea += new DevExpress.XtraPrinting.CreateAreaEventHandler(link_CreateMarginalFooterArea); pcl.Component = Printable; printSystem.Links.Add(pcl); pcl.CreateDocument(); PrinterSettingsUsing pst = new PrinterSettingsUsing(); pst.UseMargins = true; //pst.UsePaperKind = false; printSystem.PageSettings.PaperKind = paperKind; //printSystem.PageSettings.PaperName = "A4"; printSystem.PageSettings.LeftMargin = 30; printSystem.PageSettings.RightMargin = 30; printSystem.PageSettings.AssignDefaultPrinterSettings(pst); }
private void printExportItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { var ps = new PrintingSystem(); var gridLink = new PrintableComponentLink(ps) { Component = eventGrid }; var schedulerLink = new PrintableComponentLink(ps) { Component = scheduler }; var combinedLink = new CompositeLink(ps) { PaperKind = PaperKind.A4 }; combinedLink.Links.AddRange(new[] { schedulerLink, gridLink }); combinedLink.ShowPreviewDialog(); }
private void ExportToPdf() { PrintingSystem ps = new PrintingSystem(); PrintableComponentLink link1 = new PrintableComponentLink(); //link1.Component = ASPxPivotGridExporter1; link1.PrintingSystem = ps; PrintableComponentLink link2 = new PrintableComponentLink(); WebChartControl1.DataBind(); link2.Component = ((IChartContainer)WebChartControl1).Chart; link2.PrintingSystem = ps; CompositeLink compositeLink = new CompositeLink(); compositeLink.Links.AddRange(new object[] { link1, link2 }); compositeLink.PrintingSystem = ps; compositeLink.CreateDocument(); compositeLink.PrintingSystem.ExportOptions.Pdf.DocumentOptions.Author = "Test"; using (MemoryStream stream = new MemoryStream()) { compositeLink.PrintingSystem.ExportToPdf(stream); Response.Clear(); Response.Buffer = false; Response.AppendHeader("Content-Type", "application/pdf"); Response.AppendHeader("Content-Transfer-Encoding", "binary"); Response.AppendHeader("Content-Disposition", "attachment; filename=test.pdf"); Response.BinaryWrite(stream.GetBuffer()); Response.End(); } ps.Dispose(); }
public void ShowDevPreview(DevExpress.XtraPrinting.IPrintable printComponent) { PageHeaderFooterSettings(); PrintingSystem ps = new PrintingSystem(); PrintableComponentLink pc = new PrintableComponentLink(); pc.Component = printComponent; pc.Landscape = true; //是否指定页边距尺寸 if (devMargins != null) { pc.Margins = devMargins; } //是否定义纸张 if (devPaperKind != System.Drawing.Printing.PaperKind.A4) { pc.PaperKind = devPaperKind; } //标题和页脚的显示 pc.PageHeaderFooter = new PageHeaderFooter(PHA, PFA); pc.CreateDocument(ps); pc.EnablePageDialog = enableEditPage; pc.ShowPreview(); }
private void RestoreWatermark(PrintableComponentLink pcl, WatermarkStorage storage) { switch (storage) { case WatermarkStorage.Registry: { pcl.PrintingSystem.Watermark.RestoreFromRegistry(registryPath); break; } case WatermarkStorage.XML: { if (File.Exists(xmlFile)) { pcl.PrintingSystem.Watermark.RestoreFromXml(xmlFile); } break; } case WatermarkStorage.Stream: { pcl.PrintingSystem.Watermark.RestoreFromStream(stream); stream.Seek(0, SeekOrigin.Begin); break; } } }
public void SaveDataToExcel() { CompositeLink complink = new CompositeLink(new PrintingSystem()); //复合链路 PrintableComponentLink link = new PrintableComponentLink(); //可打印组件链接 link.Component = gridControl1; complink.Links.Add(link);//Links:获取一个合成基对象的链接的集合;Add:添加指定的DevExpress.XtraPrinting对象到集合 //complink.CreatePageForEachLink(); string path = "./excel\\"; if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } FileInfo fileInfo; if (File.Exists(path + excelName + ".xls")) { //fileInfo = new FileInfo(path + excelName + ".xls"); //fileInfo.IsReadOnly = false; //fileInfo.Delete(); } complink.ExportToXls(path + excelName + ".xls", new XlsExportOptions() { ExportMode = XlsExportMode.SingleFile, ShowGridLines = true }); //complink.ExportToXlsx(path + casenumber + ".xlsx", new XlsxExportOptions() { ExportMode = XlsExportMode.SingleFile, ShowGridLines = true }); fileInfo = new FileInfo(path + excelName + ".xls"); //fileInfo.IsReadOnly = true;//只读文件 XtraMessageBox.Show("保存成功!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); //Close(); }
public void ShowRibbonPreview(IPrintable component, string title) { //HEADER PageHeaderArea header = new PageHeaderArea(); header.Content.Add(string.Empty); header.Content.Add(title); header.LineAlignment = BrickAlignment.Center; header.Font = new Font("Tahoma", 16, FontStyle.Bold); //FOOTER PageFooterArea footer = new PageFooterArea(); footer.Content.AddRange(new string[] { "", "", "Página: [Page #]" }); //UNION HEADER/FOOTER PageHeaderFooter headerfooter = new PageHeaderFooter(header, footer); PrintableComponentLink print = new PrintableComponentLink(new PrintingSystem()); print.Component = component; print.PageHeaderFooter = headerfooter; print.PaperKind = PaperKind.A4; print.Margins = new Margins(60, 30, 60, 60); print.CreateDocument(); print.ShowRibbonPreview(this.LookAndFeel); }
protected void ASPxButton1_Click(object sender, EventArgs e) { PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()); link.Component = ASPxGridViewExporter1; using (MemoryStream ms = new MemoryStream()) { link.CreateDocument(false); BrickEnumerator brickEnum = link.PrintingSystem.Document.Pages[0].GetEnumerator(); float maxWidth = 0; while (brickEnum.MoveNext()) { maxWidth = maxWidth > brickEnum.CurrentBrick.Rect.X + brickEnum.CurrentBrick.Rect.Width ? maxWidth : brickEnum.CurrentBrick.Rect.X + brickEnum.CurrentBrick.Rect.Width; } float freeSpace = (link.PrintingSystem.Document.Pages[0]).PageSize.Width - maxWidth; if (freeSpace > 600) { link.Margins.Left = (int)(freeSpace / 6); link.CreateDocument(false); } link.ExportToPdf(ms); WriteDataToResponse(ms.ToArray(), ExportType.PDF); } }
private void barButtonItem1_ItemClick_1(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { PrintingSystem p = new PrintingSystem(); p.ShowMarginsWarning = false; // p.PreviewFormEx.KeyUp += new KeyEventHandler(PreviewFormEx_KeyUp); PrintableComponentLink i = new PrintableComponentLink(p); i.Component = GridMain; i.Landscape = true; i.PaperKind = System.Drawing.Printing.PaperKind.A3; //i.RtfReportFooter = "Tổng Cộng"; i.Margins = new System.Drawing.Printing.Margins(25, 25, 25, 25); //i.CreateReportHeaderArea += new CreateAreaEventHandler(i_CreateReportHeaderArea); // i.CreateReportFooterArea += new CreateAreaEventHandler(i_CreateReportFooterArea); i.CreateDetailArea += new CreateAreaEventHandler(i_CreateDetailArea); gridView1.ColumnPanelRowHeight = 30; gridView1.OptionsPrint.UsePrintStyles = true; i.CreateDocument(p); i.ShowPreview(GridMain.LookAndFeel); }
void CreateLink(PrintingSystem ps) { frmMain frm = BackstageView.Ribbon.FindForm() as frmMain; bool showMemo = memoStyle.Checked && frm.CurrentRichEdit != null; if (showMemo) { Link link = new Link(ps); link.RtfReportHeader = frm.CurrentRichEdit.RtfText; link.PaperKind = GetPaperKind(); link.Landscape = GetLandscape(); link.Margins = GetMargins(); link.CreateDocument(); } else { PrintableComponentLink link = new PrintableComponentLink(ps); link.Component = frm.CurrentPrintableComponent; link.PaperKind = GetPaperKind(); link.Landscape = GetLandscape(); link.Margins = GetMargins(); link.CreateDocument(); } }
private static void PrintViaLink(IPrintable srv) { PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()); link.Component = srv; // Disable warnings. link.PrintingSystem.ShowMarginsWarning = false; link.PrintingSystem.ShowPrintStatusDialog = false; // Find a printer containing Canon in its name PrinterSettings settings = new PrinterSettings(); string printerName = String.Empty; for (int i = 0; i < PrinterSettings.InstalledPrinters.Count; i++) { string pName = PrinterSettings.InstalledPrinters[i]; if (pName.Contains("Canon")) { printerName = pName; break; } } // Print to the specified printer. link.Print(printerName); }
private void xuatExcel() { string ten_cautruyvan = ""; if (this.lookUpEditCauTruyVan.EditValue.ToString() != "Tên Câu Truy Vấn") { ten_cautruyvan = this.lookUpEditCauTruyVan.Text.ToString(); } SaveFileDialog f = new SaveFileDialog(); f.Filter = "Excel file (*.xlsx)|*.xlsx"; f.FileName = "PhanTichMau14a_" + ten_cautruyvan + "_" + DateTime.Now.Second.ToString() + DateTime.Now.Minute.ToString() + DateTime.Now.Hour.ToString() + DateTime.Now.Day.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Year.ToString(); if (f.ShowDialog() == DialogResult.OK) { CompositeLink complink = new CompositeLink(new PrintingSystem()); PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()); link.Component = this.gridControlKetQua; link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea); complink.Links.Add(link); //Rename Sheet complink.PrintingSystem.XlSheetCreated += PrintingSystem_XlSheetCreated; complink.CreatePageForEachLink(); XlsxExportOptions options = new XlsxExportOptions(); options.ExportMode = XlsxExportMode.SingleFilePageByPage; complink.ExportToXlsx(f.FileName, options); MessageBox.Show("Xuất Excel Thành Công!"); } }
private void btnPrintAsPdf_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { this.Cursor = Cursors.WaitCursor; this.UseWaitCursor = true; //ProdPrint if (tcMain.SelectedTab.Name == "tpProd") { checkDirectory(); fileName = "-Production"; checkPdf(); CompositeLink comp = new CompositeLink(new PrintingSystem()); PrintableComponentLink link1 = new PrintableComponentLink(); PrintableComponentLink link2 = new PrintableComponentLink(); link1.Component = gcProd; link1.CreateReportHeaderArea += new CreateAreaEventHandler(link1_CreateReportHeaderArea); comp.Links.Add(link2); comp.Links.Add(link1); comp.Landscape = true; comp.PaperKind = System.Drawing.Printing.PaperKind.A2; comp.ExportToPdf(pdfName); } if (tcMain.SelectedTab.Name == "tpTramming") { //TrammingPrint checkDirectory(); fileName = "-Tramming"; checkPdf(); CompositeLink comp = new CompositeLink(new PrintingSystem()); PrintableComponentLink link1 = new PrintableComponentLink(); PrintableComponentLink link2 = new PrintableComponentLink(); link1.Component = gcTramming; link1.CreateReportHeaderArea += new CreateAreaEventHandler(link1_CreateReportHeaderArea); comp.Links.Add(link2); comp.Links.Add(link1); comp.Landscape = true; comp.PaperKind = System.Drawing.Printing.PaperKind.A2; comp.ExportToPdf(pdfName); } if (tcMain.SelectedTab.Name == "tpSB") { //SBPrint checkDirectory(); fileName = "-ShiftBoss"; checkPdf(); CompositeLink comp = new CompositeLink(new PrintingSystem()); PrintableComponentLink link1 = new PrintableComponentLink(); PrintableComponentLink link2 = new PrintableComponentLink(); link1.Component = gcSB; link1.CreateReportHeaderArea += new CreateAreaEventHandler(link1_CreateReportHeaderArea); comp.Links.Add(link2); comp.Links.Add(link1); comp.Landscape = true; comp.PaperKind = System.Drawing.Printing.PaperKind.A2; comp.ExportToPdf(pdfName); } this.Cursor = Cursors.Default; this.UseWaitCursor = false; acControl.Show(frmMain.ActiveForm, "Print Completed", "Click on folder to open"); //RemovedCode2 }
public void CreateReport() { var link = new CompositeLink(new PrintingSystem()); var link1 = new PrintableComponentLink(); var pcLink1 = new PrintableComponentLink(); var footer = new PageFooterArea(); footer.Content.Add("Printed on " + "[Date Printed]" + " by " + Utils.Username); footer.LineAlignment = BrickAlignment.Near; var header = new PageHeaderArea(); link.CreateMarginalHeaderArea += CreateMarginalHeaderArea; link.PageHeaderFooter = new PageHeaderFooter(header, footer); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Save, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Watermark, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.FillBackground, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.HandTool, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Open, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Customize, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Scale, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Parameters, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SubmitParameters, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Background, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.None, CommandVisibility.None); link.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.DocumentMap, CommandVisibility.None); link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Document"].Visible = false; link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Background"].Visible =false; link.PrintingSystem.PreviewRibbonFormEx.RibbonControl.Pages["Print Preview"].Groups["Zoom"].Visible =false; link.Margins.Left = 100; link.Margins.Right = 100; link.Margins.Top = 100; link.Margins.Bottom = 90; link.PaperKind = PaperKind.A4; var linkGrid1Report = new Link(); linkGrid1Report.CreateDetailArea += linkGrid1Report_CreateDetailArea; var linkGrid2Report = new Link(); // link.PrintingSystem.Document.AutoFitToPagesWidth = 1; link1.Component = gridControl1; link.Links.Add(link1); link.Links.Add(linkGrid1Report); pcLink1.Component = gridControl2; link.Links.Add(pcLink1); link.CreateDocument(); //if (string.IsNullOrEmpty(watermark)) // link.PrintingSystemBase.Watermark.Text = "Draft"; //else //{ // link.PrintingSystemBase.Watermark.Text = "watermark"; //} link.ShowRibbonPreview(UserLookAndFeel.Default); }
private void m_cmd_xuat_pdf_Click(object sender, EventArgs e) { try { DevExpress.XtraPrinting.PrintingSystem ps = new DevExpress.XtraPrinting.PrintingSystem(); CompositeLink cl = new CompositeLink(ps); PrintableComponentLink pclChart = new PrintableComponentLink(); PrintableComponentLink pclPivot = new PrintableComponentLink(); pclChart.Component = m_chart_gpa_cpa; pclPivot.Component = m_pivot_kq_sinh_vien; cl.Links.AddRange(new object[] { pclChart, pclPivot }); cl.ShowPreviewDialog(); cl.PrintingSystem.ExportToPdf(Application.StartupPath + "\\..\\..\\CPA_GPA.pdf"); } catch (Exception v) { MessageBox.Show("Đã xảy ra lỗi hệ thống!"); } }
void CreateLink(PrintingSystem ps) { frmMain frm = FindForm() as frmMain; bool showMemo = memoStyle.Checked && frm.CurrentRichEdit != null; if(showMemo) { Link link = new Link(ps); link.RtfReportHeader = frm.CurrentRichEdit.RtfText; link.PaperKind = GetPaperKind(); link.Landscape = GetLandscape(); link.Margins = GetMargins(); link.CreateDocument(); } else { PrintableComponentLink link = new PrintableComponentLink(ps); link.Component = frm.CurrentPrintableComponent; link.PaperKind = GetPaperKind(); link.Landscape = GetLandscape(); link.Margins = GetMargins(); link.CreateDocument(); } }
public void PrintGrid(DevExpress.XtraGrid.GridControl gc, bool printPreview) { //GridView gvwContact = (GridView) gc.DefaultView; // string strHeader = strMenuOption; //strHeader = strHeader.Remove(strHeader.Length - 3, 3); //strHeader += " Information"; PageHeaderFooter phf = new PageHeaderFooter(); phf.Header.Font = new Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point); string str = ""; phf.Header.LineAlignment = BrickAlignment.Near; str = "Pay Details By Instructor"; // str.AppendFormat(Environment.NewLine); //Page header = phf.Header; phf.Header.Content.Add(str); // str.AppendFormat("Date Generated: {0}", System.DateTime.Today.ToShortDateString()); //str.AppendFormat(Environment.NewLine); if (checkEdit1.Checked && checkEdit2.Checked) { str = dateEditStartDate.DateTime.ToShortDateString() + " - " + dateEditEndDate.DateTime.ToShortDateString(); } else if (checkEdit1.Checked && !checkEdit2.Checked) { str = dateEditStartDate.DateTime.ToLongDateString() + " - Unlimited"; } else if (!checkEdit1.Checked && checkEdit2.Checked) { str = "Unlimited - " + dateEditEndDate.DateTime.ToShortDateString(); } else { str = ""; //str.AppendFormat("From: Not Filtered To: Not Filtered"); } phf.Header.LineAlignment = BrickAlignment.Center; phf.Header.Content.Add(str); phf.Footer.LineAlignment = BrickAlignment.Near; phf.Footer.Content.Add(""); phf.Footer.LineAlignment = BrickAlignment.Center; phf.Footer.Content.Add(""); phf.Footer.LineAlignment = BrickAlignment.Far; String footer = "Date Generated: " + System.DateTime.Today.ToShortDateString(); phf.Footer.Content.Add(footer); phf.Footer.LineAlignment = BrickAlignment.Far; PrintableComponentLink _link = new PrintableComponentLink(new PrintingSystem()); _link.Component = gc; _link.Landscape = true; _link.PageHeaderFooter = phf; _link.PaperKind = System.Drawing.Printing.PaperKind.A4; _link.Margins.Top = 60; _link.Margins.Bottom = 60; _link.Margins.Left = 10; _link.Margins.Right = 10; if (printPreview) { _link.ShowPreviewDialog(); } else { _link.PrintDlg(); } /* * PrinterSettings settings = printDocument1.PrinterSettings; * //Set PageSize to 'A4' * bool found=false; * foreach (PaperSize size in settings.PaperSizes) * { * if (size.PaperName == "A4, 210x297 mm") * found = true; * if (found) * { * settings.DefaultPageSettings.PaperSize = size; * break; * } * else continue; * } * * printDocument1.DefaultPageSettings.Landscape = true; * printDocument1.DefaultPageSettings.Margins = new Margins(50, 50, 15, 50); * //printDocument1.DefaultPageSettings.PaperSize = new PaperSize("A4, 210x297 mm", 827, 1169); * * dataGridPrinter1 = new GridViewPrinter(gc, printDocument1, gvwContact); * dataGridPrinter1.PageNumber = 1; * dataGridPrinter1.RowCount = 0; * if (printPreviewDialog1.ShowDialog() == DialogResult.OK) * { * }*/ }
private void exportSatis(string dil, bool eMail = false) { int tstID = (int)tstGridView.GetFocusedRowCellValue(colTSTIDt); rprTklfTableAdapter.Fill(teklifDataSet.RPR_TKLF, tstID, dil); TeklifDataSet.RPR_TKLFRow rprTklfRow = (TeklifDataSet.RPR_TKLFRow)teklifDataSet.RPR_TKLF.Rows[0]; string tklfTE = "Teklif"; if (dil == "T") { colORGf.Caption = "Çıkış"; colDSTf.Caption = "Varış"; colBRMf.Caption = "Birim"; colTRNTIMEf.Caption = "Transit Süre"; colSKDY.Caption = "KDV%"; colSDVZf.Caption = "Para Birim"; colSFYTf.Caption = "Fiyat"; colSFYT1f.Caption = "Min"; colSFYT2f.Caption = "-45"; colSFYT3f.Caption = "+45"; colSFYT4f.Caption = "+100"; colSFYT5f.Caption = "+250"; colSFYT6f.Caption = "+300"; colSFYT7f.Caption = "+500"; colSFYT8f.Caption = "+1000"; colSFYTE.Caption = "Fiyat"; colSFYT1E.Caption = "Min"; colSFYT2E.Caption = "-45"; colSFYT3E.Caption = "+45"; colSFYT4E.Caption = "+100"; colSFYT5E.Caption = "+250"; colSFYT6E.Caption = "+300"; colSFYT7E.Caption = "+500"; colSFYT8E.Caption = "+1000"; } else { tklfTE = "Tender"; colORGf.Caption = "Origin"; colDSTf.Caption = "Destination"; colBRMf.Caption = "Unit"; colTRNTIMEf.Caption = "Transit Time"; colSKDY.Caption = "%VAT"; colSDVZf.Caption = "Currency"; colSFYTf.Caption = "Rate"; colSFYT1f.Caption = "Min"; colSFYT2f.Caption = "-45"; colSFYT3f.Caption = "+45"; colSFYT4f.Caption = "+100"; colSFYT5f.Caption = "+250"; colSFYT6f.Caption = "+300"; colSFYT7f.Caption = "+500"; colSFYT8f.Caption = "+1000"; colSFYTE.Caption = "Rate"; colSFYT1E.Caption = "Min"; colSFYT2E.Caption = "-45"; colSFYT3E.Caption = "+45"; colSFYT4E.Caption = "+100"; colSFYT5E.Caption = "+250"; colSFYT6E.Caption = "+300"; colSFYT7E.Caption = "+500"; colSFYT8E.Caption = "+1000"; } if (colG9.GroupIndex == 0) { tsfGridView.CollapseAllGroups(); //tsfGridView.OptionsView.ShowFooter = true; tsfGridView.OptionsPrint.ExpandAllGroups = false; tsfGridView.OptionsPrint.PrintFooter = true; //tsfGridView.OptionsPrint.AutoWidth = false; tsfGridView.OptionsPrint.AutoWidth = true; } else { tsfGridView.ExpandAllGroups(); //tsfGridView.OptionsView.ShowFooter = false; tsfGridView.OptionsPrint.ExpandAllGroups = true; tsfGridView.OptionsPrint.PrintFooter = false; //tsfGridView.OptionsPrint.AutoWidth = false; tsfGridView.OptionsPrint.AutoWidth = true; //tsfGridView.BestFitColumns(); } RichEditDocumentServer richServer = new RichEditDocumentServer(); richServer.RtfText = rprTklfRow.ALTNOT; //richServer.Document.AppendText(" SENER"); if (!rprTklfRow.IsDTYNOTNull()) { if (string.IsNullOrEmpty(richServer.Text)) { richServer.RtfText = rprTklfRow.DTYNOT; } else { richServer.Document.AppendRtfText(rprTklfRow.DTYNOT); } } tsfGridView.OptionsPrint.RtfReportFooter = richServer.RtfText; tsfGridView.OptionsPrint.RtfPageFooter = rprTklfRow.FOOTER; PrintingSystem ps = new PrintingSystem(); PrintableComponentLink link = new PrintableComponentLink(ps); link.Component = tsfGridControl; link.PaperKind = System.Drawing.Printing.PaperKind.A4; link.Landscape = false; link.Margins.Left = 10; link.Margins.Right = 10; link.Margins.Top = 10; link.Margins.Bottom = 10; // tsfGridView.OptionsPrint.RtfPageHeader = tsfGridView.OptionsPrint.RtfReportHeader = rprTklfRow.USTNOT .Replace("@TSTID@", rprTklfRow.TSTID.ToString()) .Replace("@FIRMA@", rprTklfRow.FIRMA) .Replace("@TLPTRH@", rprTklfRow.TLPTRHS) .Replace("@TKLTRH@", rprTklfRow.TKLTRHS) .Replace("@GCRTRH@", rprTklfRow.GCRTRHS) .Replace("@ROT@", rprTklfRow.ROT) .Replace("@MOT@", rprTklfRow.MOT) .Replace("@PTM@", rprTklfRow.PTM) .Replace("@DTM@", rprTklfRow.DTM) .Replace("@HORGS@", rprTklfRow.HORGS) .Replace("@HDSTS@", rprTklfRow.HDSTS) .Replace("@MORGS@", rprTklfRow.MORGS) .Replace("@MDSTS@", rprTklfRow.MDSTS) .Replace("@MALCINSI@", rprTklfRow["MALCINSI"].ToString()) .Replace("@INFO@", rprTklfRow.INFO); link.CreateDocument(); if (eMail) { if (string.IsNullOrWhiteSpace(rprTklfRow.EMAILS)) { XtraMessageBox.Show("eMail adresi bulunamadı", "eMail Teklif", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } Cursor = Cursors.WaitCursor; try { MainDataSet.SMTPRow SMTP = Program.MF.SMTP(); MailMessage mail = new MailMessage(); // Create a new memory stream and export the report into it as PDF. MemoryStream ms = new MemoryStream(); link.ExportToPdf(ms); // Create a new attachment and put the PDF report into it. ms.Seek(0, System.IO.SeekOrigin.Begin); Attachment att = new Attachment(ms, string.Format("{0}-{1}.pdf", tklfTE, tstID), "application/pdf"); mail.Attachments.Add(att); mail.To.Add(rprTklfRow.EMAILS); mail.Subject = rprTklfRow.EMAILSUBJECT; mail.Body = rprTklfRow.EMAILBODY; mail.IsBodyHtml = true; mail.From = new MailAddress(SMTP.MAIL_FROM_ADDRESS, SMTP.MAIL_FROM_DISPLAY_NAME); SmtpClient smtp = new SmtpClient(SMTP.CLIENT_HOST); smtp.Credentials = new System.Net.NetworkCredential(SMTP.CREDENTIALS_USER_NAME, SMTP.CREDENTIALS_USER_PASSWORD); smtp.EnableSsl = SMTP.ENABLE_SSL == "T" ? true : false; smtp.Port = SMTP.PORT; smtp.Send(mail); int len = (int)ms.Length; byte[] img = new byte[len]; ms.Read(img, 0, len); //teklifQueriesTableAdapter.DOC_INS2("TST", tstID, "Teklif", ".pdf", "TKLF", Program.USR, len, img); teklifQueriesTableAdapter.DOC_INS2("TST", tstID, string.Format("Teklif {0}", tstGridView.GetFocusedRowCellValue(colRVSNOt)), ".pdf", "TKLF", Program.USR, len, img); // Close the memory stream. ms.Close(); ms.Flush(); rptInfo rpti = new rptInfo(); rpti.put("TKLF", "TST", tstID, Program.USR, "F", "eMail Teklif"); Program.MF.reportDone(rpti, false); } catch (Exception ex) { MessageBox.Show(this, "Error sending eMail.\n" + ex.ToString()); } finally { Cursor = Cursors.Default; } } else { link.ShowPreviewDialog(); if (XtraMessageBox.Show("İşlem tamamlandı mı?", "Print", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes) { MemoryStream ms = new MemoryStream(); link.ExportToPdf(ms); ms.Seek(0, System.IO.SeekOrigin.Begin); int len = (int)ms.Length; byte[] img = new byte[len]; ms.Read(img, 0, len); ms.Close(); teklifQueriesTableAdapter.DOC_INS2("TST", tstID, string.Format("Teklif {0}", tstGridView.GetFocusedRowCellValue(colRVSNOt)), ".pdf", "TKLF", Program.USR, len, img); rptInfo rpti = new rptInfo(); rpti.put("TKLF", "TST", tstID, Program.USR, "F", "eMail Teklif"); Program.MF.reportDone(rpti, false); } } }
private void nbiPrintPreviewRibbon_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e) { using(DevExpress.XtraPrinting.Preview.PrintPreviewRibbonFormEx form = new DevExpress.XtraPrinting.Preview.PrintPreviewRibbonFormEx()) { PrintingSystem ps = new PrintingSystem(); form.PrintControl.PrintingSystem = ps; PrintableComponentLink link = new PrintableComponentLink(ps); link.Component = gridControl1; link.CreateDocument(); form.ShowDialog(); } }
protected virtual void OnPreview() { if (Printer == null) return; SplashScreenManager.ShowForm(typeof (EasyWaitForm)); var ps = new PrintingSystem(); var link = new PrintableComponentLink(ps); link.Component = Printer; link.PaperKind = PaperKind.A4; link.CreateReportHeaderArea += printableComponentLink_CreateReportHeaderArea; link.CreateReportFooterArea += printableComponentLink_CreateReportFooterArea; link.Margins.Bottom = link.Margins.Left = link.Margins.Right = link.Margins.Top = 50; link.CreateDocument(); link.ShowPreview(); SplashScreenManager.CloseForm(); }
private void xpButton2_Click(object sender, EventArgs e) { if (printableComponentLink2 == null) printableComponentLink2 = new PrintableComponentLink(); printableComponentLink2.CreateMarginalHeaderArea += Link_CreateMarginalHeaderArea; printableComponentLink2.CreateDocument(); printableComponentLink2.Landscape = false; printableComponentLink2.ShowPreviewDialog(); }
private void ExportToPdf(string file) { System.Drawing.Font fhead = new System.Drawing.Font("DFKai-SB", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); System.Drawing.Font fcontent = new System.Drawing.Font("DFKai-SB", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); System.Drawing.Font tmpHead = null; System.Drawing.Font tmpContent = null; if (this.gridView1.Columns.Count > 0) { tmpHead = this.gridView1.Columns[0].AppearanceHeader.Font; tmpContent = this.gridView1.Columns[0].AppearanceCell.Font; } foreach (GridColumn column in this.gridView1.Columns) { column.AppearanceHeader.Font = fhead; column.AppearanceCell.Font = fcontent; } PrintingSystem system = new PrintingSystem(); PrintableComponentLink link = new PrintableComponentLink(system); try { link.Component = this.gridView1.GridControl; link.Landscape = true; link.PaperKind = System.Drawing.Printing.PaperKind.A4; link.Margins = new System.Drawing.Printing.Margins(30, 30, 50, 50); link.CreateDocument(); //link.PrintingSystem.Document.PrintingSystem.PageMargins.Bottom = 10; //link.PrintingSystem.Document.PrintingSystem.PageMargins.Left = 1000; //link.PrintingSystem.Document.PrintingSystem.PageMargins.Right = 10; //link.PrintingSystem.Document.PrintingSystem.PageMargins.Top = 30; //PdfDocumentOptions pdo = new PdfDocumentOptions(); //pdo.Author = "author"; //pdo.Keywords = "keywords"; //pdo.Subject = "subject"; //pdo.Title = "title"; //pdo.Application = "application"; PdfExportOptions op = new PdfExportOptions(); op.DocumentOptions.Author = "author"; op.DocumentOptions.Keywords = "keywords"; op.DocumentOptions.Subject = "subject"; op.DocumentOptions.Title = "title"; op.DocumentOptions.Application = "application"; op.ImageQuality = PdfJpegImageQuality.Highest; link.PrintingSystem.ExportToPdf(file, op); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { system = null; link = null; foreach (GridColumn column in this.gridView1.Columns) { column.AppearanceHeader.Font = tmpHead; column.AppearanceCell.Font = tmpContent; } } }
private PrintableComponentLink PrepareGridForPrint(GridView gridView) { gridView.OptionsPrint.AutoWidth = true; var printComp = new PrintableComponentLink(new PrintingSystem()); printComp.CreateReportHeaderArea += PrintCompOnCreateReportHeaderArea; printComp.Component = gridView.GridControl; printComp.CreateDocument(); return printComp; }
private void truyVanTheoCSKCBVoiCacDieuKien(string _MaCSKCB) { string MaCSKCB = _MaCSKCB; complinkMain = new CompositeLink(new PrintingSystem()); int soluongGridControl = this.gridViewDieuKien.GetSelectedRows().Length; int i_sl = 0; GridControl[] gridcontrolTemps = new GridControl[soluongGridControl + 1]; PrintableComponentLink[] linkTemps = new PrintableComponentLink[soluongGridControl + 1]; DataTable[] dt_Temps = new DataTable[soluongGridControl + 1]; maDieuKiens = new string[soluongGridControl]; tenDieuKiens = new string[soluongGridControl]; DieuKiens = new string[soluongGridControl]; string _ngayBatDau = this.tbThoiGianBatDau.Text; string _ngayKetThuc = this.tbThoiGianKetThuc.Text; string _menhDeWhereKyQuyetToan = "KY_QT BETWEEN " + _ngayBatDau + " AND " + _ngayKetThuc; _menhDeWhereKyQuyetToan = " AND (" + _menhDeWhereKyQuyetToan + ")"; string queryTongHopTatCaCacDieuKien = ""; int soLuongSheet = 0; if (this.gridViewDieuKien.GetSelectedRows().Length > 0) { string DieuKien = ""; ////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// //Query Tổng hợp tất cả các điều kiện //SHEET 1 trong EXCEL xuất ra //Truy Vấn Theo GridControl /*foreach (int i in this.gridViewCSKCB.GetSelectedRows()) * { * * string MaCSKCB = this.gridViewCSKCB.GetDataRow(i)["Mã CSKCB"].ToString(); * }*/ //Truy Vấn Theo Look Up Edit queryTongHopTatCaCacDieuKien = traVeChuoiCacDieuKienDuocChonTheoMaCSKCB(MaCSKCB); //string queryTemp = "SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH = '1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh'"; string queryTemp = "SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH = '1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh'"; for (int j = 0; j < maDieuKiens.Length; j++) { //queryTemp = queryTemp + ", SUM(" + '"' + maDieuKiens[j] + '"' + ") as " + "'" + maDieuKiens[j] + "'"; queryTemp = queryTemp + ",( CASE WHEN SUM(" + '"' + maDieuKiens[j] + '"' + ") >= 1 THEN 'x' ELSE '' END) as " + "'" + maDieuKiens[j] + "'"; //(CASE WHEN GIOI_TINH = '1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính' } //queryTongHopTatCaCacDieuKien = queryTemp + " FROM " + "(" + queryTongHopTatCaCacDieuKien + ")" + " as test GROUP BY HO_TEN,MA_THE,NGAY_SINH,GIOI_TINH,MA_DKBD,NGAY_VAO,NGAY_RA,MA_BENH,MA_BENHKHAC,TEN_BENH,ma_cp,TEN_CP,SO_LUONG_BV,don_gia, thanh_tien,NGAY_YL"; queryTongHopTatCaCacDieuKien = queryTemp + " FROM " + "(" + queryTongHopTatCaCacDieuKien + ")" + " as test GROUP BY HO_TEN,MA_THE,NGAY_SINH,GIOI_TINH,MA_DKBD,NGAY_VAO,NGAY_RA,MA_BENH,MA_BENHKHAC,TEN_BENH"; SqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); try { dt_Temps[soluongGridControl] = DBUtils.GetDBTable(queryTongHopTatCaCacDieuKien, conn); DataColumn Col = dt_Temps[soluongGridControl].Columns.Add("STT"); Col.SetOrdinal(0); for (int i = 0; i < dt_Temps[soluongGridControl].Rows.Count; i++) { dt_Temps[soluongGridControl].Rows[i]["STT"] = i + 1; } if (dt_Temps[soluongGridControl].Rows.Count > 0) { gridcontrolTemps[soluongGridControl] = new GridControl(); gridcontrolTemps[soluongGridControl].BindingContext = new System.Windows.Forms.BindingContext(); gridcontrolTemps[soluongGridControl].DataSource = dt_Temps[soluongGridControl]; //Hiển thị gridcontrol this.gridViewKetQua.Columns.Clear(); this.gridControlKetQua.DataSource = gridcontrolTemps[soluongGridControl].DataSource;; this.gridControlKetQua.Refresh(); Form frm = new Form(); frm.Controls.Add(gridcontrolTemps[soluongGridControl]); gridcontrolTemps[soluongGridControl].ForceInitialize(); linkTemps[soluongGridControl] = new PrintableComponentLink(new PrintingSystem()); linkTemps[soluongGridControl].Component = gridcontrolTemps[soluongGridControl]; linkTemps[soluongGridControl].CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea); complinkMain.Links.Add(linkTemps[soluongGridControl]); } } catch (SqlException ex) { MessageBox.Show("Error: " + ex.ToString()); } finally { conn.Close(); conn.Dispose(); } ////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////// string query = ""; foreach (int j in this.gridViewDieuKien.GetSelectedRows()) { //BẮT ĐẦU ĐIỀU KIỆN DieuKien = this.gridViewDieuKien.GetDataRow(j)["Điều Kiện"].ToString() + _menhDeWhereKyQuyetToan; maDieuKiens[i_sl] = this.gridViewDieuKien.GetDataRow(j)["Mã Điều Kiện"].ToString(); tenDieuKiens[i_sl] = this.gridViewDieuKien.GetDataRow(j)["Tên Tiêu Chí"].ToString(); /*Truy vấn theo nhiều Cơ sở khám chữa bệnh + Grid Control * query = ""; * if (this.gridViewCSKCB.GetSelectedRows().Length > 0) * { * bool flag_MaCSKCB = true; * //MessageBox.Show("Sl CSKCB: " + this.gridViewCSKCB.GetSelectedRows().Length.ToString()); * foreach (int i in this.gridViewCSKCB.GetSelectedRows()) * { * string MaCSKCB = this.gridViewCSKCB.GetDataRow(i)["Mã CSKCB"].ToString(); * //query = "(SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH='1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh' FROM xml123_" + MaCSKCB + " WHERE " + DieuKien + ")"; * if (flag_MaCSKCB) * { * flag_MaCSKCB = false; * query = "(SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH='1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh' FROM xml123_" + MaCSKCB + " WHERE " + DieuKien + ")"; * * } * else * { * query = query + " UNION (SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH='1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh' FROM xml123_" + MaCSKCB + " WHERE " + DieuKien + ")"; * } * } * * * } * else * { * MessageBox.Show("Chưa Chọn Cơ Sở KCB"); * } *///////////////////////////////////////////////////////////////////////////////////////////////// /*Truy vấn theo 1 Cơ sở khám chữa bệnh + Look Up Edit*/ query = "(SELECT HO_TEN as 'Họ tên',MA_THE as 'Mã thẻ',NGAY_SINH as 'Ngày sinh',(CASE WHEN GIOI_TINH='1' THEN 'Nam' ELSE 'Nu' END) as 'Giới tính',MA_DKBD as 'Mã ĐKBĐ',NGAY_VAO as 'Ngày vào',NGAY_RA as 'Ngày ra',MA_BENH as 'Mã bệnh',MA_BENHKHAC as 'Mã bệnh khác',TEN_BENH as 'Tên bệnh',ma_cp as 'Mã CP',TEN_CP as 'Tên CP',SO_LUONG_BV as 'Số lượng',don_gia as 'Đơn giá', thanh_tien as 'Thành tiền',NGAY_YL as 'Ngày y lệnh' FROM xml123_" + MaCSKCB + " WHERE " + DieuKien + ")"; ////////////////////////////////////////////////////////////////////////////////////////////////// //Gridv conn = DBUtils.GetDBConnection(); conn.Open(); try { dt_Temps[i_sl] = DBUtils.GetDBTable(query, conn); DataColumn Col = dt_Temps[i_sl].Columns.Add("STT"); Col.SetOrdinal(0); for (int i = 0; i < dt_Temps[i_sl].Rows.Count; i++) { dt_Temps[i_sl].Rows[i]["STT"] = i + 1; } //MessageBox.Show(dt_Temps[i_sl].Rows.Count.ToString()); if (dt_Temps[i_sl].Rows.Count > 0) { gridcontrolTemps[i_sl] = new GridControl(); gridcontrolTemps[i_sl].BindingContext = new System.Windows.Forms.BindingContext(); gridcontrolTemps[i_sl].DataSource = dt_Temps[i_sl]; Form frm = new Form(); frm.Controls.Add(gridcontrolTemps[i_sl]); gridcontrolTemps[i_sl].ForceInitialize(); linkTemps[i_sl] = new PrintableComponentLink(new PrintingSystem()); linkTemps[i_sl].Component = gridcontrolTemps[i_sl]; //Bảng đổi tên soLuongSheets[soLuongSheet] = tenDieuKiens[i_sl]; soLuongMaDieuKienSheets[soLuongSheet] = maDieuKiens[i_sl]; soLuongSheet++; linkTemps[i_sl].CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea); complinkMain.Links.Add(linkTemps[i_sl]); } } catch (SqlException ex) { MessageBox.Show("Error: " + ex.ToString()); } finally { conn.Close(); conn.Dispose(); } //KẾT THÚC ĐIỀU KIỆN i_sl++; } }//END MessageBox.Show("Truy vấn xong!"); }
protected virtual void BeforeCreatingPage(PrintableComponentLink link, ExportOptions options) { }
public static void ExportToFile(GridControl gridControl, string typeExport) { var dlg = new SaveFileDialog { InitialDirectory = Application.StartupPath }; switch (typeExport) { case "btnExportCsv": dlg.Filter = @"Archivo Csv (*.csv) | *.csv | Todos los archivo (*.*) | *.*"; break; case "btnExportHtml": dlg.Filter = @"Archivo Html (*.html) | *.html | Todos los archivo (*.*) | *.*"; break; case "btnExportImg": dlg.Filter = @"Archivo Png (*.png) | *.png | Todos los archivo (*.*) | *.*"; break; case "btnExportMht": dlg.Filter = @"Archivo Mht (*.Mht) | *.mht | Todos los archivo (*.*) | *.*"; break; case "btnExportPdf": dlg.Filter = @"Archivo Pdf (*.Pdf) | *.pdf | Todos los archivo (*.*) | *.*"; break; case "btnExportRtf": dlg.Filter = @"Archivo Rtf (*.Rtf) | *.rtf | Todos los archivo (*.*) | *.*"; break; case "btnExportTxt": dlg.Filter = @"Archivo Txt (*.txt) | *.txt | Todos los archivo (*.*) | *.*"; break; case "btnExportXls": dlg.Filter = @"Archivo Xls (*.xls) | *.xls | Todos los archivo (*.*) | *.*"; break; case "btnExportXlsx": dlg.Filter = @"Archivo Xlsx (*.xlsx) | *.xlsx | Todos los archivo (*.*) | *.*"; break; } if (dlg.ShowDialog() == DialogResult.OK) { switch (typeExport) { case "btnExportCsv": gridControl.ExportToCsv(dlg.FileName); break; case "btnExportHtml": gridControl.ExportToHtml(dlg.FileName); break; case "btnExportImg": var ps = new PrintingSystem(); var link = new PrintableComponentLink(ps) { Component = gridControl }; link.CreateDocument(); link.PrintingSystem.ExportToImage(dlg.FileName); break; case "btnExportMht": gridControl.ExportToMht(dlg.FileName); break; case "btnExportPdf": gridControl.ExportToPdf(dlg.FileName); break; case "btnExportRtf": gridControl.ExportToRtf(dlg.FileName); break; case "btnExportTxt": gridControl.ExportToText(dlg.FileName); break; case "btnExportXls": gridControl.ExportToXls(dlg.FileName); break; case "btnExportXlsx": gridControl.ExportToXlsx(dlg.FileName); break; } if (DialogResult.Yes == XtraMessageBox.Show("¿Desea abrir el archivo?", "Exportar archivo", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)) { var process = new Process { StartInfo = { FileName = dlg.FileName } }; process.Start(); } } }
public static void PrintPreview(ChartControl chartControl, GridControl grid) { chartControl.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Zoom; CompositeLink composLink = new CompositeLink(new PrintingSystem()); PrintableComponentLink pcLink1 = new PrintableComponentLink(); PrintableComponentLink pcLink2 = new PrintableComponentLink(); Link linkMainReport = new Link(); linkMainReport.CreateDetailArea += new CreateAreaEventHandler(linkMainReport_CreateDetailArea); Link linkGrid1Report = new Link(); linkGrid1Report.CreateDetailArea += new CreateAreaEventHandler(linkGrid1Report_CreateDetailArea); Link linkGrid2Report = new Link(); linkGrid2Report.CreateDetailArea += new CreateAreaEventHandler(linkChartReport_CreateDetailArea); pcLink1.Component = grid; pcLink2.Component = chartControl; composLink.Links.Add(linkGrid2Report); composLink.Links.Add(pcLink2); composLink.Links.Add(linkGrid1Report); composLink.Links.Add(pcLink1); composLink.Links.Add(linkMainReport); composLink.ShowPreviewDialog(); }
///// <summary> ///// Add the footer total ///// </summary> //public bool AddFooterTotal //{ // get { return _addFooterTotal; } // set { _addFooterTotal = value; } //} ///// <summary> ///// The footer total value ///// </summary> //public decimal FooterTotalValue //{ // get { return _footerTotalValue; } // set { _footerTotalValue = value; } //} ///// <summary> ///// The footer total caption ///// </summary> //public string FooterTotalCaption //{ // get { return _footerTotalCaption; } // set { _footerTotalCaption = value; } //} ///// <summary> ///// The footer alignment ///// Default is System.Drawing.StringAlignment.Far (right) ///// </summary> //public System.Drawing.StringAlignment FooterAlignment //{ // get { return _footerTextAlignment; } // set { _footerTextAlignment = value; } //} /// <summary> /// Show the preview window based on how the control is set /// </summary> public DevExpress.XtraPrinting.Preview.PrintPreviewFormEx ShowPreview(System.Windows.Forms.Form mainMDIForm) { // Check whether the XtraGrid control can be previewed. if (!_view.GridControl.IsPrintingAvailable) { MessageBox.Show("The 'DevExpress.XtraPrinting' library could not be found.", "Error"); return(null); } if (_view is GridView) { ((GridView)_view).OptionsPrint.EnableAppearanceEvenRow = ((GridView)_view).OptionsPrint.EnableAppearanceOddRow = true; ((GridView)_view).OptionsPrint.UsePrintStyles = true; // Set the options on the footer ((GridView)_view).OptionsPrint.PrintFooter = true; ((GridView)_view).OptionsPrint.PrintGroupFooter = true; // Set the alignment of the cells (vertical) //((GridView)_view).OptionsPrint.UsePrintStyles = true; //foreach (GridColumn col in ((GridView)_view).Columns) //{ // col.AppearanceCell.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top; //} //((GridView)_view).AppearancePrint. //((GridView)_view).AppearancePrint.Preview.Options.UseTextOptions = true; //((GridView)_view).AppearancePrint.Preview.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top; //((GridView)_view).AppearancePrint.Row.Options.UseTextOptions = true; //((GridView)_view).AppearancePrint.Row.TextOptions.VAlignment = DevExpress.Utils.VertAlignment.Top; } else if (_view is LayoutView) { //((LayoutView)_view).OptionsPrint.us = } PrintingSystem ps = new PrintingSystem(); //ps.PreviewFormEx.MdiParent = mwsLEAD.common.UserInterface._mainMDIForm; ps.PreviewFormEx.SaveState = false; ps.PreviewFormEx.PrintBarManager.MainMenu.Visible = false; ps.PreviewFormEx.SaveState = true; ps.PreviewFormEx.Icon = mainMDIForm.Icon; System.Drawing.Printing.Margins margins = ps.PageMargins; if (_margins != null) { margins.Left = _margins.Left; margins.Top = _margins.Top; margins.Bottom = _margins.Bottom; margins.Right = _margins.Right; } else { margins.Left = 50; margins.Top = 137; margins.Bottom = 87; margins.Right = 50; } PrintableComponentLink link = new PrintableComponentLink(ps); link.Component = _view.GridControl; link.Margins = margins; //if (_margins != null) //{ // link.Margins = _margins; //} link.CreateMarginalHeaderArea -= new CreateAreaEventHandler(link_CreateMarginalHeaderArea); link.CreateMarginalFooterArea -= new CreateAreaEventHandler(link_CreateMarginalFooterArea); link.CreateMarginalHeaderArea += new CreateAreaEventHandler(link_CreateMarginalHeaderArea); link.CreateMarginalFooterArea += new CreateAreaEventHandler(link_CreateMarginalFooterArea); link.CreateDetailArea += new CreateAreaEventHandler(link_CreateDetailArea); link.CreateDocument(); //if (_orientation == DocSQLPrintOrientation.Landscape) //{ // link.Landscape = true; // link.PrintingSystem.PageSettings.Landscape = true; //} // Opens the Preview window. ps.PreviewFormEx.MdiParent = mainMDIForm; link.ShowPreview(); //mwsCommon.UserInterface.FormFillsClientArea(ps.PreviewFormEx); //mwsCommon.UserInterface.SizeScreen(ps.PreviewFormEx, MWSScreenSize.FormFillsClientArea); return(ps.PreviewFormEx); // Return the form that was just created }
protected void AlertSettings_ItemClick(object source, DevExpress.Web.MenuItemEventArgs e) { if (e.Item.Name == "AlertSettingsItem") { Response.Redirect("~/Configurator/Alert_Settings.aspx", false); Context.ApplicationInstance.CompleteRequest(); } else if (e.Item.Name == "ExportXLSItem") { if (startDate.Value != "") { ServerGridViewExporter.FileName = "AlertsHistory" + "_" + startDate.Value; ServerGridViewExporter.WriteXlsToResponse(); } else { ServerGridViewExporter.FileName = "AlertsHistory" + "_" + DateTime.Now.ToString(); ServerGridViewExporter.WriteXlsToResponse(); } } else if (e.Item.Name == "ExportXLSXItem") { if (startDate.Value != "") { ServerGridViewExporter.FileName = "AlertsHistory" + "_" + startDate.Value; ServerGridViewExporter.WriteXlsxToResponse(); } else { ServerGridViewExporter.FileName = "AlertsHistory" + "_" + DateTime.Now.ToString(); ServerGridViewExporter.WriteXlsxToResponse(); } } else if (e.Item.Name == "ExportPDFItem") { if (startDate.Value != "") { ServerGridViewExporter.FileName = "AlertsHistory" + "_" + startDate.Value; //ServerGridViewExporter.WriteXlsxToResponse(); } else { ServerGridViewExporter.FileName = "AlertsHistory" + "_" + DateTime.Now.ToString(); //ServerGridViewExporter.WriteXlsxToResponse(); } ServerGridViewExporter.Landscape = true; using (MemoryStream ms = new MemoryStream()) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = ServerGridViewExporter; pcl.Margins.Left = pcl.Margins.Right = 50; pcl.Landscape = true; pcl.CreateDocument(false); pcl.PrintingSystem.Document.AutoFitToPagesWidth = 1; pcl.ExportToPdf(ms); WriteResponse(this.Response, ms.ToArray(), System.Net.Mime.DispositionTypeNames.Attachment.ToString()); //ServerGridViewExporter.WritePdfToResponse(); } } }
private void Initialize() { _GridView = new GridView() { Name = "GridView" }; _BandedGridView = new BandedGridView() { Name = "BandedGridView" }; _AdvBandedGridView = new AdvBandedGridView() { Name = "AdvBandedGridView" }; _CardView = new CardView() { Name = "CardView" }; _LayoutView = new LayoutView() { Name = "LayoutView" }; _TileView = new TileView() { Name = "TileView" }; _WinExplorerView = new WinExplorerView() { Name = "WinExplorerView" }; _GridView.GridControl = Grid; _BandedGridView.GridControl = Grid; _AdvBandedGridView.GridControl = Grid; _CardView.GridControl = Grid; _LayoutView.GridControl = Grid; _TileView.GridControl = Grid; _WinExplorerView.GridControl = Grid; Grid.ViewCollection.AddRange(new BaseView[] { _GridView, _BandedGridView, _AdvBandedGridView, _CardView, _LayoutView, _TileView, _WinExplorerView }); Grid.MainView = _GridView; View.OptionsView.ShowGroupPanel = false; _GridView.OptionsView.ShowGroupPanel = false; _BandedGridView.OptionsView.ShowGroupPanel = false; _AdvBandedGridView.OptionsView.ShowGroupPanel = false; if (View != null) { View.Dispose(); } _PrintingSystem = new PrintingSystem(); _PrintableComponentLink = new PrintableComponentLink(_PrintingSystem) { Component = Grid, PaperKind = PaperKind.A4 }; }
public void PrintGrid(DevExpress.XtraGrid.GridControl gc, bool printPreview) { //GridView gvwContact = (GridView) gc.DefaultView; // string strHeader = strMenuOption; //strHeader = strHeader.Remove(strHeader.Length - 3, 3); //strHeader += " Information"; PageHeaderFooter phf = new PageHeaderFooter(); phf.Header.Font = new Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point); string str = ""; phf.Header.LineAlignment = BrickAlignment.Near; str = "Payroll By Instructor"; // str.AppendFormat(Environment.NewLine); //Page header = phf.Header; phf.Header.Content.Add(str); // str.AppendFormat("Date Generated: {0}", System.DateTime.Today.ToShortDateString()); //str.AppendFormat(Environment.NewLine); if (checkEdit1.Checked && checkEdit2.Checked) str = dateEditStartDate.DateTime.ToShortDateString() + " - " + dateEditEndDate.DateTime.ToShortDateString(); else if (checkEdit1.Checked && !checkEdit2.Checked) { str = dateEditStartDate.DateTime.ToLongDateString() + " - Unlimited"; } else if (!checkEdit1.Checked && checkEdit2.Checked) { str = "Unlimited - " + dateEditEndDate.DateTime.ToShortDateString(); } else { str = ""; //str.AppendFormat("From: Not Filtered To: Not Filtered"); } phf.Header.LineAlignment = BrickAlignment.Center; phf.Header.Content.Add(str); phf.Footer.LineAlignment = BrickAlignment.Near; phf.Footer.Content.Add(""); phf.Footer.LineAlignment = BrickAlignment.Center; phf.Footer.Content.Add(""); phf.Footer.LineAlignment = BrickAlignment.Far; String footer = "Date Generated: " + System.DateTime.Today.ToShortDateString(); phf.Footer.Content.Add(footer); phf.Footer.LineAlignment = BrickAlignment.Far; PrintableComponentLink _link = new PrintableComponentLink(new PrintingSystem()); _link.Component = gc; _link.Landscape = true; _link.PageHeaderFooter = phf; _link.PaperKind = System.Drawing.Printing.PaperKind.A4; _link.Margins.Top = 60; _link.Margins.Bottom = 60; _link.Margins.Right = 10; _link.Margins.Left = 10; if (printPreview) _link.ShowPreviewDialog(); else _link.PrintDlg(); /* PrinterSettings settings = printDocument1.PrinterSettings; //Set PageSize to 'A4' bool found=false; foreach (PaperSize size in settings.PaperSizes) { if (size.PaperName == "A4, 210x297 mm") found = true; if (found) { settings.DefaultPageSettings.PaperSize = size; break; } else continue; } printDocument1.DefaultPageSettings.Landscape = true; printDocument1.DefaultPageSettings.Margins = new Margins(50, 50, 15, 50); //printDocument1.DefaultPageSettings.PaperSize = new PaperSize("A4, 210x297 mm", 827, 1169); dataGridPrinter1 = new GridViewPrinter(gc, printDocument1, gvwContact); dataGridPrinter1.PageNumber = 1; dataGridPrinter1.RowCount = 0; if (printPreviewDialog1.ShowDialog() == DialogResult.OK) { }*/ }
private void btnPrint_Click(object sender, EventArgs e) { gridViewPriceHistory.OptionsPrint.AutoWidth = true; var printableComponent = new PrintableComponentLink(new PrintingSystem()) { Component = gridPriceHistory, Landscape = true, PaperKind = PaperKind.A4, }; printableComponent.CreateReportHeaderArea += printableComponent_CreateReportHeaderArea; printableComponent.CreateDocument(); printableComponent.ShowPreview(); }
private void ExportButton_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; PopUpExportation pop = new PopUpExportation(); if (pop.ShowDialog() == DialogResult.Yes) { } // Obtain the current export options. PdfExportOptions options = new PdfExportOptions(); // Set Print Preview options. options.Compressed = false; options.ImageQuality = PdfJpegImageQuality.Highest; options.PdfACompatible = true; forceVitesseChart.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Stretch; forceVitesseMChart.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Stretch; forcePositionChart.OptionsPrint.SizeMode = DevExpress.XtraCharts.Printing.PrintSizeMode.Stretch; PrintableComponentLink link1 = new PrintableComponentLink(); PrintableComponentLink link2 = new PrintableComponentLink(); PrintableComponentLink link3 = new PrintableComponentLink(); var composentlink = new DevExpress.XtraPrintingLinks.CompositeLink(new PrintingSystem()); foreach (int val in pop.valeurs) { switch (val) { case 0: link1.Component = forcePositionChart; composentlink.Links.Add(link1); break; case 1: link2.Component = forceVitesseChart; composentlink.Links.Add(link2); break; case 2: link3.Component = forceVitesseMChart; composentlink.Links.Add(link3); break; } } composentlink.Landscape = true; //page permettant de choisir l'emplacement et le nom du fichier pour l'enregistrement SaveFileDialog saveFileDialog1 = new SaveFileDialog(); if (saveFileDialog1.ShowDialog() == DialogResult.OK) { composentlink.ExportToPdf(saveFileDialog1.FileName + ".pdf", options); MessageBox.Show("Exportation réussie", "PDF"); } Cursor.Current = Cursors.Default; }
private void InDuLieu() { try { PrintingSystem printingSystem1 = new PrintingSystem(); //Set default export option printingSystem1.ExportDefault = PrintingSystemCommand.ExportXls; printingSystem1.SetCommandVisibility(PrintingSystemCommand.ExportXls, CommandVisibility.All); printingSystem1.SendDefault = PrintingSystemCommand.SendXls; printingSystem1.SetCommandVisibility(PrintingSystemCommand.SendXls, CommandVisibility.All); //Create a link to print the Grid control. PrintableComponentLink printableComponentLink1 = new PrintableComponentLink(); // Specify the link's printable component. printableComponentLink1.Component = grdDanhMuc; // Assign the printing system to this link. printableComponentLink1.PrintingSystem = printingSystem1; //add image Image a = (Image)(new Bitmap(Image.FromFile("d:\\2.jpg"), new Size(50, 50))); printableComponentLink1.Images.Add(a); printableComponentLink1.PaperKind = System.Drawing.Printing.PaperKind.A4; int icolVis = 0; foreach (DevExpress.XtraGrid.Columns.GridColumn column in grvDanhMuc.Columns) { if (column.Visible) { icolVis++; } } if (icolVis > 5) { printableComponentLink1.Landscape = true; } printableComponentLink1.Margins.Left = 10; printableComponentLink1.Margins.Right = 10; printableComponentLink1.Margins.Top = 90; printableComponentLink1.Margins.Bottom = 40; PageHeaderFooter phf = printableComponentLink1.PageHeaderFooter as PageHeaderFooter; phf.Header.Content.Clear(); // Add custom information to the link's header. string[] sTitle = lab_Link.Text.Split(new Char[] { '/' }); phf.Header.Content.AddRange(new string[] { "[Image 0]", sTitle[1].ToString().Trim(), "" }); phf.Header.Font = new Font(phf.Header.Font.Name, 24, FontStyle.Bold); phf.Footer.Content.AddRange(new string[] { "Date: [Date Printed]", "", "Pages: [Page # of Pages #]" }); phf.Header.LineAlignment = BrickAlignment.Center; phf.Footer.LineAlignment = BrickAlignment.Far; printableComponentLink1.ShowPreview(); } catch (Exception ex) { XtraMessageBox.Show(ex.Message.ToString()); } }
private void printGridBarButtonItem_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); PrintableComponentLink pcl2 = null; pcl.CreateReportHeaderArea += PrintableComponentLink_CreateReportHeaderArea; //INSTANT C# NOTE: The following VB 'Select Case' included either a non-ordinal switch expression or non-ordinal, range-type, or non-constant 'Case' expressions and was converted to C# 'if-else' logic: // Select Case locationsXtraTabControl.SelectedTabPage.Name //ORIGINAL LINE: Case inventoryXtraTabPage.Name if (locationsXtraTabControl.SelectedTabPage.Name == inventoryXtraTabPage.Name) { pcl.Component = inventoryGridControl; m_GridReportTitle = "Inventory At " + m_CurrentLocation.LocationCode; } //ORIGINAL LINE: Case inventoryByLotXtraTabPage.Name else if (locationsXtraTabControl.SelectedTabPage.Name == inventoryByLotXtraTabPage.Name) { pcl.Component = inventoryByLotGridControl; m_GridReportTitle = "Inventory By LPN - Lot At " + m_CurrentLocation.LocationCode; } //ORIGINAL LINE: Case transfersXtraTabPage.Name else if (locationsXtraTabControl.SelectedTabPage.Name == transfersXtraTabPage.Name) { pcl.Component = transfersFromGridControl; m_GridReportTitle = "Transfers From/To " + m_CurrentLocation.LocationCode; pcl2 = new PrintableComponentLink(new PrintingSystem()); pcl2.CreateReportHeaderArea += PrintableComponentLink_CreateReportHeaderArea; pcl2.Component = transfersToGridControl; } //ORIGINAL LINE: Case receivingReturnsXtraTabPage.Name else if (locationsXtraTabControl.SelectedTabPage.Name == receivingReturnsXtraTabPage.Name) { pcl.Component = receivingReturnsGridControl; m_GridReportTitle = "Receiving Returns At " + m_CurrentLocation.LocationCode; } //ORIGINAL LINE: Case receivingXtraTabPage.Name else if (locationsXtraTabControl.SelectedTabPage.Name == receivingXtraTabPage.Name) { pcl.Component = receivingsGridControl; m_GridReportTitle = "Receivings At " + m_CurrentLocation.LocationCode; } //ORIGINAL LINE: Case productionXtraTabPage.Name else if (locationsXtraTabControl.SelectedTabPage.Name == productionXtraTabPage.Name) { pcl.Component = productionGridControl; m_GridReportTitle = "Production At " + m_CurrentLocation.LocationCode; } //ORIGINAL LINE: Case shippingsXtraTabPage.Name else if (locationsXtraTabControl.SelectedTabPage.Name == shippingsXtraTabPage.Name) { pcl.Component = shippingsGridControl; m_GridReportTitle = "Shippings At " + m_CurrentLocation.LocationCode; } //ORIGINAL LINE: Case shippingReturnsXtraTabPage.Name else if (locationsXtraTabControl.SelectedTabPage.Name == shippingReturnsXtraTabPage.Name) { pcl.Component = shippingReturnsGridControl; m_GridReportTitle = "Shipping Returns At " + m_CurrentLocation.LocationCode; } //ORIGINAL LINE: Case Else else { } pcl.CreateDocument(); pcl.ShowPreviewDialog(); if (pcl2 != null) { pcl2.CreateDocument(); pcl2.ShowPreviewDialog(); } }
private void BtnPrintClicked(object sender, EventArgs e) { if (transactionGrid.DataSource == null) { XtraMessageBox.Show("Select the BinCard to Print", "Select Bincard", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (tabControl1.SelectedTabPage == tbSOHLocation) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = gridLocations; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Locations For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } else if (tabControl1.SelectedTabPage == tbSOHPriceSummary) { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = gridSOHSummary; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Price Summary For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } else { PrintableComponentLink pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = transactionGrid; pcl.Landscape = true; Item itm = new Item(); itm.GetItemById(_ItemID); pcl.RtfReportHeader = "Transactions For: " + itm.FullItemName + "\n"; pcl.RtfReportFooter = DateTimeHelper.ServerDateTime.ToShortDateString(); pcl.PrintDlg(); } }
public void ExportData() { using (var dialog = new SaveFileDialog()) { dialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); dialog.FileName = string.Format("quickSITES & Emails({0}).xlsx", DateTime.Now.ToString("MMddyy-hmmtt")); dialog.Filter = "Excel files|*.xlsx"; dialog.Title = "Export quickSites & Emails"; if (dialog.ShowDialog() != DialogResult.OK) return; var options = new XlsxExportOptions(); options.SheetName = Path.GetFileNameWithoutExtension(dialog.FileName); options.TextExportMode = TextExportMode.Text; options.ExportHyperlinks = true; options.ShowGridLines = true; options.ExportMode = XlsxExportMode.SingleFile; var parts = new Dictionary<string, string>(); using (var form = new FormProgress()) { FormMain.Instance.ribbonControl.Enabled = false; Enabled = false; form.laProgress.Text = "Exporting data..."; form.TopMost = true; form.Show(); Application.DoEvents(); var thread = new Thread(() => { var tempFile = Path.Combine(Path.GetTempPath(), String.Format("{0}.xlsx", Guid.NewGuid())); BeginInvoke(new Action(() => { using (var printingSystem = new PrintingSystem()) { var printLink = new PrintableComponentLink { Landscape = true, PaperKind = PaperKind.A4, Component = gridControlRecords }; printLink.CreateReportHeaderArea += OnCreateReportHeaderArea; printLink.CreateDocument(printingSystem); printingSystem.ExportToXlsx(tempFile, options); } })); parts.Add("quickSITES & Emails", tempFile); ActivityExportHelper.ExportCommonData(dialog.FileName, parts); }); thread.Start(); while (thread.IsAlive) { Thread.Sleep(100); Application.DoEvents(); } form.Close(); Enabled = true; FormMain.Instance.ribbonControl.Enabled = true; } if (File.Exists(dialog.FileName)) Process.Start(dialog.FileName); } }
private void xxxxx(object sender, EventArgs e) { int tstID = (int)tstGridView.GetFocusedRowCellValue(colTSTIDt); rprTklfTableAdapter.Fill(teklifDataSet.RPR_TKLF, tstID, "T"); TeklifDataSet.RPR_TKLFRow rprTklfRow = (TeklifDataSet.RPR_TKLFRow)teklifDataSet.RPR_TKLF.Rows[0]; hdrTmp = rprTklfRow.USTNOT; PrintingSystem ps = new PrintingSystem(); PrintableComponentLink link = new PrintableComponentLink(ps); link.Component = tsfGridControl; link.PaperKind = System.Drawing.Printing.PaperKind.A4; link.Landscape = true; link.Margins.Left = 50; link.Margins.Right = 50; link.Margins.Top = 50; link.Margins.Bottom = 50; var Font = new Font("Tahoma", 10, FontStyle.Bold); object frm = tstGridView.GetFocusedRowCellDisplayText(colFRTIDt); object rot = tstGridView.GetFocusedRowCellValue(colROTt); object mot = tstGridView.GetFocusedRowCellValue(colMOTt); object hOrg = tstGridView.GetFocusedRowCellValue(colORGSt); object hDst = tstGridView.GetFocusedRowCellValue(colDSTSt); object mOrg = tstGridView.GetFocusedRowCellValue(colPOLSt); object mDst = tstGridView.GetFocusedRowCellValue(colPOUSt); PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter; string mdlH = string.Format("Talep/Teklif {0} ", tstGridView.GetFocusedRowCellValue(colTSTIDt)); phf.Header.Content.AddRange(new string[] { "", mdlH, "" }); phf.Header.LineAlignment = BrickAlignment.Far; phf.Header.Font = Font; int frtID = (int)tstGridView.GetFocusedRowCellValue(colFRTIDt); string firma = Program.MF.FrtAd(frtID); string lblFRT = "Firma"; string lblTKLTRH = "Teklif Tarihi"; string lblGCRTRH = "Geçerlilik Tarihi"; string lblHORGS = "Çı kı ş Yeri"; string lblHDSTS = "Varı ş Yeri"; string lblMORGS = "Çı kı ş Limanı"; string lblMDSTS = "Varı ş Limanı"; string lblMALCINSI = "Mal Cinsi"; tsfGridView.OptionsPrint.RtfReportHeader = hdrTmp .Replace("@lblFRT@", lblFRT) .Replace("@FRT@", firma) .Replace("@lblTKLTRH@", lblTKLTRH) .Replace("@TKLTRH@", tstGridView.GetFocusedRowCellDisplayText(colTKLTRHt)) .Replace("@lblGCRTRH@", lblGCRTRH) .Replace("@GCRTRH@", tstGridView.GetFocusedRowCellDisplayText(colGCRTRHt)) .Replace("@ROT@", tstGridView.GetFocusedRowCellDisplayText(colROTt)) .Replace("@MOT@", tstGridView.GetFocusedRowCellDisplayText(colMOTt)) .Replace("@lblHORGS@", lblHORGS) .Replace("@HORGS@", tstGridView.GetFocusedRowCellDisplayText(colORGSt)) .Replace("@lblHDSTS@", lblHDSTS) .Replace("@HDSTS@", tstGridView.GetFocusedRowCellDisplayText(colDSTSt)) .Replace("@lblMORGS@", lblMORGS) .Replace("@MORGS@", tstGridView.GetFocusedRowCellDisplayText(colPOLSt)) .Replace("@lblMDSTS@", lblMDSTS) .Replace("@MDSTS@", tstGridView.GetFocusedRowCellDisplayText(colPOUSt)) .Replace("@DTM@", tstGridView.GetFocusedRowCellDisplayText(colDTMt)) .Replace("@PTM@", tstGridView.GetFocusedRowCellDisplayText(colPTMt)) .Replace("@lblMALCINSI@", lblMALCINSI) .Replace("@MALCINSI@", tstGridView.GetFocusedRowCellDisplayText(colMALCINSIt)) .Replace("@INFO@", tstGridView.GetFocusedRowCellDisplayText(colINFOt)); string s = tstGridView.GetFocusedRowCellDisplayText(colGCRTRHt); // phf.Footer.Content.AddRange(new string[] { "[Date Printed] [Time Printed]", "", Program.USR }); // phf.Footer.LineAlignment = BrickAlignment.Near; link.CreateDocument(); link.ShowPreview(); }
public ActionResult ExportChart(long IdModuloActual) { switch (IdModuloActual) { case 13010300: ChartControlSettings settings = ChartHelpers.GetChartSettings(); using (MemoryStream stream = new MemoryStream()) { settings.SaveToStream(stream); stream.Seek(0, SeekOrigin.Begin); WebChartControl chartControl = new WebChartControl(); chartControl.LoadFromStream(stream); chartControl.Width = Convert.ToInt16(settings.Width.Value); chartControl.Height = Convert.ToInt16(settings.Height.Value); chartControl.DataSource = new DataView(ChartHelpers.GenerateDataIO(Metodos.GetDataGraficoImpactoOperacional())); var pcl = new PrintableComponentLink(new PrintingSystem()); pcl.Component = ((IChartContainer)chartControl).Chart; pcl.Landscape = true; pcl.CreateDocument(); using (var exstream = new MemoryStream()) { pcl.PrintingSystem.ExportToPdf(exstream); byte[] buf = new byte[(int)exstream.Length]; exstream.Seek(0, SeekOrigin.Begin); exstream.Read(buf, 0, buf.Length); return(File(buf, "application/pdf", "chart" + Guid.NewGuid().ToString() + ".pdf")); } } case 13010600: //< div id = "multichart" > // < div class="MTD"> // <div class="Titulo"> // @Html.Raw(Resources.ReporteResource.captionMDTHeader) // </div> // @Html.Partial("GraficoMTDPartialView", Model.DataMTD) // </div> // <div class="RPO"> // <div class="Titulo"> // @Html.Raw(Resources.ReporteResource.captionRPOHeader) // </div> // @Html.Partial("GraficoRPOPartialView", Model.DataRPO) // </div> // <div class="RTO"> // <div class="Titulo"> // @Html.Raw(Resources.ReporteResource.captionRTOHeader) // </div> // @Html.Partial("GraficoRTOPartialView", Model.DataRTO) // </div> // <div class="WRT"> // <div class="Titulo"> // @Html.Raw(Resources.ReporteResource.captionWRTHeader) // </div> // @Html.Partial("GraficoWRTPartialView", Model.DataWRT) // </div> //</div> break; case 13010900: //chartControl.DataSource = new DataView(ChartHelpers.GenerateDataIO(Metodos.GetNroProcesosByImpactoOperacional())); break; } return(null); }
/// <summary> /// 数据表格打印预览 /// </summary> /// <param name="ListGrid">数据表格</param> /// <param name="strHead">表头显示信息</param> public static void PrintView(DevExpress.XtraGrid.GridControl ListGrid,DevExpress.XtraGrid.Views.Grid.GridView gridView, string strHead) { Cursor currentCursor = Cursor.Current; Cursor.Current = Cursors.WaitCursor; //"Report file creating","Read Data, Please waiting..." DevExpress.Utils.WaitDialogForm frmWait = new DevExpress.Utils.WaitDialogForm("正在获取数据,请稍候...", "表格报表"); frmWait.Show(); //以下以前的一种用法,现在改为可加上表头信息的印方式 //if (DevExpress.XtraPrinting.PrintHelper.IsPrintingAvailable) // DevExpress.XtraPrinting.PrintHelper.ShowPreview(ListGrid); //else // //"XtraPrinting Library is not found..." // DevExpress.XtraEditors.XtraMessageBox.Show(common.GetLanguageWord("MESSAGE", "M0028"), "", MessageBoxButtons.OK, MessageBoxIcon.Information); //以下为采用新的打印方式 string middleColumn = strHead; string rightColumn = string.Format("打印时间:{0:g}", DateTime.Now); PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()); PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter; phf.Header.Content.Clear(); phf.Header.Font = new Font("宋体", 12, FontStyle.Bold); phf.Header.Content.AddRange(new string[] { "打印用户:" + Common._personname, middleColumn, rightColumn }); phf.Footer.Content.AddRange(new string[] { "", "页次[页 #/#]", "" }); gridView.OptionsPrint.AutoWidth = false; //<- 2012-09-18 add link.Component = ListGrid; //link.CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea); DevExpress.LookAndFeel.UserLookAndFeel lookfeel = new DevExpress.LookAndFeel.UserLookAndFeel(ListGrid); lookfeel.ParentLookAndFeel = ListGrid.LookAndFeel; PrintingSystem printSystem = new PrintingSystem(); PrinterSettingsUsing pst = new PrinterSettingsUsing(); pst.UseMargins = true; pst.UsePaperKind = true; printSystem.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.A4; printSystem.PageSettings.PaperName = "A4"; printSystem.PageSettings.LeftMargin = 1; printSystem.PageSettings.RightMargin = 1; printSystem.PageSettings.Landscape = true; printSystem.PageSettings.AssignDefaultPrinterSettings(pst); link.PaperKind = printSystem.PageSettings.PaperKind; link.Margins = printSystem.PageSettings.Margins; link.Landscape = printSystem.PageSettings.Landscape; link.CreateDocument(); link.ShowPreview(lookfeel); Cursor.Current = currentCursor; frmWait.Dispose(); frmWait = null; }
private void btnTruyVan_Click(object sender, EventArgs e) { tenCSKCB = ""; complinkMain = new CompositeLink(new PrintingSystem()); int soluongGridControl = soluongLookupEdit; int i_sl = 0; GridControl[] gridcontrolTemps = new GridControl[soluongGridControl + 1]; PrintableComponentLink[] linkTemps = new PrintableComponentLink[soluongGridControl + 1]; DataTable[] dt_Temps = new DataTable[soluongGridControl + 1]; int soLuongSheet = 0; maDieuKiens = new string[soluongGridControl]; tenDieuKiens = new string[soluongGridControl]; DieuKiens = new string[soluongGridControl]; if (this.lookUpEditCSKCB.EditValue.ToString() != "Tên CSKCB") { if (this.lookUpEditCSKCB.Text == "Tất cả CSKCB") { flag_excel = false; string query = "select table_name from information_schema.tables where table_name like '%xml123_%' and table_name not like 'xml123_dtdi'"; SqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); try { DataTable _dt_schema_table = DBUtils.GetDBTable(query, conn); if (_dt_schema_table.Rows.Count > 0) { string temp = ""; string temp_cautruyvan = ""; if (this.lookUpEditCauTruyVan.EditValue.ToString() != "Tất cả điều kiện") { //Code string _ngayBatDau = this.tbThoiGianBatDau.Text; string _ngayKetThuc = this.tbThoiGianKetThuc.Text; string _CauTruyVan = this.lookUpEditCauTruyVan.EditValue.ToString(); _CauTruyVan = _CauTruyVan.Replace("_ngaybatdau_", _ngayBatDau); _CauTruyVan = _CauTruyVan.Replace("_ngayketthuc_", _ngayKetThuc); temp_cautruyvan = _CauTruyVan; temp = temp_cautruyvan.Replace("xml123", _dt_schema_table.Rows[0][0].ToString()); if (_dt_schema_table.Rows.Count > 1) { for (int i = 1; i < _dt_schema_table.Rows.Count; i++) { temp_cautruyvan = _CauTruyVan; string _MaCSKCB = _dt_schema_table.Rows[i][0].ToString(); temp = temp + " UNION ALL " + temp_cautruyvan.Replace("xml123", _MaCSKCB); } } //MessageBox.Show(temp); DataTable dt_alllll = DBUtils.GetDBTable(temp, conn); this.gridControlKetQua.DataSource = dt_alllll; } else { MessageBox.Show("Không được chọn tất cả các điều kiện!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } catch (SqlException ex) { MessageBox.Show("Error: " + ex.ToString()); } finally { conn.Close(); conn.Dispose(); } } else //Từng cơ sở khám chữa bệnh { string _MaCSKCB = this.lookUpEditCSKCB.EditValue.ToString(); tenCSKCB = _MaCSKCB; _MaCSKCB = "xml123_" + _MaCSKCB; if (this.lookUpEditCauTruyVan.EditValue.ToString() != "Tất cả điều kiện") { flag_excel = false; //Code string _ngayBatDau = this.tbThoiGianBatDau.Text; string _ngayKetThuc = this.tbThoiGianKetThuc.Text; string _CauTruyVan = this.lookUpEditCauTruyVan.EditValue.ToString(); _CauTruyVan = _CauTruyVan.Replace("_ngaybatdau_", _ngayBatDau); _CauTruyVan = _CauTruyVan.Replace("_ngayketthuc_", _ngayKetThuc); _CauTruyVan = _CauTruyVan.Replace("xml123", _MaCSKCB); SqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); try { DataTable dt = DBUtils.GetDBTable(_CauTruyVan, conn); this.gridControlKetQua.DataSource = dt; } catch (SqlException ex) { MessageBox.Show("Error: " + ex.ToString()); } finally { conn.Close(); conn.Dispose(); } } else //Chọn tất cả các câu truy vấn. { flag_excel = true; /* * **************************************************** * **************************************************** * **************************************************** * **************************************************** * **************************************************** * **************************************************** * **************************************************** */ //MessageBox.Show(dtBangDieuKien.Rows.Count.ToString()); string DieuKien = ""; string query = ""; for (int j = 0; j < dtBangDieuKien.Rows.Count - 1; j++) { string _ngayBatDau = this.tbThoiGianBatDau.Text; string _ngayKetThuc = this.tbThoiGianKetThuc.Text; string _CauTruyVan = dtBangDieuKien.Rows[j][2].ToString(); _CauTruyVan = _CauTruyVan.Replace("_ngaybatdau_", _ngayBatDau); _CauTruyVan = _CauTruyVan.Replace("_ngayketthuc_", _ngayKetThuc); _CauTruyVan = _CauTruyVan.Replace("xml123", _MaCSKCB); query = _CauTruyVan; DieuKien = _CauTruyVan; maDieuKiens[i_sl] = dtBangDieuKien.Rows[j][0].ToString(); tenDieuKiens[i_sl] = dtBangDieuKien.Rows[j][1].ToString(); //Gridv SqlConnection conn = DBUtils.GetDBConnection(); conn.Open(); try { dt_Temps[i_sl] = DBUtils.GetDBTable(query, conn); DataColumn Col = dt_Temps[i_sl].Columns.Add("STT"); Col.SetOrdinal(0); for (int i = 0; i < dt_Temps[i_sl].Rows.Count; i++) { dt_Temps[i_sl].Rows[i]["STT"] = i + 1; } //MessageBox.Show(dt_Temps[i_sl].Rows.Count.ToString()); if (dt_Temps[i_sl].Rows.Count > 0) { gridcontrolTemps[i_sl] = new GridControl(); gridcontrolTemps[i_sl].BindingContext = new System.Windows.Forms.BindingContext(); gridcontrolTemps[i_sl].DataSource = dt_Temps[i_sl]; Form frm = new Form(); frm.Controls.Add(gridcontrolTemps[i_sl]); gridcontrolTemps[i_sl].ForceInitialize(); linkTemps[i_sl] = new PrintableComponentLink(new PrintingSystem()); linkTemps[i_sl].Component = gridcontrolTemps[i_sl]; //Bảng đổi tên soLuongSheets[soLuongSheet] = tenDieuKiens[i_sl]; soLuongMaDieuKienSheets[soLuongSheet] = maDieuKiens[i_sl]; soLuongSheet++; linkTemps[i_sl].CreateMarginalHeaderArea += new CreateAreaEventHandler(Link_CreateMarginalHeaderArea); complinkMain.Links.Add(linkTemps[i_sl]); } } catch (SqlException ex) { MessageBox.Show("Error: " + ex.ToString()); } finally { conn.Close(); conn.Dispose(); } //KẾT THÚC ĐIỀU KIỆN i_sl++; } MessageBox.Show("Đã khởi tạo xong dữ liệu!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } } } else { MessageBox.Show("Chưa chọn Cơ sở khám chữa bệnh!", "Thông báo!", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
private void exportToolStripMenuItem_Click(object sender, EventArgs e) { /* * CompositeLink cLink = new CompositeLink(new PrintingSystem()); * PrintableComponentLink pcl1 = new PrintableComponentLink(); * pcl1.Component = accKlnDtyAllGridControl; * PrintableComponentLink pcl2 = new PrintableComponentLink(); * pcl2.Component = accKlnOztAllTopGridControl; * * Link npl = new Link(); // newPage Link * npl.CreateDetailArea += npl_CreateDetailArea; * * cLink.Links.Add(pcl1); * cLink.Links.Add(npl); * cLink.Links.Add(pcl2); * * cLink.PaperKind = System.Drawing.Printing.PaperKind.A4; * cLink.Landscape = true; * cLink.Margins.Left = 50; * cLink.Margins.Right = 50; * cLink.Margins.Top = 50; * cLink.Margins.Bottom = 50; * * var Font = new Font("Tahoma", 12, FontStyle.Bold); * * PageHeaderFooter phf = cLink.PageHeaderFooter as PageHeaderFooter; * string mdlH = string.Format("Müşteri Kalan Takibi"); * phf.Header.Content.AddRange(new string[] { "", mdlH, "" }); * phf.Header.LineAlignment = BrickAlignment.Far; * phf.Header.Font = Font; * * phf.Footer.Content.AddRange(new string[] { "[Date Printed] [Time Printed]", "", Program.USR }); * phf.Footer.LineAlignment = BrickAlignment.Near; * * cLink.ShowPreviewDialog(); */ DevExpress.Export.ExportSettings.DefaultExportType = DevExpress.Export.ExportType.DataAware; PrintableComponentLink link = new PrintableComponentLink(new PrintingSystem()); link.Component = accKlnDtyAllGridControl; link.PaperKind = System.Drawing.Printing.PaperKind.A4; link.Landscape = true; link.Margins.Left = 50; link.Margins.Right = 50; link.Margins.Top = 50; link.Margins.Bottom = 50; var Font = new Font("Tahoma", 12, FontStyle.Bold); PageHeaderFooter phf = link.PageHeaderFooter as PageHeaderFooter; string mdlH = string.Format("Müşteri Kalan Takibi"); phf.Header.Content.AddRange(new string[] { "", mdlH, "" }); phf.Header.LineAlignment = BrickAlignment.Far; phf.Header.Font = Font; phf.Footer.Content.AddRange(new string[] { "[Date Printed] [Time Printed]", "", Program.USR }); phf.Footer.LineAlignment = BrickAlignment.Near; link.CreateDocument(); link.ShowPreview(); }
private void PrintGrid(GridControl gc) { //GridView gvwContact = (GridView) gc.DefaultView; string strHeader = strMenuOption; strHeader = strHeader.Remove(strHeader.Length - 3, 3); //strHeader += " Information"; PageHeaderFooter phf = new PageHeaderFooter(); phf.Header.Font = new Font("Arial", 15, FontStyle.Bold, GraphicsUnit.Point); phf.Header.Content.Add(strHeader); PrintableComponentLink _link = new PrintableComponentLink(new PrintingSystem()); _link.Component = gc; _link.Landscape = true; _link.PageHeaderFooter = phf; _link.PaperKind = PaperKind.A4; _link.Margins.Top = 60; _link.Margins.Bottom = 60; _link.Margins.Right = 10; _link.Margins.Left = 10; _link.ShowPreviewDialog(); /* PrinterSettings settings = printDocument1.PrinterSettings; //Set PageSize to 'A4' bool found=false; foreach (PaperSize size in settings.PaperSizes) { if (size.PaperName == "A4, 210x297 mm") found = true; if (found) { settings.DefaultPageSettings.PaperSize = size; break; } else continue; } printDocument1.DefaultPageSettings.Landscape = true; printDocument1.DefaultPageSettings.Margins = new Margins(50, 50, 15, 50); //printDocument1.DefaultPageSettings.PaperSize = new PaperSize("A4, 210x297 mm", 827, 1169); dataGridPrinter1 = new GridViewPrinter(gc, printDocument1, gvwContact); dataGridPrinter1.PageNumber = 1; dataGridPrinter1.RowCount = 0; if (printPreviewDialog1.ShowDialog() == DialogResult.OK) { }*/ }
protected virtual void OnExportXls() { if (Printer == null) return; var ps = new PrintingSystem(); var link = new PrintableComponentLink(ps); link.Component = Printer; link.CreateReportHeaderArea += printableComponentLink_CreateReportHeaderArea; link.PaperKind = PaperKind.A4; link.Margins.Bottom = link.Margins.Left = link.Margins.Right = link.Margins.Top = 50; link.CreateDocument(); var fileName = string.Empty; var save = new SaveFileDialog(); save.Filter = "Exel 2003 (*.xls)|*.xls"; if (save.ShowDialog() == DialogResult.OK) fileName = save.FileName; if (string.IsNullOrEmpty(fileName)) return; link.ExportToXls(fileName); }