Browse Source

添加正则之后的分割

章政 7 years ago
parent
commit
3919d364cb
1 changed files with 26 additions and 11 deletions
  1. 26 11
      UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

+ 26 - 11
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -245,16 +245,18 @@ namespace UAS_LabelMachine
             }
             }
         }
         }
 
 
-        private void FrontCheckFunction(string msg)
+        private bool FrontCheckFunction(string msg)
         {
         {
             for (int i = 0; i < ScanGroup.Rows.Count; i++)
             for (int i = 0; i < ScanGroup.Rows.Count; i++)
             {
             {
                 string sg_name = ScanGroup.Rows[i]["sg_name"].ToString();
                 string sg_name = ScanGroup.Rows[i]["sg_name"].ToString();
                 string sg_brand = ScanGroup.Rows[i]["sg_brand"].ToString();
                 string sg_brand = ScanGroup.Rows[i]["sg_brand"].ToString();
                 reg = new Regex(ScanGroup.Rows[i]["sg_script"].ToString());
                 reg = new Regex(ScanGroup.Rows[i]["sg_script"].ToString());
-                MatchCollection matchs = reg.Matches(msg);
+                Match matchs1 = reg.Match(msg);
                 int index = 0;
                 int index = 0;
-                DataTable dt = BaseUtil.filterDataTable(ScanItem, "sg_name='" + sg_name + "' and sg_brand='" + sg_brand + "' and items_num=" + matchs.Count);
+                string[] arr = matchs1.Value.Split(',');
+                DataTable dt = BaseUtil.filterDataTable(ScanItem, "sg_name='" + sg_name + "' and sg_brand='" + sg_brand + "' and items_num=" + arr.Length);
+
                 if (dt.Rows.Count > 0)
                 if (dt.Rows.Count > 0)
                 {
                 {
                     for (int j = 0; j < dt.Rows.Count; j++)
                     for (int j = 0; j < dt.Rows.Count; j++)
@@ -267,37 +269,49 @@ namespace UAS_LabelMachine
                                 if (si_expression != "")
                                 if (si_expression != "")
                                 {
                                 {
                                     si_exp = new Regex(si_expression);
                                     si_exp = new Regex(si_expression);
-                                    DateCode = si_exp.Match(matchs[index].Value).Value;
+                                    DateCode = si_exp.Match(arr[index]).Value;
                                 }
                                 }
                                 else
                                 else
                                 {
                                 {
-                                    DateCode = matchs[index].Value;
+                                    DateCode = arr[index];
                                 }
                                 }
                                 LabelInfDataTable.Rows[CurrentRowIndex]["pib_datecode"] = DateCode;
                                 LabelInfDataTable.Rows[CurrentRowIndex]["pib_datecode"] = DateCode;
                                 break;
                                 break;
                             case "LotNo":
                             case "LotNo":
-                                LotNo = matchs[index].Value;
+                                LotNo = arr[index];
                                 LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"] = LotNo;
                                 LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"] = LotNo;
                                 break;
                                 break;
                             case "PN":
                             case "PN":
-                                PN = matchs[index].Value;
+                                PN = arr[index];
+                                if (LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"].ToString() != QTY.ToString())
+                                {
+                                    return false;
+                                }
                                 break;
                                 break;
                             case "Order":
                             case "Order":
-                                Order = matchs[index].Value;
+                                Order = arr[index];
+                                if (LabelInfDataTable.Rows[CurrentRowIndex]["pib_ordercode"].ToString() != QTY.ToString())
+                                {
+                                    return false;
+                                }
                                 break;
                                 break;
                             case "QTY":
                             case "QTY":
                                 if (si_expression != "")
                                 if (si_expression != "")
                                 {
                                 {
                                     si_exp = new Regex(si_expression);
                                     si_exp = new Regex(si_expression);
-                                    QTY = si_exp.Match(matchs[index].Value).Value;
+                                    QTY = si_exp.Match(arr[index]).Value;
                                 }
                                 }
                                 else
                                 else
                                 {
                                 {
-                                    QTY = matchs[index].Value;
+                                    QTY = arr[index];
+                                }
+                                if (LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"].ToString() != QTY.ToString())
+                                {
+                                    return false;
                                 }
                                 }
                                 break;
                                 break;
                             case "OutBox":
                             case "OutBox":
-                                OutBox = matchs[index].Value;
+                                OutBox = arr[index];
                                 break;
                                 break;
                             default:
                             default:
                                 break;
                                 break;
@@ -309,6 +323,7 @@ namespace UAS_LabelMachine
             }
             }
             LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifpick"] = true;
             LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifpick"] = true;
             LabelInf.Refresh();
             LabelInf.Refresh();
+            return true;
         }
         }
 
 
         private void BackendCheckFunction(string msg, string pib_id)
         private void BackendCheckFunction(string msg, string pib_id)