Procházet zdrojové kódy

日期设置调整

章政 před 6 roky
rodič
revize
5bd8b65f58

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

@@ -294,7 +294,7 @@ namespace UAS_LabelMachine
                 port.Read(readBuffer, 0, len); //将数据读入缓存
                 string msg = Encoding.ASCII.GetString(readBuffer, 0, len).Replace("\n", "").Replace("\r", "").Replace("\t", ""); //获取出入库产品编号
                 if (LabelInf.Rows.Count == 0)
-                    return; 
+                    return;
                 int pib_pdno = int.Parse(LabelInf.Rows[CurrentRowIndex].Cells["pib_pdno"].Value.ToString());
                 if (DetailRange.Checked)
                 {
@@ -433,6 +433,10 @@ namespace UAS_LabelMachine
                     int rownum = 0;
                     Matched = true;
                     string ItemStr = "";
+                    string year = "";
+                    string month = "";
+                    string day = "";
+                    string date = "";
                     foreach (var groupName in reg.GetGroupNames())
                     {
                         for (int j = 0; j < dt.Rows.Count; j++)
@@ -460,10 +464,6 @@ namespace UAS_LabelMachine
                                         {
                                             DateCode = matchs1.Groups[reg.GroupNumberFromName(groupName)].Value;
                                         }
-                                        string year = "";
-                                        string month = "";
-                                        string day = "";
-                                        string date = "";
                                         LogicHandler.GetTimeFromDatecode(dh, DateCode, pi_cardcode.Text, out year, out month, out day, out date);
                                         System.DateTime dtime;
                                         //有效期比对
@@ -549,6 +549,20 @@ namespace UAS_LabelMachine
                             }
                         }
                     }
+                    //查询设置解析的DateCode的值
+                    DataRow[] dr = LabelInfDataTable.Select("pib_id=" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value);
+                    if (dr.Length > 0)
+                    {
+                        try
+                        {
+                            dr[0]["pib_year"] = year;
+                            dr[0]["pib_month"] = month;
+                            dr[0]["pib_day"] = day;
+                        }
+                        catch (Exception)
+                        {
+                        }
+                    }
                     //如果品牌不对应的话则不能使用本次的匹配规则
                     if (ErrorMsg == "" && ItemStr.Contains("QTY") && LabelInf.Rows[CurrentRowIndex].Cells["pib_qty"].Value.ToString() != QTY.ToString())
                     {
@@ -692,34 +706,19 @@ namespace UAS_LabelMachine
                 {
                     if (CheckItem.Count == 0 || (ManualCheckCount.Count == 1 && CheckItem.Count == 1))
                     {
-                        string year = "0";
-                        string month = "0";
-                        string day = "0";
-                        string date = "";
                         DataRow[] dr = LabelInfDataTable.Select("pib_id=" + pibid1 + " and pr_orispeccode='" + PN + "'");
                         if (dr.Length > 0)
                         {
                             dr[0]["pib_ifrecheck"] = -1;
                             dr[0]["pib_lotno"] = LotNo;
                             dr[0]["pib_datecode"] = DateCode;
-                            try
-                            {
-                                LogicHandler.GetTimeFromDatecode(dh1, DateCode, pi_cardcode.Text, out year, out month, out day, out date);
-                                dr[0]["pib_year"] = year;
-                                dr[0]["pib_month"] = month;
-                                dr[0]["pib_day"] = day;
-                            }
-                            catch (Exception)
-                            {
-
-                            }
                         }
                         else
                         {
                             ErrorMsg = "未匹配到合适的原厂型号";
                             return false;
                         }
-                        back_adh.ExecuteSql("update prodiobarcode set pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "',pib_ifrecheck=-1,pib_datecode='" + DateCode + "',pib_lotno='" + LotNo + "' where pib_id=" + pibid1 + " and pr_orispeccode='" + PN + "'", "update");
+                        back_adh.ExecuteSql("update prodiobarcode set pib_ifrecheck=-1,pib_datecode='" + DateCode + "',pib_lotno='" + LotNo + "' where pib_id=" + pibid1 + " and pr_orispeccode='" + PN + "'", "update");
                     }
                 }
                 else
@@ -772,25 +771,13 @@ namespace UAS_LabelMachine
             {
                 if (RegexMatch("BackCheck", msg, out ErrorMsg))
                 {
-                    string year = "0";
-                    string month = "0";
-                    string day = "0";
-                    string date = "";
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value = DateCode;
                     //解析DateCode,将值设置到年月日
-                    try
-                    {
-                        LogicHandler.GetTimeFromDatecode(dh1, DateCode, pi_cardcode.Text, out year, out month, out day, out date);
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
-                        LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
-                    }
-                    catch (Exception) { }
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value = LotNo;
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_ifmodify"].Value = true;
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_ifrecheck"].Value = true;
                     LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
-                    adh.ExecuteSQLTran("update prodiobarcode set pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "',pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1,pib_ifrecheck=-1 where pib_id=" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value);
+                    adh.ExecuteSQLTran("update prodiobarcode set pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1,pib_ifrecheck=-1 where pib_id=" + LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value);
                     LogicHandler.CheckUploadData(pi_inoutno.Text, UploadNum);
                     LabelInf.Invalidate();
                     return true;
@@ -2354,19 +2341,10 @@ namespace UAS_LabelMachine
 
         private void SetOutboxBarcode()
         {
-            string year = "0";
-            string month = "0";
-            string day = "0";
-            string date = "";
-            //解析DateCode,将值设置到年月日
-            try
-            {
-                LogicHandler.GetTimeFromDatecode(dh, DateCode, pi_cardcode.Text, out year, out month, out day, out date);
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value = year;
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value = month;
-                LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value = day;
-            }
-            catch (Exception) { }
+            string year = LabelInf.Rows[CurrentRowIndex].Cells["pib_year"].Value.ToString();
+            string month = LabelInf.Rows[CurrentRowIndex].Cells["pib_month"].Value.ToString();
+            string day = LabelInf.Rows[CurrentRowIndex].Cells["pib_day"].Value.ToString();
+            string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
             int outboxcode1 = int.Parse(Process_midboxcode.Text == "" ? "1" : Process_midboxcode.Text);
             int outboxcode2 = int.Parse(Process_outboxcode.Text == "" ? "1" : Process_outboxcode.Text);
             string pd_id = LabelInf.Rows[CurrentRowIndex].Cells["pd_id"].Value.ToString();
@@ -2536,7 +2514,6 @@ namespace UAS_LabelMachine
             //设置中盒外箱号
             LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value = outboxcode1;
             LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = outboxcode2;
-            string pib_id = LabelInf.Rows[CurrentRowIndex].Cells["pib_id1"].Value.ToString();
             if (SingleLabelAutoPrint.Checked)
                 adh.ExecuteSql("update prodiobarcode set pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "',pib_outboxcode2=" + outboxcode2 + ",pib_outboxcode1=" + outboxcode1 + ",pib_custoutboxcode='" + OutBoxBarCode + "',pib_custmidboxcode='" + MidBoxBarCode + "',pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1,pib_ifprint=-1 where pib_id=" + pib_id, "update");
             else