本篇內(nèi)容主要講解“怎么用DevExpress Report控件實(shí)現(xiàn)pdf打印”,感興趣的朋友不妨來(lái)看看。本文介紹的方法操作簡(jiǎn)單快捷,實(shí)用性強(qiáng)。下面就讓小編來(lái)帶大家學(xué)習(xí)“怎么用DevExpress Report控件實(shí)現(xiàn)pdf打印”吧!
專業(yè)領(lǐng)域包括成都網(wǎng)站制作、成都網(wǎng)站建設(shè)、商城網(wǎng)站建設(shè)、微信營(yíng)銷、系統(tǒng)平臺(tái)開發(fā), 與其他網(wǎng)站設(shè)計(jì)及系統(tǒng)開發(fā)公司不同,創(chuàng)新互聯(lián)建站的整合解決方案結(jié)合了幫做網(wǎng)絡(luò)品牌建設(shè)經(jīng)驗(yàn)和互聯(lián)網(wǎng)整合營(yíng)銷的理念,并將策略和執(zhí)行緊密結(jié)合,為客戶提供全網(wǎng)互聯(lián)網(wǎng)整合方案。
按鈕彈出(獲取當(dāng)前頁(yè)面選中的BatchID,通過構(gòu)造函數(shù)傳參傳入子窗口并打開窗口):
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("請(qǐng)選擇一條或多條參數(shù)");//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); } }
子窗口獲取參數(shù),并根據(jù)該參數(shù)執(zhí)行SQL語(yǔ)句查詢需要的數(shù)據(jù),再將查到的數(shù)據(jù)放入Report中(條形碼賦值即可自動(dòng)生成)
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(); } } }
到此,相信大家對(duì)“怎么用DevExpress Report控件實(shí)現(xiàn)pdf打印”有了更深的了解,不妨來(lái)實(shí)際操作一番吧!這里是創(chuàng)新互聯(lián)網(wǎng)站,更多相關(guān)內(nèi)容可以進(jìn)入相關(guān)頻道進(jìn)行查詢,關(guān)注我們,繼續(xù)學(xué)習(xí)!