Ejemplo n.º 1
0
        /// <summary>
        ///chenqiang 2018.04.20 add by Case:31026   打印电子健康卡二维码
        /// </summary>
        /// <param name="imgData">电子健康卡二维码base64数据</param>
        private void printVirtualCard(HealthCardInfoStruct Entity)

        {
            try
            {
                string       path  = Application.StartupPath + @"\\Reports\\电子卡二维码.frx";
                PrintManager print = new PrintManager();
                if (System.IO.File.Exists(path) == true)
                {
                    using (PrintManager report = new PrintManager())
                    {
                        DataTable dtQRCode = new DataTable("reportQR");
                        if (Entity.imgData != "" && Entity.imgData != null)
                        {
                            byte[] bytesImg = Convert.FromBase64String(Entity.imgData);//字符串转换为字节
                            dtQRCode.Columns.Add("QRCode", typeof(byte[]));
                            DataRow drQrCode = dtQRCode.NewRow();
                            drQrCode["QRCode"] = bytesImg;
                            dtQRCode.Rows.Add(drQrCode);
                        }
                        else
                        {
                            dtQRCode.Columns.Add("QRCode", typeof(string));
                            DataRow drQrCode = dtQRCode.NewRow();
                            drQrCode["QRCode"] = Entity.QRCode;
                            dtQRCode.Rows.Add(drQrCode);
                        }
                        string cardType = string.Empty;
                        if (Entity.QRCode.IndexOf("EH") == 0)
                        {
                            cardType = "1";
                        }
                        else if (Entity.QRCode.IndexOf("EM") == 0)
                        {
                            cardType = "2";
                        }
                        else
                        {
                            cardType = "0";
                        }
                        print.InitReport("电子卡二维码");
                        print.AddParam("二维码", Entity.QRCode);
                        print.AddDataSet(dtQRCode, "电子卡二维码");
                        print.AddVariable("姓名", IdInfo.Name);
                        print.AddVariable("性别", IdInfo.Sex);
                        print.AddVariable("年龄", "");
                        print.AddVariable("出生日期", IdInfo.Birthday);
                        string idNumber = IdInfo.Number;
                        print.AddVariable("身份证号", idNumber);
                        print.AddVariable("卡类型", cardType);
                        PrintManager.CanDesign = true;
                        //print.PreView();
                        print.Print();
                        print.Dispose();
                    }
                }
                else
                {
                    SkynetMessage.MsgInfo("系统没有找到报表文件“电子卡二维码.frx”!");
                }
            }
            catch (Exception lex)
            {
                if (lex.Message.IndexOf("灾难性") > 0)
                {
                    SkynetMessage.MsgInfo(lex.Message + ": 打印机连接失败,请检查!");
                }
                else
                {
                    SkynetMessage.MsgInfo(lex.Message);
                }
            }
        }