Exemplo n.º 1
0
        private Dictionary <string, string> ctcodeToDic(CTCode ctcode, List <MandUnionFieldType> mandUnionFieldTypeList)
        {
            PropertyInfo[] propertyInfoARR       = ctcode.GetType().GetProperties();
            Dictionary <string, string> property = new Dictionary <string, string>();

            foreach (PropertyInfo propertyInfo in propertyInfoARR)
            {
                Object propertyVal = ctcode.GetType().GetProperty(propertyInfo.Name).GetValue(ctcode, null);
                if (propertyVal != null)
                {
                    property.Add(propertyInfo.Name.ToUpper(), propertyVal.ToString());
                }
            }

            Dictionary <string, string> ctDict = new Dictionary <string, string>();

            foreach (MandUnionFieldType mandUnionFieldType in mandUnionFieldTypeList)
            {
                string fieldName = mandUnionFieldType.FieldName.ToUpper();
                if (property.ContainsKey(fieldName))
                {
                    ctDict.Add(fieldName, property[fieldName]);
                }
                else
                {
                    ctDict.Add(fieldName, mandUnionFieldType.FieldValue);
                }
            }

            return(ctDict);
        }
Exemplo n.º 2
0
 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (this.textBox1.Text == null || this.textBox1.Text.Trim() == "")
         {
             this.textBox1.Focus();
             clearAll();
             return;
         }
         string ctcode   = this.textBox1.Text.Trim();
         CTCode codeInfo = ctCodeService.queryCTCodeByCtcode(ctcode);
         if (codeInfo != null)
         {
             filePath = modelInfoService.previewModelFile("F062");
             if (filePath == null)
             {
                 MessageBox.Show("未找到對應的打印模板信息,請維護相關信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 return;
             }
             printLabel(codeInfo);
         }
         else
         {
             this.textBox1.Focus();
             clearAll();
         }
     }
 }
Exemplo n.º 3
0
        public bool saveCTInfo(CTCode ctCode, MySqlConnection conn, MySqlTransaction mysqlTrans)
        {
            bool          saveMark = true;
            StringBuilder strSql   = new StringBuilder();

            strSql.Append("insert into t_code_info (uuid,ct_code,rule_no,work_no,cus_no,cus_name,cus_po,po_qty,cus_matno,del_matno,offi_no,ver_no,wo_quantity,model_no,op_user,create_time,so_order,quantity,capacity_no)");
            strSql.Append("values(@uuid,@ctcode,@ruleno,@workno,@cusno,@cusname,@cuspo,@poqty,@cusmatno,@delmatno,@offino,@verno,@woquantity,@model_no,@opuser,@createtime,@soOrder,@quantity,@capacityNo)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@uuid",       MySqlDbType.VarChar, 900),
                new MySqlParameter("@ctcode",     MySqlDbType.VarChar, 900),
                new MySqlParameter("@ruleno",     MySqlDbType.VarChar, 900),
                new MySqlParameter("@workno",     MySqlDbType.VarChar, 900),
                new MySqlParameter("@cusno",      MySqlDbType.VarChar, 900),
                new MySqlParameter("@cuspo",      MySqlDbType.VarChar, 900),
                new MySqlParameter("@cusmatno",   MySqlDbType.VarChar, 900),
                new MySqlParameter("@delmatno",   MySqlDbType.VarChar, 900),
                new MySqlParameter("@offino",     MySqlDbType.VarChar, 900),
                new MySqlParameter("@verno",      MySqlDbType.VarChar, 900),
                new MySqlParameter("@woquantity", MySqlDbType.VarChar, 900),
                new MySqlParameter("@opuser",     MySqlDbType.VarChar, 900),
                new MySqlParameter("@createtime", MySqlDbType.VarChar, 900),
                new MySqlParameter("@model_no",   MySqlDbType.VarChar, 900),
                new MySqlParameter("@poqty",      MySqlDbType.VarChar, 900),
                new MySqlParameter("@soOrder",    MySqlDbType.VarChar, 900),
                new MySqlParameter("@cusname",    MySqlDbType.VarChar, 900),
                new MySqlParameter("@quantity",   MySqlDbType.Int32,   900),
                new MySqlParameter("@capacityNo", MySqlDbType.VarChar, 900)
            };
            parameters[0].Value  = ctCode.Uuid;
            parameters[1].Value  = ctCode.Ctcode;
            parameters[2].Value  = ctCode.Ruleno;
            parameters[3].Value  = ctCode.Workno;
            parameters[4].Value  = ctCode.Cusno;
            parameters[5].Value  = ctCode.Cuspo;
            parameters[6].Value  = ctCode.Cusmatno;
            parameters[7].Value  = ctCode.Delmatno;
            parameters[8].Value  = ctCode.Offino;
            parameters[9].Value  = ctCode.Verno;
            parameters[10].Value = ctCode.Woquantity;
            parameters[11].Value = ctCode.Opuser;
            parameters[12].Value = ctCode.Createtime;
            parameters[13].Value = ctCode.Modelno;
            parameters[14].Value = ctCode.Orderqty;
            parameters[15].Value = ctCode.SoOrder;
            parameters[16].Value = ctCode.Cusname;
            parameters[17].Value = ctCode.Quantity;
            parameters[18].Value = ctCode.CapacityNo;
            int rows = SQLHelper.ExecuteNonQueryTrans(conn, mysqlTrans, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                saveMark = true;
            }
            else
            {
                saveMark = false;
            }
            return(saveMark);
        }
Exemplo n.º 4
0
 /// <summary>
 /// 保存打印CT碼記錄
 /// </summary>
 /// <param name="record"></param>
 /// <returns></returns>
 public bool savePrintRecord(CTCode ctCode)
 {
     ctCode.Uuid       = Auxiliary.Get_UUID();
     ctCode.Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     ctCode.Opuser     = Auxiliary.loginName;
     return(printM.savePrintRecord(ctCode));
 }
Exemplo n.º 5
0
 public bool saveCTCodeInfo(CTCode ctCode, MySqlConnection conn, MySqlTransaction mysqlTrans)
 {
     ctCode.Uuid       = Auxiliary.Get_UUID();
     ctCode.Createtime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     ctCode.Opuser     = Auxiliary.loginName;
     return(cTCodeDao.saveCTInfo(ctCode, conn, mysqlTrans));
 }
Exemplo n.º 6
0
        /// <summary>
        /// 保存打印記錄
        /// </summary>
        /// <param name="record"></param>
        /// <returns></returns>
        public bool savePrintRecord(CTCode ctCode)
        {
            bool          saveMark = true;
            StringBuilder strSql   = new StringBuilder();

            strSql.Append("insert into t_print_record (uuid,ct_code,op_user,create_time)");
            strSql.Append("values(@uuid,@ctcode,@opuser,@createtime)");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@uuid",       MySqlDbType.VarChar, 900),
                new MySqlParameter("@ctcode",     MySqlDbType.VarChar, 900),
                new MySqlParameter("@opuser",     MySqlDbType.VarChar, 900),
                new MySqlParameter("@createtime", MySqlDbType.VarChar, 900),
            };
            parameters[0].Value = ctCode.Uuid;
            parameters[1].Value = ctCode.Ctcode;
            parameters[2].Value = ctCode.Opuser;
            parameters[3].Value = ctCode.Createtime;
            int rows = SQLHelper.ExecuteNonQuery(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

            if (rows > 0)
            {
                saveMark = true;
            }
            else
            {
                saveMark = false;
            }
            return(saveMark);
        }
Exemplo n.º 7
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (this.dataGridView1.CurrentRow == null)
            {
                MessageBox.Show("請輸入正確的查詢條件或請選中表中的行!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.textBox1.Focus();
                return;
            }
            int    index    = this.dataGridView1.CurrentRow.Index;
            string modelNo  = this.dataGridView1.Rows[index].Cells["model_no"].Value.ToString();
            string cusNo    = this.dataGridView1.Rows[index].Cells["cus_no"].Value.ToString();
            string delMatno = this.dataGridView1.Rows[index].Cells["del_matno"].Value.ToString();

            //下載模板並預覽   1.查询模板是否存在, 若存在不下载  2.若不存在下载模板
            string filePath = modelInfoService.previewModelFile(modelNo);

            if (filePath == null)
            {
                MessageBox.Show("未找到該客戶出貨料號對應的打印模板信息,請維護相關信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            //查詢打印模板的打印字段
            MandRelDel mandRelDel = mandRelDelService.queryManNoByDel(cusNo, delMatno, "0");

            if (mandRelDel == null)
            {
                MessageBox.Show("未找到該客戶出貨料號對應的打印字段規則信息,請維護相關信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            List <MandUnionFieldType> mandUnionFieldTypeList = manRelFieldTypeService.queryMandUnionFieldTypeList(mandRelDel.ManNo);

            if (mandUnionFieldTypeList == null)
            {
                MessageBox.Show("未找到該客戶出貨料號對應的打印字段規則信息,請維護相關信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
            string ctcode       = this.dataGridView1.Rows[index].Cells["ct_code"].Value.ToString();
            CTCode ctcodeEntity = cTCodeService.queryCTCodeByCtcode(ctcode);
            bool   judge        = barPrint.bactchPrintPalletByModel(filePath, ctcodeToDic(ctcodeEntity, mandUnionFieldTypeList));

            if (judge)
            {
                printQ.savePrintRecord(ctcodeEntity);
            }
            else
            {
                MessageBox.Show("打印失敗請聯係管理員!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Exemplo n.º 8
0
        private void printLabel(CTCode content)
        {
            List <MandUnionFieldType> mandUnionFieldTypeList = manRelFieldTypeService.queryMandUnionFieldTypeList("MF0110");
            bool judgePrint = barPrint.bactchPrintPalletByModel(filePath, contentToDic(content, mandUnionFieldTypeList));

            if (judgePrint)
            {
                //清空质检标打印签信息
                clearAll();
            }
            else
            {
                MessageBox.Show("打印失敗請聯係管理員!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// TODO 初始化行信息
        /// </summary>
        /// <param name="index"></param>
        /// <param name="ctcode"></param>
        public void initRow(CTCode ctcode)
        {
            DataGridViewRow dr = new DataGridViewRow();

            dr.CreateCells(dataGridView1);

            dr.Cells[0].Value  = ctcode.Ctcode;
            dr.Cells[1].Value  = ctcode.Delmatno;
            dr.Cells[2].Value  = ctcode.Cusname;
            dr.Cells[3].Value  = ctcode.Cusno;
            dr.Cells[4].Value  = ctcode.Workno;
            dr.Cells[5].Value  = ctcode.Woquantity;
            dr.Cells[6].Value  = ctcode.Cusmatno;
            this.textBox1.Text = "";
            this.dataGridView1.Rows.Insert(0, dr);
            this.dataGridView1.Rows[0].Selected = true;
            ctCodeList.Add(ctcode);
        }
Exemplo n.º 10
0
 public CTCode exchangeCT(CTCode ctCode1, CTCode ctCode2)
 {
     ctCode1.Uuid       = Auxiliary.Get_UUID();
     ctCode1.Workno     = ctCode2.Workno;
     ctCode1.Cusno      = ctCode2.Cusno;
     ctCode1.Cuspo      = ctCode2.Cuspo;
     ctCode1.Cusname    = ctCode2.Cusname;
     ctCode1.Orderqty   = ctCode2.Orderqty;
     ctCode1.Cusmatno   = ctCode2.Cusmatno;
     ctCode1.SoOrder    = ctCode2.SoOrder;
     ctCode1.Opuser     = Auxiliary.loginName;
     ctCode1.Woquantity = ctCode2.Woquantity;
     ctCode1.CapacityNo = ctCode2.CapacityNo;
     ctCode1.Quantity   = ctCode2.Quantity;
     ctCode1.Offino     = ctCode2.Offino;
     ctCode1.Delmatno   = ctCode2.Delmatno;
     ctCode1.Ruleno     = ctCode2.Ruleno;
     ctCode1.Verno      = ctCode2.Verno;
     ctCode1.Modelno    = ctCode2.Modelno;
     ctCode1.Createtime = DateTime.Now.ToString();
     return(ctCode1);
 }
Exemplo n.º 11
0
        public CTCode queryCTCodeByCtcode(string ctcode)
        {
            CTCode        cTCode = null;
            StringBuilder strSql = new StringBuilder();

            strSql.Append("SELECT uuid,ct_code,quantity,rule_no,work_no,cus_no,cus_name,cus_po,po_qty,cus_matno,del_matno,offi_no,ver_no,wo_quantity,model_no,so_order,op_user,create_time FROM t_code_info where ct_code=@ctcode");
            MySqlParameter[] parameters =
            {
                new MySqlParameter("@ctcode", MySqlDbType.VarChar, 900),
            };
            parameters[0].Value = ctcode;
            DataSet ds = SQLHelper.ExecuteDataset(SQLHelper.ConnectionString, CommandType.Text, strSql.ToString(), parameters);

            if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
            {
                cTCode            = new CTCode();
                cTCode.Uuid       = ds.Tables[0].Rows[0]["uuid"].ToString();
                cTCode.Ctcode     = ds.Tables[0].Rows[0]["ct_code"].ToString();
                cTCode.Quantity   = (int)ds.Tables[0].Rows[0]["quantity"];
                cTCode.Ruleno     = ds.Tables[0].Rows[0]["rule_no"].ToString();
                cTCode.Workno     = ds.Tables[0].Rows[0]["work_no"].ToString();
                cTCode.Cusno      = ds.Tables[0].Rows[0]["cus_no"].ToString();
                cTCode.Cusname    = ds.Tables[0].Rows[0]["cus_name"].ToString();
                cTCode.Cuspo      = ds.Tables[0].Rows[0]["cus_po"].ToString();
                cTCode.Orderqty   = ds.Tables[0].Rows[0]["po_qty"].ToString();
                cTCode.Cusmatno   = ds.Tables[0].Rows[0]["cus_matno"].ToString();
                cTCode.Delmatno   = ds.Tables[0].Rows[0]["del_matno"].ToString();
                cTCode.Offino     = ds.Tables[0].Rows[0]["offi_no"].ToString();
                cTCode.Verno      = ds.Tables[0].Rows[0]["ver_no"].ToString();
                cTCode.Woquantity = ds.Tables[0].Rows[0]["wo_quantity"].ToString();
                cTCode.Modelno    = ds.Tables[0].Rows[0]["model_no"].ToString();
                cTCode.SoOrder    = ds.Tables[0].Rows[0]["so_order"].ToString();
                cTCode.Opuser     = ds.Tables[0].Rows[0]["op_user"].ToString();
                cTCode.Createtime = ds.Tables[0].Rows[0]["create_time"].ToString();
            }
            return(cTCode);
        }
Exemplo n.º 12
0
        public bool PrintBCByModel(string templateFileName, CTCode ctCode, List <MandUnionFieldType> mandUnionFieldTypeList)
        {
            if (lbl == null)
            {
                lbl = new ApplicationClass();
            }
            //未加載模板文件或者模板發生變更時,重新加載新的模板
            if (lbl.Documents.Count == 0 || templateFileName.IndexOf(lbl.ActiveDocument.Name) == -1)
            {
                lbl.Documents.Open(templateFileName, false);// 调用设计好的label文件
            }
            Document doc = lbl.ActiveDocument;

            try
            {
                for (int i = 1; i <= doc.Variables.FormVariables.Count; i++)
                {
                    string variableName = doc.Variables.FormVariables.Item(i).Name.ToString();
                    foreach (MandUnionFieldType mandUnionFieldType in mandUnionFieldTypeList)
                    {
                        if (mandUnionFieldType.FieldName.ToUpper() == variableName.ToUpper())
                        {
                            bool           judge           = false;
                            PropertyInfo[] propertyInfoARR = ctCode.GetType().GetProperties();
                            foreach (PropertyInfo propertyInfo in propertyInfoARR)
                            {
                                if (propertyInfo.Name == mandUnionFieldType.FieldName)
                                {
                                    string entityValue = ctCode.GetType().GetProperty(propertyInfo.Name).GetValue(ctCode, null).ToString();
                                    doc.Variables.FormVariables.Item(i).Value = entityValue;
                                    judge = true;
                                    break;
                                }
                            }
                            if (!judge)
                            {
                                doc.Variables.FormVariables.Item(i).Value = mandUnionFieldType.FieldValue;
                                break;
                            }
                        }
                    }
                }

                int Num = 1;                      //打印数量
                doc.Printer.SwitchTo(DefaultPrinter());
                doc.PrintLabel(1, 1, 1, Num, 1, "");
                //doc.PrintDocument(Num);           //打印
            }
            catch (Exception ex)
            {
                return(false);                          //返回,後面代碼不執行
            }
            finally
            {
                //內存釋放和回收
                doc.FormFeed();
                lbl.Documents.CloseAll();
                lbl.Quit();
                lbl = null;
                doc = null;
                GC.Collect(0);
            }
            return(true);
        }
Exemplo n.º 13
0
 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         if (this.textBox1.Text == null || this.textBox1.Text.Trim() == "")
         {
             this.textBox1.Focus();
             return;
         }
         CTCode ctcode = ctCodeService.queryCTCodeByCtcode(this.textBox1.Text.Trim());
         if (ctcode == null)
         {
             this.textBox1.Text = "";
             this.textBox1.Focus();
             CommonAuxiliary.playFail();
             return;
         }
         if (cartonService.exists(ctcode.Ctcode))
         {
             MessageBox.Show("該CT碼已綁定,請檢查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
             this.textBox1.Text = "";
             this.textBox1.Focus();
             CommonAuxiliary.playFail();
             return;
         }
         if (this.dataGridView1.Rows.Count == 0)
         {
             if (firstScan == null || !(firstScan.Workno.Equals(ctcode.Workno) && firstScan.Delmatno.Equals(ctcode.Delmatno) && firstScan.Cusno.Equals(ctcode.Cusno)))
             {
                 codeRule = codeRuleService.queryRuleByCond(ctcode.Cusno, ctcode.Delmatno, "1");  //1代表Carton碼編碼規則
                 if (codeRule == null)
                 {
                     MessageBox.Show("请联系管理员,绑定装箱单编码规则!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.textBox1.Text = "";
                     this.textBox1.Focus();
                     CommonAuxiliary.playFail();
                     return;
                 }
                 //查询标签模板
                 fileRelDel = fileRelDelService.queryFileRelDelCusNo(ctcode.Cusno, ctcode.Delmatno, "1");
                 if (fileRelDel == null)
                 {
                     MessageBox.Show("请联系管理员,绑定标签模板!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.textBox1.Text = "";
                     this.textBox1.Focus();
                     CommonAuxiliary.playFail();
                     return;
                 }
                 //查询标签参数信息
                 mandUnionFieldTypeList = manRelFieldTypeService.queryFieldListByCond(ctcode.Cusno, ctcode.Delmatno, "1");
                 if (mandUnionFieldTypeList == null)
                 {
                     MessageBox.Show("未找到該客戶出貨料號對應的打印字段規則信息,請維護相關信息", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                     this.textBox1.Text = "";
                     this.textBox1.Focus();
                     CommonAuxiliary.playFail();
                     return;
                 }
                 //裝箱容量查詢
                 capacity = capacityService.queryByRelation(ctcode.Cusno, ctcode.Delmatno, "1");
                 if (capacity != null)
                 {
                     this.textBox11.Text = capacity.Capacityqty.ToString();
                     this.textBox12.Text = capacity.Capacitydesc;
                 }
                 firstScan = ctcode;
                 //下載模板並預覽   1.查询模板是否存在, 若存在不下载  2.若不存在下载模板
                 filePath = modelInfoService.previewModelFile(fileRelDel.FileNo);
             }
             firstScan = ctcode;
             initRow(ctcode);
             //初始化信息
             this.textBox2.Text = ctcode.Workno;
             this.textBox4.Text = ctcode.Woquantity;
             //根據工單號查詢已裝箱數量;
             this.textBox6.Text  = ctcode.Cusname;
             this.textBox7.Text  = ctcode.Cusno;
             this.textBox8.Text  = ctcode.Delmatno;
             this.textBox9.Text  = ctcode.Cusmatno;
             this.textBox13.Text = codeRule.RuleDesc;
             this.textBox5.Text  = cartonService.getCartonQtyByWO(ctcode.Workno);
             this.textBox14.Text = ctcode.Quantity.ToString();
             this.textBox3.Text  = this.dataGridView1.Rows.Count.ToString();
             this.label18.Text   = this.dataGridView1.Rows.Count.ToString();
             CommonAuxiliary.playSuccess();
             //if (filePath != null)
             //{
             //    string pictureFile = barPrint.PreviewPrintBC(filePath);
             //    this.pictureBox1.Load(pictureFile);
             //}
         }
         else
         {
             // 判断当前条码出货料号和工单以及客户编号是否一致
             if (ctcode.Workno.Trim().Equals(firstScan.Workno.Trim()) && ctcode.Delmatno.Equals(firstScan.Delmatno) && ctcode.Cusno.Equals(firstScan.Cusno))
             {
                 if (!checkRepeat(ctcode.Ctcode))
                 {
                     initRow(ctcode);
                     this.textBox3.Text  = this.dataGridView1.Rows.Count.ToString();
                     this.label18.Text   = this.dataGridView1.Rows.Count.ToString();
                     this.textBox14.Text = countQty(ctCodeList).ToString();
                     CommonAuxiliary.playSuccess();
                 }
                 else
                 {
                     this.textBox1.Text = "";
                     this.textBox1.Focus();
                     CommonAuxiliary.playFail();
                 }
             }
             else
             {
                 MessageBox.Show("底座条码工单/客户编号不一致,请检查!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.textBox1.Text = "";
                 this.textBox1.Focus();
                 CommonAuxiliary.playFail();
                 return;
             }
         }
         if (capacity != null)
         {
             //扫码包装数量等于容量时打印标签
             if (countQty(ctCodeList) == capacity.Capacityqty)
             {
                 printCarton();
             }
         }
     }
 }
Exemplo n.º 14
0
        public List <CTCode> generateCTNumber(CTCode ctCodeInfo, int printQty, DateTime currentTime)
        {
            bool          judgeSerial = false;                                      //判断是否需要流水号
            List <CTCode> listCode    = new List <CTCode>();
            StringBuilder ctCode      = new StringBuilder();
            CodeRule      codeRule    = codeRuleService.queryRuleById(ctCodeInfo.Ruleno);

            if (codeRule != null)
            {
                foreach (RuleItem ruleItem in codeRule.RuleItem)
                {
                    int ruleInt = ruleItem.Rulelength;
                    switch (ruleItem.Ruletype)
                    {
                    case "T001":
                        string poOrWorkNo = "";
                        if (ctCodeInfo.Cuspo != null && ctCodeInfo.Cuspo != "")
                        {
                            poOrWorkNo = ctCodeInfo.Cuspo;
                        }
                        else
                        {
                            poOrWorkNo = ctCodeInfo.Workno;
                        }
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + poOrWorkNo.Substring(0, ruleInt);
                            }
                        }
                        else
                        {
                            ctCode.Append(poOrWorkNo.Substring(0, ruleInt));
                        }
                        break;

                    case "T002":
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + GenerateTimeCode(ruleInt, currentTime);
                            }
                        }
                        else
                        {
                            ctCode.Append(GenerateTimeCode(ruleInt, currentTime));
                        }
                        break;

                    case "T003":
                        string assistStr = "";
                        if (ctCodeInfo.Cusmatno.Length > ruleInt)
                        {
                            assistStr = ctCodeInfo.Cusmatno.Trim().Substring(0, ruleInt);
                        }
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + assistStr;
                            }
                        }
                        else
                        {
                            ctCode.Append(assistStr);
                        }
                        break;

                    case "T004":
                        if (ctCodeInfo.Offino.Trim().Length > ruleInt)
                        {
                            string assistT004 = ctCodeInfo.Offino.Trim().Substring(0, ruleInt);

                            if (listCode.Count > 1)
                            {
                                for (int i = 0; i < listCode.Count; i++)
                                {
                                    listCode[i].Ctcode = listCode[i].Ctcode + assistT004;
                                }
                            }
                            else
                            {
                                ctCode.Append(assistT004);
                            }
                        }
                        else
                        {
                            if (listCode.Count > 1)
                            {
                                for (int i = 0; i < listCode.Count; i++)
                                {
                                    listCode[i].Ctcode = listCode[i].Ctcode + ctCodeInfo.Offino.Trim();
                                }
                            }
                            else
                            {
                                ctCode.Append(ctCodeInfo.Offino.Trim());
                            }
                        }
                        break;

                    case "T005":
                        string assistT005 = "";
                        if (ctCodeInfo.Verno.Length > ruleInt)
                        {
                            assistT005 = ctCodeInfo.Verno.Trim().Substring(0, ruleInt);
                        }

                        if (listCode.Count >= 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + assistT005;
                            }
                        }
                        else
                        {
                            ctCode.Append(assistT005);
                        }
                        break;

                    case "T006":
                        judgeSerial = true;
                        string maxCode  = printM.getMaxCTCode(ctCode.ToString());
                        string prefixCT = ctCode.ToString();
                        if (maxCode == null || maxCode == "")
                        {
                            for (int i = 1; i <= printQty; i++)
                            {
                                CTCode ctCodeIn = new CTCode();
                                ctCodeIn = exchangeCT(ctCodeIn, ctCodeInfo);
                                string seqNo   = "";
                                string tempCT  = "";
                                string seqCode = Convert34Code(i);
                                for (int numLength = seqCode.Length; numLength < ruleInt; numLength++)
                                {
                                    seqNo += "0";
                                }
                                seqNo          += seqCode;
                                tempCT          = prefixCT + seqNo;
                                ctCodeIn.Ctcode = tempCT;
                                listCode.Add(ctCodeIn);
                            }
                            if (printQty == 1)
                            {
                                ctCode.Clear();
                                ctCode.Append(listCode[0].Ctcode);
                            }
                        }
                        else
                        {
                            //獲取流水號
                            string subCode = maxCode.Substring(ctCode.Length, ruleInt);
                            int    ctNo    = convert34CodeTo10(subCode);
                            for (int i = 0; i < printQty; i++)
                            {
                                CTCode ctCodeIn = new CTCode();
                                ctCodeIn = exchangeCT(ctCodeIn, ctCodeInfo);
                                ctNo++;
                                string ct34Code = Convert34Code(ctNo);
                                string temStr   = "";
                                string tempCT   = "";
                                for (int j = ct34Code.Length; j < ruleInt; j++)
                                {
                                    temStr += 0;
                                }
                                ct34Code        = temStr + ct34Code;
                                tempCT          = prefixCT + ct34Code;
                                ctCodeIn.Ctcode = tempCT;
                                listCode.Add(ctCodeIn);
                            }
                            if (printQty == 1)
                            {
                                ctCode.Clear();
                                ctCode.Append(listCode[0].Ctcode);
                            }
                        }
                        break;

                    case "T007":
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + ruleItem.Rulevalue;
                            }
                        }
                        else
                        {
                            ctCode.Append(ruleItem.Rulevalue);
                        }
                        break;

                    case "T008":
                        string subOperation = this.extractString(ctCodeInfo.SoOrder, ruleInt);
                        //ctCode.Append(subOperation);
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + subOperation;
                            }
                        }
                        else
                        {
                            ctCode.Append(subOperation);
                        }
                        break;

                    case "T013":                    //十進制流水碼
                        judgeSerial = true;
                        string maxTenCode  = printM.getMaxCTCode(ctCode.ToString());
                        string prefixTenCT = ctCode.ToString();
                        if (maxTenCode == null || maxTenCode == "")
                        {
                            for (int i = 1; i <= printQty; i++)
                            {
                                CTCode ctCodeIn = new CTCode();
                                ctCodeIn = exchangeCT(ctCodeIn, ctCodeInfo);
                                string seqNo   = "";
                                string tempCT  = "";
                                string seqCode = i.ToString();
                                for (int numLength = seqCode.Length; numLength < ruleInt; numLength++)
                                {
                                    seqNo += "0";
                                }
                                seqNo          += seqCode;
                                tempCT          = prefixTenCT + seqNo;
                                ctCodeIn.Ctcode = tempCT;
                                listCode.Add(ctCodeIn);
                            }
                            if (printQty == 1)
                            {
                                ctCode.Clear();
                                ctCode.Append(listCode[0].Ctcode);
                            }
                        }
                        else
                        {
                            //獲取流水號
                            string subCode = maxTenCode.Substring(ctCode.Length, ruleInt);
                            int    ctNo    = int.Parse(subCode);
                            for (int i = 0; i < printQty; i++)
                            {
                                CTCode ctCodeIn = new CTCode();
                                ctCodeIn = exchangeCT(ctCodeIn, ctCodeInfo);
                                ctNo++;
                                string ct34Code = ctNo.ToString();
                                string temStr   = "";
                                string tempCT   = "";
                                for (int j = ct34Code.Length; j < ruleInt; j++)
                                {
                                    temStr += 0;
                                }
                                ct34Code        = temStr + ct34Code;
                                tempCT          = prefixTenCT + ct34Code;
                                ctCodeIn.Ctcode = tempCT;
                                listCode.Add(ctCodeIn);
                            }
                            if (printQty == 1)
                            {
                                ctCode.Clear();
                                ctCode.Append(listCode[0].Ctcode);
                            }
                        }
                        break;

                    case "T014":                    //年月日進制表示
                        StringBuilder timeString = new StringBuilder();
                        string        yearString = currentTime.Year.ToString();
                        int           yearInt    = int.Parse(yearString.Substring(yearString.Length - 2)); //獲取兩位年
                        int           monthInt   = currentTime.Month;
                        int           dayInt     = currentTime.Day;
                        timeString.Append(Base31Code[yearInt]);
                        timeString.Append(Base31Code[monthInt]);
                        timeString.Append(Base31Code[dayInt]);
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + timeString.ToString();
                            }
                        }
                        else
                        {
                            ctCode.Append(timeString.ToString());
                        }
                        break;

                    case "T015":                    //浪潮年月日進制表示
                        if (listCode.Count > 1)
                        {
                            for (int i = 0; i < listCode.Count; i++)
                            {
                                listCode[i].Ctcode = listCode[i].Ctcode + getInsuprTime();
                            }
                        }
                        else
                        {
                            ctCode.Append(getInsuprTime());
                        }
                        break;

                    case "T016":                                                              //浪潮批次号
                        string woBatchNo  = woBatchService.getBatchNoByWO(ctCodeInfo.Workno); //查询工单批次号
                        string batchSeqNo = "1";
                        if (woBatchNo == null || woBatchNo.Equals(""))
                        {
                            string        queryCond = getInsuprTime() + "Q";
                            List <String> batchNos  = woBatchService.queryBatchNos(queryCond);
                            if (batchNos != null && batchNos.Count > 0)
                            {
                                int maxNo = 0;
                                foreach (string batch in batchNos)
                                {
                                    int tempMathNo = InverseBase34Code[batch.Substring(batch.Length - 1, 1)];
                                    if (tempMathNo > maxNo)
                                    {
                                        maxNo = tempMathNo;
                                    }
                                }
                                batchSeqNo = Base34Code[maxNo + 1];
                            }
                            if (listCode.Count > 1)
                            {
                                for (int i = 0; i < listCode.Count; i++)
                                {
                                    listCode[i].Ctcode = listCode[i].Ctcode + batchSeqNo;
                                }
                                woBatchNo = listCode[0].Ctcode;
                            }
                            else
                            {
                                ctCode.Append(batchSeqNo);
                                woBatchNo = ctCode.ToString();
                            }
                            //保存工单批次
                            WoBatch woBatch = new WoBatch();
                            woBatch.BatchNo = woBatchNo;
                            woBatch.Workno  = ctCodeInfo.Workno;
                            woBatchService.saveWoBatch(woBatch);                        //占用工单批次
                        }
                        else
                        {
                            if (listCode.Count > 1)
                            {
                                for (int i = 0; i < listCode.Count; i++)
                                {
                                    listCode[i].Ctcode = "";
                                    listCode[i].Ctcode = woBatchNo;
                                }
                            }
                            else
                            {
                                ctCode.Clear();
                                ctCode.Append(woBatchNo);
                            }
                        }

                        break;
                    }
                }
            }
            if (!judgeSerial)
            {
                for (int i = 1; i <= printQty; i++)
                {
                    CTCode ctCodeIn = new CTCode();
                    ctCodeIn        = exchangeCT(ctCodeIn, ctCodeInfo);
                    ctCodeIn.Ctcode = ctCode.ToString();
                    listCode.Add(ctCodeIn);
                }
            }
            if (printQty == 1)
            {
                listCode[0].Ctcode = ctCode.ToString();
            }
            return(listCode);
        }