浏览代码

Merge remote-tracking branch 'refs/remotes/origin/master'

章政 8 年之前
父节点
当前提交
434e9dad6d
共有 2 个文件被更改,包括 129 次插入3 次删除
  1. 61 2
      UAS-MES/FunctionCode/Make/Make_SeqProgramTransform.cs
  2. 68 1
      UAS-MES/FunctionCode/Make/Make_SeqTransform.cs

+ 61 - 2
UAS-MES/FunctionCode/Make/Make_SeqProgramTransform.cs

@@ -45,6 +45,11 @@ namespace UAS_MES.Make
         string makecode;
         //存放所有关联信息的类型和录入的值
         Hashtable hs;
+        string startNo = "";//起始序列
+
+        string endNo = "";//终止序列
+
+        string system = "";//进制
         public Make_SeqProgramTransform()
         {
             InitializeComponent();
@@ -435,7 +440,7 @@ namespace UAS_MES.Make
             SNLength_checkBox.Enabled = true;
 
             //查询表工单序列号防呆规则表
-            dt = (DataTable)dh.ExecuteSql("select msr_type, msr_prefix ,msr_length from makesnrule where msr_makecode='" + ms_macode.Text + "'", "select");
+            dt = (DataTable)dh.ExecuteSql("select msr_startno,msr_endno,msr_system,msr_type, msr_prefix ,msr_length from makesnrule where msr_makecode='" + ms_macode.Text + "'", "select");
             if (dt.Rows.Count > 0)
             {
                 foreach (DataRow dr in dt.Rows)
@@ -477,6 +482,8 @@ namespace UAS_MES.Make
                         //临时变量记录
                         string length = dr["msr_length"].ToString();
                         string prefix = dr["msr_prefix"].ToString();
+                        //记录进制
+                        system = dr["msr_system"].ToString();
                         //不为空
                         if (prefix != "" && prefix != null)
                         {
@@ -487,7 +494,12 @@ namespace UAS_MES.Make
                             //勾选
                             SNPre_checkBox.Checked = true;
                             SNPre_checkBox.Enabled = false;
+                            //记录起止序列号
+                            startNo = dr["msr_startno"].ToString().Substring(prefix.Length - 1);
+                            endNo = dr["msr_endno"].ToString().Substring(prefix.Length - 1);
                         }
+                        startNo = dr["msr_startno"].ToString();
+                        endNo = dr["msr_endno"].ToString();
                         if (length != "" && length != null)
                         {
                             //赋值
@@ -518,7 +530,54 @@ namespace UAS_MES.Make
                 //}
             }
         }
-
+        /// <summary>
+        /// 检测转换后的序列号是否满足起止序列号范围
+        /// </summary>
+        /// <returns></returns>
+        private bool checkStartAndEnd()
+        {
+            if (system == "decimal")
+            {
+                //十进制
+                if (SNPre.Text.Trim() == "")
+                {
+                    if (int.Parse(code.Text) >= int.Parse(startNo) && int.Parse(code.Text) <= int.Parse(endNo))
+                    {
+                        //满足范围条件
+                        return true;
+                    }
+                }
+                else
+                {
+                    if (int.Parse(code.Text.Substring(SNPre.Text.Length - 1)) >= int.Parse(startNo) && int.Parse(code.Text.Substring(SNPre.Text.Length - 1)) <= int.Parse(endNo))
+                    {
+                        //满足
+                        return true;
+                    }
+                }
+            }
+            else
+            {
+                //十六进制
+                if (SNPre.Text.Trim() == "")
+                {
+                    if (int.Parse(code.Text) >= int.Parse(startNo, System.Globalization.NumberStyles.HexNumber) && int.Parse(code.Text) <= int.Parse(endNo, System.Globalization.NumberStyles.HexNumber))
+                    {
+                        //满足范围条件
+                        return true;
+                    }
+                }
+                else
+                {
+                    if (int.Parse(code.Text.Substring(SNPre.Text.Length - 1)) >= int.Parse(startNo, System.Globalization.NumberStyles.HexNumber) && int.Parse(code.Text.Substring(SNPre.Text.Length - 1)) <= int.Parse(endNo, System.Globalization.NumberStyles.HexNumber))
+                    {
+                        //满足
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
         private bool checkExist(string fields)
         {
             //不存在

+ 68 - 1
UAS-MES/FunctionCode/Make/Make_SeqTransform.cs

@@ -23,6 +23,12 @@ namespace UAS_MES.Make
 
         string errorMessage = "";
 
+        string startNo = "";//起始序列
+
+        string endNo = "";//终止序列
+
+        string system = "";//进制
+
         public Make_SeqTransform()
         {
             InitializeComponent();
@@ -150,6 +156,13 @@ namespace UAS_MES.Make
                         //bsncode不为空,说明输入的是转换后的序列号
                         else
                         {
+                            //判断输入的转换后序列号是否符合起始终止
+                            if (!checkStartAndEnd())
+                            {
+                                OperateResult.AppendText(">>序列号" + sncode.Text + "校验错误,不在工单防呆规则指定范围内!\n", Color.Red);
+                                sncode.Text = "";
+                                return;
+                            }
                             //判断用户是否锁定输入转换后序列号长度,
                             if (!checkLengthOrPre(afterTransSNLength_checkBox, afterTransSNLength, "长度"))
                                 return;
@@ -273,7 +286,7 @@ namespace UAS_MES.Make
             afterTransSNPre_checkBox.Enabled = true;
             afterTransSNLength_checkBox.Enabled = true;
             //查询表工单序列号防呆规则表
-            dt = (DataTable)dh.ExecuteSql("select msr_type, msr_prefix ,msr_length from makesnrule where msr_makecode='" + ma_code.Text + "'", "select");
+            dt = (DataTable)dh.ExecuteSql("select msr_startno,msr_endno,msr_system,msr_type, msr_prefix ,msr_length from makesnrule where msr_makecode='" + ma_code.Text + "'", "select");
             if (dt.Rows.Count > 0)
             {
                 foreach (DataRow dr in dt.Rows)
@@ -315,6 +328,8 @@ namespace UAS_MES.Make
                         //临时变量记录
                         string length = dr["msr_length"].ToString();
                         string prefix = dr["msr_prefix"].ToString();
+                        //记录进制
+                        system = dr["msr_system"].ToString();
                         //不为空
                         if (prefix != "" && prefix != null)
                         {
@@ -325,7 +340,12 @@ namespace UAS_MES.Make
                             //勾选
                             afterTransSNPre_checkBox.Checked = true;
                             afterTransSNPre_checkBox.Enabled = false;
+                            //记录起止序列号
+                            startNo = dr["msr_startno"].ToString().Substring(prefix.Length - 1);
+                            endNo = dr["msr_endno"].ToString().Substring(prefix.Length - 1);
                         }
+                        startNo = dr["msr_startno"].ToString();
+                        endNo = dr["msr_endno"].ToString();
                         if (length != "" && length != null)
                         {
                             //赋值
@@ -399,5 +419,52 @@ namespace UAS_MES.Make
             }
             return true;
         }
+        /// <summary>
+        /// 检测转换后的序列号是否满足起止序列号范围
+        /// </summary>
+        /// <returns></returns>
+        private bool checkStartAndEnd()
+        {
+            if (system == "decimal")
+            {
+                //十进制
+                if (afterTransSNPre.Text.Trim() == "")
+                {
+                    if (int.Parse(sncode.Text) >= int.Parse(startNo) && int.Parse(sncode.Text) <= int.Parse(endNo))
+                    {
+                        //满足范围条件
+                        return true;
+                    }
+                }
+                else
+                {
+                    if (int.Parse(sncode.Text.Substring(afterTransSNPre.Text.Length-1))>= int.Parse(startNo)&& int.Parse(sncode.Text.Substring(afterTransSNPre.Text.Length - 1)) <= int.Parse(endNo))
+                    {
+                        //满足
+                        return true;
+                    }
+                }
+            }
+            else {
+                //十六进制
+                if (afterTransSNPre.Text.Trim() == "")
+                {
+                    if (int.Parse(sncode.Text) >= int.Parse(startNo,System.Globalization.NumberStyles.HexNumber) && int.Parse(sncode.Text) <= int.Parse(endNo, System.Globalization.NumberStyles.HexNumber))
+                    {
+                        //满足范围条件
+                        return true;
+                    }
+                }
+                else
+                {
+                    if (int.Parse(sncode.Text.Substring(afterTransSNPre.Text.Length - 1)) >= int.Parse(startNo, System.Globalization.NumberStyles.HexNumber) && int.Parse(sncode.Text.Substring(afterTransSNPre.Text.Length - 1)) <= int.Parse(endNo, System.Globalization.NumberStyles.HexNumber))
+                    {
+                        //满足
+                        return true;
+                    }
+                }
+            }
+            return false;
+        }
     }
 }