Beispiel #1
0
        /// <summary>
        /// 打印标签
        /// </summary>
        /// <param name="cartonInfo"></param>
        private void PrintLabel(WaitRePrintCarton cartonInfo)
        {
            string strProcedureName =
                $"{className}.{MethodBase.GetCurrentMethod().Name}";

            int    errCode = 0;
            string errText = "";

            #region 根据 T117LeafID 获取标签打印模板
            TemplateContent template = new TemplateContent();
            IRAPMDMClient.Instance.ufn_GetInfo_TemplateFMTStr(
                IRAPUser.Instance.CommunityID,
                cartonInfo.T117LeafID,
                IRAPUser.Instance.SysLogID,
                ref template,
                out errCode,
                out errText);
            WriteLog.Instance.Write(
                $"({errCode}){errText}",
                strProcedureName);
            if (errCode != 0 || template.TemplateFMTStr.Trim() == "")
            {
                XtraMessageBox.Show(
                    $"无法获取到 [T117LeafID={cartonInfo.T117LeafID}] 的模板",
                    "",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            else
            {
                PrintCartonLabel(cartonInfo, template.TemplateFMTStr);
            }
            #endregion
        }
Beispiel #2
0
        private void PrintCartonLabel(WaitRePrintCarton cartonInfo, string labelTemplate)
        {
            string strProcedureName =
                $"{className}.{MethodBase.GetCurrentMethod().Name}";

            Report rpt = new Report();

            try
            {
                rpt.LoadFromString(labelTemplate);
            }
            catch (Exception error)
            {
                WriteLog.Instance.Write(
                    $"外包装标签打印模板装载失败:{error.Message},",
                    strProcedureName);
                XtraMessageBox.Show(
                    $"外包装标签打印模板装载失败:{error.Message},\n" +
                    "请联系系统开发人员,并发起重打申请!",
                    "",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            #region 打印外包装标签
            PrinterSettings prntSettings = new PrinterSettings();
            //prntSettings.Copies = Convert.ToInt16(cartonInfo.PrintQty);
            prntSettings.PrinterName = (string)cboPrinters.SelectedItem;

            rpt.Parameters.FindByName("Model").Value             = cartonInfo.Model;
            rpt.Parameters.FindByName("DrawingID").Value         = cartonInfo.DrawingID;
            rpt.Parameters.FindByName("MaterialCategory").Value  = cartonInfo.MaterialCategory;
            rpt.Parameters.FindByName("CartonQty").Value         = $"{cartonInfo.CartonQty} {cartonInfo.UnitOfMeasure}";
            rpt.Parameters.FindByName("CartonProductNo").Value   = cartonInfo.CartonProductNo;
            rpt.Parameters.FindByName("LotNumber").Value         = cartonInfo.LotNumber;
            rpt.Parameters.FindByName("SupplyCode").Value        = cartonInfo.SupplyCode;
            rpt.Parameters.FindByName("T134AlternateCode").Value = cartonInfo.T134AlternateCode;
            rpt.Parameters.FindByName("BarCode").Value           =
                $"{cartonInfo.CartonProductNo}/" +
                $"{cartonInfo.CartonNumber}/" +
                $"{cartonInfo.CartonQty.ToString()}";

            if (rpt.Prepare())
            {
                for (int i = 0; i < cartonInfo.PrintQty; i++)
                {
                    rpt.PrintPrepared(prntSettings);
                }
            }
            #endregion

            #region 获取内包装标签列表
            int                errCode = 0;
            string             errText = "";
            List <BoxOfCarton> boxes   = new List <BoxOfCarton>();
            AsimcoPackageClient.Instance.ufn_GetList_BoxOfCarton(
                IRAPUser.Instance.CommunityID,
                cartonInfo.CartonNumber,
                IRAPUser.Instance.SysLogID,
                ref boxes,
                out errCode,
                out errText);
            WriteLog.Instance.Write(
                $"({errCode}){errText}",
                strProcedureName);
            if (errCode != 0)
            {
                XtraMessageBox.Show(
                    $"获取标签打印信息时发生错误,请发起重打申请!",
                    "",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                XtraMessageBox.Show(
                    $"错误信息:{errText}",
                    "",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }

            if (boxes.Count == 0)
            {
                XtraMessageBox.Show(
                    $"未获取到外包装号 [{cartonInfo.CartonNumber}] 的内包装标签数据," +
                    "请联系系统开发人员,并发起重打申请!",
                    "",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            #endregion

            #region 打印内标签
            foreach (BoxOfCarton box in boxes)
            {
                int    t117LeafID       = 0;
                string boxLabelTemplate = "";

                if (t117LeafID != box.T117LeafID)
                {
                    #region 根据 T117LeafID 获取标签打印模板
                    TemplateContent template = new TemplateContent();
                    IRAPMDMClient.Instance.ufn_GetInfo_TemplateFMTStr(
                        IRAPUser.Instance.CommunityID,
                        box.T117LeafID,
                        IRAPUser.Instance.SysLogID,
                        ref template,
                        out errCode,
                        out errText);
                    WriteLog.Instance.Write(
                        $"({errCode}){errText}",
                        strProcedureName);
                    if (errCode != 0 || template.TemplateFMTStr.Trim() == "")
                    {
                        XtraMessageBox.Show(
                            $"无法获取到 [T117LeafID={box.T117LeafID}] 的模板",
                            "",
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error);
                        boxLabelTemplate = "";
                    }
                    else
                    {
                        t117LeafID       = box.T117LeafID;
                        boxLabelTemplate = template.TemplateFMTStr;
                    }
                    #endregion
                }

                if (boxLabelTemplate != "")
                {
                    PrintBoxLabel(box, boxLabelTemplate);
                }
            }
            #endregion
        }