Beispiel #1
0
        /// <summary>
        /// 3、得到打印內容
        /// 每個打印任務衹調用OnBeginPrint()一次。
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void pdDocument_BeginPrint(object sender, PrintEventArgs e)
        {
            //显示生成条码进度条
            msg.Visible          = true;
            progressBar1.Visible = true;
            msg.Text             = "正在加载送货清单内容,请稍等...";
            //  this.barcode = "F20040E2728B2B9F-0820210306-0054";
            //  Bitmap QRCode = QRCodeHelper.GenQRCode("F20040E2728B2B9F-0820210306-0054", 120, 120);

            this.barcode = this.ScanDataDataSource.Rows[0]["tagInvoice"].ToString().Trim().ToUpper();
            Bitmap QRCode = QRCodeHelper.GenQRCode(this.barcode, 120, 120);

            pictureBox1.Image = QRCode;
            this.barcodeimg   = pictureBox1.Image;
            //自定义纸张大小
            pdDocument.DefaultPageSettings.PaperSize = new PaperSize("newPage_A4"
                                                                     , (int)(m_pageWidth / 25.4 * 100)
                                                                     , (int)(m_pageHeight / 25.4 * 100));
            //自定义图片内容整体上间距/左间距
            pdDocument.OriginAtMargins = true;
            pdDocument.DefaultPageSettings.Margins.Top  = (int)(20 / 25.4 * 100); //顶边距离
            pdDocument.DefaultPageSettings.Margins.Left = (int)(20 / 25.4 * 100); //左边距离
            msg.Text             = "条码生成完成";
            msg.Visible          = false;
            progressBar1.Visible = false;
            Application.DoEvents();
        }
Beispiel #2
0
        private void butPrint_Click(object sender, EventArgs e)
        {
            if (this.ScanDataDataSource.Rows.Count <= 0)
            {
                return;
            }
            string invoice             = this.ScanDataDataSource.Rows[0]["tagInvoice"].ToString().Trim().ToUpper();
            Bitmap QRCode              = QRCodeHelper.GenQRCode(invoice, 120, 120);
            FrmCompletedToMesPrint frm = FrmCompletedToMesPrint.GetSingleton(invoice, QRCode);

            frm.Show();
            frm.Activate();
        }
Beispiel #3
0
        private void getMesworktagscansByinvoice(string tagInvoice)
        {
            if (tagInvoice.Length <= 0)
            {
                return;
            }

            DataTable ScanData = cmm.getMesworktagscansByinvoice(tagInvoice);

            if (ScanData.Rows.Count <= 0)
            {
                return;
            }
            this.ScanDataDataSource = ScanData;
            SetScanData(this.ScanDataDataSource);
            //  print(this.ScanDataDataSource,0);
            // this.dgvWorkTagScans.DataSource = this.ScanDataDataSource;

            if (this.ScanDataDataSource.Rows.Count <= 0)
            {
                return;
            }

            if (!this.cbAutoPrint.Checked)
            {
                return;
            }

            /*
             * //调用打印程式
             *
             *
             */
            //声明一个LocalReport对象并加载一个报表文件
            LocalReport report = new LocalReport();

            // 设置需要打印的报表的文件名称。
            report.ReportPath = Application.StartupPath + "\\ReportCompletedToMes.rdlc";
            //传递报表参数
            DataTable ScanSourceData       = cms.getMesworktagscansByinvoiceGroup(tagInvoice);
            DataTable ScanSourceDataDetail = cms.getMesworktagscansByinvoiceDetail(tagInvoice);
            //this.reportViewer1.RefreshReport();

            string invoicetag = this.ScanDataDataSource.Rows[0]["tagInvoice"].ToString().Trim().ToUpper();
            Bitmap QRCode     = QRCodeHelper.GenQRCode(invoicetag, 120, 120);
            //自定义参数
            List <ReportParameter> list = new List <ReportParameter>();
            string styles   = "";
            string colors   = "";
            string sizes    = "";
            string qtys     = "";
            string location = "";

            location = ScanSourceData.Rows[0]["taglocation"].ToString();
            if (location == "")
            {
                location = "NA";
            }

            // String.Format("{0,-10}", str) String.format("%-12s",str);
            //   for (int i = 0; i < ScanSourceData.Rows.Count; i++)
            // {
            styles = ScanSourceData.Rows[0]["tagStyle"].ToString();
            colors = ScanSourceData.Rows[0]["tagColor"].ToString();
            sizes  = ScanSourceData.Rows[0]["tagSize"].ToString();
            qtys   = ScanSourceData.Rows[0]["tagQty"].ToString();
            // }
            string[] ss = sizes.Split(',');
            string[] qs = qtys.ToString().Split(',');
            sizes = "";
            qtys  = "";
            foreach (var s in ss)
            {
                sizes = sizes + " , " + string.Format("{0,-7:G}", s.Trim());
            }
            foreach (var q in qs)
            {
                qtys = qtys + " , " + string.Format("{0,-6:G}", q.Trim());
            }
            // sizes = sizes + " | " + string.Format("%-10s", ScanSourceData.Rows[i]["tagSize"].ToString());
            // qtys = qtys + Convert.ToInt32(string.Format("%-10s", (ScanSourceData.Rows[i]["tagQty"].ToString())));
            sizes  = sizes.Substring(2, sizes.Length - 2);
            qtys   = qtys.Substring(2, qtys.Length - 2);
            styles = styles.Substring(1, styles.Length - 1);
            colors = colors.Substring(1, colors.Length - 1);
            //sizes = sizes.Substring(1, sizes.Length - 1);
            ReportParameter invoice     = new ReportParameter("tagInvoice", ScanSourceData.Rows[0]["tagInvoice"].ToString());
            ReportParameter style       = new ReportParameter("tagStyle", styles);
            ReportParameter color       = new ReportParameter("tagColor", colors);
            ReportParameter size        = new ReportParameter("tagSize", sizes);
            ReportParameter qty         = new ReportParameter("tagQty", qtys.ToString());
            ReportParameter dept        = new ReportParameter("DeptName", ScanSourceData.Rows[0]["DeptName"].ToString());
            ReportParameter org         = new ReportParameter("tagOrg", ScanSourceData.Rows[0]["tagOrg"].ToString());
            ReportParameter taglocation = new ReportParameter("taglocation", location);
            ReportParameter part        = new ReportParameter("part", ScanSourceData.Rows[0]["part"].ToString());


            byte[]          imgBytes = bmpToBytes(QRCode);
            string          strB64   = Convert.ToBase64String(imgBytes);
            ReportParameter rpTest   = new ReportParameter("RPTest", strB64);//(rpTest为定义的报表参数变量,RPTest为在【报表】->【报表参数】中添加的参数。

            list.Add(rpTest);
            list.Add(part);
            list.Add(invoice);
            list.Add(style);
            list.Add(color);
            list.Add(size);
            list.Add(qty);
            list.Add(dept);
            list.Add(org);
            list.Add(taglocation);
            //创建要打印的数据源

            ReportDataSource source = new ReportDataSource("DataSet1", ScanSourceDataDetail); // 指定数据源

            report.DataSources.Clear();
            report.DataSources.Add(source);
            report.SetParameters(list); //参数设置
            //刷新报表中的需要呈现的数据
            styles = "";
            colors = "";
            sizes  = "";
            qtys   = "";
            report.Refresh();
            ReportClass.Print(report, ScanSourceDataDetail);
        }