private void btnPrint_Click(object sender, EventArgs e) { try { XtraReport report = new XtraReport(); report.LoadLayout(Application.StartupPath + "/Print/TongJiCount.repx"); report.DataSource = (DataTable)grd.DataSource; report.Parameters.Clear(); DevExpress.XtraReports.Parameters.Parameter p2 = new DevExpress.XtraReports.Parameters.Parameter(); p2.Name = "标题"; p2.Description = "标题"; p2.Value = "鉴定机构中标率统计报表 " + DateTime.Now.ToString("yyyy-MM-dd"); report.Parameters.Add(p2); if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } } catch { } }
public void Yazdirr(string DosyaAdi, Nasil NasilAcsin) { try { Rapor = new XtraReport(); Rapor.LoadLayout(DosyaAdi); Rapor.DataSource = ds; switch (NasilAcsin) { case Nasil.dizayn: XRDesignFormEx XrDesigner = new XRDesignFormEx() { FileName = DosyaAdi }; XrDesigner.OpenReport(Rapor); XrDesigner.Show(); break; case Nasil.Goster: Rapor.ShowPreview(); break; case Nasil.Yazdir: Rapor.Print(); break; } } catch (Exception hata) { frmHataBildir frmHataBildir = new frmHataBildir(hata.Message, hata.StackTrace); frmHataBildir.ShowDialog(); } }
private void btnPrint_Click(object sender, EventArgs e) { try { XtraReport report = new XtraReport(); report.LoadLayout(Application.StartupPath + "/Print/AnQingCount.repx"); report.DataSource = (DataTable)grd.DataSource; //添加参数 report.Parameters.Clear(); DevExpress.XtraReports.Parameters.Parameter p2 = new DevExpress.XtraReports.Parameters.Parameter(); p2.Name = "标题"; p2.Description = "标题"; p2.Value = "交通事故案情报统计 " + CommonInfo.CDate(this.dateEdit1.EditValue).ToString("yyyy-MM-dd") + "至" + CommonInfo.CDate(this.dateEdit2.EditValue).ToString("yyyy-MM-dd"); report.Parameters.Add(p2); DevExpress.XtraReports.Parameters.Parameter p3_1 = new DevExpress.XtraReports.Parameters.Parameter(); p3_1.Name = "统计"; p3_1.Description = "统计"; p3_1.Value = gridColumn2.SummaryText;;;; report.Parameters.Add(p3_1); DevExpress.XtraReports.Parameters.Parameter p3_2 = new DevExpress.XtraReports.Parameters.Parameter(); p3_2.Name = "A统计"; p3_2.Description = "A统计"; p3_2.Value = " " + gridColumn5.SummaryText; report.Parameters.Add(p3_2); DevExpress.XtraReports.Parameters.Parameter p3_3 = new DevExpress.XtraReports.Parameters.Parameter(); p3_3.Name = "B统计"; p3_3.Description = "B统计"; p3_3.Value = " " + gridColumn7.SummaryText; report.Parameters.Add(p3_3); DevExpress.XtraReports.Parameters.Parameter p3_4 = new DevExpress.XtraReports.Parameters.Parameter(); p3_4.Name = "D统计"; p3_4.Description = "D统计"; p3_4.Value = " " + gridColumn8.SummaryText; report.Parameters.Add(p3_4); DevExpress.XtraReports.Parameters.Parameter p3_5 = new DevExpress.XtraReports.Parameters.Parameter(); p3_5.Name = "S统计"; p3_5.Description = "S统计"; p3_5.Value = " " + gridColumn9.SummaryText; report.Parameters.Add(p3_5); if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } } catch { } }
public static void Print(MemoryStream reportStream, DataSet ds, string printName) { if (reportStream == null) { DevExpress.XtraEditors.XtraMessageBox.Show("报表模板未设置。"); return; } XtraReport report = new XtraReport { DisplayName = "Report" }; try { report.LoadLayout(reportStream); } catch { DevExpress.XtraEditors.XtraMessageBox.Show("报表模板不正确,请重新设置报表模板"); return; } report.DataSource = ds; try { report.Print(printName); } catch (Exception ex) { DevExpress.XtraEditors.XtraMessageBox.Show(ex.Message); } }
/// <summary> /// 打印操作 /// </summary> /// <param name="operation"></param> public void PrintDialog(string operation) { //当修改原数据是要进行保存后才能去打印 if (biSave.Enabled == true) { MessageBox.Show("在原数据上进行修改时请先保存后再进行打印!!!"); } var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = _cTempletFileName; //_cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.PrintingSystem.StartPrint += PrintingSystem_StartPrint; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; //模板赋值 DllWorkPrintLabel.SetParametersValue(xtreport, "cSerialNumber", lblTitleMain.lblcSerialNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cBarCode", "R*" + _FitemId + "*L*" + txtcLotNo.Text + "*S*" + lblTitleMain.lblcSerialNumber.Text + ";" + dtpcDefine2.Value.ToShortDateString()); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvCode", txtcInvCode.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvName", utecInvName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dtpdDate.Value.ToShortDateString()); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvStd", txtcInvStd.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cFullName", txtcFullName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cVendor", txtcVendor.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cLotNo", txtcLotNo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "iQuantity", uneiQuantity.Value); DllWorkPrintLabel.SetParametersValue(xtreport, "cMemo", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cDefine1", txtcDefine1.Text); if (dtpdDate.Checked) { DllWorkPrintLabel.SetParametersValue(xtreport, "cVendorDate", dtpdDate.Value); } //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
void PrintReportFromPrnx(byte[] prnx) { using (XtraReport report = new XtraReport()) { using (MemoryStream stream = new MemoryStream(prnx)) { report.PrintingSystem.LoadDocument(stream); } report.Print("Microsoft XPS Document Writer"); //specify a printer name here } }
void FisYazdir1(bool Disigner, string pkSatislar, string SatisFisTipi, string YaziciAdi) { try { string fisid = pkSatislar; System.Data.DataSet ds = new DataSet("Test"); DataTable FisDetay = DB.GetData(@"exec sp_SatisDetay " + fisid + ",1"); FisDetay.TableName = "FisDetay"; ds.Tables.Add(FisDetay); DataTable Fis = DB.GetData(@"exec sp_Satislar " + fisid); if (Fis.Rows.Count == 0) { MessageBox.Show("Satış Bulunamadı"); return; } string fkFirma = Fis.Rows[0]["fkFirma"].ToString(); Fis.TableName = "Fis"; ds.Tables.Add(Fis); //şirket bilgileri DataTable Sirket = DB.GetData(@"select top 1 * from Sirketler"); Sirket.TableName = "Sirket"; ds.Tables.Add(Sirket); //Bakiye bilgileri DataTable Bakiye = DB.GetData(@"select dbo.fon_MusteriBakiyesi(fkFirma) as Bakiye,ToplamTutar as FisTutar,dbo.fon_MusteriBakiyesi(fkFirma)-ToplamTutar as OncekiBakiye from Satislar where pkSatislar=" + pkSatislar); Bakiye.TableName = "Bakiye"; ds.Tables.Add(Bakiye); //Firma bilgileri DataTable Musteri = DB.GetData("select * from Firmalar where pkFirma=" + fkFirma); Musteri.TableName = "Musteri"; ds.Tables.Add(Musteri); string exedizini = Path.GetDirectoryName(Application.ExecutablePath); string RaporDosyasi = exedizini + "\\Raporlar\\" + SatisFisTipi + ".repx"; if (!File.Exists(RaporDosyasi)) { MessageBox.Show("Dosya Bulunamadı"); return; } XtraReport rapor = new XtraReport(); rapor.DataSource = ds; rapor.LoadLayout(RaporDosyasi); if (Disigner) { rapor.ShowDesigner(); } else { rapor.Print(YaziciAdi);//.ShowPreview(); } } catch (Exception exp) { MessageBox.Show("Hata Oluştu " + exp.Message); } }
private void btnControl_btnEventPrint_Click(object sender, EventArgs e) { try { rpt.Print(); } catch (Exception) { } }
private void _print() { try { rptGlobal.Print(); } catch (Exception) { } }
public virtual void Print(string doc) { if (!string.IsNullOrEmpty(doc)) { XtraReport rpt = InitializeReport(doc); if (rpt != null) { rpt.Print(); } } }
/// <summary> /// 打印操作 /// </summary> /// <param name="operation"></param> public void PrintDialog(string operation) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = Application.StartupPath + @"\Stencil\ProOemOrder.repx"; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; xtreport.DataSource = uGridChecks.DataSource; //模板赋值 for (var i = 0; i < uGridCheck.DisplayLayout.Bands[0].Columns.Count; i++) { var cKey = uGridCheck.DisplayLayout.Bands[0].Columns[i].Key; string cValue; if (uGridCheck.Rows.Count > _iRowNo) { cValue = uGridCheck.Rows[_iRowNo].Cells[i].Value.ToString(); } else { cValue = ""; } DLL.DllWorkPrintLabel.SetParametersValue(xtreport, cKey, cValue); } //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
public void PrintASN() { List <AsnBodyEntity> focusedBills = ucGridPanel.FocusedHeaders; if (focusedBills.Count == 0) { MsgBox.Warn("请选中要打印的单据。"); return; } if (MsgBox.AskOK(string.Format("一共选中了“{0}”个单据“{1}”,确定要开始打印吗?", focusedBills.Count, GetBillNOs(focusedBills))) != DialogResult.OK) { return; } try { #region foreach (AsnBodyEntity header in focusedBills) { XtraReport repAsn = null; bool containerNoCheck = GetContainerNochek(header); if (!containerNoCheck) { //MsgBox.Warn("该订单关联的托盘 " + containerNoCheck + " 还未复核完毕!"); return; } if (!CheckQtyPutQty(header.BillID)) { return; } repAsn = GetRepDetail(header, repAsn, 1); //repAsn.ShowPreviewDialog(); for (int i = 0; i < 2; i++) { Thread.Sleep(50); //repAsn.ShowPreviewDialog(); repAsn.Print(); repAsn = GetRepDetail(header, repAsn, 2); //whc } //更新打印标记为已打印 //this.asnDal.UpdatePrintedFlag(header.BillID); //header.Printed = 1; } #endregion } catch (Exception ex) { MsgBox.Err(ex.Message + "==" + ex.StackTrace); } }
protected override void PrintReport(IReportDataV2 reportData) { XtraReport report = ReportDataProvider.ReportsStorage.LoadReport(reportData); ReportsModuleV2 reportsModule = ReportsModuleV2.FindReportsModule(Application.Modules); if (reportsModule != null && reportsModule.ReportsDataSourceHelper != null) { reportsModule.ReportsDataSourceHelper.SetupBeforePrint(report, null, ((ListView)View).CollectionSource.Criteria["filter"], true, null, false); report.Print(); } }
public void PrintDialog(string operation) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = _cTempletFileName; //_cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; //模板赋值 DllWorkPrintLabel.SetParametersValue(xtreport, "cSerialNumber", lblTitleMain.lblcSerialNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cBarCode", "P*" + _FitemId + "*L*" + txtFBatchNo.Text + "*S*"); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvCode", txtcInvCode.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvName", utecInvName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvStd", txtcInvStd.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cFullName", txtcFullName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "iQuantity", uneiQuantity.Value); DllWorkPrintLabel.SetParametersValue(xtreport, "cMemo", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dtpdDate.Value.ToShortDateString()); DllWorkPrintLabel.SetParametersValue(xtreport, "cOrderNumber", txtcOrderNumber.Text); xtreport.DataSource = GetPrintData(); //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
public void ShowReportPrint(DataSet ds, XtraReport freport, int cnt) { this.Cursor = Cursors.WaitCursor; try { copiecnt = cnt; freport.DataSource = ds; freport.PrintingSystem.ShowMarginsWarning = false; freport.PrintingSystem.ShowPrintStatusDialog = false; freport.PrintingSystem.StartPrint += new PrintDocumentEventHandler(startPrintEventHandler); freport.Margins = new System.Drawing.Printing.Margins(20, 20, 20, 20); freport.Print(); } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Cursor = Cursors.Default; }
private void PrintSelection(Boolean details) { int parsedValue; if (!String.IsNullOrEmpty(txtName.Text) && !String.IsNullOrEmpty(txtHeight.Text) && !String.IsNullOrEmpty(cmbPrinters.SelectedItem.ToString()) && int.TryParse(txtWidth.Text, out parsedValue) && int.TryParse(txtHeight.Text, out parsedValue)) { this.Cursor = Cursors.WaitCursor; DetailBand detail = new DetailBand(); XtraReport quickPrint = new XtraReport() { ReportUnit = ReportUnit.TenthsOfAMillimeter, PaperKind = PaperKind.Custom, PageWidth = Convert.ToInt32(txtWidth.Text) * 10, PageHeight = Convert.ToInt32(txtHeight.Text) * 10 }; quickPrint.Margins.Bottom = 0; quickPrint.Margins.Top = 0; quickPrint.Margins.Left = 0; quickPrint.Margins.Right = 0; quickPrint.RequestParameters = false; quickPrint.Bands.AddRange(new Band[] { detail }); quickPrint.Bands[BandKind.Detail].Controls.Add(new XRLabel() { Text = txtName.Text, LocationF = new PointF(0, 0), Font = new Font("Segoe UI", 12) }); quickPrint.Bands[BandKind.Detail].Controls.Add(CreateCode39BarCode(txtBarcode.Text)); quickPrint.CreateDocument(); quickPrint.PrintingSystem.Document.AutoFitToPagesWidth = 1; if (details) { quickPrint.ShowRibbonDesignerDialog(); } else { quickPrint.Print(cmbPrinters.SelectedItem.ToString()); } this.Cursor = Cursors.Default; } else { MessageBox.Show("Kağıt boyutlarını giriniz!", "Üzgünüm!", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public static void PrintSale(string alisveriId, string printerName = "") { try { EnsureFormLoaded(); using (var db = new Db()) { _saleForm.DataSource = db.GetSaleInvoiceFormDatasource(alisveriId); _saleForm.CreateDocument(); } _saleForm.PrinterName = printerName; _saleForm.Print(printerName); } catch (Exception ex) { AppContext.Logger.Error(ex); throw new B2CPackageCollectException(StringResource.OperationFailedRetry); } }
/// <summary> /// 打印操作 /// </summary> /// <param name="p"></param> private void PrintDialog(string p) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = Application.StartupPath + @"\Stencil\TrackDeliveryOrder.repx"; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.Name = "TrackDeliveryOrder"; xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.RequestParameters = false; DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "cCode", txtcCode.Text); DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "cOrderType", cbxcOrderType.Text); DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "cCusName", utxtcCusName.Text); DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dtpdDate.Text); DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "OrderDate", dtpOrderDate.Text); DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "DeliveryDate", dtpDeliveryDate.Text); DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "cDepName", utecDepName.Text); //模板赋值 switch (p) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
public void Yazdirr(Nasil NasilAcsin) { //Rapor.DataAdapter = ds; //ds = new DataSet(); Rapor.DataSource = ds; switch (NasilAcsin) { case Nasil.Goster: Rapor.ShowPreviewDialog(); break; case Nasil.Yazdir: Rapor.Print(); break; case Nasil.YazdirmaDiyalogu: Rapor.PrintDialog(); break; } }
public void ShowReport(DataSet ds, XtraReport freport, bool IsPrint) { this.Cursor = Cursors.WaitCursor; try { freport.DataSource = ds; previewControlF.Report = freport; previewControlF.Report.PrintingSystem.ShowMarginsWarning = false; previewControlF.Report.Margins = new System.Drawing.Printing.Margins(20, 20, 20, 20); if (IsPrint) { freport.PrintingSystem.StartPrint += new PrintDocumentEventHandler(startPrintEventHandler); freport.Print(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } this.Cursor = Cursors.Default; }
void FisYazdir(bool Disigner, string pkSatislar, string SatisFisTipi, string YaziciAdi) { try { string fisid = pkSatislar; System.Data.DataSet ds = new DataSet("Test"); DataTable FisDetay = DB.GetData(@"exec sp_AlisDetay " + fisid + ",1"); FisDetay.TableName = "FisDetay"; ds.Tables.Add(FisDetay); DataTable Fis = DB.GetData(@"exec sp_Alislar " + fisid); Fis.TableName = "Fis"; ds.Tables.Add(Fis); string exedizini = Path.GetDirectoryName(Application.ExecutablePath); string RaporDosyasi = exedizini + "\\Raporlar\\" + SatisFisTipi + ".repx"; if (!File.Exists(RaporDosyasi)) { MessageBox.Show("Dosya Bulunamadı"); return; } //string RaporDosyasi = exedizini + "\\Raporlar\\MusteriSatis.repx"; XtraReport rapor = new XtraReport(); rapor.DataSource = ds; rapor.LoadLayout(RaporDosyasi); if (Disigner) { rapor.ShowDesigner(); } else { rapor.Print(YaziciAdi);//.ShowPreview(); } } catch (Exception exp) { MessageBox.Show("Hata Oluştu " + exp.Message); } }
void Yazdir(bool dizayn) { XtraReport rapor = new XtraReport(); //rapor.FindControl("label15", true).Text = DB.PersonellerBaslik; try { System.Data.DataSet ds = new DataSet("Test"); int i = gridView1.FocusedRowHandle; DataRow dr = gridView1.GetDataRow(i); string _fkFirma = dr["pkTedarikciler"].ToString(); DataTable Cari = DB.GetData("select *,dbo.fon_TedarikciBakiyesi(pkTedarikciler) as Bakiye from Tedarikciler with(nolock) where pkTedarikciler=" + _fkFirma); Cari.TableName = "Cari"; ds.Tables.Add(Cari); //şirket DataTable Sirket = DB.GetData("select top 1 * from Sirketler with(nolock)"); Sirket.TableName = "Sirket"; ds.Tables.Add(Sirket); rapor.DataSource = ds; rapor.LoadLayout(DB.exeDizini + "\\Raporlar\\TedarikciBakiyesi.repx"); rapor.Name = "TedarikciBakiyesi"; rapor.Report.Name = "TedarikciBakiyesi"; } catch (Exception ex) { MessageBox.Show(ex.Message); } if (dizayn) { rapor.ShowDesigner(); } else { rapor.Print(); } }
/// <summary> /// 打印 /// </summary> public override void Preview() { InitXr(); try { uiHelper.BeginLoading(this); using (ProxyAdverseEvent proxy = new ProxyAdverseEvent()) { xr.DataSource = proxy.Service.GetXrDataSource(vo.rptId); xr.CreateDocument(); } } finally { uiHelper.CloseLoading(this); } if (xr != null && xr.DataSource != null) { xr.Print(); } }
/// <summary> /// 打印操作 /// </summary> /// <param name="operation"></param> /// <param name="cTemplet"></param> /// <param name="dSource"></param> public void PrintDialog(string operation, string cTemplet, DataTable dSource) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = string.Format("{0}\\Stencil\\{1}.repx", Application.StartupPath, cTemplet); if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; xtreport.DataSource = dSource; //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
/// <summary> /// 打印 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnPrint_Click(object sender, EventArgs e) { try { XtraReport report = new XtraReport(); report.LoadLayout(Application.StartupPath + "/Print/DieCount.repx"); report.DataSource = (DataTable)grd.DataSource; //添加参数 report.Parameters.Clear(); DevExpress.XtraReports.Parameters.Parameter p2 = new DevExpress.XtraReports.Parameters.Parameter(); p2.Name = "标题"; p2.Description = "标题"; //死亡人数统计2018 - 03 - 01至2018 - 03 - 31 p2.Value = CommonInfo.CObjectToStr(this.dateEdit1.EditValue).Trim() + "至" + CommonInfo.CObjectToStr(this.dateEdit2.EditValue).Trim() + "死亡人数统计"; report.Parameters.Add(p2); DevExpress.XtraReports.Parameters.Parameter p3_5 = new DevExpress.XtraReports.Parameters.Parameter(); p3_5.Name = "死亡人数"; p3_5.Description = "死亡人数"; p3_5.Value = gridColumn3.SummaryText; report.Parameters.Add(p3_5); if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } } catch { } }
/// <summary> /// 打印操作 /// </summary> /// <param name="operation"></param> public void PrintDialog(string operation) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = Application.StartupPath + @"\Stencil\DeliveryOrder.repx"; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.Name = "DeliveryOrder"; xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; xtreport.DataSource = uGridChecks.DataSource; //模板赋值 string cKey, cValue; for (var i = 0; i < uGridCheck.DisplayLayout.Bands[0].Columns.Count; i++) { cKey = uGridCheck.DisplayLayout.Bands[0].Columns[i].Key; cValue = uGridCheck.Rows[_iRowNo].Cells[i].Value.ToString(); DLL.DllWorkPrintLabel.SetParametersValue(xtreport, cKey, cValue); } //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
private void btnPrint_Click(object sender, EventArgs e) { getSum(); try { string sError = ""; DataSet ds = new DataSet();//创建数据集 string sql = $"select * from T_AnQing where AnQingNo={sID}"; DataTable tb = SqlHelper.RunQuery(CommandType.Text, sql, null, out sError); DataTable tb2 = (DataTable)grd.DataSource; tb.TableName = "dt1n"; ds.Tables.Add(tb2.Copy()); tb2.TableName = "dt2n"; ds.Tables.Add(tb.Copy()); XtraReport report = new XtraReport(); report.LoadLayout(Application.StartupPath + "/Print/AnQingXX.repx"); report.DataSource = ds; // report.PageHeight = 320 + 18 * dt.Rows.Count; //添加参数 report.Parameters.Clear(); DevExpress.XtraReports.Parameters.Parameter p2 = new DevExpress.XtraReports.Parameters.Parameter(); p2.Name = "标题"; p2.Description = "标题"; if (CommonInfo.CLng(this.cmbDeptID.EditValue) == -1) { p2.Value = "案情编号:" + sID + " 交通事故详情"; } if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 1) { p2.Value = "案情编号:" + sID + " 交通事故痕迹检验详情"; } if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 2) { p2.Value = "案情编号:" + sID + " 交通事故酒精检验详情"; } if (CommonInfo.CLng(this.cmbDeptID.EditValue) == 3) { p2.Value = "案情编号:" + sID + " 交通事故尸体检验详情"; } report.Parameters.Add(p2); DevExpress.XtraReports.Parameters.Parameter p3_1 = new DevExpress.XtraReports.Parameters.Parameter(); p3_1.Name = "统计"; p3_1.Description = "统计"; p3_1.Value = gridColumn4.SummaryText;;;; report.Parameters.Add(p3_1); DevExpress.XtraReports.Parameters.Parameter p3_2 = new DevExpress.XtraReports.Parameters.Parameter(); p3_2.Name = "打包价"; p3_2.Description = "打包价"; if (sum == 0) { p3_2.Value = " " + gridColumn4.SummaryText; } else { p3_2.Value = " " + sum; } report.Parameters.Add(p3_2); DevExpress.XtraReports.Parameters.Parameter p3_3 = new DevExpress.XtraReports.Parameters.Parameter(); p3_3.Name = "状态"; p3_3.Description = "状态"; p3_3.Value = ja; report.Parameters.Add(p3_3); if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } } catch { } }
public void PrintDialogRm(string operation,Infragistics.Win.UltraWinGrid.UltraGridRow uRow,DataTable dt) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 //var _RmcTempletFileName = Application.StartupPath + @"\Label\班次制令单.repx"; var temPath = _RmcTempletFileName; //_cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; var cFitemID = uRow.Cells["cFitemID"].Value.ToString(); var cLotNo = uRow.Cells["FBatchNo"].Value.ToString(); var cDefine2 = dt.Rows[0]["cDefine2"].ToString(); var cSerialNumber = dt.Rows[0]["cSerialNumber"].ToString(); var cInvCode = dt.Rows[0]["cInvCode"].ToString(); var cInvName = dt.Rows[0]["cInvName"].ToString(); var dDate= dt.Rows[0]["dDate"].ToString(); var cInvStd = dt.Rows[0]["cInvStd"].ToString(); var cFullName = dt.Rows[0]["cFullName"].ToString(); var iQuantity = uRow.Cells["iQuantity"].Value.ToString(); var cMemo = dt.Rows[0]["cMemo"].ToString(); var cDefine1 = dt.Rows[0]["cDefine1"].ToString(); //模板赋值 DllWorkPrintLabel.SetParametersValue(xtreport, "cSerialNumber", lblTitleMain.lblcSerialNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cBarCode", "R*" + cFitemID + "*L*" + cLotNo + "*S*" + cSerialNumber + ";" + cDefine2); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvCode", cInvCode); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvName", cInvName); DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dDate); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvStd", cInvStd); DllWorkPrintLabel.SetParametersValue(xtreport, "cFullName", txtcFullName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cVendor", cFullName); DllWorkPrintLabel.SetParametersValue(xtreport, "cLotNo", cLotNo); DllWorkPrintLabel.SetParametersValue(xtreport, "iQuantity", iQuantity); DllWorkPrintLabel.SetParametersValue(xtreport, "cMemo", cMemo); DllWorkPrintLabel.SetParametersValue(xtreport, "cDefine1", cDefine1); if (dtpdDate.Checked) DllWorkPrintLabel.SetParametersValue(xtreport, "cVendorDate", dtpdDate.Value); //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
public void PrintDialog(string operation) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var _cTempletFileName = Application.StartupPath + @"\Label\班次制令单.repx"; var temPath = _cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; //模板赋值 DllWorkPrintLabel.SetParametersValue(xtreport, "cSerialNumber", lblTitleMain.lblcSerialNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvCode", txtcInvCode.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvName", utecInvName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvStd", txtcInvStd.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cFullName", txtcFullName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cOrderNuber", txtcOrderNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "FBatchNo", txtFBatchNo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "iQuantity", uneiQuantity.Value); DllWorkPrintLabel.SetParametersValue(xtreport, "cDepartment", txtcDept.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dtpdDate.Value.ToShortDateString()); DllWorkPrintLabel.SetParametersValue(xtreport, "cMemo", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "批次", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "库位", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "库存", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "发货数", txtcMemo.Text); //xtreport.DataSource = dataInventory.BomDetail; DataSet ds = new DataSet(); using (var con = new SqlConnection(BaseStructure.WmsCon)) { using (var cmd = new SqlCommand { CommandType = CommandType.StoredProcedure, Connection = con }) { cmd.CommandText = "proc_Bomdetail"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@BomID", bomID); using (SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd)) { dataAdapter.Fill(ds); } cmd.Parameters.Clear(); } } int count = 0; if(!int.TryParse(uneiQuantity.Value.ToString(), out count)) { count = 0; } DataTable dt = null; if (ds != null && ds.Tables[0].Rows.Count > 0) { dt = ds.Tables[0].Clone(); dt.Columns.Add("发货数", typeof(int)); //DataTable dt = ds.Tables[0]; var dtE = ds.Tables[0].AsEnumerable(); foreach (DataRow dr in GetBomDetail()) { var iquantity = Convert.ToDecimal(dr["iQuantity"]) * count; var drs = dtE.Where(w => w.Field<string>("cInvCode") == dr["cInvCode"].ToString()).OrderBy(o => o.Field<string>("批次")).ToList(); //DataRow[] drs = dtE.Select(" cInvCode = '"+dr["cInvCode"].ToString()+"'").OrderBy(""); foreach (DataRow dr1 in drs) { if (iquantity >= 0) { var kc = Convert.ToDecimal(dr1["库存"]); var fhs = kc > iquantity ? iquantity : kc; //假如库存大于发货数,直接当前库位发货,如果小于发货数,当前库位发完当前数,并到下一个库位发剩余数量 iquantity = kc >= iquantity ? -1 : iquantity - kc; DataRow drNew = dt.NewRow(); drNew["AutoID"] = dr1["AutoID"]; drNew["BomID"] = dr1["BomID"]; drNew["cInvCode"] = dr1["cInvCode"]; drNew["cInvName"] = dr1["cInvName"]; drNew["iQuantity"] = dr1["iQuantity"]; drNew["cUnitID"] = dr1["cUnitID"]; drNew["cUnitName"] = dr1["cUnitName"]; drNew["cInvStd"] = dr1["cInvStd"]; drNew["cFullName"] = dr1["cFullName"]; drNew["cMemo"] = dr1["cMemo"]; drNew["dAddTime"] = dr1["dAddTime"]; drNew["cFitemID"] = dr1["cFitemID"]; drNew["批次"] = dr1["批次"]; drNew["库位"] = dr1["库位"]; drNew["库存"] = dr1["库存"]; drNew["发货数"] = fhs; dt.Rows.Add(drNew); } } } } xtreport.DataSource = dt; //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
public void PrintDialog(string operation) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = _cTempletFileName; //_cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; //模板赋值 DllWorkPrintLabel.SetParametersValue(xtreport, "cSerialNumber", lblTitleMain.lblcSerialNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cBarCode", "P*" + _FitemId + "*L*" + txtFBatchNo.Text + "*S*" ); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvCode", txtcInvCode.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvName", utecInvName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvStd", txtcInvStd.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cFullName", txtcFullName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "iQuantity", uneiQuantity.Value); DllWorkPrintLabel.SetParametersValue(xtreport, "cMemo", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dtpdDate.Value.ToShortDateString()); DllWorkPrintLabel.SetParametersValue(xtreport, "cOrderNumber", txtcOrderNumber.Text); xtreport.DataSource = GetPrintData(); //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
public void PrintDialogRm(string operation, Infragistics.Win.UltraWinGrid.UltraGridRow uRow, DataTable dt) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 //var _RmcTempletFileName = Application.StartupPath + @"\Label\班次制令单.repx"; var temPath = _RmcTempletFileName; //_cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; var cFitemID = uRow.Cells["cFitemID"].Value.ToString(); var cLotNo = uRow.Cells["FBatchNo"].Value.ToString(); var cDefine2 = dt.Rows[0]["cDefine2"].ToString(); var cSerialNumber = dt.Rows[0]["cSerialNumber"].ToString(); var cInvCode = dt.Rows[0]["cInvCode"].ToString(); var cInvName = dt.Rows[0]["cInvName"].ToString(); var dDate = dt.Rows[0]["dDate"].ToString(); var cInvStd = dt.Rows[0]["cInvStd"].ToString(); var cFullName = dt.Rows[0]["cFullName"].ToString(); var iQuantity = uRow.Cells["iQuantity"].Value.ToString(); var cMemo = dt.Rows[0]["cMemo"].ToString(); var cDefine1 = dt.Rows[0]["cDefine1"].ToString(); //模板赋值 DllWorkPrintLabel.SetParametersValue(xtreport, "cSerialNumber", lblTitleMain.lblcSerialNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cBarCode", "R*" + cFitemID + "*L*" + cLotNo + "*S*" + cSerialNumber + ";" + cDefine2); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvCode", cInvCode); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvName", cInvName); DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dDate); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvStd", cInvStd); DllWorkPrintLabel.SetParametersValue(xtreport, "cFullName", txtcFullName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cVendor", cFullName); DllWorkPrintLabel.SetParametersValue(xtreport, "cLotNo", cLotNo); DllWorkPrintLabel.SetParametersValue(xtreport, "iQuantity", iQuantity); DllWorkPrintLabel.SetParametersValue(xtreport, "cMemo", cMemo); DllWorkPrintLabel.SetParametersValue(xtreport, "cDefine1", cDefine1); if (dtpdDate.Checked) { DllWorkPrintLabel.SetParametersValue(xtreport, "cVendorDate", dtpdDate.Value); } //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
public void PrintDialog(string operation) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var _cTempletFileName = Application.StartupPath + @"\Label\班次制令单.repx"; var temPath = _cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; //模板赋值 DllWorkPrintLabel.SetParametersValue(xtreport, "cSerialNumber", lblTitleMain.lblcSerialNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvCode", txtcInvCode.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvName", utecInvName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvStd", txtcInvStd.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cFullName", txtcFullName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cOrderNuber", txtcOrderNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "FBatchNo", txtFBatchNo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "iQuantity", uneiQuantity.Value); DllWorkPrintLabel.SetParametersValue(xtreport, "cDepartment", txtcDept.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dtpdDate.Value.ToShortDateString()); DllWorkPrintLabel.SetParametersValue(xtreport, "cMemo", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "批次", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "库位", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "库存", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "发货数", txtcMemo.Text); //xtreport.DataSource = dataInventory.BomDetail; DataSet ds = new DataSet(); using (var con = new SqlConnection(BaseStructure.WmsCon)) { using (var cmd = new SqlCommand { CommandType = CommandType.StoredProcedure, Connection = con }) { cmd.CommandText = "proc_Bomdetail"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@BomID", bomID); using (SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd)) { dataAdapter.Fill(ds); } cmd.Parameters.Clear(); } } int count = 0; if (!int.TryParse(uneiQuantity.Value.ToString(), out count)) { count = 0; } DataTable dt = null; if (ds != null && ds.Tables[0].Rows.Count > 0) { dt = ds.Tables[0].Clone(); dt.Columns.Add("发货数", typeof(int)); //DataTable dt = ds.Tables[0]; var dtE = ds.Tables[0].AsEnumerable(); foreach (DataRow dr in GetBomDetail()) { var iquantity = Convert.ToDecimal(dr["iQuantity"]) * count; var drs = dtE.Where(w => w.Field <string>("cInvCode") == dr["cInvCode"].ToString()).OrderBy(o => o.Field <string>("批次")).ToList(); //DataRow[] drs = dtE.Select(" cInvCode = '"+dr["cInvCode"].ToString()+"'").OrderBy(""); foreach (DataRow dr1 in drs) { if (iquantity >= 0) { var kc = Convert.ToDecimal(dr1["库存"]); var fhs = kc > iquantity ? iquantity : kc; //假如库存大于发货数,直接当前库位发货,如果小于发货数,当前库位发完当前数,并到下一个库位发剩余数量 iquantity = kc >= iquantity ? -1 : iquantity - kc; DataRow drNew = dt.NewRow(); drNew["AutoID"] = dr1["AutoID"]; drNew["BomID"] = dr1["BomID"]; drNew["cInvCode"] = dr1["cInvCode"]; drNew["cInvName"] = dr1["cInvName"]; drNew["iQuantity"] = dr1["iQuantity"]; drNew["cUnitID"] = dr1["cUnitID"]; drNew["cUnitName"] = dr1["cUnitName"]; drNew["cInvStd"] = dr1["cInvStd"]; drNew["cFullName"] = dr1["cFullName"]; drNew["cMemo"] = dr1["cMemo"]; drNew["dAddTime"] = dr1["dAddTime"]; drNew["cFitemID"] = dr1["cFitemID"]; drNew["批次"] = dr1["批次"]; drNew["库位"] = dr1["库位"]; drNew["库存"] = dr1["库存"]; drNew["发货数"] = fhs; dt.Rows.Add(drNew); } } } } xtreport.DataSource = dt; //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
private void printXtraReport(XtraReport report) { report.Print(settings.PrinterName); }
public void PrintDialog(string operation) { if (string.IsNullOrEmpty(biEditTemplet.Caption)) { MessageBox.Show(@"请先在 维护中心-模板管理,添加仓位标签项,再打开此界面!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var dt = new DataKis.StockPlacePrintDataTable(); foreach (var uRow in uGridCheck.Rows.GetFilteredInNonGroupByRows()) { var nRow = dt.NewStockPlacePrintRow(); nRow.FSPID = int.Parse(uRow.Cells["FSPID"].Value.ToString()); nRow.FNumber = uRow.Cells["FNumber"].Value.ToString(); nRow.FName = uRow.Cells["FName"].Value.ToString(); nRow.FFullName = uRow.Cells["FFullName"].Value.ToString(); dt.Rows.Add(nRow); } if (dt.Rows.Count < 1) { MessageBox.Show(@"请先筛选要打印的数据!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = _cTempletFileName; //_cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; //模板赋值 xtreport.DataSource = dt; //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
private void DoStdPrint(bool PrtPreView) { var proces = gcOrder.GetDataSource<V_ERP_PrintOrderPrd>().Where(k => k.Num > 0) .Select(k => new { k.ProceName, k.Guid, k.ProceUser }).ToList(); var odrs = SerNoCaller.Calr_V_ERP_PrintOrderProce.Get(" where printsession=@0", PrintSession); //var proces = SerNoCaller.Calr_V_ERP_PrintOrderProceDetail.Get(" where printsession=@0", PrintSession); var pordrs = odrs.MapTo<List<V_ERP_PrintOrderProce>, List<PrtOrder>>(); var prts = new List<ProcePrtInfo>(); pordrs.ForEach(k => { prts.Add(new ProcePrtInfo() { PrtOrder = k, Detail = proces.Where(j => k.Guid == j.Guid && !j.ProceName.Equals("木工")).Select(j => new T_ERP_OrderProce { ProceName = j.ProceName, ProceUser = j.ProceUser }).ToList() }); var mg = proces.FirstOrDefault(j => k.Guid == j.Guid && j.ProceName.Equals("木工")); if (mg != null) { prts.Add(new ProcePrtInfo() { PrtOrder = k, Detail = new List<T_ERP_OrderProce> { new T_ERP_OrderProce { ProceName = mg.ProceName, ProceUser = mg.ProceUser } } }); } }); var prtsys = new XtraReport(); var rpt = new NewRptSub(prts); rpt.BindData(); rpt.CreateDocument(); prtsys.Pages.AddRange(rpt.Pages); SetPrintToolsVisible(prtsys); prtsys.PrintingSystem.ShowMarginsWarning = false; if (PrtPreView) { prtsys.ShowPreview(); } else { prtsys.Print(); } }
public void Print(int id) { DataSet ds = new DataSet();//创建数据集 string sqlError = ""; string sql = $"select * from T_AnQing where AnQingNo={ID}"; DataTable tb = SqlHelper.RunQuery(CommandType.Text, sql, null, out sqlError); sql = $"SELECT GongSiName,Bao_Name FROM T_AnQingXiang x join T_GongSi g on x.GongSiID=g.GongSiId join T_BaoType t on x.BaoType_Id=t.Bao_TypeId where AnQingId={ID} and BaoType_Id ={id}"; DataTable tb2 = SqlHelper.RunQuery(CommandType.Text, sql, null, out sqlError); sql = $"select stuff((SELECT ',' + XiangMuName FROM T_AnQingXiang x JOIN T_XiangMu m ON x.XiangMuId = m.XiangMuNo where x.AnQingId = {ID} and x.BaoType_Id = {id} GROUP BY XiangMuName FOR XML path('')), 1, 1, '')"; DataTable tb3 = SqlHelper.RunQuery(CommandType.Text, sql, null, out sqlError); tb.TableName = "dt1n"; ds.Tables.Add(tb.Copy()); tb2.TableName = "dt2n"; ds.Tables.Add(tb2.Copy()); tb3.TableName = "dt3n"; ds.Tables.Add(tb3.Copy()); XtraReport report = new XtraReport(); if (TYPEID == 1) { if (id == 1) { report.LoadLayout(Application.StartupPath + "/Print/RE_AnQingJD.repx"); } if (id == 2) { report.LoadLayout(Application.StartupPath + "/Print/RE_AnQingJDB.repx"); } if (id == 3) { report.LoadLayout(Application.StartupPath + "/Print/RE_AnQingJDD.repx"); } } else { if (id == 1) { report.LoadLayout(Application.StartupPath + "/Print/AnQingJD.repx"); } if (id == 2) { report.LoadLayout(Application.StartupPath + "/Print/AnQingJDB.repx"); } if (id == 3) { report.LoadLayout(Application.StartupPath + "/Print/AnQingJDD.repx"); } } report.DataSource = ds; if (Program.sOperID != "admin") { report.Print(); } else { report.ShowDesignerDialog(); } }
/// <summary> /// 打印操作 /// </summary> /// <param name="operation"></param> public void PrintDialog(string operation) { //当修改原数据是要进行保存后才能去打印 if (biSave.Enabled == true) { MessageBox.Show("在原数据上进行修改时请先保存后再进行打印!!!"); } var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = _cTempletFileName; //_cTempletFileName; //Application.StartupPath + @"\Label\" + _cTempletFileName; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.PrinterName = _cPrinter; xtreport.PrintingSystem.StartPrint += PrintingSystem_StartPrint; xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; //模板赋值 DllWorkPrintLabel.SetParametersValue(xtreport, "cSerialNumber", lblTitleMain.lblcSerialNumber.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cBarCode", "R*" + _FitemId + "*L*" + txtcLotNo.Text + "*S*" + lblTitleMain.lblcSerialNumber.Text+";"+dtpcDefine2.Value.ToShortDateString()); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvCode", txtcInvCode.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvName", utecInvName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "dDate", dtpdDate.Value.ToShortDateString()); DllWorkPrintLabel.SetParametersValue(xtreport, "cInvStd", txtcInvStd.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cFullName", txtcFullName.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cVendor", txtcVendor.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cLotNo", txtcLotNo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "iQuantity", uneiQuantity.Value); DllWorkPrintLabel.SetParametersValue(xtreport, "cMemo", txtcMemo.Text); DllWorkPrintLabel.SetParametersValue(xtreport, "cDefine1", txtcDefine1.Text); if (dtpdDate.Checked) DllWorkPrintLabel.SetParametersValue(xtreport, "cVendorDate", dtpdDate.Value); //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }
/// <summary> /// 打印操作 /// </summary> /// <param name="operation"></param> public void PrintDialog(string operation) { var xtreport = new XtraReport(); // _btApp = new BarTender.Application(); //判断当前打印模版路径是否存在 var temPath = Application.StartupPath + @"\Stencil\ProSaleOrder.repx"; if (!File.Exists(temPath)) { MessageBox.Show(@"当前路径下的打印模版文件不存在!", @"异常", MessageBoxButtons.OK, MessageBoxIcon.Warning); xtreport.Name = "ProSaleOrder"; xtreport.ShowDesigner(); return; } xtreport.LoadLayout(temPath); xtreport.RequestParameters = false; xtreport.ShowPrintStatusDialog = false; xtreport.ShowPrintMarginsWarning = false; var dt = (DataTable)uGridChecks.DataSource; xtreport.DataSource = dt; var iSum = dt.Compute("sum(FAMOUNT)", "True"); decimal dSum; if (decimal.TryParse(iSum.ToString(), out dSum)) { DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "cSum", WmsFunction.ExchangeUper(dSum)); } DLL.DllWorkPrintLabel.SetParametersValue(xtreport, "iSum", iSum); //模板赋值 for (var i = 0; i < uGridCheck.DisplayLayout.Bands[0].Columns.Count; i++) { var cKey = uGridCheck.DisplayLayout.Bands[0].Columns[i].Key; string cValue; if (uGridCheck.ActiveRow != null) { cValue = uGridCheck.ActiveRow.Cells[i].Value.ToString(); } else { cValue = ""; } DLL.DllWorkPrintLabel.SetParametersValue(xtreport, cKey, cValue); } //模板赋值 switch (operation) { case "print": xtreport.Print(); break; case "design": xtreport.ShowDesigner(); break; case "preview": xtreport.ShowPreview(); break; } }