• 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);
                        }
  • 相关阅读:
    vue实现 toggle显示隐藏效果
    html+css奇淫技巧 3 教你如何伪类控制字体间距左右排版
    js 数组,字符串,json互相转换
    forEach 与for in
    js/jq 选项卡开发js代码
    html奇淫技巧 2 教你如何进行图文环绕布局 原创
    2019-05-07 开始记笔记vue
    vue src 拼接
    js 反选 全选看出你处于哪个阶段!
    JS获取浏览器窗口大小 获取屏幕,浏览器,网页高度宽度(转载)
  • 原文地址:https://www.cnblogs.com/freexiaoyu/p/2729377.html
Copyright © 2020-2023  润新知