Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use DevExpress Report Control to realize pdf Printing

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article focuses on "how to use DevExpress Report controls to achieve pdf printing", interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to use DevExpress Report controls to achieve pdf printing"!

The button pops up (get the BatchID selected on the current page, pass parameters into the child window through the constructor and open the window):

FrmQCMTranInspBatchList.cs (parent window)

Private void btnInspBatchPrint_ItemClick (object sender, DevExpress.XtraBars.ItemClickEventArgs e) {try {GlobalVariable.gaSelectPOID.Clear (); int [] iaPOs = gdvDetail.GetSelectedRows (); if (iaPOs.Length)

< 1) { CommonFunction.ShowMsgBox("请选择一条或多条参数");//ToDo: Multi-Language return; } int[] iaRAWID = new int[iaPOs.Length];//+2 string sBatchID = ""; for (int i = 0; i < iaPOs.Length; i++) { sBatchID = gdvDetail.GetRowCellValue(iaPOs[i], "BATCH_ID").ToString(); } //saPARA_ID[iaPOs.Length] = cboModelVer.EditValue.ToString(); //saPARA_ID[iaPOs.Length + 1] = "EVENT"; rptQCMInspBatchCard InspBatchCard = new rptQCMInspBatchCard(sBatchID); DevExpress.XtraReports.UI.ReportPrintTool printTool = new DevExpress.XtraReports.UI.ReportPrintTool(InspBatchCard); printTool.ShowPreviewDialog(); } catch (Exception ex) { CommonFunction.ShowMsgBox("frmAPSReleaseWO.btnSelect_Click()\n" + ex.Message); } } 子窗口获取参数,并根据该参数执行SQL语句查询需要的数据,再将查到的数据放入Report中(条形码赋值即可自动生成) rptQCMInspBatchCard.cs(子窗口): using System;using System.Drawing;using System.Collections;using System.ComponentModel;using DevExpress.XtraReports.UI;using System.Data;using TRSCore;using System.Text;using MESCore;namespace QCMCore.Reports{ public partial class rptQCMInspBatchCard : DevExpress.XtraReports.UI.XtraReport { public rptQCMInspBatchCard(string sBatchId) { InitializeComponent(); this.sBatchID = sBatchId; } #region Variable private string sBatchID; #endregion #region Function private bool FillHeader() { try { DataTable dtOrd = new DataTable(); dtOrd.Columns.Add("BATCH_ID"); dtOrd.Columns.Add("LOT_ID"); dtOrd.Columns.Add("START_RES_ID"); dtOrd.Columns.Add("MAT_ID"); TRSNode in_node = new TRSNode("Sql_In"); TRSNode out_node = new TRSNode("Sql_Out"); StringBuilder sb = new StringBuilder(); CommonRoutine.SetInMsg(in_node); string sFactory =in_node.Factory; in_node.ProcStep = '1'; in_node.AddInt("NEXT_ROW", 0); sb.Append("SELECT A.BATCH_ID, A.LOT_ID, A.START_RES_ID, A.MAT_ID FROM WIPLOTSTS A INNER JOIN QCMITEMINSP B ON A.LOT_ID = B.ITEM_ID WHERE A.FACTORY =B.FACTORY "); sb.Append(" AND B.FACTORY= '"+sFactory+"' AND B.BATCH_ID='" + sBatchID+"' "); in_node.SetString("SQL", sb.ToString()); do { if (CommonRoutine.CallService("BAS", "BAS_SQL_Query", in_node, ref out_node) == false) { return false; } CommonRoutine.ConvertToDataTable(dtOrd, out_node); in_node.SetInt("NEXT_ROW", out_node.GetInt("NEXT_ROW")); } while (in_node.GetInt("NEXT_ROW") >

0); if (dtOrd.Rows.Count > 0) {this.xrBarCode1.Text = dtOrd.Rows [0] ["BATCH_ID"] .ToString (); this.xrtBatchID.Text = dtOrd.Rows [0] ["BATCH_ID"] .ToString (); this.xrtLotID.Text = dtOrd.Rows [0] ["LOT_ID"] .ToString () This.xrtStartResID.Text = dtOrd.Rows [0] ["START_RES_ID"] .ToString (); this.xrtMatID.Text = dtOrd.Rows [0] ["MAT_ID"] .ToString ();} return true;} catch (Exception ex) {CommonFunction.ShowMsgBox (ex.Message) Return false;} # endregion # region Control Event # endregion private void BottomMargin_BeforePrint (object sender, System.Drawing.Printing.PrintEventArgs e) {FillHeader ();} so far, I believe you have a deeper understanding of "how to use DevExpress Report controls to achieve pdf printing". You might as well do it in practice! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report