Ejemplo n.º 1
0
        /// <summary>
        /// 处理批量打印的数据,以标签为单位
        /// </summary>
        /// <param name="vars"></param>
        /// <param name="labelPrintVars"></param>
        /// <returns></returns>
        public string[] ProcessVars(string[] vars, LabelPrintVars labelPrintVars)
        {
            //获取最大的序号
            int intMaxSeq = vars.Length - 1;

            for (int i = 0; i < labelPrintVars.LabelVars_No2.Length; i++)
            {
                int intSeq = int.Parse(labelPrintVars.LabelVars_No2[i].Substring(3));
                if (intMaxSeq < intSeq)
                {
                    intMaxSeq = intSeq;
                }
            }
            for (int i = 0; i < labelPrintVars.LabelVars_No3.Length; i++)
            {
                int intSeq = int.Parse(labelPrintVars.LabelVars_No3[i].Substring(3));
                if (intMaxSeq < intSeq)
                {
                    intMaxSeq = intSeq;
                }
            }

            //****赋值******
            string[] results = new string[intMaxSeq + 1];
            for (int i = 0; i <= intMaxSeq; i++)
            {
                results[i] = string.Empty;
            }

            //vars
            for (int i = 0; i < vars.Length; i++)
            {
                results[i] = vars[i];
            }
            //并排打印赋值
            for (int i = 0; i < labelPrintVars.LabelVars_No2.Length; i++)
            {
                int intSeq = int.Parse(labelPrintVars.LabelVars_No2[i].Substring(3));
                results[intSeq] = labelPrintVars.LabelValues_No2[i];
            }
            for (int i = 0; i < labelPrintVars.LabelVars_No3.Length; i++)
            {
                int intSeq = int.Parse(labelPrintVars.LabelVars_No3[i].Substring(3));
                results[intSeq] = labelPrintVars.LabelValues_No3[i];
            }

            return(results);
        }
Ejemplo n.º 2
0
        public UserControl.Messages Print(string printer, string templatePath, MKeyPart mKeyPart, List <MKeyPartDetail> mKeyPartDetailList, List <string> reserveInfo)
        {
            UserControl.Messages messages = new UserControl.Messages();

            try
            {
                try
                {
                    this.PrePrint();
                    _CodeSoftFacade.OpenTemplate(printer, templatePath);
                }
                catch (System.Exception ex)
                {
                    messages.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message));
                    return(messages);
                }

                //批量打印前生成文本文件
                string strBatchDataFile = string.Empty;
                if (_IsBatchPrint)
                {
                    strBatchDataFile = CreateFile();
                }

                for (int i = 0; i < mKeyPartDetailList.Count; i++)
                {
                    LabelPrintVars labelPrintVars = new LabelPrintVars();

                    string[] vars = new string[0];

                    if (messages.IsSuccess())
                    {
                        try
                        {
                            //要传给Codesoft的数组,字段顺序不能修改
                            vars = this.GetPrintVars(mKeyPart, mKeyPartDetailList[i], reserveInfo);

                            //批量打印前的写文件
                            if (_IsBatchPrint)
                            {
                                string[] printVars = ProcessVars(vars, labelPrintVars);
                                WriteFile(strBatchDataFile, printVars);
                            }
                            //直接打印
                            else
                            {
                                _CodeSoftFacade.LabelPrintVars = labelPrintVars;
                                _CodeSoftFacade.Print(vars);
                            }
                        }
                        catch (System.Exception ex)
                        {
                            messages.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message));
                            return(messages);
                        }
                    }
                }

                //批量打印
                if (_IsBatchPrint)
                {
                    try
                    {
                        _CodeSoftFacade.Print(strBatchDataFile, GetDataDescPath(_DataDescFileName));
                    }
                    catch (System.Exception ex)
                    {
                        messages.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message));
                        return(messages);
                    }
                }

                messages.Add(new UserControl.Message(UserControl.MessageType.Success, "$Success_Print_Label"));
            }
            finally
            {
            }

            return(messages);
        }
Ejemplo n.º 3
0
        //bighai.wang 2009/03/03 发料物料标签打印

        public UserControl.Messages PrintMaterialLot(string printer, List <string> materialLot)
        {
            UserControl.Messages messages = new UserControl.Messages();
            string varName      = string.Empty;
            string templatePath = string.Empty;
            string fileName     = string.Empty;

            try
            {
                try
                {
                    SystemSettingFacade parameter = new SystemSettingFacade();
                    fileName = parameter.GetGetParameterFileName("TemplateFileName", "MATERIALTYPE");
                    //templatePath = System.Environment.CurrentDirectory+"\\" + fileName;
                    varName = parameter.GetGetParameterFileName("VarName", "MATERIALTYPE");

                    this.PrePrint();
                    _CodeSoftFacade.OpenTemplateMaterialLot(printer, fileName, varName);
                }
                catch (System.Exception ex)
                {
                    messages.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message));
                    return(messages);
                }

                //批量打印前生成文本文件
                string strBatchDataFile = string.Empty;
                if (_IsBatchPrint)
                {
                    strBatchDataFile = CreateFile();
                }

                for (int i = 0; i < materialLot.Count; i++)
                {
                    LabelPrintVars labelPrintVars = new LabelPrintVars();

                    string[] vars = new string[0];

                    if (messages.IsSuccess())
                    {
                        try
                        {
                            //要传给Codesoft的数组,字段顺序不能修改
                            vars = this.GetPrintVarsMaterialLot(materialLot[i]);

                            //批量打印前的写文件
                            if (_IsBatchPrint)
                            {
                                string[] printVars = ProcessVars(vars, labelPrintVars);
                                WriteFile(strBatchDataFile, printVars);
                            }
                            //直接打印
                            //else
                            //{
                            _CodeSoftFacade.LabelPrintVars = labelPrintVars;
                            _CodeSoftFacade.Print(vars, varName, fileName);
                            //}
                        }
                        catch (System.Exception ex)
                        {
                            messages.Add(new UserControl.Message(UserControl.MessageType.Error, ex.Message));
                            return(messages);
                        }
                    }
                }

                //messages.Add(new UserControl.Message(UserControl.MessageType.Success, "$Success_Print_Label"));
            }
            finally
            {
            }

            return(messages);
        }