Browse Source

1代码提交

章政 6 years ago
parent
commit
640fab1b0b
1 changed files with 46 additions and 16 deletions
  1. 46 16
      UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

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

@@ -677,7 +677,7 @@ namespace UAS_LabelMachine
                             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_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
@@ -747,7 +747,7 @@ namespace UAS_LabelMachine
                     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_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);
                     LogicHandler.CheckUploadData(pi_inoutno.Text, UploadNum);
                     LabelInf.Invalidate();
                     return true;
@@ -1203,7 +1203,7 @@ namespace UAS_LabelMachine
                 string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
                 for (int i = (begin == 0 ? 0 : begin); i <= (end == 0 ? LabelInf.Rows.Count - 1 : end); i++)
                 {
-                    if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()))
+                    if (!MidIDAndOutboxcode.ContainsValue(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString())&& LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()!="")
                         MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
                     string outboxcode1 = LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString();
                     if (!MidOutBoxCode.Contains(int.Parse(outboxcode1 == "" ? "0" : outboxcode1)))
@@ -1358,6 +1358,7 @@ namespace UAS_LabelMachine
             }
             sql.Append("1,");
             DataTable dt = (DataTable)adh.ExecuteSql("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1), "select");
+            Console.WriteLine("select " + sql.ToString().Substring(0, sql.Length - 1) + " from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + (pib_outboxcode1 == "" ? "0" : pib_outboxcode1));
             for (int j = 0; j < MidDoc.Variables.FormVariables.Count; j++)
             {
                 DataRow[] dr1 = MidLabelParam.Select("lp_name='" + MidDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
@@ -1382,6 +1383,20 @@ namespace UAS_LabelMachine
                             {
                                 MidDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
                             }
+                            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)
+                                {
+                                    date = dtime.ToString("yyyymmdd");
+                                }
+                                MidDoc.Variables.FormVariables.Item(k + 1).Value = date;
+                            }
                         }
                     }
                 }
@@ -1452,6 +1467,20 @@ namespace UAS_LabelMachine
                                 {
                                     OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = dt1.Rows[i][0].ToString();
                                 }
+                                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)
+                                    {
+                                        date = dtime.ToString("yyyymmdd");
+                                    }
+                                    OutBoxDoc.Variables.FormVariables.Item(k + 1).Value = date;
+                                }
                             }
                         }
                     }
@@ -2250,7 +2279,7 @@ namespace UAS_LabelMachine
             string month = "0";
             string day = "0";
             LogicHandler.GetTimeFromDatecode(datecode, "", out year, out month, out day);
-            adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_ifmodify=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + " where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "update");
+            adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_ifmodify=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "' where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "update");
             LoadGridData();
             setvalue.FindForm().Close();
         }
@@ -2265,7 +2294,7 @@ namespace UAS_LabelMachine
             string month = "0";
             string day = "0";
             LogicHandler.GetTimeFromDatecode(datecode, "", out year, out month, out day);
-            adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_ifmodify=-1,pib_ifprint=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year=" + year + ",pib_month=" + month + ",pib_day=" + day + " where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "update");
+            adh.ExecuteSql("update prodiobarcode set pib_ifpick=-1,pib_ifmodify=-1,pib_ifprint=-1,pib_lotno='" + lotno + "',pib_datecode='" + datecode + "',pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "' where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "update");
             LoadGridData();
             DataTable pibid_dt = (DataTable)adh.ExecuteSql("select pib_id from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_pdno=" + pdno, "select");
             for (int i = 0; i < pibid_dt.Rows.Count; i++)
@@ -2393,7 +2422,6 @@ namespace UAS_LabelMachine
                 GetBarcode = true;
                 outboxcode2 = outboxcode2 + 1;
                 LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                Console.WriteLine("1" + OutBoxBarCode);
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
             }
             else if (CurrentRowNum - 1 > 0)
@@ -2405,7 +2433,6 @@ namespace UAS_LabelMachine
                     if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString() && !GetBarcode)
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        Console.WriteLine("2" + OutBoxBarCode);
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
@@ -2415,7 +2442,6 @@ namespace UAS_LabelMachine
                     if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() && !GetBarcode)
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        Console.WriteLine("3" + OutBoxBarCode);
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
@@ -2425,7 +2451,6 @@ namespace UAS_LabelMachine
                     if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString() && !GetBarcode)
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        Console.WriteLine("4" + OutBoxBarCode);
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
@@ -2435,7 +2460,6 @@ namespace UAS_LabelMachine
                     if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString() && !GetBarcode)
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        Console.WriteLine("5" + OutBoxBarCode);
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
@@ -2445,7 +2469,6 @@ namespace UAS_LabelMachine
                     if (TempData != "" && TempData != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString() && !GetBarcode)
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        Console.WriteLine("6" + OutBoxBarCode);
                         LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
@@ -2457,7 +2480,6 @@ namespace UAS_LabelMachine
             else
             {
                 LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                Console.WriteLine("1" + OutBoxBarCode);
                 LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
             }
             //设置中盒外箱号
@@ -2465,9 +2487,9 @@ namespace UAS_LabelMachine
             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");
+                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
-                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");
+                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();
         }
 
@@ -2480,7 +2502,8 @@ namespace UAS_LabelMachine
                 DataRow[] dr1 = SingleLabelParam.Select("lp_name='" + SingleDoc.Variables.FormVariables.Item(j + 1).Name.ToLower() + "'");
                 if (dr1.Length > 0)
                 {
-                    sql.Append(dr1[0]["lp_sql"].ToString() + ",");
+                    if (dr1[0]["lp_sql"].ToString() == "字符串")
+                        sql.Append(dr1[0]["lp_sql"].ToString() + ",");
                 }
             }
             sql.Append("1,");
@@ -2498,7 +2521,14 @@ namespace UAS_LabelMachine
                         {
                             string date = dt1.Rows[0][0].ToString();
                             System.DateTime dtime = System.DateTime.ParseExact(date, "yyyymmdd", System.Globalization.CultureInfo.CurrentCulture);
-                            date = dtime.ToString(cu_print_dateformat.Text);
+                            try
+                            {
+                                date = dtime.ToString(cu_print_dateformat.Text);
+                            }
+                            catch (Exception)
+                            {
+                                date = dtime.ToString("yyyymmdd");
+                            }
                             SingleDoc.Variables.FormVariables.Item(j + 1).Value = date;
                         }
                     }