瀏覽代碼

添加点击行超出索引异常处理

章政 8 年之前
父節點
當前提交
778f63981d
共有 1 個文件被更改,包括 13 次插入9 次删除
  1. 13 9
      UAS-MES/FunctionCode/Make/Make_PositionStock.cs

+ 13 - 9
UAS-MES/FunctionCode/Make/Make_PositionStock.cs

@@ -73,7 +73,8 @@ namespace UAS_MES.Make
                     if (ma_code.Text != "")
                     {
                         string ErrMessage = "";
-                        if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrMessage)) {
+                        if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrMessage))
+                        {
                             sql.Clear();
                             sql.Append("select cr_code from craft left join craftdetail on cd_crid=cr_id where cr_code in (" + craftcode_condition + ") ");
                             sql.Append("and cr_prodcode='" + ma_prodcode.Text + "'  and  cr_statuscode='AUDITED'  and  cd_stepcode='" + User.CurrentStepCode + "'");
@@ -115,7 +116,7 @@ namespace UAS_MES.Make
                             }
                             else OperateResult.AppendText(">>当前岗位资源工序不在工单对应的途程中\n", Color.Red);
                         }
-                        else OperateResult.AppendText(">>"+ErrMessage+"\n", Color.Red);
+                        else OperateResult.AppendText(">>" + ErrMessage + "\n", Color.Red);
                     }
                     else OperateResult.AppendText(">>工单号不能为空\n", Color.Red, pr_batchnum);
                 }
@@ -130,7 +131,7 @@ namespace UAS_MES.Make
             sql.Append("select nvl(mss_id,0) mss_id,sp_soncode,mss_prodcode,sp_oneuseqty,mss_barcode,nvl(mss_qty,0) mss_qty ,mss_remain,");
             sql.Append("pr_detail,nvl(mss_useqty,0) mss_useqty from stepbom left join stepproduct on sp_sbid=sb_id left join product on ");
             sql.Append("pr_code=sp_mothercode left join makesourcestock on mss_makecode='" + ma_code.Text + "' and  mss_craftcode=sb_craftcode ");
-            sql.Append("and mss_stepcode=sp_stepcode where sb_prodcode='" + ma_prodcode.Text + "' and sb_craftcode='" + ma_craftcode.Text + "' ");
+            sql.Append("and mss_stepcode=sp_stepcode and sp_soncode=mss_prodcode where sb_prodcode='" + ma_prodcode.Text + "' and sb_craftcode='" + ma_craftcode.Text + "' ");
             sql.Append("and sp_stepcode='" + User.CurrentStepCode + "' and sp_tracekind=2");
             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             BaseUtil.FillDgvWithDataTable(BatchProductDGV, dt);
@@ -166,11 +167,14 @@ namespace UAS_MES.Make
         {
             if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow")
             {
-                string id = BatchProductDGV.Rows[e.RowIndex].Cells["mss_id"].Value.ToString();
-                if (id != "0")
+                if (e.RowIndex >= 0)
                 {
-                    BatchProductDGV.Rows.RemoveAt(e.RowIndex);
-                    dh.ExecuteSql("delete from makesourcestock where mss_id='" + id + "'", "delete");
+                    string id = BatchProductDGV.Rows[e.RowIndex].Cells["mss_id"].Value.ToString();
+                    if (id != "0")
+                    {
+                        BatchProductDGV.Rows.RemoveAt(e.RowIndex);
+                        dh.ExecuteSql("delete from makesourcestock where mss_id='" + id + "'", "delete");
+                    }
                 }
             }
         }
@@ -206,7 +210,7 @@ namespace UAS_MES.Make
         private void BatchProductDGV_CellEndEdit(object sender, DataGridViewCellEventArgs e)
         {
             string id = BatchProductDGV.Rows[e.RowIndex].Cells["mss_id"].Value.ToString();
-            string qty ="0";
+            string qty = "0";
             if (id != "0")
             {
                 try
@@ -226,7 +230,7 @@ namespace UAS_MES.Make
                     OperateResult.AppendText(">>数量必须大于0\n", Color.Red);
                     return;
                 }
-                dh.UpdateByCondition("makesourcestock", "mss_qty='"+ qty + "'", "mss_id='" + id + "'");
+                dh.UpdateByCondition("makesourcestock", "mss_qty='" + qty + "'", "mss_id='" + id + "'");
             }
         }
     }