• XtraReport 一张纸打印3条记录


    首先创建二个XtraReport一个是主一个是从

    主:在Detail里面加三个xrSubreport控件

    View Code
     /// <summary>
            /// 打印
            /// </summary>
            /// <param name="ds">数据集</param> 
            /// <param name="PrinterName">打印机名称</param>
            public NewSuNingReport(DataTable dt1, DataTable dt2, DataTable dt3, string PrinterName)
            {
                InitializeComponent(); 
                if (dt1!=null)
                {
                    SuNingReport sunrep1 = new SuNingReport(dt1);
                    this.xrSubreport1.ReportSource = sunrep1;
                }
                if (dt2 != null)
                {
                    SuNingReport sunrep2 = new SuNingReport(dt2);
                    this.xrSubreport2.ReportSource = sunrep2;
                }
                if (dt3 != null)
                {
                    SuNingReport sunrep3 = new SuNingReport(dt3);
                    this.xrSubreport3.ReportSource = sunrep3;
                }
                this.PrinterName = PrinterName;
                this.Print();
            }

    从里面设置好你的报表格式绑定好数据

    View Code
      public SuNingReport(DataTable dt)
            {
                InitializeComponent();
                if (dt != null && dt.Rows.Count > 0)
                {
                    this.xrBarCode1.Text = dt.Rows[0]["订单1"].ToString();
                    this.xrBarCode2.Text = dt.Rows[0]["订单2"].ToString();
                    this.xrLabel2.Text = String.Format("共 {0} 箱", dt.Rows[0]["共几箱"].ToString());
                    this.xrLabel3.Text = String.Format("第 {0} 箱", dt.Rows[0]["第几箱"].ToString());
    
                    this.DetailReport.DataSource = dt;
                    this.xrTableCell5.DataBindings.Add("Text", dt, "商品编号");
                    this.xrTableCell6.DataBindings.Add("Text", dt, "商品名称");
                    this.xrTableCell7.DataBindings.Add("Text", dt, "商品数量");
                    this.xrTableCell8.DataBindings.Add("Text", dt, "商品库位");
                }
            }

    调用方法

    View Code
     for (int j = 0; j < ds.Tables.Count; j = j + 3)
                        {
                            DataTable dt1 = null;
                            DataTable dt2 = null;
                            DataTable dt3 = null;
                            if (count > j)
                            {
                                dt1 = ds.Tables[j];
                            }
                            if (count > j + 1)
                            {
                                dt2 = ds.Tables[j + 1];
                            }
                            if (count > j + 2)
                            {
                                dt3 = ds.Tables[j + 2];
                            }
                            NewSuNingReport suning = new NewSuNingReport(dt1, dt2, dt3, PrinterName);
                        }
  • 相关阅读:
    OGG初始化之使用Oracle Data Pump加载数据
    OGG初始化之使用数据库实用程序加载数据
    OGG初始加载过程概述
    管理凭证存储中的身份
    使用ENCKEYS方法加密数据
    使用主密钥和钱包方法加密数据
    配置Oracle GoldenGate安全性
    建立Oracle GoldenGate凭证
    System.DllNotFoundException:“无法加载 DLL“SQLite.Interop.dll”: 找不到指定的模块 的解决方法
    记录一下Oracle添加、查看表、字段注释及导出ddl
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/2729377.html
Copyright © 2020-2023  润新知