Эх сурвалжийг харах

DataGridView添加全选,修复BUG

章政 8 жил өмнө
parent
commit
8326e1ef5b

+ 10 - 1
UAS-MES/CustomControl/DataGrid_View/DataGridViewWithCheckBox.Designer.cs

@@ -28,7 +28,16 @@
         /// </summary>
         private void InitializeComponent()
         {
-            components = new System.ComponentModel.Container();
+            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // DataGridViewWithCheckBox
+            // 
+            this.RowTemplate.Height = 27;
+            this.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridViewWithCheckBox_CellContentClick);
+            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
+            this.ResumeLayout(false);
+
         }
 
         #endregion

+ 8 - 0
UAS-MES/CustomControl/DataGrid_View/DataGridViewWithCheckBox.cs

@@ -15,6 +15,14 @@ namespace UAS_MES.CustomControl.DataGrid_View
         {
             InitializeComponent();
         }
+
+        private void DataGridViewWithCheckBox_CellContentClick(object sender, DataGridViewCellEventArgs e)
+        {
+            if (Columns[0] is DataGridViewCheckBoxColumn && e.ColumnIndex > 0)
+            {
+                Rows[e.RowIndex].Cells[0].Value = true;
+            }
+        }
     }
 
     public class DataGridViewCheckBoxHeaderCell : DataGridViewColumnHeaderCell

+ 10 - 2
UAS-MES/CustomControl/DataGrid_View/DataGridViewWithSerialNum.Designer.cs

@@ -32,8 +32,16 @@ namespace UAS_MES.CustomControl.DataGrid_View
         /// </summary>
         private void InitializeComponent()
         {
-            components = new System.ComponentModel.Container();
-           // this.AutoScaleMode = AutoScaleMode.Font;
+            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
+            this.SuspendLayout();
+            // 
+            // DataGridViewWithSerialNum
+            // 
+            this.RowTemplate.Height = 27;
+            this.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.DataGridViewWithSerialNum_CellContentClick);
+            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
+            this.ResumeLayout(false);
+
         }
 
         #endregion

+ 8 - 0
UAS-MES/CustomControl/DataGrid_View/DataGridViewWithSerialNum.cs

@@ -24,5 +24,13 @@ namespace UAS_MES.CustomControl.DataGrid_View
             e.Graphics.DrawString((e.RowIndex + 1).ToString(), e.InheritedRowStyle.Font, solidBrush, e.RowBounds.Location.X + 15, e.RowBounds.Location.Y + 5);
             base.OnRowPostPaint(e);
         }
+
+        private void DataGridViewWithSerialNum_CellContentClick(object sender, DataGridViewCellEventArgs e)
+        {
+            if (Columns[0] is DataGridViewCheckBoxColumn && e.ColumnIndex > 0)
+            {
+                Rows[e.RowIndex].Cells[0].Value = true;
+            }
+        }
     }
 }

+ 6 - 10
UAS-MES/FunctionCode/OQC/OQC_BatchResultJudge.cs

@@ -130,11 +130,7 @@ namespace UAS_MES.OQC
         {
             if (CheckBefore() && PassCheckStep)
             {
-                sql.Clear();
-                sql.Append("select max(nvl(ad_maxngacceptqty,0)) maxngacceptqty from QUA_Aql,QUA_AqlDetail where al_id=ad_alid ");
-                sql.Append("and al_statuscode='AUDITED'  and al_code ='" + ob_aqlcode.Text + "' and " + (ob_nowcheckqty.Text != "" ? ob_nowcheckqty.Text : "0") + " >= ad_minqty ");
-                sql.Append("and " + (ob_nowcheckqty.Text != "" ? ob_nowcheckqty.Text : "0") + "<=ad_maxqty ");
-                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                dh.ExecuteSql("update makeserial set ms_status=3 where ms_checkno='" + ob_checkno.Text + "'", "update");
                 dh.ExecuteSql("update OQCBatch set ob_status='NG',ob_result='NG' where ob_checkno='" + ob_checkno.Text + "'", "select");
                 //如果勾选了发起反攻需求则新增记录
                 if (ReworkRequire.Checked)
@@ -153,7 +149,7 @@ namespace UAS_MES.OQC
                     sql.Append("from OQCBatch  left join OQCBatchDetail on obd_obid=ob_id where ob_checkno='" + ob_checkno.Text + "'");
                     dh.ExecuteSql(sql.GetString(), "insert");
                     //将工单信息写回到OQC主表
-                    dh.ExecuteSql("update oqcbatch set ob_rmcode='"+re_code+"' where ob_checkno='"+ob_checkno.Text+"'", "update");
+                    dh.ExecuteSql("update oqcbatch set ob_rmcode='" + re_code + "' where ob_checkno='" + ob_checkno.Text + "'", "update");
                 }
                 DoLog("判退通过", "批次判退成功", "通过");
                 OperateResult.AppendText(">>判退批成功\n", Color.Green);
@@ -176,6 +172,7 @@ namespace UAS_MES.OQC
         {
             if (PassCheckStep)
             {
+                dh.ExecuteSql("update makeserial set ms_status=3 where ms_checkno='" + ob_checkno.Text + "'", "update");
                 dh.ExecuteSql("update OQCBatch set ob_status='NG' ,ob_result='FNG' where ob_checkno='" + ob_checkno.Text + "'", "select");
                 DoLog("强制判退通过", "强制判退通过成功", "判退");
                 GetBatch.PerformClick();
@@ -320,16 +317,16 @@ namespace UAS_MES.OQC
                 {
                     List<string> sql = new List<string>();
                     //该序列号的批次数量
-                    int batchqty = dh.getRowCount("makeserial", "ms_checkno='" + ob_checkno.Text + "'");
+                    string batchqty = dh.getFieldDataByCondition("oqcbatch", "ob_nowcheckqty", "ob_checkno='" + ob_checkno.Text + "'").ToString();
                     //撤销时如果没有下一工序表示工单已经完工了,此时撤销需要将完工数减掉一个批次
                     if (dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_sncode='" + ms_sncode.Text + "'").ToString() == "")
                     {
                         sql.Add("update make set ma_madeqty=ma_madeqty-" + batchqty + " where ma_code='" + ob_makecode.Text + "'");
                     }
                     //获取上一步执行的工序
-                    string PastCode = dh.getFieldDataByCondition("makeserial", "SUBSTR(ms_paststep,0,INSTR(ms_paststep,',', -1, 1)-1) ms_paststep", "ms_checkno='" + ob_checkno.Text + "'").ToString();
+                    string PastCode = dh.getFieldDataByCondition("makeserial", "SUBSTR(ms_paststep,0,INSTR(ms_paststep,',', -1, 1)-1) ms_paststep", "ms_checkno='" + ob_checkno.Text + "' and ms_status<>3").ToString();
                     string[] LastStepCode = PastCode.Split(',');
-                    sql.Add("update makeserial set ms_paststep=(select distinct SUBSTR(ms_paststep,0,INSTR(ms_paststep,',', -1, 1)-1)  from makeserial where ms_checkno='" + ob_checkno.Text + "') where ms_checkno='" + ob_checkno.Text + "'");
+                    sql.Add("update makeserial set ms_paststep=(select distinct SUBSTR(ms_paststep,0,INSTR(ms_paststep,',', -1, 1)-1)  from makeserial where ms_checkno='" + ob_checkno.Text + "' and ms_status<>3 and rownum=1) where ms_checkno='" + ob_checkno.Text + "' and ms_status<>3 ");
                     sql.Add("update makeserial set ms_stepcode='" + LastStepCode[LastStepCode.Length - 1] + "',ms_nextstepcode='" + User.CurrentStepCode + "',ms_status=1 where ms_checkno='" + ob_checkno.Text + "'");
                     sql.Add("update makecraftdetail set mcd_inqty=mcd_inqty-" + batchqty + ",mcd_outqty = mcd_outqty - " + batchqty + ",mcd_okqty = mcd_okqty -" + batchqty + " where mcd_macode='" + ob_makecode.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
                     dh.ExecuteSQLTran(sql.ToArray());
@@ -337,7 +334,6 @@ namespace UAS_MES.OQC
                 else if (Type == "通过")
                 {
                     //更新下一工序
-
                     LogicHandler.UpdateOQCMessage(ms_sncode.Text, ob_checkno.Text, ob_makecode.Text, Kind, User.UserSourceCode, User.UserName, Result, out ErrorMessage);
                     sql.Clear();
                     sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");

+ 81 - 61
UAS-MES/FunctionCode/OQC/OQC_SamplingDataCollection.Designer.cs

@@ -55,13 +55,7 @@
             this.ob_prodcode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.ob_makecode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.ChoosedDGV = new UAS_MES.CustomControl.DataGrid_View.DataGridViewExpand();
-            this.or_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.bc_code1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.bc_name1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.WaitChooseDGV = new UAS_MES.CustomControl.DataGrid_View.DataGridViewWithCheckBox();
-            this.ChooseAll = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.bc_code = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.bc_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.ob_remark = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.sncode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.CheckTypeDGV = new UAS_MES.CustomControl.DataGrid_View.DataGridViewWithCheckBox();
@@ -93,6 +87,14 @@
             this.ob_makecode_dgv = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.obd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.BadGroupCode = new UAS_MES.CustomControl.ComBoxWithFocus.ComBoxWithFocus();
+            this.ChooseAll = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.bg_code = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.bc_code = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.bc_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.or_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.bg_code1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.bc_code1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.bc_name1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.ChoosedDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.WaitChooseDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.CheckTypeDGV)).BeginInit();
@@ -433,6 +435,7 @@
             this.ChoosedDGV.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.ChoosedDGV.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.or_id,
+            this.bg_code1,
             this.bc_code1,
             this.bc_name1});
             this.ChoosedDGV.Location = new System.Drawing.Point(1080, 255);
@@ -443,36 +446,13 @@
             this.ChoosedDGV.Size = new System.Drawing.Size(325, 321);
             this.ChoosedDGV.TabIndex = 205;
             // 
-            // or_id
-            // 
-            this.or_id.DataPropertyName = "or_id";
-            this.or_id.HeaderText = "or_id";
-            this.or_id.Name = "or_id";
-            this.or_id.Visible = false;
-            // 
-            // bc_code1
-            // 
-            this.bc_code1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.bc_code1.DataPropertyName = "bc_code";
-            this.bc_code1.HeaderText = "不良代码";
-            this.bc_code1.Name = "bc_code1";
-            this.bc_code1.ReadOnly = true;
-            this.bc_code1.Width = 130;
-            // 
-            // bc_name1
-            // 
-            this.bc_name1.DataPropertyName = "bc_name";
-            this.bc_name1.HeaderText = "不良名称 ";
-            this.bc_name1.Name = "bc_name1";
-            this.bc_name1.ReadOnly = true;
-            this.bc_name1.Width = 151;
-            // 
             // WaitChooseDGV
             // 
             this.WaitChooseDGV.AllowUserToAddRows = false;
             this.WaitChooseDGV.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
             this.WaitChooseDGV.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
             this.ChooseAll,
+            this.bg_code,
             this.bc_code,
             this.bc_name});
             this.WaitChooseDGV.Location = new System.Drawing.Point(629, 255);
@@ -485,31 +465,6 @@
             this.WaitChooseDGV.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.WaitChooseDGV_CellContentClick);
             this.WaitChooseDGV.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.WaitChooseDGV_DataError);
             // 
-            // ChooseAll
-            // 
-            this.ChooseAll.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.ChooseAll.DataPropertyName = "ChooseAll";
-            this.ChooseAll.HeaderText = "勾选";
-            this.ChooseAll.Name = "ChooseAll";
-            this.ChooseAll.Resizable = System.Windows.Forms.DataGridViewTriState.False;
-            this.ChooseAll.Width = 60;
-            // 
-            // bc_code
-            // 
-            this.bc_code.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.bc_code.DataPropertyName = "bc_code";
-            this.bc_code.HeaderText = "不良代码";
-            this.bc_code.Name = "bc_code";
-            this.bc_code.ReadOnly = true;
-            this.bc_code.Width = 130;
-            // 
-            // bc_name
-            // 
-            this.bc_name.DataPropertyName = "bc_name";
-            this.bc_name.HeaderText = "不良名称";
-            this.bc_name.Name = "bc_name";
-            this.bc_name.ReadOnly = true;
-            // 
             // ob_remark
             // 
             this.ob_remark.AllPower = null;
@@ -905,6 +860,69 @@
             this.BadGroupCode.TabIndex = 219;
             this.BadGroupCode.SelectedIndexChanged += new System.EventHandler(this.BadGroupCode_SelectedIndexChanged);
             // 
+            // ChooseAll
+            // 
+            this.ChooseAll.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.ChooseAll.DataPropertyName = "ChooseAll";
+            this.ChooseAll.HeaderText = "勾选";
+            this.ChooseAll.Name = "ChooseAll";
+            this.ChooseAll.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+            this.ChooseAll.Width = 60;
+            // 
+            // bg_code
+            // 
+            this.bg_code.DataPropertyName = "bg_code";
+            this.bg_code.HeaderText = "不良组别编号";
+            this.bg_code.Name = "bg_code";
+            this.bg_code.Visible = false;
+            // 
+            // bc_code
+            // 
+            this.bc_code.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.bc_code.DataPropertyName = "bc_code";
+            this.bc_code.HeaderText = "不良代码";
+            this.bc_code.Name = "bc_code";
+            this.bc_code.ReadOnly = true;
+            this.bc_code.Width = 130;
+            // 
+            // bc_name
+            // 
+            this.bc_name.DataPropertyName = "bc_name";
+            this.bc_name.HeaderText = "不良名称";
+            this.bc_name.Name = "bc_name";
+            this.bc_name.ReadOnly = true;
+            // 
+            // or_id
+            // 
+            this.or_id.DataPropertyName = "or_id";
+            this.or_id.HeaderText = "or_id";
+            this.or_id.Name = "or_id";
+            this.or_id.Visible = false;
+            // 
+            // bg_code1
+            // 
+            this.bg_code1.DataPropertyName = "bg_code";
+            this.bg_code1.HeaderText = "不良组别编号";
+            this.bg_code1.Name = "bg_code1";
+            this.bg_code1.Visible = false;
+            // 
+            // bc_code1
+            // 
+            this.bc_code1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.bc_code1.DataPropertyName = "bc_code";
+            this.bc_code1.HeaderText = "不良代码";
+            this.bc_code1.Name = "bc_code1";
+            this.bc_code1.ReadOnly = true;
+            this.bc_code1.Width = 130;
+            // 
+            // bc_name1
+            // 
+            this.bc_name1.DataPropertyName = "bc_name";
+            this.bc_name1.HeaderText = "不良名称 ";
+            this.bc_name1.Name = "bc_name1";
+            this.bc_name1.ReadOnly = true;
+            this.bc_name1.Width = 151;
+            // 
             // OQC_SamplingDataCollection
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
@@ -1018,12 +1036,6 @@
         private System.Windows.Forms.Label ob_maxngacceptqty_label;
         private System.Windows.Forms.Label ob_projectcode_label;
         private CustomControl.ComBoxWithFocus.ComBoxWithFocus BadGroupCode;
-        private System.Windows.Forms.DataGridViewCheckBoxColumn ChooseAll;
-        private System.Windows.Forms.DataGridViewTextBoxColumn bc_code;
-        private System.Windows.Forms.DataGridViewTextBoxColumn bc_name;
-        private System.Windows.Forms.DataGridViewTextBoxColumn or_id;
-        private System.Windows.Forms.DataGridViewTextBoxColumn bc_code1;
-        private System.Windows.Forms.DataGridViewTextBoxColumn bc_name1;
         private System.Windows.Forms.DataGridViewCheckBoxColumn choose;
         private System.Windows.Forms.DataGridViewTextBoxColumn oi_itemcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn ci_name;
@@ -1033,5 +1045,13 @@
         private System.Windows.Forms.DataGridViewComboBoxColumn oi_leveldefect;
         private System.Windows.Forms.DataGridViewTextBoxColumn ois_remark;
         private System.Windows.Forms.DataGridViewTextBoxColumn ois_status;
+        private System.Windows.Forms.DataGridViewCheckBoxColumn ChooseAll;
+        private System.Windows.Forms.DataGridViewTextBoxColumn bg_code;
+        private System.Windows.Forms.DataGridViewTextBoxColumn bc_code;
+        private System.Windows.Forms.DataGridViewTextBoxColumn bc_name;
+        private System.Windows.Forms.DataGridViewTextBoxColumn or_id;
+        private System.Windows.Forms.DataGridViewTextBoxColumn bg_code1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn bc_code1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn bc_name1;
     }
 }

+ 15 - 10
UAS-MES/FunctionCode/OQC/OQC_SamplingDataCollection.cs

@@ -83,7 +83,7 @@ namespace UAS_MES.OQC
                 GetBatch.PerformClick();
                 if (CheckSnCode())
                 {
-                    dt = (DataTable)dh.ExecuteSql("select or_id,or_reasoncode bc_code, oi_description bc_name from OQCNGReason where or_checkno='" + ob_checkno.Text + "' and or_sncode='" + sncode.Text + "'", "select");
+                    dt = (DataTable)dh.ExecuteSql("select or_id,or_badcode bc_code, or_description bc_name from OQCNGReason where or_checkno='" + ob_checkno.Text + "' and or_sncode='" + sncode.Text + "'", "select");
                     BaseUtil.FillDgvWithDataTable(ChoosedDGV, dt);
                     GetBatchTypeGridData();
                 }
@@ -234,8 +234,6 @@ namespace UAS_MES.OQC
                                 ois_remark_insert.Add(Savedt.Rows[i]["ois_remark"].ToString());
                             }
                         }
-                        //判断是否含不通过的内容
-
                         //执行批量更新的SQL
                         if (ois_id_update.Count > 0)
                         {
@@ -258,19 +256,21 @@ namespace UAS_MES.OQC
                         //采集不良信息
                         List<string> bc_code = new List<string>();
                         List<string> bc_name = new List<string>();
+                        List<string> bg_code = new List<string>();
                         for (int i = 0; i < ChoosedDGV.RowCount; i++)
                         {
-                            bc_code.Add(ChoosedDGV.Rows[i].Cells[1].Value.ToString());
-                            bc_name.Add(ChoosedDGV.Rows[i].Cells[2].Value.ToString());
+                            bc_code.Add(ChoosedDGV.Rows[i].Cells["bc_code1"].Value.ToString());
+                            bc_name.Add(ChoosedDGV.Rows[i].Cells["bc_name1"].Value.ToString());
+                            bg_code.Add(ChoosedDGV.Rows[i].Cells["bg_code1"].Value.ToString());
                         }
                         if (bc_name.Count > 0)
                         {
-                            dh.UpdateByCondition("makeserial", "ms_badtimes=ms_badtimes+1", "ms_sncode='" + sncode.Text + "'");
+                            //dh.UpdateByCondition("makeserial", "ms_badtimes=ms_badtimes+1", "ms_sncode='" + sncode.Text + "'");
                             dh.ExecuteSql("delete from OQCNGReason where or_sncode='" + sncode.Text + "' and or_checkno='" + ob_checkno.Text + "'", "delete");
                             sql.Clear();
-                            sql.Append("insert into OQCNGReason(or_id, or_checkno, or_makecode, or_sncode, or_reasoncode, oi_description, oi_remark)");
-                            sql.Append("values (OQCNGReason_seq.nextval,'" + ob_checkno.Text + "','" + ob_makecode.Text + "','" + sncode.Text + "',:a,:b,'" + ob_remark.Text + "')");
-                            dh.BatchInsert(sql.GetString(), new string[] { "a", "b" }, bc_code.ToArray(), bc_name.ToArray());
+                            sql.Append("insert into OQCNGReason(or_id, or_checkno, or_makecode, or_sncode, or_badcode, or_description, or_remark,or_bgcode)");
+                            sql.Append("values (OQCNGReason_seq.nextval,'" + ob_checkno.Text + "','" + ob_makecode.Text + "','" + sncode.Text + "',:a,:b,'" + ob_remark.Text + "',:c)");
+                            dh.BatchInsert(sql.GetString(), new string[] { "a", "b","c" }, bc_code.ToArray(), bc_name.ToArray(), bg_code.ToArray());
                         }
                         //更新项目编号中的抽检数、不合格数,根据采样项目记录
                         sql.Clear();
@@ -278,6 +278,11 @@ namespace UAS_MES.OQC
                         sql.Append("nvl(ois_ifng,0)=0 then 0 else 1 end),0) ,count(1) from OQCItemSamples where ois_checkno=oi_checkno ");
                         sql.Append("and ois_itemcode=oi_itemcode)where oi_checkno ='" + ob_checkno.Text + "' and oi_projectcode ='" + ob_projectcode.Text + "'");
                         dh.ExecuteSql(sql.GetString(), "update");
+                        //含有不良的将序列号更新为不良
+                        if (IfContainNG)
+                            dh.ExecuteSql("update makeserial set ms_status=3 where ms_sncode='" + sncode.Text + "'", "update");
+                        else
+                            dh.ExecuteSql("update makeserial set ms_status=1 where ms_sncode='" + sncode.Text + "'", "update");
                         //更新检验状态,如果是待检验的更新为检验中
                         dh.ExecuteSql("update OQCBatch set ob_status='CHECKING' where ob_checkno='" + ob_checkno.Text + "' and ob_status='UNCHECK'", "update");
                         //更新批次中的合格数不合格数:用抽检批检验项目表获取最大的抽检数和不合格数
@@ -445,7 +450,7 @@ namespace UAS_MES.OQC
         {
             string bg_code = BadGroupCode.SelectedValue.ToString();
             sql.Clear();
-            sql.Append("select 0 ChooseAll,bc_code,bc_name from badgroupdetail left join badgroup on bgd_bgcode=bg_code ");
+            sql.Append("select 0 ChooseAll,bc_code,bc_name,bg_code from badgroupdetail left join badgroup on bgd_bgcode=bg_code ");
             sql.Append("left join badcode on bgd_badcode=bc_code where bg_code='" + ((bg_code != "" && bg_code != "System.Data.DataRowView") ? bg_code.ToString() : "") + "' and bg_code is not null ");
             sql.Append(" order by bc_code");
             DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");

+ 16 - 7
UAS-MES/FunctionCode/OQC/OQC_SamplingDataCollection.resx

@@ -252,6 +252,9 @@
   <metadata name="or_id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="bg_code1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="bc_code1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
@@ -261,13 +264,7 @@
   <metadata name="ChooseAll.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="bc_code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="bc_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="ChooseAll.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+  <metadata name="bg_code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
   <metadata name="bc_code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
@@ -776,4 +773,16 @@
   <metadata name="obd_id.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="ChooseAll.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="bg_code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="bc_code.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="bc_name.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>

+ 6 - 11
UAS-MES/PublicMethod/LogicHandler.cs

@@ -1217,26 +1217,21 @@ namespace UAS_MES.PublicMethod
             }
             GetStepCodeAndNameAndLineBySource(iSourceCode, ref StepCode, ref StepName, ref LineCode);
             //查询批次和批数量
-            int batchqty = 0;
-            DataTable dt = (DataTable)dh.ExecuteSql("select count(ms_checkno) count,ms_checkno from makeserial where ms_checkno='" + iCheckno + "' group by ms_checkno", "select");
-            if (dt.Rows.Count > 0)
-            {
-                batchqty = int.Parse(dt.Rows[0]["count"].ToString());
-            }
+            string batchqty = dh.getFieldDataByCondition("oqcbatch", "ob_nowcheckqty", "ob_checkno='" + iCheckno + "'").ToString();
             string nextstepcode = dh.getFieldDataByCondition("make left join craft on ma_craftcode=cr_code and ma_prodcode=cr_prodcode left join craftdetail on cr_id = cd_crid", "cd_nextstepcode", "ma_code='" + iMakeCode + "' and cd_stepcode='" + StepCode + "'").ToString();
-            if (iResult.Contains("批次通过") && dt.Rows.Count > 0)
+            if (iResult.Contains("批次通过"))
             {
                 //更新执行的数量
                 sqls.Add("update makecraftdetail set mcd_inqty=mcd_inqty+" + batchqty + ",mcd_outqty = mcd_outqty + " + batchqty + ",mcd_okqty = mcd_okqty + " + batchqty + " where mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "' ");
                 //更新makeSerial 的下一工序
-                sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_stepcode='" + StepCode + "',ms_nextstepcode='" + nextstepcode + "' where ms_checkno='" + iCheckno + "'");
+                sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_stepcode='" + StepCode + "',ms_nextstepcode='" + nextstepcode + "' where ms_checkno='" + iCheckno + "' and ms_status<>3");
             }
             else
             {
                 //更新执行的数量
                 sqls.Add("update makecraftdetail set mcd_inqty=mcd_inqty+1,mcd_outqty = mcd_outqty + 1,mcd_okqty = mcd_okqty + 1 where mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "' ");
                 //更新makeSerial 的下一工序
-                sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_stepcode='" + StepCode + "',ms_nextstepcode='" + nextstepcode + "' where ms_checkno='" + iCheckno + "'");
+                sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_stepcode='" + StepCode + "',ms_nextstepcode='" + nextstepcode + "' where ms_checkno='" + iCheckno + "' and ms_status<>3");
             }
             //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
             dh.ExecuteSQLTran(sqls.ToArray());
@@ -1247,12 +1242,12 @@ namespace UAS_MES.PublicMethod
                 if (iResult.Contains("批次通过"))
                 {
                     sqls.Add("update make set ma_madeqty=ma_madeqty+" + batchqty + " where ma_code='" + iMakeCode + "'");
-                    sqls.Add("update makeserial set ms_status=2 where ms_checkno='" + iCheckno + "'");
+                    sqls.Add("update makeserial set ms_status=2 where ms_checkno='" + iCheckno + "' and ms_status<>3");
                 }
                 else
                 {
                     sqls.Add("update make set ma_madeqty=ma_madeqty+1  where ma_code='" + iMakeCode + "'");
-                    sqls.Add("update makeserial set ms_status=2 where ms_checkno='" + iCheckno + "'");
+                    sqls.Add("update makeserial set ms_status=2 where ms_checkno='" + iCheckno + "' and ms_status<>3");
                 }
                 dh.ExecuteSQLTran(sqls.ToArray());
                 sqls.Clear();