怎么用DevExpressReport控件实现pdf打印
本篇内容主要讲解“怎么用DevExpress Report控件实现pdf打印”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“怎么用DevExpress Report控件实现pdf打印”吧!
专业领域包括成都网站制作、成都网站建设、商城网站建设、微信营销、系统平台开发, 与其他网站设计及系统开发公司不同,创新互联建站的整合解决方案结合了帮做网络品牌建设经验和互联网整合营销的理念,并将策略和执行紧密结合,为客户提供全网互联网整合方案。
按钮弹出(获取当前页面选中的BatchID,通过构造函数传参传入子窗口并打开窗口):
frmQCMTranInspBatchList.cs(父窗口)
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(); } } }
到此,相信大家对“怎么用DevExpress Report控件实现pdf打印”有了更深的了解,不妨来实际操作一番吧!这里是创新互联网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
网页标题:怎么用DevExpressReport控件实现pdf打印
浏览地址:http://ybzwz.com/article/ijcpgh.html