Example #1
0
        public void Print(List <System.Collections.Specialized.StringDictionary> valueLists)
        {
            try
            {
                if (NoCodeSoft != "1")
                {
                    if (_doc == null)
                    {
                        throw new Exception("$ERROR_Label_Open 2");
                    }

                    if (_doc.Variables == null)
                    {
                        throw new Exception("$ERROR_Open_Label_Variable  1!");
                    }

                    if (valueLists == null || valueLists.Count <= 0)
                    {
                        throw new Exception("$ERROR_Pass_Params 2!");
                    }

                    foreach (System.Collections.Specialized.StringDictionary valueList in valueLists)
                    {
                        if (valueList == null)
                        {
                            throw new Exception("$ERROR_Pass_Params 2!");
                        }

                        //if (_doc.Variables.Count < valueList.Count)
                        //    throw new Exception("$ERROR_Lable_Vars_Count");

                        if (valueList != null && valueList.Count > 0 && _doc.Variables.Count > 0)
                        {
                            LabelManager2.Variable var = null;
                            foreach (string itemKey in valueList.Keys)
                            {
                                if (_doc.Variables.Item(itemKey) != null)
                                {
                                    var       = _doc.Variables.Item(itemKey);
                                    var.Value = valueList[itemKey];
                                }
                                else if (_doc.Variables.Item(itemKey + "1") != null)
                                {
                                    var       = _doc.Variables.Item(itemKey + "1");//打印模板参数输出值应为变量名+流水号,因只查到一个值,传过来的打印值未产生流水号,在此补足
                                    var.Value = valueList[itemKey];
                                }
                            }

                            _doc.PrintDocument(1);
                        }
                    }
                }
            }
            finally
            {
                ReleaseCom();
            }
        }
Example #2
0
        //bighai 20090306
        public void Print(string[] vars, string varName, string fileName)
        {
            if (NoCodeSoft != "1")
            {
                if (_doc == null)
                {
                    throw new Exception("$ERROR_Label_Open:" + fileName);
                }

                if (_doc.Variables == null)
                {
                    //throw new Exception("打开模板变量出错 !");
                    throw new Exception("$ERROR_Open_Label_Variable :" + varName);
                }

                if (vars == null)
                {
                    throw new Exception("$ERROR_Pass_Params !");
                }

                if (_doc.Variables.Count < vars.Length)
                {
                    throw new Exception("$ERROR_Lable_Vars_Count");
                }

                if (vars != null && vars.Length > 0)
                {
                    for (int i = 0; i < vars.Length; i++)
                    {
                        LabelManager2.Variable var = (LabelManager2.Variable)_doc.Variables.Item(varName);

                        if (var == null)
                        {
                            throw new Exception("$ERROR_Open_Label_Variable :" + varName);
                        }

                        var.Value = vars[i];
                    }

                    _doc.PrintDocument(1);
                }
            }
        }
Example #3
0
        //将相应的variable传给模板文件进行打印
        public void Print(string[] vars)
        {
            try
            {
                if (NoCodeSoft != "1")
                {
                    if (_doc == null)
                    {
                        throw new Exception("$ERROR_Label_Open 2");
                    }

                    if (_doc.Variables == null)
                    {
                        throw new Exception("$ERROR_Open_Label_Variable 1!");
                    }

                    if (vars == null)
                    {
                        throw new Exception("$ERROR_Pass_Params 2!");
                    }

                    if (_doc.Variables.Count < vars.Length)
                    {
                        throw new Exception("$ERROR_Lable_Vars_Count");
                    }

                    if (vars != null && vars.Length > 0)
                    {
                        for (int i = 0; i < vars.Length; i++)
                        {
                            LabelManager2.Variable var = (LabelManager2.Variable)_doc.Variables.Item("var" + i.ToString());

                            if (var == null)
                            {
                                throw new Exception("$ERROR_Open_Label_Variable 3! " + i.ToString());
                            }

                            var.Value = vars[i];
                        }

                        //added by leon yuan 2008/05/28, 允许一次打印多张标签
                        //process #3
                        for (int i = 0; i < _labelPrintVars.LabelVars_No3.Length; i++)
                        {
                            LabelManager2.Variable var = (LabelManager2.Variable)_doc.Variables.Item(_labelPrintVars.LabelVars_No3[i]);

                            if (_labelPrintVars.LabelValues_No3[i].Trim().Length > 0)
                            {
                                if (var == null)
                                {
                                    throw new Exception("$ERROR_Open_Label_Variable 4! " + i.ToString());
                                }

                                var.Value = _labelPrintVars.LabelValues_No3[i].Trim();
                            }
                            else
                            {
                                if (var != null)
                                {
                                    var.Value = "";
                                }
                            }
                        }
                        //Process #2
                        for (int i = 0; i < _labelPrintVars.LabelVars_No2.Length; i++)
                        {
                            LabelManager2.Variable var = (LabelManager2.Variable)_doc.Variables.Item(_labelPrintVars.LabelVars_No2[i]);

                            if (_labelPrintVars.LabelValues_No2[i].Trim().Length > 0)
                            {
                                if (var == null)
                                {
                                    throw new Exception("$ERROR_Open_Label_Variable 4! " + i.ToString());
                                }

                                var.Value = _labelPrintVars.LabelValues_No2[i].Trim();
                            }
                            else
                            {
                                if (var != null)
                                {
                                    var.Value = "";
                                }
                            }
                        }

                        _doc.PrintDocument(1);
                    }
                }
            }
            finally
            {
                ReleaseCom();
            }
        }