Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
        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;
            }
        }