Browse Source

修改提取DateCode的存储过程

章政 6 years ago
parent
commit
3f93177ed2

+ 14 - 0
UAS-出货标签管理(吉利通)/PublicMethod/BaseUtil.cs

@@ -56,6 +56,20 @@ namespace UAS_LabelMachine
             }
         }
 
+        public static void GetDayFromDateCode(string DateCode, out int oYear, out int oMonth, out int oDay)
+        {
+            oYear = 0;
+            oMonth = 0;
+            oDay = 0;
+            if (DateCode.Length == 4)
+            {
+                oYear = int.Parse(DateCode.Substring(0, 2));
+                DateTime date=  new DateTime(DateTime.Now.Year, 1, 1).AddDays(7 * int.Parse(DateCode.Substring(2, 2)));
+                oMonth = date.Month;
+                oDay = date.Day;
+            }
+        }
+
         public static string SysDisc1
         {
             get

+ 14 - 2
UAS-出货标签管理(吉利通)/PublicMethod/LogicHandler.cs

@@ -63,6 +63,18 @@ namespace UAS_LabelMachine.PublicMethod
             oBarCode = param[9];
         }
 
+        public static void GetTimeFromDatecode(string iDatecode, string iCustcode, out string  oYear, out string oMonth ,out string oDay)
+        {
+            oYear = "0";
+            oMonth = "0";
+            oDay = "0";
+            string[] param = new string[] { iDatecode, iCustcode, oYear , oMonth, oDay };
+            dh.CallProcedure("GETTIMEFROMDATECODE", ref param);
+            oYear = param[2];
+            oMonth = param[3];
+            oDay = param[4];
+        }
+
         /// <summary>
         /// 获取十六进制字节数组
         /// </summary>
@@ -81,7 +93,7 @@ namespace UAS_LabelMachine.PublicMethod
         /// <param name="iInoutno"></param>
         public static bool CheckUploadData(string iInoutno, int iUploadNum)
         {
-            DataTable dt = (DataTable)adh.ExecuteSql("select pib_id,pib_outboxcode1,pib_outboxcode2,pib_custmidboxcode,pib_custoutboxcode,pib_lotno,pib_datecode,pib_ifmodify,pib_ifupload,pib_ifpick,pib_ifprint,pib_ifrecheck from prodiobarcode where pib_inoutno='" + iInoutno + "'   ", "select");
+            DataTable dt = (DataTable)adh.ExecuteSql("select pib_id,pib_outboxcode1,pib_outboxcode2,pib_custmidboxcode,pib_custoutboxcode,pib_lotno,pib_datecode,pib_ifmodify,pib_ifupload,pib_ifpick,pib_ifprint,pib_ifrecheck,pib_year,pib_month,pib_day from prodiobarcode where pib_inoutno='" + iInoutno + "'   ", "select");
             DataTable upload = BaseUtil.filterDataTable(dt, "pib_ifupload=0 and pib_ifrecheck=-1");
             DataTable unupload = BaseUtil.filterDataTable(dt, "pib_ifpick=0");
             //如果本地需要上传的数据已经达到了需要上传的条数或者已经采集完了最后一条数据
@@ -107,7 +119,7 @@ namespace UAS_LabelMachine.PublicMethod
         /// <param name="iInoutno"></param>
         public static bool CheckUploadData(string iInoutno)
         {
-            DataTable dt = (DataTable)adh.ExecuteSql("select pib_id,pib_outboxcode1,pib_outboxcode2,pib_custmidboxcode,pib_custoutboxcode,pib_lotno,pib_datecode,pib_ifmodify,-1 as pib_ifupload,pib_ifpick,pib_ifprint,pib_ifrecheck from prodiobarcode where pib_inoutno='" + iInoutno + "' and pib_ifupload=0 and pib_ifrecheck=-1  ", "select");
+            DataTable dt = (DataTable)adh.ExecuteSql("select pib_id,pib_outboxcode1,pib_outboxcode2,pib_custmidboxcode,pib_custoutboxcode,pib_lotno,pib_datecode,pib_ifmodify,-1 as pib_ifupload,pib_ifpick,pib_ifprint,pib_ifrecheck,pib_year,pib_month,pib_day from prodiobarcode where pib_inoutno='" + iInoutno + "' and pib_ifupload=0 and pib_ifrecheck=-1  ", "select");
             if (dt.Rows.Count > 0)
             {
                 dh.CallProcedure("sp_uploadbarcode", dt);

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

@@ -529,6 +529,9 @@ namespace UAS_LabelMachine
         private bool FrontCheckFunction(string msg, out string ErrorMsg)
         {
             ErrorMsg = "";
+            string year = "0";
+            string month = "0";
+            string day = "0";
             //调用正则验证
             RegexMatch("FrontCheck", msg, out ErrorMsg);
             if (ErrorMsg != "")
@@ -539,6 +542,18 @@ namespace UAS_LabelMachine
             {
                 //获取当前最大的箱号
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value = DateCode;
+                //解析DateCode,将值设置到年月日
+                try
+                {
+                    LogicHandler.GetTimeFromDatecode(DateCode, "", out year, out month, out day);
+                    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;
                 string boxcode = front_adh.getFieldDataByCondition("prodiobarcode", "max(pib_outboxcode1)", "pib_inoutno='" + pi_inoutno.Text + "'").ToString();
@@ -699,7 +714,7 @@ 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();
-                front_adh.ExecuteSql("update prodiobarcode set pib_outboxcode2=" + outboxcode2 + ",pib_outboxcode1=" + outboxcode1 + ",pib_custoutboxcode='" + OutBoxBarCode + "',pib_custmidboxcode='" + MidBoxBarCode + "',pib_lotno='" + LotNo + "',pib_datecode='" + DateCode + "',pib_ifpick=-1,pib_ifmodify=-1 where pib_id=" + pib_id, "update");
+                front_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 where pib_id=" + pib_id, "update");
                 LabelInf.Invalidate();
                 return true;
             }
@@ -779,19 +794,33 @@ namespace UAS_LabelMachine
             {
                 if (CheckItem.Count == 0 || (ManualCheckCount.Count == 1 && CheckItem.Count == 1))
                 {
+                    string year = "0";
+                    string month = "0";
+                    string day = "0";
                     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(DateCode, "", out year, out month, out day);
+                            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_ifrecheck=-1,pib_datecode='" + DateCode + "',pib_lotno='" + LotNo + "' where pib_id=" + pibid1 + " and pr_orispeccode='" + PN + "'", "update");
+                    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");
                 }
             }
             else