Browse Source

二次正则匹配修改

章政 6 years ago
parent
commit
db7dfc7f8c

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

@@ -2045,7 +2045,7 @@
             // 
             this.Expression.AutoSize = true;
             this.Expression.Font = new System.Drawing.Font("微软雅黑", 9F);
-            this.Expression.Location = new System.Drawing.Point(91, 37);
+            this.Expression.Location = new System.Drawing.Point(79, 31);
             this.Expression.Name = "Expression";
             this.Expression.Size = new System.Drawing.Size(62, 21);
             this.Expression.TabIndex = 1;
@@ -2057,7 +2057,7 @@
             // 
             this.Equal.AutoSize = true;
             this.Equal.Font = new System.Drawing.Font("微软雅黑", 9F);
-            this.Equal.Location = new System.Drawing.Point(25, 37);
+            this.Equal.Location = new System.Drawing.Point(13, 31);
             this.Equal.Name = "Equal";
             this.Equal.Size = new System.Drawing.Size(50, 21);
             this.Equal.TabIndex = 0;

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

@@ -445,7 +445,12 @@ namespace UAS_LabelMachine
                                         if (si_expression != "")
                                         {
                                             si_exp = new Regex(si_expression);
-                                            DateCode = si_exp.Match(matchs1.Groups[reg.GroupNumberFromName(groupName)].Value).Value;
+                                            Match mat = si_exp.Match(matchs1.Groups[reg.GroupNumberFromName(groupName)].Value);
+                                            foreach (var dtgroup in si_exp.GetGroupNames())
+                                            {
+                                                if (dtgroup == dt.Rows[j]["si_name"].ToString())
+                                                    DateCode = mat.Groups[si_exp.GroupNumberFromName(dtgroup)].Value;
+                                            }
                                         }
                                         else
                                         {
@@ -503,7 +508,16 @@ namespace UAS_LabelMachine
                                         if (si_expression != "")
                                         {
                                             si_exp = new Regex(si_expression);
-                                            QTY = si_exp.Match(matchs1.Groups[reg.GroupNumberFromName(groupName)].Value).Value;
+                                            Console.WriteLine(matchs1.Groups[reg.GroupNumberFromName(groupName)].Value);
+                                            Match mat = si_exp.Match(matchs1.Groups[reg.GroupNumberFromName(groupName)].Value);
+                                            foreach (var dtgroup in si_exp.GetGroupNames())
+                                            {
+                                                if (dtgroup == dt.Rows[j]["si_name"].ToString())
+                                                {
+                                                    Console.WriteLine(mat.Groups[si_exp.GroupNumberFromName(dtgroup)].Value);
+                                                    QTY = mat.Groups[si_exp.GroupNumberFromName(dtgroup)].Value;
+                                                }
+                                            }
                                         }
                                         else
                                         {
@@ -614,9 +628,21 @@ namespace UAS_LabelMachine
                         else if (Expression.Checked)
                         {
                             Regex re = new Regex(cu_print_regexpression.Text);
-                            if (re.Match(msgArr[i]).Value == LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString())
+                            Match matchs1 = re.Match(msgArr[i]);
+                            foreach (var groupName in re.GetGroupNames())
                             {
-                                CheckItem.Remove("客户料号");
+                                if (groupName == "custPN")
+                                {
+                                    if (LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() == matchs1.Groups[re.GroupNumberFromName(groupName)].Value)
+                                    {
+                                        pibid = back_adh.getFieldDataByCondition("prodiobarcode", "min(pib_id)", "pib_inoutno='" + pi_inoutno.Text + "' and pd_custprodcode='" + msgArr[i] + "' and pib_ifrecheck=0").ToString();
+                                        if (pibid != "")
+                                        {
+                                            pibid1 = pibid;
+                                            CheckItem.Remove("客户料号");
+                                        }
+                                    }
+                                }
                             }
                         }
                         if (RegexMatch("BackCheck", msgArr[i], out ErrorMsg))
@@ -1386,16 +1412,19 @@ namespace UAS_LabelMachine
                             if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
                             {
                                 string date = dt1.Rows[0][0].ToString();
-                                System.DateTime dtime = System.DateTime.ParseExact(date, "yyyymmdd", System.Globalization.CultureInfo.CurrentCulture);
-                                try
+                                System.DateTime dtime;
+                                if (System.DateTime.TryParseExact(date, "yyyymmdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtime))
                                 {
-                                    date = dtime.ToString(cu_print_dateformat.Text);
-                                }
-                                catch (Exception)
-                                {
-                                    date = dtime.ToString("yyyymmdd");
+                                    try
+                                    {
+                                        date = dtime.ToString(cu_print_dateformat.Text);
+                                    }
+                                    catch (Exception)
+                                    {
+                                        date = dtime.ToString("yyyymmdd");
+                                    }
+                                    MidDoc.Variables.FormVariables.Item(k + 1).Value = date;
                                 }
-                                MidDoc.Variables.FormVariables.Item(k + 1).Value = date;
                             }
                         }
                     }
@@ -1470,16 +1499,19 @@ namespace UAS_LabelMachine
                                 if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
                                 {
                                     string date = dt1.Rows[0][0].ToString();
-                                    System.DateTime dtime = System.DateTime.ParseExact(date, "yyyymmdd", System.Globalization.CultureInfo.CurrentCulture);
-                                    try
-                                    {
-                                        date = dtime.ToString(cu_print_dateformat.Text);
-                                    }
-                                    catch (Exception)
+                                    System.DateTime dtime;
+                                    if (System.DateTime.TryParseExact(date, "yyyymmdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtime))
                                     {
-                                        date = dtime.ToString("yyyymmdd");
+                                        try
+                                        {
+                                            date = dtime.ToString(cu_print_dateformat.Text);
+                                        }
+                                        catch (Exception)
+                                        {
+                                            date = dtime.ToString("yyyymmdd");
+                                        }
+                                        OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = date;
                                     }
-                                    OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = date;
                                 }
                             }
                         }
@@ -2520,16 +2552,19 @@ namespace UAS_LabelMachine
                         if (dr1[0]["lp_sql"].ToString().Contains("pib_year"))
                         {
                             string date = dt1.Rows[0][0].ToString();
-                            System.DateTime dtime = System.DateTime.ParseExact(date, "yyyymmdd", System.Globalization.CultureInfo.CurrentCulture);
-                            try
+                            System.DateTime dtime;
+                            if (System.DateTime.TryParseExact(date, "yyyymmdd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dtime))
                             {
-                                date = dtime.ToString(cu_print_dateformat.Text);
-                            }
-                            catch (Exception)
-                            {
-                                date = dtime.ToString("yyyymmdd");
+                                try
+                                {
+                                    date = dtime.ToString(cu_print_dateformat.Text);
+                                }
+                                catch (Exception)
+                                {
+                                    date = dtime.ToString("yyyymmdd");
+                                }
+                                SingleDoc.Variables.FormVariables.Item(j + 1).Value = date;
                             }
-                            SingleDoc.Variables.FormVariables.Item(j + 1).Value = date;
                         }
                     }
                 }