Browse Source

自动翻页程序和复核不通过提示

章政 7 years ago
parent
commit
b539be2ae3

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

@@ -617,7 +617,7 @@
             // 
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label3.Location = new System.Drawing.Point(5, 607);
+            this.label3.Location = new System.Drawing.Point(5, 609);
             this.label3.Name = "label3";
             this.label3.Size = new System.Drawing.Size(74, 21);
             this.label3.TabIndex = 29;

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

@@ -267,7 +267,7 @@ namespace UAS_LabelMachine
                             //勾选了中盒自动打印
                             if (MidLabelAutoPrint.Checked)
                                 AutoPrintMidLabel();
-                            LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifpick"] = true;
+                            LabelInf.Rows[CurrentRowIndex].Cells["pib_ifpick"].Value = true;
                             LogicHandler.SendDataToPLC(PLC1, PLCInstruct.FrontDataPass);
                             LabelInf.Refresh();
                         }
@@ -352,19 +352,20 @@ namespace UAS_LabelMachine
                             case "PN":
                                 PN = arr[ItemIndex[j]];
                                 //自动匹配客户PN
-                                DataTable pndt = BaseUtil.filterDataTable(LabelInfDataTable, "pr_orispeccode='" + PN + "' and pib_ifpick=0 ");
+                                DataTable pndt = BaseUtil.filterDataTable(ShowDt, "pr_orispeccode='" + PN + "' and pib_ifpick=0 ");
                                 int rownum = 0;
                                 if (pndt.Rows.Count > 0)
                                 {
                                     rownum = int.Parse(pndt.Rows[0]["rownum"].ToString());
                                     //如果需要翻页的话
-                                    if (rownum > PageSize)
+                                    if (!(rownum >= (PageSize * (CurrentPage - 1) + 1) && rownum <= PageSize * CurrentPage))
                                     {
                                         CurrentPage = rownum / PageSize + 1;
                                         LoadGridData();
                                         CurrentRowIndex = rownum % PageSize - 1;
+                                        if (CurrentRowIndex - 10 > 0)
+                                            LabelInf.FirstDisplayedScrollingRowIndex = CurrentRowIndex - 10;
                                     }
-                                    CurrentRowIndex = rownum - 1;
                                 }
                                 else
                                 {
@@ -373,7 +374,7 @@ namespace UAS_LabelMachine
                                 break;
                             case "Order":
                                 Order = arr[ItemIndex[j]];
-                                if (LabelInfDataTable.Rows[CurrentRowIndex]["pd_pocode"].ToString() != Order)
+                                if (LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() != Order)
                                 {
                                     ErrorMsg = "订单号不匹配";
                                 }
@@ -397,16 +398,16 @@ namespace UAS_LabelMachine
                         }
                         index = index + 1;
                     }
-                    if (ErrorMsg == "" && ItemStr.Contains("QTY") && LabelInfDataTable.Rows[CurrentRowIndex]["pib_qty"].ToString() != QTY.ToString())
+                    if (ErrorMsg == "" && ItemStr.Contains("QTY") && LabelInf.Rows[CurrentRowIndex].Cells["pib_qty"].Value.ToString() != QTY.ToString())
                     {
                         ErrorMsg = "数量不匹配";
                     }
-                    if (ErrorMsg == "" && ItemStr.Contains("PO") && LabelInfDataTable.Rows[CurrentRowIndex]["pd_pocode"].ToString() != Order)
+                    if (ErrorMsg == "" && ItemStr.Contains("PO") && LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString() != Order)
                     {
                         ErrorMsg = "订单号不匹配";
                     }
                     //如果品牌不对应的话则不能使用本次的匹配规则
-                    if (LabelInfDataTable.Rows[CurrentRowIndex]["pib_brand"].ToString() != sg_brand)
+                    if (LabelInf.Rows[CurrentRowIndex].Cells["pib_brand"].Value.ToString() != sg_brand)
                     {
                         break;
                     }
@@ -426,8 +427,8 @@ namespace UAS_LabelMachine
             }
             else
             {
-                LabelInfDataTable.Rows[CurrentRowIndex]["pib_datecode"] = DateCode;
-                LabelInfDataTable.Rows[CurrentRowIndex]["pib_lotno"] = LotNo;
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value = DateCode;
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value = LotNo;
                 return true;
             }
         }
@@ -444,15 +445,22 @@ namespace UAS_LabelMachine
             string[] msgArr = msg.Split(back_sg_separator.Text.ToCharArray());
             //需要校验2项数据,完成校验后此项的值需要为2则表示校验成功
             int checkItemCount = 0;
+            List<string> CheckItem = new List<string>();
             for (int i = 0; i < msgArr.Length; i++)
             {
                 if (RecheckCuprodcode.Checked)
                 {
+                    if (!CheckItem.Contains("客户料号") && !CheckItem.Contains("原厂型号"))
+                    {
+                        CheckItem.Add("客户料号");
+                        CheckItem.Add("原厂型号");
+                    }
                     //直接验证两个值相等
                     if (Equal.Checked)
                     {
                         if (msgArr[i] == LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString())
                         {
+                            CheckItem.Remove("客户料号");
                             checkItemCount = checkItemCount + 1;
                         }
                     }
@@ -462,22 +470,31 @@ namespace UAS_LabelMachine
                         Regex re = new Regex(cu_print_regexpression.Text);
                         if (re.Match(msgArr[i]).Value == LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString())
                         {
+                            CheckItem.Remove("客户料号");
                             checkItemCount = checkItemCount + 1;
                         }
                     }
                     if (msgArr[i] == LabelInf.Rows[CurrentRowIndex].Cells["pr_orispeccode"].Value.ToString())
                     {
+                        CheckItem.Remove("原厂型号");
                         checkItemCount = checkItemCount + 1;
                     }
                 }
                 else if (RecheckBarcode.Checked)
                 {
+                    if (!CheckItem.Contains("唯一条码") && !CheckItem.Contains("原厂型号"))
+                    {
+                        CheckItem.Add("唯一条码");
+                        CheckItem.Add("原厂型号");
+                    }
                     if (msgArr[i] == LabelInf.Rows[CurrentRowIndex].Cells["pib_custbarcode"].Value.ToString())
                     {
+                        CheckItem.Remove("唯一条码");
                         checkItemCount = checkItemCount + 1;
                     }
                     if (msgArr[i] == LabelInf.Rows[CurrentRowIndex].Cells["pr_orispeccode"].Value.ToString())
                     {
+                        CheckItem.Remove("原厂型号");
                         checkItemCount = checkItemCount + 1;
                     }
                 }
@@ -487,7 +504,7 @@ namespace UAS_LabelMachine
                 MessageBox.Show("复核不通过");
                 return false;
             }
-            LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifrecheck"] = true;
+            LabelInf.Rows[CurrentRowIndex].Cells["pib_ifrecheck"].Value = true;
             adh.ExecuteSql("update prodiobarcode set pib_ifrecheck=-1 where pib_id=" + pib_id, "update");
             LabelInf.Refresh();
             //获取当前最大的箱号
@@ -497,11 +514,12 @@ namespace UAS_LabelMachine
             int outboxcode2 = int.Parse(boxcode == "" ? "1" : boxcode);
             string pd_id = LabelInf.Rows[CurrentRowIndex].Cells["pd_id"].Value.ToString();
             //超过中盒容量中盒号+1
-            if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + outboxcode1) >= MidBoxCapacity.Value)
+            if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode1=" + outboxcode1) > MidBoxCapacity.Value)
             {
                 outboxcode1 = outboxcode1 + 1;
+                LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
             }
-            else if (CurrentRowIndex - 1 >= 0)
+            if (CurrentRowIndex - 1 >= 0)
             {
                 //或者不符合合并条件中盒号+1
                 if (cu_print_midlotno.Checked)
@@ -509,7 +527,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_lotno"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custmidboxcode"] = MidBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
@@ -518,7 +536,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pd_pocode"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custmidboxcode"] = MidBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
@@ -527,7 +545,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pr_orispeccode"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custmidboxcode"] = MidBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
@@ -536,7 +554,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pd_custprodspec"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custmidboxcode"] = MidBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
@@ -545,7 +563,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_datecode"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custmidboxcode"] = MidBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
                         outboxcode1 = outboxcode1 + 1;
                     }
                 }
@@ -553,13 +571,13 @@ namespace UAS_LabelMachine
                 {
                     LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
                 }
-                LabelInfDataTable.Rows[CurrentRowIndex]["pib_custmidboxcode"] = MidBoxBarCode;
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_custmidboxcode"].Value = MidBoxBarCode;
             }
             if (adh.getRowCount("prodiobarcode", "pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2=" + outboxcode2) >= OutBoxCapacity.Value)
             {
                 outboxcode2 = outboxcode2 + 1;
                 LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                LabelInfDataTable.Rows[CurrentRowIndex]["pib_custoutboxcode"] = OutBoxBarCode;
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
             }
             else if (CurrentRowIndex - 1 >= 0)
             {
@@ -569,7 +587,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_lotno"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custoutboxcode"] = OutBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
                 else if (cu_print_outpo.Checked)
@@ -577,7 +595,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pd_pocode"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_pocode"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custoutboxcode"] = OutBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
                 else if (cu_print_outprod.Checked)
@@ -585,7 +603,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pr_orispeccode"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodcode"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custoutboxcode"] = OutBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
                 else if (cu_print_outspec.Checked)
@@ -593,7 +611,7 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pd_custprodspec"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pd_custprodspec"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custoutboxcode"] = OutBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
                 else if (cu_print_outdc.Checked)
@@ -601,17 +619,17 @@ namespace UAS_LabelMachine
                     if (LabelInf.Rows[CurrentRowIndex - 1].Cells["pib_datecode"].Value.ToString() != LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString())
                     {
                         LogicHandler.GetBarCode(PI_ID, pd_id, 1, out MidBoxBarCode);
-                        LabelInfDataTable.Rows[CurrentRowIndex]["pib_custoutboxcode"] = OutBoxBarCode;
+                        LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
                     }
                 }
                 if (OutBoxBarCode == "")
                 {
                     LogicHandler.GetBarCode(PI_ID, pd_id, 1, out OutBoxBarCode);
                 }
-                LabelInfDataTable.Rows[CurrentRowIndex]["pib_custoutboxcode"] = OutBoxBarCode;
+                LabelInf.Rows[CurrentRowIndex].Cells["pib_custoutboxcode"].Value = OutBoxBarCode;
             }
-            LabelInfDataTable.Rows[CurrentRowIndex]["pib_outboxcode1"] = outboxcode1;
-            LabelInfDataTable.Rows[CurrentRowIndex]["pib_outboxcode2"] = outboxcode2;
+            LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode1"].Value = outboxcode1;
+            LabelInf.Rows[CurrentRowIndex].Cells["pib_outboxcode2"].Value = outboxcode2;
             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 where pib_id=" + pib_id, "update");
             LabelInf.Refresh();
             if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
@@ -701,7 +719,7 @@ namespace UAS_LabelMachine
             SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
             SingleDoc.PrintDocument();
             LogicHandler.UpdateRowPrinted(pib_id);
-            LabelInfDataTable.Rows[CurrentRowIndex]["pib_ifprint"] = true;
+            LabelInf.Rows[CurrentRowIndex].Cells["pib_ifprint"].Value = true;
         }
 
         //关闭窗口前提示用户确认
@@ -880,7 +898,7 @@ namespace UAS_LabelMachine
                     BackCombo.DataSource = dt1;
                     BackCombo.DisplayMember = "sg_brand";
                     BackCombo.ValueMember = "sg_brand";
-                    LoadGridData(sender, e);
+                    LoadGridData();
                     //重新输入单号后清除缓存
                     MidBoxArgument.Clear();
                     SingleBoxArgument.Clear();
@@ -1020,7 +1038,7 @@ namespace UAS_LabelMachine
                                 }
                             }
                             //勾选为已打印
-                            LabelInfDataTable.Rows[i]["pib_ifprint"] = true;
+                            LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
                         }
                         catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }
@@ -1053,8 +1071,8 @@ namespace UAS_LabelMachine
                         {
                             for (int i = begin - 1; i < end; i++)
                             {
-                                LabelInfDataTable.Rows[i]["pib_ifpick"] = true;
-                                LabelInfDataTable.Rows[i]["pib_ifprint"] = false;
+                                LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
+                                LabelInf.Rows[i].Cells["pib_ifprint"].Value = false;
                             }
                         }
                         else
@@ -1376,7 +1394,7 @@ namespace UAS_LabelMachine
         int PageSize = 500;
         int DataSize = 0;
         int MaxPageSize = 0;
-        DataTable LabelInfDataTable;
+        DataTable ShowDt;
         /// <summary>
         /// 自定义函数  加载明细行的数据,多处使用添加进函数
         /// </summary>
@@ -1392,7 +1410,8 @@ namespace UAS_LabelMachine
                 sql.Append(" and pib_pdno between " + DetailRange1.Value + " and " + DetailRange2.Value);
             }
             sql.Append(" order by rownum");
-            LabelInfDataTable = (DataTable)adh.ExecuteSql(sql.ToString(), "select");
+            DataTable LabelInfDataTable = (DataTable)adh.ExecuteSql(sql.ToString(), "select");
+            ShowDt = (DataTable)adh.ExecuteSql("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by rownum", "select");
             if (LabelInfDataTable.Rows.Count == 0)
             {
                 //嵌套查询重置RowNum
@@ -1416,6 +1435,9 @@ namespace UAS_LabelMachine
                     LabelInfDataTable = BaseUtil.filterDataTable(LabelInfDataTable, "rownum <=" + PageSize + " and pib_pdno >= " + DetailRange1.Value + " and pib_pdno<=" + DetailRange2.Value);
                 }
             }
+            LabelInf.DataSource = null;
+            BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
+
             //获取数据总条数
             if (!DetailRange.Checked)
             {
@@ -1428,7 +1450,6 @@ namespace UAS_LabelMachine
             PageNum.Text = "总数" + DataSize;
             MaxPageSize = DataSize % PageSize == 0 ? DataSize / PageSize : (DataSize / PageSize) + 1;
             PageInf.Text = CurrentPage + "/" + MaxPageSize;
-            BaseUtil.FillDgvWithDataTable(LabelInf, LabelInfDataTable);
             //获取系统设置的上传数量,如参数异常则默认为100
             dt = (DataTable)adh.ExecuteSql("select uploadnum,splitback,splitfront from dataextra", "select");
             if (dt.Rows.Count > 0)
@@ -1648,7 +1669,7 @@ namespace UAS_LabelMachine
             if (result == DialogResult.OK)
             {
                 ExcelHandler eh = new ExcelHandler();
-                DataTable dt = LabelInfDataTable;
+                DataTable dt = ShowDt;
                 for (int i = dt.Columns.Count - 1; i >= 0; i--)
                 {
                     for (int j = 0; j < LabelInf.Columns.Count; j++)

+ 0 - 3
UAS-出货标签管理(吉利通)/UAS_出货标签管理.resx

@@ -180,9 +180,6 @@
   <metadata name="PLC1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     <value>677, 18</value>
   </metadata>
-  <metadata name="AllData.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
-    <value>758, 18</value>
-  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>