ソースを参照

Merge branch 'master' of ssh://10.10.100.21/source/mes-client

Hcsy 8 年 前
親
コミット
aead3363d1

+ 79 - 5
UAS-MES/FunctionCode/Make/Make_CollectBTMAC.cs

@@ -78,6 +78,50 @@ namespace UAS_MES.Make
             sncode.Focus();
         }
 
+
+        /// <summary>
+        /// 检验长度或者前缀是否合法
+        /// </summary>
+        /// <param name="checkbox"></param>
+        /// <param name="c"></param>
+        /// <param name="info"></param>
+        private bool checkLengthOrPre(int psr_length, string psr_prefix, string TSNorSN)
+        {
+            if (sncode.Text.Trim().Length > 40)
+            {
+                sncode.Text = sncode.Text.Trim().Substring(0, 40);
+            }
+            //则判断输入转换前的序列号长度是否合法,不合法则提示
+            if (sncode.Text.Trim().Length != psr_length && psr_length!=0)
+            {
+                //序列号校验错误,长度错误
+                OperateResult.AppendText("<<" + TSNorSN + ":" + sncode.Text + "校验错误,长度错误\n", Color.Red, sncode);
+                OperateResult.AppendText(">>请重新输入" + TSNorSN + "\n", Color.Black);
+                return false;
+            }
+            string[] pres = psr_prefix.Split('|');
+            bool f = false;
+            for (int i = 0; i < pres.Length; i++)
+            {
+                if (pres[i] == "" ? true : sncode.Text.StartsWith(pres[i]))
+                {
+                    //满足其中一条即可
+                    f = true;
+                    break;
+                }
+            }
+            //则判断输入转换前的序列号前缀是否合法,不合法则提示
+            if (!f)
+            {
+                //序列号校验错误,前缀错误
+                OperateResult.AppendText("<<" + TSNorSN + ":" + sncode.Text + "校验错误,前缀错误\n", Color.Red, sncode);
+                OperateResult.AppendText(">>请重新输入" + TSNorSN + "\n", Color.Black);
+                return false;
+            }
+            return true;
+        }
+
+
         private void sncode_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)
@@ -100,6 +144,12 @@ namespace UAS_MES.Make
                             // 获取工单归属工单下一工序是否正确
                             if (LogicHandler.CheckStepSNAndMacode("", User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage2))
                             {
+                                string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsID + "'").ToString();
+                                if (nextstepcode != User.CurrentStepCode)
+                                {
+                                    OperateResult.AppendText("<<序列号:" + sncode.Text + "下一工序是" + nextstepcode + ",不是当前岗位的工序\n", Color.Red, sncode);
+                                    return;
+                                }
                                 sql.Clear();
                                 sql.Append("select ma_code as ms_makecode,nvl(mcd_okqty,0),ma_prodcode,pr_detail,");
                                 sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty,nvl(ma_unlimitin,0) ma_unlimitin from make left join makecraftdetail on ");
@@ -109,7 +159,7 @@ namespace UAS_MES.Make
                                 {
                                     ma_unlimitin = int.Parse(dt.Rows[0]["ma_unlimitin"].ToString());
                                     BaseUtil.SetFormValue(this.Controls, dt);
-                                    dh.UpdateByCondition("makeserial", "ms_currentstepcode = '" + User.CurrentStepCode + "'", "ms_id = '" + oMsID + "'");
+                                    //dh.UpdateByCondition("makeserial", "ms_currentstepcode = '" + User.CurrentStepCode + "'", "ms_id = '" + oMsID + "'");
                                     OperateResult.AppendText(">>请输入BT\n", Color.Black);
                                     sn_code = sncode.Text;
                                     sncode.Text = "";
@@ -143,6 +193,19 @@ namespace UAS_MES.Make
                         string ErrorMessage = "";
                         string result = "";
                         sql.Clear();
+                        sql.Append("select psr_prefix,psr_length from productsnrelation where psr_prodcode = '" + ma_prodcode.Text + "' and psr_type = 'BT'");
+                        dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                        if (dt.Rows.Count > 0)
+                        {
+                            int psr_length = int.Parse(dt.Rows[0][1].ToString());
+                            string psr_prefix = dt.Rows[0][0].ToString();
+                            if (!checkLengthOrPre(psr_length, psr_prefix, "BT"))
+                            {
+                                sncode.Text = "";
+                                sncode.Focus();
+                                return;
+                            }
+                        }
                         string checkbt = sncode.Text.Replace(":", "").Replace("-", "");
                         if (dh.CheckExist("MakeAddressList", "mal_makecode = '" + ms_makecode.Text + "'"))
                         {
@@ -218,6 +281,19 @@ namespace UAS_MES.Make
                     string ErrorMessage = "";
                     string result = "";
                     sql.Clear();
+                    sql.Append("select psr_prefix,psr_length from productsnrelation where psr_prodcode = '" + ma_prodcode.Text + "' and psr_type = 'MAC'");
+                    dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                    if (dt.Rows.Count > 0)
+                    {
+                        int psr_length = int.Parse(dt.Rows[0][1].ToString());
+                        string psr_prefix = dt.Rows[0][0].ToString();
+                        if (!checkLengthOrPre(psr_length, psr_prefix, "MAC"))
+                        {
+                            sncode.Text = "";
+                            sncode.Focus();
+                            return;
+                        }
+                    }
                     string checkmac = sncode.Text.Replace(":", "").Replace("-", "");
                     if (dh.CheckExist("MakeAddressList", "mal_makecode = '" + ms_makecode.Text + "'"))
                     {
@@ -250,15 +326,13 @@ namespace UAS_MES.Make
                             return;
                         }
                     }
-                    ////根据序列号获取此时网标号
-                    //ms_mac = dh.getFieldDataByCondition("makeserial", "ms_mac", "ms_id = '" + oMsID + "'").ToString();
                     if (int.Parse(mcd_remainqty.Text) <= 0 && ma_unlimitin == 0)
                     {
                         ErrorMessage = "工单" + ms_makecode.Text + "剩余采集数不足\n>>>请输入SN";
                         OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
                         return;
                     }
-                    if (dh.CheckExist("sninfo", "si_bt = '" + checkmac + "'"))
+                    if (dh.CheckExist("sninfo", "si_mac = '" + checkmac + "'"))
                     {
                         OperateResult.AppendText(">>录入错误,此MAC:" + checkmac + "已被" + dh.getFieldDataByCondition("sninfo", "si_sn", "si_mac = '" + checkmac + "'").ToString() + "使用\n", Color.Red, sncode);
                         OperateResult.AppendText(">>请输入MAC\n", Color.Black);
@@ -277,7 +351,7 @@ namespace UAS_MES.Make
                             //提示正确返回时传递的信息
                             if (ErrorMessage.Contains("AFTERSUCCESS"))
                                 OperateResult.AppendText(">>" + ErrorMessage + "\n");
-                            string si_id = dh.getFieldDataByCondition("sninfo", "max(si_id) si_id", " si_sn='"+ sn_code + "' or si_sn in(select sn from makesnrelation where sn='"+ sn_code + "'  or beforesn = '" + sn_code + "')").ToString();
+                            string si_id = dh.getFieldDataByCondition("sninfo", "max(si_id) si_id", " si_sn in (select '"+ sn_code + "' from dual union select sn from makesnrelation where beforesn = '" + sn_code + "' and sn <> ' '  union select beforesn from makesnrelation where sn = '" + sn_code + "' and beforesn <> ' ') ").ToString();
                             if (si_id != "")
                             {
                                 dh.BatchInsert("update  sninfo set si_mac = :mac,si_bt =:bt,si_indate = sysdate where si_id = :osiId", new String[] { "mac", "bt", "osiId" }, new string[] { checkmac }, new string[] { ms_bt }, new string[] { si_id });

+ 80 - 15
UAS-MES/FunctionCode/Make/Make_CollectNetCode.cs

@@ -79,6 +79,12 @@ namespace UAS_MES.Make
                         // 获取工单归属工单下一工序是否正确
                         if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text == "" ? oMakeCode : ms_makecode.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage2))
                         {
+                            string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsID + "'").ToString();
+                            if (nextstepcode != User.CurrentStepCode)
+                            {
+                                OperateResult.AppendText("<<序列号:" + sncode.Text + "下一工序是" + nextstepcode + ",不是当前岗位的工序\n", Color.Red, sncode);
+                                return;
+                            }
                             sql.Clear();
                             sql.Append("select ma_code as ms_makecode,nvl(mcd_okqty,0),ma_prodcode,pr_detail,");
                             sql.Append("pr_spec,ma_qty - nvl(mcd_inqty, 0) mcd_remainqty,nvl(ma_unlimitin,0) ma_unlimitin from make left join makecraftdetail on ");
@@ -88,7 +94,7 @@ namespace UAS_MES.Make
                             {
                                 ma_unlimitin = int.Parse(dt.Rows[0]["ma_unlimitin"].ToString());
                                 BaseUtil.SetFormValue(this.Controls, dt);
-                                dh.UpdateByCondition("makeserial", "ms_currentstepcode = '" + User.CurrentStepCode + "'", "ms_id = '" + oMsID + "'");
+                                //dh.UpdateByCondition("makeserial", "ms_currentstepcode = '" + User.CurrentStepCode + "'", "ms_id = '" + oMsID + "'");
                                 OperateResult.AppendText(">>请输入网标\n", Color.Black);
                                 sn_code = sncode.Text;
                                 sncode.Text = "";
@@ -110,19 +116,23 @@ namespace UAS_MES.Make
                         return;
                     }
                     #region
-                    //sql.Clear();
-                    //sql.Append("select psr_prefix,psr_length from productsnrelation where psr_prodcode = '" + ma_prodcode.Text + "' and psr_type = 'NETCODE'");
-                    //dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-                    //if (dt.Rows.Count > 0) {
-                    //    int psr_length = int.Parse(dt.Rows[0][1].ToString());
-                    //    string psr_prefix = dt.Rows[0][0].ToString();
-                    //    if (sncode.Text.Length != psr_length || sncode.Text.Substring(0,psr_prefix.Length).ToString() != psr_prefix) {
-                    //        sncode.Text = "";
-                    //        sncode.Focus();
-                    //        OperateResult.AppendText("<<所输入网标不符合定义要求\n", Color.Red);
-                    //        return;
-                    //    } 
-                    //}
+                    sql.Clear();
+                    sql.Append("select psr_prefix,psr_length from productsnrelation where psr_prodcode = '" + ma_prodcode.Text + "' and psr_type = 'NETCODE'");
+                    dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                    if (dt.Rows.Count > 0)
+                    {
+                        int psr_length = int.Parse(dt.Rows[0][1].ToString());
+                        string psr_prefix = dt.Rows[0][0].ToString();
+                        if (!checkLengthOrPre(psr_length, psr_prefix, "网标"))
+                        {
+                            sncode.Text = "";
+                            sncode.Focus();
+                            return;
+                        }
+                    }
+                    else {
+                        OperateResult.AppendText("<<产品" + ma_prodcode.Text + "未维护网标关联信息\n", Color.Red,sncode);
+                    }
                     #endregion
                     OperateResult.AppendText("<<" + sncode.Text + "\n", Color.Black);
                     string ErrorMessage = "";
@@ -135,9 +145,16 @@ namespace UAS_MES.Make
                         OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
                         return;
                     }
+
+                    if (dh.CheckExist("sninfo", "si_netcode = '" + sncode.Text + "'"))
+                    {
+                        OperateResult.AppendText(">>录入错误,此网标:" + sncode.Text + "已被" + dh.getFieldDataByCondition("sninfo", "si_sn", "si_netcode = '" + sncode.Text + "'").ToString() + "使用\n", Color.Red, sncode);
+                        OperateResult.AppendText(">>请输入网标\n", Color.Black);
+                        return;
+                    }
                     if (dh.CheckExist("makeserial", "ms_netcode = '" + sncode.Text + "'"))
                     {
-                        OperateResult.AppendText(">>录入错误,已存在此网标"+ sncode.Text + "\n", Color.Red, sncode);
+                        OperateResult.AppendText(">>录入错误,此网标:" + sncode.Text + "已被" + dh.getFieldDataByCondition("makeserial", "ms_sncode", "ms_netcode = '" + sncode.Text + "'").ToString() + "使用\n", Color.Red, sncode);
                         OperateResult.AppendText(">>请输入网标\n", Color.Black);
                         return;
                     }
@@ -149,6 +166,15 @@ namespace UAS_MES.Make
                             if (ErrorMessage.Contains("AFTERSUCCESS"))
                                 OperateResult.AppendText(">>" + ErrorMessage + "\n");
                             //dh.UpdateByCondition("makeserial", "ms_netcode = '" + sncode.Text + "'", "ms_id = '" + oMsID + "'");
+                            string si_id = dh.getFieldDataByCondition("sninfo", "max(si_id) si_id", " si_sn in (select '" + sn_code + "' from dual union select sn from makesnrelation where beforesn = '" + sn_code + "' and sn <> ' '  union select beforesn from makesnrelation where sn = '" + sn_code + "' and beforesn <> ' ') ").ToString();
+                            if (si_id != "")
+                            {
+                                dh.BatchInsert("update  sninfo set si_netcode = :netcode,si_indate = sysdate where si_id = :osiId", new String[] { "netcode",  "osiId" }, new string[] { sncode.Text },new string[] { si_id });
+                            }
+                            else
+                            {
+                                dh.BatchInsert("insert into sninfo (si_id,si_sn,si_netcode,si_indate) values (SnInfo_seq.nextval,:si_sn,:netcode,sysdate)", new String[] { "si_sn", "netcode"}, new string[] { sn_code }, new string[] { sncode.Text });
+                            }
                             dh.BatchInsert("update  makeserial set ms_netcode = :netcode where ms_id = :oMsId", new String[] { "netcode", "oMsId" }, new string[] { sncode.Text }, new string[] { oMsID.ToString() });
                             OperateResult.AppendText(">>网标采集完成,执行更新\n", Color.Green);
                             LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode.Text, User.UserLineCode, User.UserSourceCode, "网标采集", "采集成功", sn_code, "");
@@ -183,6 +209,45 @@ namespace UAS_MES.Make
             sncode.Focus();
         }
 
+
+        /// <summary>
+        /// 检验长度或者前缀是否合法
+        /// </summary>
+        /// <param name="checkbox"></param>
+        /// <param name="c"></param>
+        /// <param name="info"></param>
+        private bool checkLengthOrPre(int psr_length, string psr_prefix, string TSNorSN)
+        {
+            //则判断输入转换前的序列号长度是否合法,不合法则提示
+            if (sncode.Text.Trim().Length != psr_length && psr_length != 0)
+            {
+                //序列号校验错误,长度错误
+                OperateResult.AppendText("<<" + TSNorSN + ":" + sncode.Text + "校验错误,长度错误\n", Color.Red, sncode);
+                OperateResult.AppendText(">>请重新输入" + TSNorSN + "\n", Color.Black);
+                return false;
+            }
+            string[] pres = psr_prefix.Split('|');
+            bool f = false;
+            for (int i = 0; i < pres.Length; i++)
+            {
+                if (pres[i] == "" ? true : sncode.Text.StartsWith(pres[i]))
+                {
+                    //满足其中一条即可
+                    f = true;
+                    break;
+                }
+            }
+            //则判断输入转换前的序列号前缀是否合法,不合法则提示
+            if (!f)
+            {
+                //序列号校验错误,前缀错误
+                OperateResult.AppendText("<<" + TSNorSN + ":" + sncode.Text + "校验错误,前缀错误\n", Color.Red, sncode);
+                OperateResult.AppendText(">>请重新输入" + TSNorSN + "\n", Color.Black);
+                return false;
+            }
+            return true;
+        }
+
         private void deleteButton1_Click(object sender, EventArgs e)
         {
             if (isnetcode)

+ 6 - 0
UAS-MES/FunctionCode/Make/Make_ColorBoxWeigh.cs

@@ -115,6 +115,12 @@ namespace UAS_MES.Make
                         string oMsID = "";
                         if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text, User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
                         {
+                            string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_id='" + oMsID + "'").ToString();
+                            if (nextstepcode != User.CurrentStepCode)
+                            {
+                                OperateResult.AppendText("<<序列号:" + sncode.Text + "下一工序是" + nextstepcode + ",不是当前岗位的工序\n", Color.Red, sncode);
+                                return;
+                            }
                             //如果未打开串口设置为0
                             //if (pr_colorboxunit.Text == "kg" && !WeightChange)
                             //{

+ 3 - 2
UAS-MES/FunctionCode/Make/Make_Decompose.cs

@@ -282,7 +282,7 @@ namespace UAS_MES.Make
                                 else if(sp_tracekind == "2")
                                 {
                                     if (!dh.CheckExist("makesourcestock", " (MSS_FPRODCODE = '" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value.ToString() + "' or MSS_PRODCODE = '" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value.ToString() + "') and mss_barcode = '" + LabelDataGridView.Rows[i].Cells["New_BarCode"].Value.ToString() + "'"))
-                                    {
+                                    {   
                                         OperateResult.AppendText(">>物料" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value.ToString() + "岗位备料无条码" + LabelDataGridView.Rows[i].Cells["New_BarCode"].Value.ToString() + "\n", Color.Red);
                                         continue;
                                     }
@@ -306,10 +306,11 @@ namespace UAS_MES.Make
                                 }
                             }
                             else
-                            {
+                            {                        
                                 //当前备料信息不再工序BOM中,为BOM之外的批管控物料备料
                                 if (!dh.CheckExist("makesourcestock", " (MSS_FPRODCODE = '" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value.ToString() + "' or MSS_PRODCODE = '" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value.ToString() + "') and mss_barcode = '" + LabelDataGridView.Rows[i].Cells["New_BarCode"].Value.ToString() + "'"))
                                 {
+                                    OperateResult.AppendText(">>物料" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value.ToString() + "不在当前工序BOM" + ma_bomversion + "中\n", Color.Black);
                                     OperateResult.AppendText(">>物料" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value.ToString() + "岗位备料无条码" + LabelDataGridView.Rows[i].Cells["New_BarCode"].Value.ToString() + "\n", Color.Red);
                                     continue;
                                 }

+ 2 - 2
UAS-MES/FunctionCode/Make/Make_UpdateCollectCode.cs

@@ -101,7 +101,7 @@ namespace UAS_MES.Make
                         return;
                     }
                     //判断TSN或者SN是否存在
-                    ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode ='" + inputValue.Text + "' or exists (select 1 from  makesnrelation where beforesn='" + inputValue.Text + "'  and ms_makecode=makecode)").ToString();
+                    ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode ='" + inputValue.Text + "'").ToString();
                     sncode = inputValue.Text;
                     if (ms_id == "")
                     {
@@ -302,7 +302,7 @@ namespace UAS_MES.Make
         private void insert2Sninfo(string sn)
         {
             //查询是否有记录
-            string siid = dh.getFieldDataByCondition("sninfo", "max(si_id) si_id", "si_sn='"+sn+"' or si_sn in(select sn from makesnrelation where sn='"+sn+"' or beforesn = '"+sn+"' )").ToString();
+            string siid = dh.getFieldDataByCondition("sninfo", "max(si_id) si_id", "si_sn='"+sn+"'").ToString();
             //是否为空
             if (siid == "")
             {

+ 15 - 15
UAS-出货标签管理/UAS_出货标签管理.Designer.cs

@@ -763,7 +763,7 @@
             // 
             this.label18.AutoSize = true;
             this.label18.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label18.Location = new System.Drawing.Point(66, 146);
+            this.label18.Location = new System.Drawing.Point(69, 150);
             this.label18.Name = "label18";
             this.label18.Size = new System.Drawing.Size(13, 17);
             this.label18.TabIndex = 90;
@@ -797,7 +797,7 @@
             // 
             this.label16.AutoSize = true;
             this.label16.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label16.Location = new System.Drawing.Point(65, 73);
+            this.label16.Location = new System.Drawing.Point(68, 76);
             this.label16.Name = "label16";
             this.label16.Size = new System.Drawing.Size(13, 17);
             this.label16.TabIndex = 87;
@@ -1328,7 +1328,7 @@
             // 
             this.SingleLabelAutoPrint.AutoSize = true;
             this.SingleLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(2, 105);
+            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(9, 110);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.SingleLabelAutoPrint.Name = "SingleLabelAutoPrint";
             this.SingleLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1373,7 +1373,7 @@
             // 
             this.MidLabelNum.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.MidLabelNum.ID = null;
-            this.MidLabelNum.Location = new System.Drawing.Point(51, 160);
+            this.MidLabelNum.Location = new System.Drawing.Point(51, 165);
             this.MidLabelNum.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidLabelNum.Name = "MidLabelNum";
             this.MidLabelNum.Size = new System.Drawing.Size(64, 23);
@@ -1386,7 +1386,7 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(7, 157);
+            this.label5.Location = new System.Drawing.Point(7, 167);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(32, 17);
             this.label5.TabIndex = 50;
@@ -1396,7 +1396,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(7, 129);
+            this.label4.Location = new System.Drawing.Point(7, 138);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(32, 17);
             this.label4.TabIndex = 49;
@@ -1415,7 +1415,7 @@
             // 
             this.label15.AutoSize = true;
             this.label15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label15.Location = new System.Drawing.Point(90, 128);
+            this.label15.Location = new System.Drawing.Point(94, 137);
             this.label15.Name = "label15";
             this.label15.Size = new System.Drawing.Size(20, 17);
             this.label15.TabIndex = 40;
@@ -1424,7 +1424,7 @@
             // MidBoxCapacity
             // 
             this.MidBoxCapacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidBoxCapacity.Location = new System.Drawing.Point(52, 130);
+            this.MidBoxCapacity.Location = new System.Drawing.Point(52, 135);
             this.MidBoxCapacity.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidBoxCapacity.Name = "MidBoxCapacity";
             this.MidBoxCapacity.Size = new System.Drawing.Size(38, 23);
@@ -1446,7 +1446,7 @@
             // 
             this.MidLabelAutoPrint.AutoSize = true;
             this.MidLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidLabelAutoPrint.Location = new System.Drawing.Point(10, 105);
+            this.MidLabelAutoPrint.Location = new System.Drawing.Point(10, 108);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.MidLabelAutoPrint.Name = "MidLabelAutoPrint";
             this.MidLabelAutoPrint.Size = new System.Drawing.Size(75, 21);
@@ -1496,7 +1496,7 @@
             // LogingOut
             // 
             this.LogingOut.AutoSize = true;
-            this.LogingOut.Location = new System.Drawing.Point(114, 3);
+            this.LogingOut.Location = new System.Drawing.Point(114, 16);
             this.LogingOut.Name = "LogingOut";
             this.LogingOut.Size = new System.Drawing.Size(42, 21);
             this.LogingOut.TabIndex = 77;
@@ -1533,7 +1533,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(8, 181);
+            this.label10.Location = new System.Drawing.Point(8, 182);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(32, 17);
             this.label10.TabIndex = 90;
@@ -1556,7 +1556,7 @@
             // 
             this.label9.AutoSize = true;
             this.label9.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label9.Location = new System.Drawing.Point(83, 205);
+            this.label9.Location = new System.Drawing.Point(88, 212);
             this.label9.Name = "label9";
             this.label9.Size = new System.Drawing.Size(32, 17);
             this.label9.TabIndex = 88;
@@ -1579,7 +1579,7 @@
             // 
             this.label8.AutoSize = true;
             this.label8.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label8.Location = new System.Drawing.Point(8, 210);
+            this.label8.Location = new System.Drawing.Point(8, 212);
             this.label8.Name = "label8";
             this.label8.Size = new System.Drawing.Size(32, 17);
             this.label8.TabIndex = 83;
@@ -1589,7 +1589,7 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(8, 149);
+            this.label6.Location = new System.Drawing.Point(8, 151);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(32, 17);
             this.label6.TabIndex = 87;
@@ -1646,7 +1646,7 @@
             // 
             this.OutBoxLabelAutoPrint.AutoSize = true;
             this.OutBoxLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OutBoxLabelAutoPrint.Location = new System.Drawing.Point(4, 105);
+            this.OutBoxLabelAutoPrint.Location = new System.Drawing.Point(11, 112);
             this.OutBoxLabelAutoPrint.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.OutBoxLabelAutoPrint.Name = "OutBoxLabelAutoPrint";
             this.OutBoxLabelAutoPrint.Size = new System.Drawing.Size(75, 21);

+ 84 - 38
UAS-出货标签管理/UAS_出货标签管理.cs

@@ -1140,7 +1140,9 @@ namespace UAS_LabelMachine
                     {
                         //如果不存在中盒号则进行添加
                         if (!MidIDAndOutboxcode.ContainsValue(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());
+                        }
                     }
                 }
                 if (SingleID.ToArray().Length == 0)
@@ -1153,13 +1155,7 @@ namespace UAS_LabelMachine
                     GetSingleBoxData();
                 if (MidBoxCacheData.Rows.Count == 0)
                 {
-                    try
-                    {
-                        GetMidBoxData();
-                    }
-                    catch (Exception)
-                    {
-                    }
+                    GetMidBoxData();
                 }
                 for (int i = 0; i < LabelInf.RowCount; i++)
                 {
@@ -1226,28 +1222,30 @@ namespace UAS_LabelMachine
                             //保存参数打印
                             SingleDoc.Printer.SwitchTo(SingleLabelPrinter.Text);
                             SingleDoc.PrintDocument();
-                            //勾选为已打印
-                            LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
-                        }
-                        catch (Exception ex) { LogManager.DoLog(ex.Message); }
-                    }
-                    if (MidLabelAutoPrint.Checked && LabelInf.Rows[i].Cells["Choose"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue != null && LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True")
-                    {
-                        //判断当前行的盒号和下一行不相等或者已经是最后一行了
-                        if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
-                        {
-                            if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
+                            if (MidLabelAutoPrint.Checked)
                             {
-                                if (MidLabelCombox.SelectedValue != null)
+                                //判断当前行的盒号和下一行不相等或者已经是最后一行了
+                                if (i + 1 == LabelInf.RowCount || LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString() != LabelInf.Rows[i + 1 == LabelInf.RowCount ? i : i + 1].Cells["pib_outboxcode1"].Value.ToString())
                                 {
-                                    string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                                    MidBoxCodePrint(la_id_mid, CurrentRowIndex);
+                                    if (outboxcode1[LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()])
+                                    {
+                                        if (MidLabelCombox.SelectedValue != null)
+                                        {
+                                            string la_id_mid = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
+                                            MidBoxCodePrint(la_id_mid, CurrentRowIndex);
+                                        }
+                                    }
                                 }
                             }
+                            //勾选为已打印
+                            LabelInf.Rows[i].Cells["pib_ifprint"].Value = true;
                         }
+                        catch (Exception ex) { LogManager.DoLog(ex.Message); }
                     }
                 }
                 dh.BatchInsert("update prodiobarcode set pib_printdate=sysdate where pib_id=:pib_id", new string[] { "pib_id" }, SingleID.ToArray());
+                MidBoxCacheData.Clear();
+                BaseUtil.CleanDataTable(MidBoxCacheData);
                 if (CheckedRowCount == 0)
                     MessageBox.Show("未勾选打印明细!");
                 else if (CurrentRowIndex + 1 < LabelInf.Rows.Count)
@@ -1321,6 +1319,11 @@ namespace UAS_LabelMachine
             //id数组
             string[] pib_id_arr = MidIDAndOutboxcode.Keys.ToArray();
             string[] pib_outbox_arr = MidIDAndOutboxcode.Values.ToArray();
+            if (pib_id_arr.Length == 0)
+            {
+                MessageBox.Show("未勾选打印明细");
+                return;
+            }
             //记录一个ID用来取中盒的数量
             string pib_id = pib_id_arr[0];
             //id个数
@@ -1369,14 +1372,17 @@ namespace UAS_LabelMachine
             //将所有数据写入到CacheData中
             if (Temp.Length > 0)
             {
-                for (int i = 0; i < Temp[0].Rows.Count; i++)
+                for (int i = 0; i < pib_id_arr.Length; i++)
                 {
                     DataRow dr = MidBoxCacheData.NewRow();
                     dr["pib_id"] = pib_id_arr[i];
                     dr["pib_outboxcode1"] = pib_outbox_arr[i];
                     //由于之前加了一个ID列和箱号,导致j从2开始
                     for (int j = 2; j < MidBoxCacheData.Columns.Count; j++)
-                        dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Rows[i][0].ToString();
+                    {
+                        //选出勾选的中盒号
+                        dr[Temp[j - 2].Columns[0].ColumnName] = Temp[j - 2].Select("PIB_OUTBOXCODE1='" + pib_outbox_arr[i] + "'")[0][0];
+                    }
                     MidBoxCacheData.Rows.Add(dr);
                 }
             }
@@ -1386,29 +1392,32 @@ namespace UAS_LabelMachine
         {
             if (SingleLabelCombox.Text != "")
             {
-                try
+                if (SingleBoxBegin.Text != "" || SingleBoxEnd.Text != "")
                 {
-                    int begin = int.Parse(SingleBoxBegin.Text);
-                    int end = int.Parse(SingleBoxEnd.Text);
-                    if (begin > 0 && end < LabelInf.Rows.Count)
+                    try
                     {
-                        for (int i = begin - 1; i < end; i++)
+                        int begin = int.Parse(SingleBoxBegin.Text == "" ? "1" : SingleBoxBegin.Text);
+                        int end = int.Parse(SingleBoxEnd.Text == "" ? LabelInf.Rows.Count.ToString() : SingleBoxEnd.Text);
+                        if (begin > 0 && end <= LabelInf.Rows.Count)
                         {
-                            LabelInf.Rows[i].Cells["Choose"].Value = true;
-                            LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
+                            for (int i = begin - 1; i < end; i++)
+                            {
+                                LabelInf.Rows[i].Cells["Choose"].Value = true;
+                                LabelInf.Rows[i].Cells["pib_ifpick"].Value = true;
+                            }
+                        }
+                        else
+                        {
+                            MessageBox.Show("单盘打印范围错误");
+                            return;
                         }
                     }
-                    else
+                    catch (Exception)
                     {
                         MessageBox.Show("单盘打印范围错误");
                         return;
                     }
                 }
-                catch (Exception)
-                {
-                    MessageBox.Show("单盘打印范围错误");
-                    return;
-                }
                 thread = new Thread(SingleBoxPrint);
                 stw = new SetLoadingWindow(thread, "正在打印单盘");
                 BaseUtil.SetFormCenter(stw);
@@ -1423,13 +1432,50 @@ namespace UAS_LabelMachine
             //未输入内容打印全部中盒
             if (MidLabelNum.Text == "")
             {
+                int begin = 0;
+                int end = 0;
+                if (MidBoxBegin.Text != "" || MidBoxEnd.Text != "")
+                {
+                    try
+                    {
+                        begin = int.Parse(MidBoxBegin.Text == "" ? "1" : MidBoxBegin.Text);
+                        end = int.Parse(MidBoxEnd.Text == "" ? LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString() : MidBoxEnd.Text);
+                        int minmidbox = int.Parse(LabelInf.Rows[0].Cells["pib_outboxcode1"].Value.ToString());
+                        int maxmidbox = int.Parse(LabelInf.Rows[LabelInf.Rows.Count - 1].Cells["pib_outboxcode1"].Value.ToString());
+                        if (begin >= minmidbox && end <= maxmidbox)
+                        {
+                            //设置中盒打印范围的行号
+                            for (int i = 0; i < LabelInf.Rows.Count; i++)
+                            {
+                                if (int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()) == begin)
+                                {
+                                    begin = i;
+                                }
+                                if (int.Parse(LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString()) == end)
+                                {
+                                    end = i;
+                                }
+                            }
+                        }
+                        else
+                        {
+                            MessageBox.Show("中盒打印范围错误");
+                            return;
+                        }
+                    }
+                    catch (Exception)
+                    {
+                        MessageBox.Show("中盒打印范围错误");
+                        return;
+                    }
+                }
                 MidBoxArgument.Clear();
                 MidBoxCacheData.Clear();
                 BaseUtil.CleanDataTable(MidBoxCacheData);
                 List<int> MidOutBoxCode = new List<int>();
                 List<int> MidOutBoxCodeIndex = new List<int>();
                 string la_id = MidLabelCombox.SelectedValue.ToString().Split('#')[0];
-                for (int i = 0; i < LabelInf.Rows.Count; i++)
+                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()))
                         MidIDAndOutboxcode.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString(), LabelInf.Rows[i].Cells["pib_outboxcode1"].Value.ToString());
@@ -1959,7 +2005,7 @@ namespace UAS_LabelMachine
             {
                 sql.Clear();
                 sql.Append("select pd_custprodcode,pd_custprodspec,pd_pocode,pib_madein,pib_id,pib_pdid,pib_piid,pib_pdno,pib_prodcode,pr_brand,pr_vendprodcode,");
-                sql.Append("pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,pib_ifpick,pib_ifprint");
+                sql.Append("pib_lotno,pib_datecode,pib_qty,pib_barcode,pib_outboxcode1,pib_outboxcode2,nvl(pib_ifpick,0)pib_ifpick,nvl(pib_ifprint,0)pib_ifprint");
                 sql.Append(",sa_pocode from prodiobarcode left join prodiodetail on pib_piid=pd_piid and pd_pdno=pib_pdno and ");
                 sql.Append(" pd_prodcode=pib_prodcode left join product on pr_code=pib_prodcode left join sale on sa_code=pib_ordercode ");
                 sql.Append("where pib_piid='" + PI_ID + "' order by to_number(pib_outboxcode1),pib_id,pd_prodcode");