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

优化写入无条码打不良功能

callm 2 сар өмнө
parent
commit
52f743366b

+ 5 - 7
UAS_MES_YTDZ/FunctionCode/Make/Make_NewBadCode.cs

@@ -125,7 +125,7 @@ namespace UAS_MES_NEW.Make
                         }
                     }
                     if (!AddToReject)
-                    {                      
+                    {
                         ChoosedRejectList.Items.Add((ListViewItem)WaitRejectList.Items[i].Clone());
                         WaitRejectList.Items[i].Remove();
                         CheckedNum++;
@@ -193,13 +193,11 @@ namespace UAS_MES_NEW.Make
                 }
             }
             sql.Clear();
-            sql.Append("insert when (not exists(select 1 from makebad where mb_sncode='" + sncode + "' and mb_makecode='" + macode + "' and  ");
-            sql.Append("mb_status=0 and mb_badcode=:bc_code)) then into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,");
+            sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,");
             sql.Append("mb_indate,mb_stepcode,mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_status)");
-            sql.Append("select DISTINCT :id,ma_code,ms_code,ms_sncode,'" + User.UserCode + "',sysdate,'" + User.CurrentStepCode + "',ms_sourcecode,:bc_code,:bg_code,'',");
-            sql.Append("'0' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
-            sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode and ms_craftcode = sp_craftcode  where ms_sncode='" + sncode + "' and ms_makecode = '" + macode + "'");
-            dh.BatchInsert(sql.GetString(), new string[] { "bc_code", "id", "bc_code", "bg_code" }, bccode, id, bccode, bgcode);
+            sql.Append("select :id,'" + macode + "','" + sncode + "','" + sncode + "','" + User.UserCode + "',sysdate,'" + User.CurrentStepCode + "','" + User.UserSourceCode + "',:bc_code,:bg_code,'',");
+            sql.Append("'0' from dual ");
+            dh.BatchInsert(sql.GetString(), new string[] { "id", "bc_code", "bg_code" }, id, bccode, bgcode);
             MessageBox.Show("保存成功");
             Close();
         }

+ 57 - 50
UAS_MES_YTDZ/FunctionCode/Make/Make_RepairoffLine.Designer.cs

@@ -69,6 +69,7 @@
             this.nr_name = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.BlurSearch();
             this.nrg_name = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.BlurSearch();
             this.groupBoxWithBorder1 = new UAS_MES_NEW.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.cd_stepcode = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.ms_reworkcheckno = new System.Windows.Forms.Label();
             this.ms_makecode_label = new System.Windows.Forms.Label();
@@ -84,8 +85,7 @@
             this.pr_detail_label = new System.Windows.Forms.Label();
             this.ms_prodcode_label = new System.Windows.Forms.Label();
             this.pr_detail = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
-            this.ms_prodcode = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
-            this.ms_makecode = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
+            this.pr_code = new UAS_MES_NEW.CustomControl.ValueLabel.ValueLabel();
             this.mb_badremark = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.TextBoxWithTextArea();
             this.bd_soncode = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SearchTextBox();
             this.mbp_partdgv = new UAS_MES_NEW.CustomControl.DataGrid_View.DataGridViewWithCheckBox();
@@ -242,7 +242,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.GetSNCode_Label.AutoSize = true;
             this.GetSNCode_Label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.GetSNCode_Label.Location = new System.Drawing.Point(640, 1083);
+            this.GetSNCode_Label.Location = new System.Drawing.Point(541, 1074);
             this.GetSNCode_Label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.GetSNCode_Label.Name = "GetSNCode_Label";
             this.GetSNCode_Label.Size = new System.Drawing.Size(114, 41);
@@ -439,7 +439,7 @@
             this.normalButton1.DownImage = ((System.Drawing.Image)(resources.GetObject("normalButton1.DownImage")));
             this.normalButton1.Image = null;
             this.normalButton1.IsShowBorder = true;
-            this.normalButton1.Location = new System.Drawing.Point(220, 227);
+            this.normalButton1.Location = new System.Drawing.Point(211, 232);
             this.normalButton1.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
             this.normalButton1.MoveImage = ((System.Drawing.Image)(resources.GetObject("normalButton1.MoveImage")));
             this.normalButton1.Name = "normalButton1";
@@ -528,6 +528,7 @@
             // groupBoxWithBorder1
             // 
             this.groupBoxWithBorder1.BorderColor = System.Drawing.Color.Black;
+            this.groupBoxWithBorder1.Controls.Add(this.ma_code);
             this.groupBoxWithBorder1.Controls.Add(this.cd_stepcode);
             this.groupBoxWithBorder1.Controls.Add(this.ms_reworkcheckno);
             this.groupBoxWithBorder1.Controls.Add(this.ms_makecode_label);
@@ -543,8 +544,7 @@
             this.groupBoxWithBorder1.Controls.Add(this.pr_detail_label);
             this.groupBoxWithBorder1.Controls.Add(this.ms_prodcode_label);
             this.groupBoxWithBorder1.Controls.Add(this.pr_detail);
-            this.groupBoxWithBorder1.Controls.Add(this.ms_prodcode);
-            this.groupBoxWithBorder1.Controls.Add(this.ms_makecode);
+            this.groupBoxWithBorder1.Controls.Add(this.pr_code);
             this.groupBoxWithBorder1.Font = new System.Drawing.Font("微软雅黑", 12F);
             this.groupBoxWithBorder1.Location = new System.Drawing.Point(18, 16);
             this.groupBoxWithBorder1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
@@ -556,6 +556,27 @@
             this.groupBoxWithBorder1.Text = "工单信息";
             this.groupBoxWithBorder1.TextColor = System.Drawing.Color.Black;
             // 
+            // ma_code
+            // 
+            this.ma_code.AllPower = "ifall";
+            this.ma_code.Caller = null;
+            this.ma_code.Condition = null;
+            this.ma_code.DBTitle = "回流工序";
+            this.ma_code.Font = new System.Drawing.Font("微软雅黑", 9F);
+            this.ma_code.FormName = null;
+            this.ma_code.Location = new System.Drawing.Point(520, 68);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Power = "ifspecial";
+            this.ma_code.ReturnData = null;
+            this.ma_code.SelectField = null;
+            this.ma_code.SetValueField = null;
+            this.ma_code.Size = new System.Drawing.Size(300, 43);
+            this.ma_code.TabIndex = 130;
+            this.ma_code.TableName = null;
+            this.ma_code.Tag = "";
+            this.ma_code.TextBoxEnable = false;
+            // 
             // cd_stepcode
             // 
             this.cd_stepcode.AllPower = "ifall";
@@ -583,7 +604,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.ms_reworkcheckno.AutoSize = true;
             this.ms_reworkcheckno.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_reworkcheckno.Location = new System.Drawing.Point(1580, 115);
+            this.ms_reworkcheckno.Location = new System.Drawing.Point(1581, 115);
             this.ms_reworkcheckno.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ms_reworkcheckno.Name = "ms_reworkcheckno";
             this.ms_reworkcheckno.Size = new System.Drawing.Size(146, 41);
@@ -597,7 +618,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.ms_makecode_label.AutoSize = true;
             this.ms_makecode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_makecode_label.Location = new System.Drawing.Point(409, 70);
+            this.ms_makecode_label.Location = new System.Drawing.Point(410, 70);
             this.ms_makecode_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ms_makecode_label.Name = "ms_makecode_label";
             this.ms_makecode_label.Size = new System.Drawing.Size(114, 41);
@@ -610,7 +631,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.ms_sncode_label.AutoSize = true;
             this.ms_sncode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_sncode_label.Location = new System.Drawing.Point(34, 67);
+            this.ms_sncode_label.Location = new System.Drawing.Point(35, 67);
             this.ms_sncode_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ms_sncode_label.Name = "ms_sncode_label";
             this.ms_sncode_label.Size = new System.Drawing.Size(114, 41);
@@ -623,7 +644,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.ms_checkno.AutoSize = true;
             this.ms_checkno.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_checkno.Location = new System.Drawing.Point(1576, 51);
+            this.ms_checkno.Location = new System.Drawing.Point(1577, 51);
             this.ms_checkno.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ms_checkno.Name = "ms_checkno";
             this.ms_checkno.Size = new System.Drawing.Size(146, 41);
@@ -639,7 +660,7 @@
             this.RepairComplete.Font = new System.Drawing.Font("微软雅黑", 9F);
             this.RepairComplete.Image = null;
             this.RepairComplete.IsShowBorder = true;
-            this.RepairComplete.Location = new System.Drawing.Point(1072, 131);
+            this.RepairComplete.Location = new System.Drawing.Point(1088, 132);
             this.RepairComplete.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
             this.RepairComplete.MoveImage = ((System.Drawing.Image)(resources.GetObject("RepairComplete.MoveImage")));
             this.RepairComplete.Name = "RepairComplete";
@@ -659,7 +680,7 @@
             this.ms_sncode.AutoSize = true;
             this.ms_sncode.CutLength = null;
             this.ms_sncode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_sncode.Location = new System.Drawing.Point(183, 70);
+            this.ms_sncode.Location = new System.Drawing.Point(184, 70);
             this.ms_sncode.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ms_sncode.MaximumSize = new System.Drawing.Size(300, 0);
             this.ms_sncode.Name = "ms_sncode";
@@ -692,7 +713,7 @@
             this.nr_code.AutoSize = true;
             this.nr_code.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.nr_code.ForeColor = System.Drawing.Color.Black;
-            this.nr_code.Location = new System.Drawing.Point(1676, 440);
+            this.nr_code.Location = new System.Drawing.Point(1677, 440);
             this.nr_code.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.nr_code.Name = "nr_code";
             this.nr_code.Size = new System.Drawing.Size(0, 41);
@@ -704,7 +725,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.st_rstepcode_label.AutoSize = true;
             this.st_rstepcode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.st_rstepcode_label.Location = new System.Drawing.Point(523, 138);
+            this.st_rstepcode_label.Location = new System.Drawing.Point(524, 138);
             this.st_rstepcode_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.st_rstepcode_label.Name = "st_rstepcode_label";
             this.st_rstepcode_label.Size = new System.Drawing.Size(146, 41);
@@ -717,7 +738,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.ma_craftcode_label.AutoSize = true;
             this.ma_craftcode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ma_craftcode_label.Location = new System.Drawing.Point(27, 139);
+            this.ma_craftcode_label.Location = new System.Drawing.Point(28, 139);
             this.ma_craftcode_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ma_craftcode_label.Name = "ma_craftcode_label";
             this.ma_craftcode_label.Size = new System.Drawing.Size(146, 41);
@@ -752,7 +773,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.pr_detail_label.AutoSize = true;
             this.pr_detail_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pr_detail_label.Location = new System.Drawing.Point(1276, 70);
+            this.pr_detail_label.Location = new System.Drawing.Point(1277, 70);
             this.pr_detail_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.pr_detail_label.Name = "pr_detail_label";
             this.pr_detail_label.Size = new System.Drawing.Size(146, 41);
@@ -765,7 +786,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.ms_prodcode_label.AutoSize = true;
             this.ms_prodcode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_prodcode_label.Location = new System.Drawing.Point(819, 70);
+            this.ms_prodcode_label.Location = new System.Drawing.Point(820, 70);
             this.ms_prodcode_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.ms_prodcode_label.Name = "ms_prodcode_label";
             this.ms_prodcode_label.Size = new System.Drawing.Size(146, 41);
@@ -779,41 +800,27 @@
             this.pr_detail.AutoSize = true;
             this.pr_detail.CutLength = null;
             this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pr_detail.Location = new System.Drawing.Point(1468, 70);
+            this.pr_detail.Location = new System.Drawing.Point(1469, 70);
             this.pr_detail.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.pr_detail.MaximumSize = new System.Drawing.Size(300, 0);
             this.pr_detail.Name = "pr_detail";
             this.pr_detail.Size = new System.Drawing.Size(0, 41);
             this.pr_detail.TabIndex = 82;
             // 
-            // ms_prodcode
+            // pr_code
             // 
-            this.ms_prodcode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
-            | System.Windows.Forms.AnchorStyles.Left)));
-            this.ms_prodcode.AutoSize = true;
-            this.ms_prodcode.CutLength = null;
-            this.ms_prodcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_prodcode.Location = new System.Drawing.Point(1011, 70);
-            this.ms_prodcode.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.ms_prodcode.MaximumSize = new System.Drawing.Size(300, 0);
-            this.ms_prodcode.Name = "ms_prodcode";
-            this.ms_prodcode.Size = new System.Drawing.Size(0, 41);
-            this.ms_prodcode.TabIndex = 20;
-            this.ms_prodcode.TextChanged += new System.EventHandler(this.ms_prodcode_TextChanged);
-            // 
-            // ms_makecode
-            // 
-            this.ms_makecode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            this.pr_code.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
             | System.Windows.Forms.AnchorStyles.Left)));
-            this.ms_makecode.AutoSize = true;
-            this.ms_makecode.CutLength = null;
-            this.ms_makecode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_makecode.Location = new System.Drawing.Point(569, 70);
-            this.ms_makecode.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.ms_makecode.MaximumSize = new System.Drawing.Size(300, 0);
-            this.ms_makecode.Name = "ms_makecode";
-            this.ms_makecode.Size = new System.Drawing.Size(0, 41);
-            this.ms_makecode.TabIndex = 85;
+            this.pr_code.AutoSize = true;
+            this.pr_code.CutLength = null;
+            this.pr_code.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_code.Location = new System.Drawing.Point(1012, 70);
+            this.pr_code.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.pr_code.MaximumSize = new System.Drawing.Size(300, 0);
+            this.pr_code.Name = "pr_code";
+            this.pr_code.Size = new System.Drawing.Size(0, 41);
+            this.pr_code.TabIndex = 20;
+            this.pr_code.TextChanged += new System.EventHandler(this.ms_prodcode_TextChanged);
             // 
             // mb_badremark
             // 
@@ -940,7 +947,7 @@
             this.RefreshTreeView.AllPower = null;
             this.RefreshTreeView.Cursor = System.Windows.Forms.Cursors.Hand;
             this.RefreshTreeView.Image = global::UAS_MES_NEW.Properties.Resources.refresh;
-            this.RefreshTreeView.Location = new System.Drawing.Point(171, 235);
+            this.RefreshTreeView.Location = new System.Drawing.Point(161, 237);
             this.RefreshTreeView.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
             this.RefreshTreeView.Name = "RefreshTreeView";
             this.RefreshTreeView.Power = null;
@@ -957,7 +964,7 @@
             | System.Windows.Forms.AnchorStyles.Left)));
             this.GetSNCode.BackColor = System.Drawing.Color.White;
             this.GetSNCode.ID = null;
-            this.GetSNCode.Location = new System.Drawing.Point(837, 1083);
+            this.GetSNCode.Location = new System.Drawing.Point(667, 1080);
             this.GetSNCode.Margin = new System.Windows.Forms.Padding(6, 5, 6, 5);
             this.GetSNCode.Name = "GetSNCode";
             this.GetSNCode.Power = null;
@@ -1221,12 +1228,12 @@
             ((System.ComponentModel.ISupportInitialize)(this.LocationSource)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.ComponentSource)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.BadInfo)).EndInit();
-            this.groupBoxWithBorder1.ResumeLayout(false);
+            this.groupBoxWithBorder1.ResumeLayout(true);
             this.groupBoxWithBorder1.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.mbp_partdgv)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.mbl_locdgv)).EndInit();
             ((System.ComponentModel.ISupportInitialize)(this.RefreshTreeView)).EndInit();
-            this.ResumeLayout(false);
+            this.ResumeLayout(true);
             this.PerformLayout();
 
         }
@@ -1248,8 +1255,7 @@
         private System.Windows.Forms.Label ms_makecode_label;
         private CustomControl.ButtonUtil.NormalButton Clean;
         private CustomControl.ValueLabel.ValueLabel pr_detail;
-        private CustomControl.ValueLabel.ValueLabel ms_prodcode;
-        private CustomControl.ValueLabel.ValueLabel ms_makecode;
+        private CustomControl.ValueLabel.ValueLabel pr_code;
         private CustomControl.RichText.RichTextAutoBottom OperatResult;
         private CustomControl.TextBoxWithIcon.EnterTextBox bg_name;
         private CustomControl.TextBoxWithIcon.EnterTextBox bc_name;
@@ -1310,5 +1316,6 @@
         private System.Windows.Forms.ColumnHeader bc_name1;
         private System.Windows.Forms.BindingSource BadInfo;
         private System.Windows.Forms.CheckBox checkBox1;
+        private CustomControl.TextBoxWithIcon.SearchTextBox ma_code;
     }
 }

+ 43 - 228
UAS_MES_YTDZ/FunctionCode/Make/Make_RepairoffLine.cs

@@ -37,8 +37,6 @@ namespace UAS_MES_NEW.Make
 
         AutoSizeFormClass asc = new AutoSizeFormClass();
 
-        string macode;
-
         string msid = "";
 
         string ifrework = "";
@@ -80,6 +78,13 @@ namespace UAS_MES_NEW.Make
             bd_soncode.DBTitle = "不良零件";
             bd_soncode.DbChange += Prodcode_DbChange;
 
+            ma_code.TableName = "make left join product on ma_prodcode=pr_code";
+            ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,ma_qty # 工单数量,pr_spec # 产品规格,pr_detail # 产品名称,ma_salecode # 销售单号,pr_sendchecktype # 产品送检方式,pr_pcbacount # 拼版数";
+            ma_code.FormName = Name;
+            ma_code.SetValueField = new string[] { "ma_code", "pr_code", "ma_qty", "pr_spec", "pr_detail", "ma_salecode", "nvl(pr_sendchecktype,'LineCode')pr_sendchecktype", "pr_pcbacount" };
+            ma_code.Condition = "ma_statuscode='STARTED'";
+            ma_code.DbChange += Prodcode_DbChange;
+
             //nrg_name.BringToFront();
             nrg_name.TableName = "QUA_NGREASONGROUP";
             nrg_name.Field = "nrg_name";
@@ -122,7 +127,7 @@ namespace UAS_MES_NEW.Make
                         sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
                         sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
                         sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + bd_soncode.Text + "',");
-                        sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
+                        sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + ma_code.Text + "',");
                         sql.Append("sysdate,'" + User.UserCode + "' from dual");
                         dh.ExecuteSql(sql.GetString(), "insert");
                         DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
@@ -157,196 +162,8 @@ namespace UAS_MES_NEW.Make
                     BadCodeTree.Nodes.Clear();
                     return;
                 }
-                sql.Clear();
-                sql.Append("select ms_status,ms_outboxcode,ms_paststep,ms_reworkstatus,nvl(ms_ifrework,0)ms_ifrework,ms_makecode from makeserial left join make ");
-                sql.Append("on ms_makecode=ma_code where ms_sncode = '" + GetSNCode.Text + "' order by ms_id desc");
-                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-                string ms_paststep = "";
-                if (dt.Rows.Count > 0)
-                {
-                    string ms_status = dt.Rows[0]["ms_status"].ToString();
-                    ms_paststep = dt.Rows[0]["ms_paststep"].ToString();
-                    ifrework = dt.Rows[0]["ms_ifrework"].ToString();
-                    reworkstatus = dt.Rows[0]["ms_reworkstatus"].ToString();
-                    string ms_makecode = dt.Rows[0]["ms_makecode"].ToString();
-                    if (dt.Rows[0]["ms_outboxcode"].ToString() != "")
-                    {
-                        OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已装箱,请先进行拆箱\n", Color.Red);
-                        BaseUtil.CleanForm(this);
-                        BadCodeTree.Nodes.Clear();
-                        return;
-                    }
-                    if (checkBox1.Checked)
-                    {
-                        if (ms_status == "3")
-                        {
-                            OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "处于维修状态\n", Color.Red);
-                            BaseUtil.CleanForm(this);
-                            BadCodeTree.Nodes.Clear();
-                            return;
-                        }
-                        string ErrorMessage1 = " ";
-                        string sp_id = dh.getFieldDataByCondition("steppassed", "max(sp_id)", "sp_makecode = '" + ms_makecode + "' and sp_sncode = '" + GetSNCode.Text + "' and sp_result = '良品'").ToString();
-                        if (sp_id != "")
-                        {
-                            string usecode = dh.getFieldDataByCondition("steppassed", "sp_sccode", "sp_id = " + sp_id + "").ToString();
-                            string stepcpde = dh.getFieldDataByCondition("steppassed", "sp_stepcode", "sp_id = " + sp_id + "").ToString();
-                            dh.UpdateByCondition("steppassed", "sp_result='不良品',sp_ifng=-1,sp_ymd=to_char(sysdate,'yyyymmdd'),sp_hm=to_char(sysdate,'hh24miss')", "sp_id=" + sp_id + "");
-                            dh.UpdateByCondition("makecraftdetail", "mcd_okqty=mcd_okqty-1", "mcd_macode='" + ms_makecode + "' and mcd_stepcode='" + stepcpde + "'");
-
-                        }
-                        LogicHandler.SetTestNGDetail(GetSNCode.Text, ms_makecode, User.UserCode, User.UserSourceCode, "检查未通过", out ErrorMessage1);
-                        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ms_makecode, User.UserLineCode, User.UserSourceCode, "采集成不良", "维修采集不良", GetSNCode.Text, "");
-                        OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不良采集成功\n", Color.Green, GetSNCode);
-                        return;
-                    }
-
-                    //如果不是返修序列号执行原来的步骤
-                    if (ifrework == "0")
-                    {
-                        if (ms_status == "4")
-                        {
-                            OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已处于报废状态\n", Color.Red);
-                            BaseUtil.CleanForm(this);
-                            BadCodeTree.Nodes.Clear();
-                            return;
-                        }
-                        if (ms_status != "3")
-                        {
-                            OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
-                            BaseUtil.CleanForm(this);
-                            BadCodeTree.Nodes.Clear();
-                            return;
-                        }
-                    }
-                    else
-                    {
-                        if (reworkstatus == "4")
-                        {
-                            OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "已处于报废状态\n", Color.Red);
-                            BaseUtil.CleanForm(this);
-                            BadCodeTree.Nodes.Clear();
-                            return;
-                        }
-                        if (reworkstatus != "0" && reworkstatus != "3")
-                        {
-                            OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不处于维修状态\n", Color.Red);
-                            BaseUtil.CleanForm(this);
-                            BadCodeTree.Nodes.Clear();
-                            return;
-                        }
-                    }
-                }
-                else
-                {
-                    OperatResult.AppendText(">>序列号:" + GetSNCode.Text + "不存在\n", Color.Red);
-                    BaseUtil.CleanForm(this);
-                    BadCodeTree.Nodes.Clear();
-                    return;
-                }
-                //dt = (DataTable)dh.ExecuteSql("select mb_stepcode from makebad where mb_sncode='" + GetSNCode.Text + "' and mb_status=0 order by mb_id desc", "select");
-                ////打不良的资源和当前资源相等可以快速维修,无须登录维修资源
-                //bool QuickRepair = false;
-                //if (dt.Rows.Count > 0)
-                //{
-                //    if (dt.Rows[0]["mb_stepcode"].ToString() == User.CurrentStepCode)
-                //    {
-                //        QuickRepair = true;
-                //    }
-                //}
-                string ErrorMessage = "";
-                //验证工序是否正确
-                if (LogicHandler.CheckStepAttribute(Tag.ToString(), User.UserSourceCode, out ErrorMessage))
-                {
-                    BadInf_1.Clear();
-                    string oStatus = "";
-                    if (LogicHandler.GetMakeInfo(GetSNCode.Text, out macode, out oStatus, out ErrorMessage))
-                    {
-                        //验证makeserial或者ms_firstsn表序列号是否存在
-                        sql.Clear();
-                        sql.Append("select max(ms_id) ms_id,ms_makecode,ma_craftcode,ms_stepcode,ms_firstsn,ms_prodcode,ms_sncode,pr_detail,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno ");
-                        sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on pr_code=ms_prodcode where ms_makecode ='" + macode + "' and ms_sncode in(");
-                        sql.Append("select '" + GetSNCode.Text + "' from dual union select firstsn from makesnrelation where ");
-                        sql.Append("sn='" + GetSNCode.Text + "') group by ms_makecode,ms_stepcode,ms_prodcode,ma_craftcode,ms_sncode,pr_detail,ms_firstsn,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno");
-                        dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-                        if (dt.Rows.Count > 0)
-                        {
-                            msid = dt.Rows[0]["ms_id"].ToString();
-                            ms_stepcode = dt.Rows[0]["ms_stepcode"].ToString();
-                            BaseUtil.SetFormValue(this.Controls, dt);
-                            //判断是否当前工单途程的上料记录
-                            firstsn = dt.Rows[0]["ms_firstsn"].ToString();
-                            string cdstepcode = "";
-                            sql.Clear();
-                            sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
-                            sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
-                            sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "' union select '" + firstsn + "' from dual)) ");
-                            sql.Append("and cm_craftcode='" + cr_code.Text + "'and nvl(cm_lastdeco,0)<>0 group by cm_craftcode,cm_stepcode,cm_soncode having ");
-                            sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
-                            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-                            if (dt.Rows.Count > 0)
-                            {
-                                //如果本工序包含老化则默认选择本工序,否则选择上料的后一道工序
-                                if (dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_ifburnin,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + dt.Rows[0]["cm_stepcode"].ToString() + "'").ToString() != "0")
-                                    cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
-                                else
-                                {
-                                    string nextstep = LogicHandler.GetNextStep(dt.Rows[0]["cm_craftcode"].ToString(), dt.Rows[0]["cm_stepcode"].ToString(), ms_prodcode.Text);
-                                    if (ms_paststep.Contains(nextstep))
-                                    {
-                                        cdstepcode = nextstep;
-                                    }
-                                    else
-                                    {
-                                        cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
-                                    }
-                                }
-                            }
-                            else
-                            {
-                                sql.Clear();
-                                sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
-                                sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
-                                sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "'  union select '" + firstsn + "' from dual)) ");
-                                sql.Append("and cm_craftcode='" + cr_code.Text + "' group by cm_craftcode,cm_stepcode,cm_soncode having ");
-                                sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
-                                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-                                if (dt.Rows.Count > 0)
-                                {
-                                    cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
-                                }
-                            }
-                            if (cdstepcode == "")
-                            {
-                                //序号小于等于当前不良的序号
-                                string currentdetno = dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "cd_detno", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + ms_stepcode + "'").ToString();
-                                sql.Clear();
-                                sql.Append("select cd_stepcode from craft left join craftdetail on cr_id =cd_crid where ");
-                                sql.Append("cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and  ");
-                                sql.Append("nvl(cd_ifburnin,0)<>0 and cd_detno <='" + currentdetno + "'");
-                                dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-                                if (dt.Rows.Count > 0)
-                                {
-                                    cdstepcode = dt.Rows[0][0].ToString();
-                                }
-                            }
-                            //如果ms_stepcode和扣料工序均没有查到返修的工序
-                            if (cdstepcode == "")
-                            {
-                                cdstepcode = ms_stepcode;
-                            }
-                            cd_stepcode.Text = cdstepcode;
-                            if (dh.getFieldDataByCondition("craftdetail left JOIN craft on cr_id = cd_crid", "nvl(cd_ifinput,0)cd_ifinput", "cr_code=  '" + cr_code.Text + "' and cr_prodcode = '" + ms_prodcode.Text + "' and cd_stepcode = '" + cd_stepcode.Text + "'").ToString() == "-1")
-                                cd_stepcode.Enabled = false;
-                            else
-                                cd_stepcode.Enabled = true;
-                            LoadBadInfTree(sender, e);
-                        }
-                        else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
-                    }
-                    else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
-                }
-                else OperatResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
+                LoadBadInfTree(sender, e);
+                ms_sncode.Text = GetSNCode.Text;
             }
         }
 
@@ -418,14 +235,14 @@ namespace UAS_MES_NEW.Make
             //不是返工工单时的取当前工单
             sql.Append("select mb_id,mb_sncode,mb_badcode,mb_bgcode,nvl(bc_name,mb_badcode) bc_name,nvl(bg_name,mb_bgcode) bg_name,");
             sql.Append("mb_badremark from makebad left join badcode on bc_code=mb_badcode left join badgroup ");
-            sql.Append("on bg_code=mb_bgcode where mb_sncode='" + (GetSNCode.Text == "" ? ms_sncode.Text : GetSNCode.Text) + "' and mb_makecode='" + macode + "' and mb_status=0");
+            sql.Append("on bg_code=mb_bgcode where mb_sncode='" + (GetSNCode.Text == "" ? ms_sncode.Text : GetSNCode.Text) + "' and mb_makecode='" + ma_code.Text + "' and mb_status=0");
             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             if (dt.Rows.Count == 0)
             {
                 sql.Clear();
                 sql.Append("select mb_id,mb_sncode,mb_badcode,mb_bgcode,nvl(bc_name,mb_badcode) bc_name,nvl(bg_name,mb_bgcode) bg_name, ");
                 sql.Append("mb_badremark from makebad left join badcode on bc_code=mb_badcode left join badgroup on bg_code=mb_bgcode  ");
-                sql.Append("left join make on ma_code=mb_makecode where mb_sncode='" + (GetSNCode.Text == "" ? ms_sncode.Text : GetSNCode.Text) + "' and mb_makecode<>'" + macode + "' and mb_status=0");
+                sql.Append("left join make on ma_code=mb_makecode where mb_sncode='" + (GetSNCode.Text == "" ? ms_sncode.Text : GetSNCode.Text) + "' and mb_makecode<>'" + ma_code.Text + "' and mb_status=0");
                 dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             }
             for (int i = 0; i < dt.Rows.Count; i++)
@@ -518,14 +335,14 @@ namespace UAS_MES_NEW.Make
             }
             if (ifrework != "0" && reworkstatus == "0")
             {
-                if (dh.getRowCount("Makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status=0") == 0)
+                if (dh.getRowCount("Makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and mb_status=0") == 0)
                 {
                     OperatResult.AppendText(">>维修必须维护不良代码\n", Color.Red);
                     return;
                 }
             }
             //判断是否所有的不良信息都有维护不良原因
-            DataTable dt = (DataTable)dh.ExecuteSql("select mb_id,bc_name,mbr_mbid from makebad left join makebadreason on mbr_mbid=mb_id left join badcode on mb_badcode=bc_code where mb_sncode='" + ms_sncode.Text + "'  and mb_makecode='" + ms_makecode.Text + "' and mb_status=0", "select");
+            DataTable dt = (DataTable)dh.ExecuteSql("select mb_id,bc_name,mbr_mbid from makebad left join makebadreason on mbr_mbid=mb_id left join badcode on mb_badcode=bc_code where mb_sncode='" + ms_sncode.Text + "'  and mb_makecode='" + ma_code.Text + "' and mb_status=0", "select");
             string ErrorMessage = "";
             for (int i = 0; i < dt.Rows.Count; i++)
             {
@@ -540,7 +357,7 @@ namespace UAS_MES_NEW.Make
             //查询拆解的物料
             sql.Clear();
             sql.Append("select distinct cm_soncode from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union ");
-            sql.Append("select sn from makesnrelation where firstsn='" + firstsn + "') and cm_craftcode<>'" + cr_code.Text + "' and cm_makecode<>'" + ms_makecode.Text + "' and cm_status=-1 ");
+            sql.Append("select sn from makesnrelation where firstsn='" + firstsn + "') and cm_craftcode<>'" + cr_code.Text + "' and cm_makecode<>'" + ma_code.Text + "' and cm_status=-1 ");
             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             //如果含有序列号物料有被拆解过
             if (dt.Rows.Count > 0)
@@ -580,7 +397,7 @@ namespace UAS_MES_NEW.Make
                     OperatResult.AppendText(">>回流工序不在回流工艺中\n", Color.Red);
                 else
                 {
-                    dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0) ms_ifrework", "ms_paststep" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
+                    dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0) ms_ifrework", "ms_paststep" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + ma_code.Text + "'");
                     List<string> SQLS = new List<string>();
                     if (dt.Rows.Count > 0)
                     {
@@ -597,12 +414,12 @@ namespace UAS_MES_NEW.Make
                         else
                             SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_reworkstatus=1 where ms_id='" + msid + "'");
                     }
-                    SQLS.Add("update makebad set mb_status=-1 where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "'");
+                    SQLS.Add("update makebad set mb_status=-1 where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "'");
                     //取消最近拆解部件
-                    SQLS.Add("update craftmaterial set cm_lastdeco=0 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + ms_makecode.Text + "' and nvl(cm_lastdeco,0)<>0");
+                    SQLS.Add("update craftmaterial set cm_lastdeco=0 where cm_sncode='" + ms_sncode.Text + "' and cm_makecode='" + ma_code.Text + "' and nvl(cm_lastdeco,0)<>0");
                     dh.ExecuteSQLTran(SQLS.ToArray());
-                    LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "回流工序", "完成维修回流", User.UserCode);
-                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "回流工序", "完成维修回流", ms_sncode.Text, ms_checkno.Text);
+                    LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "回流工序", "完成维修回流", User.UserCode);
+                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "回流工序", "完成维修回流", ms_sncode.Text, ms_checkno.Text);
                     OperatResult.AppendText(">>序列号" + ms_sncode.Text + "回流成功\n", Color.Green);
                     cd_stepcode.Enabled = true;
                     BaseUtil.CleanForm(this);
@@ -626,29 +443,29 @@ namespace UAS_MES_NEW.Make
                     string confirm = MessageBox.Show(this.ParentForm, "此操作不可撤销,是否确认报废", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk).ToString();
                     if (confirm == "Yes")
                     {
-                        DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcode" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
+                        DataTable dt = dh.getFieldsDataByCondition("makeserial", new string[] { "nvl(ms_ifrework,0)ms_ifrework", "ms_reworkcode" }, "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + ma_code.Text + "'");
                         if (dt.Rows.Count > 0)
                         {
                             string ms_ifrework = dt.Rows[0]["ms_ifrework"].ToString();
                             string reworkcode = dt.Rows[0]["ms_reworkcode"].ToString();
                             if (ms_ifrework == "0")
                             {
-                                dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_nextstepcode='',ms_stepcode='" + User.CurrentStepCode + "'", "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
+                                dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_nextstepcode='',ms_stepcode='" + User.CurrentStepCode + "'", "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + ma_code.Text + "'");
                             }
                             else
                             {
                                 sqls.Clear();
-                                sqls.Add("update makeserial set ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_reworkstatus= 4,ms_nextstepcode='',ms_stepcode='" + User.CurrentStepCode + "' where ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'");
+                                sqls.Add("update makeserial set ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_status=4,ms_reworkstatus= 4,ms_nextstepcode='',ms_stepcode='" + User.CurrentStepCode + "' where ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + ma_code.Text + "'");
                                 sqls.Add("update oqcbatch set ob_nowcheckqty=ob_nowcheckqty-1 where ob_checkno='" + ms_reworkcheckno.Text + "'");
                                 sqls.Add("delete from oqcbatchdetail where obd_sncode='" + ms_sncode.Text + "' and obd_checkno='" + ms_reworkcheckno.Text + "'");
                                 sqls.Add("update ReworkDetail set rd_rwstatus='报废' where rd_reid=(select re_id from rework where re_code='" + reworkcode + "') and rd_sncode='" + reworkcode + "'");
                                 dh.ExecuteSQLTran(sqls.ToArray());
                             }
                         }
-                        dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1", "mcd_macode='" + ms_makecode.Text + "' and mcd_stepcode='" + ms_stepcode + "'");
-                        dh.UpdateByCondition("make", "MA_NGMADEQTY=nvl(MA_NGMADEQTY,0)+1", "ma_code='" + macode + "'");
-                        LogicHandler.InsertMakeProcess(ms_sncode.Text, ms_makecode.Text, User.UserSourceCode, "报废", "序列号报废", User.UserCode);
-                        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, macode, User.UserLineCode, User.UserSourceCode, "报废", "序列号报废", ms_sncode.Text, ms_checkno.Text);
+                        dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1", "mcd_macode='" + ma_code.Text + "' and mcd_stepcode='" + ms_stepcode + "'");
+                        dh.UpdateByCondition("make", "MA_NGMADEQTY=nvl(MA_NGMADEQTY,0)+1", "ma_code='" + ma_code.Text + "'");
+                        LogicHandler.InsertMakeProcess(ms_sncode.Text, ma_code.Text, User.UserSourceCode, "报废", "序列号报废", User.UserCode);
+                        LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "报废", "序列号报废", ms_sncode.Text, ms_checkno.Text);
                         OperatResult.AppendText(">>报废成功\n", Color.Green);
                         GetSNCode.Clear();
                         BaseUtil.CleanForm(this);
@@ -661,13 +478,13 @@ namespace UAS_MES_NEW.Make
 
         private void NewBadCode_Click(object sender, EventArgs e)
         {
-            if (GetSNCode.Text == "" || macode == null || macode == "")
+            if (GetSNCode.Text == "" || ma_code.Text == "")
             {
                 OperatResult.AppendText(">>序列号和工单号不允许为空\n", Color.Red);
             }
             else
             {
-                Make_NewBadCode badcode = new Make_NewBadCode(GetSNCode.Text, macode);
+                Make_NewBadCode badcode = new Make_NewBadCode(GetSNCode.Text, ma_code.Text);
                 badcode.FormClosed += LoadBadInfTree;
                 BaseUtil.SetFormCenter(badcode);
                 badcode.ShowDialog();
@@ -742,7 +559,7 @@ namespace UAS_MES_NEW.Make
             sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
             sql.Append("mbr_inman,mbr_brname,mbr_solutionname,mbr_badname,mbr_brgname,mbr_dutyname) select '" + mb_id + "','" + mbr_id + "','" + nr_code.Text + "',");
             sql.Append("'" + so_code.Text + "','" + mbr_dutyname.Text + "','" + nrg_code.Text + "','" + bc_code.Text + "',");
-            sql.Append("'" + ms_sncode.Text + "','" + ms_makecode.Text + "',sysdate,'" + User.UserCode + "','" + nr_name.Text + "','" + so_name.Text + "','" + bc_name.Text + "','" + nrg_name.Text + "','" + mbr_dutyname.Text + "' from dual");
+            sql.Append("'" + ms_sncode.Text + "','" + ma_code.Text + "',sysdate,'" + User.UserCode + "','" + nr_name.Text + "','" + so_name.Text + "','" + bc_name.Text + "','" + nrg_name.Text + "','" + mbr_dutyname.Text + "' from dual");
             dh.ExecuteSql(sql.GetString(), "insert");
             if (mbc_component.Text != "")
             {
@@ -750,7 +567,7 @@ namespace UAS_MES_NEW.Make
                 sql.Append("insert into makebadrscom (mbc_id,mbc_mbrid,mbc_component,mbc_badcode,");
                 sql.Append("mbc_brcode,mbc_sncode,mbc_makecode,mbc_indate,mbc_inman ) values ");
                 sql.Append("(makebadrscom_seq.nextval,'" + mbr_id + "' ,'" + mbc_component.Text + "',");
-                sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + ms_sncode.Text + "','" + ms_makecode.Text + "',sysdate,'" + User.UserCode + "')");
+                sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + ms_sncode.Text + "','" + ma_code.Text + "',sysdate,'" + User.UserCode + "')");
                 dh.ExecuteSql(sql.GetString(), "insert");
             }
             OperatResult.AppendText(">>不良原因保存成功\n", Color.Green);
@@ -797,14 +614,14 @@ namespace UAS_MES_NEW.Make
                             sql.Clear();
                             sql.Append("insert into makebadrsloc(mbl_id,mbl_mbrid,mbl_loc,mbl_badcode,mbl_brcode,");
                             sql.Append("mbl_sncode,mbl_makecode,mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval," + mbr_id);
-                            sql.Append(",'" + mbl_loc.Text.ToUpper() + "','" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
+                            sql.Append(",'" + mbl_loc.Text.ToUpper() + "','" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + ma_code.Text + "',");
                             sql.Append("sysdate,'" + User.UserCode + "' from dual");
                             dh.ExecuteSql(sql.GetString(), "insert");
                             dt = (DataTable)dh.ExecuteSql("select mbl_id,mbl_loc from makebadrsloc where mbl_mbrid=" + mbr_id, "select");
                             BaseUtil.FillDgvWithDataTable(mbl_locdgv, dt);
                             sql.Clear();
                             sql.Append("with temp1 as (select bd_soncode,bd_location from bomdetail,bom where bo_id=bd_bomid ");
-                            sql.Append(" start with bo_mothercode='" + ms_prodcode.Text + "' connect by bo_mothercode= prior bd_soncode) ");
+                            sql.Append(" start with bo_mothercode='" + pr_code.Text + "' connect by bo_mothercode= prior bd_soncode) ");
                             sql.Append("select bd_soncode from temp1 where instr(','||bd_location||',','," + mbl_loc.Text.ToUpper() + ",')>0");
                             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             if (dt.Rows.Count > 0)
@@ -813,7 +630,7 @@ namespace UAS_MES_NEW.Make
                                 sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
                                 sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
                                 sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + dt.Rows[0][0].ToString() + "',");
-                                sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
+                                sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + ma_code.Text + "',");
                                 sql.Append("sysdate,'" + User.UserCode + "' from dual");
                                 dh.ExecuteSql(sql.GetString(), "insert");
                                 dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
@@ -856,7 +673,7 @@ namespace UAS_MES_NEW.Make
                         sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");
                         sql.Append("mbp_brcode,mbp_sncode,mbp_makecode,mbp_indate,mbp_inman)");
                         sql.Append("select makebadrspart_seq.nextval," + mbr_id + ",'" + bd_soncode.Text + "',");
-                        sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + macode + "',");
+                        sql.Append("'" + bc_code.Text + "','" + nr_code.Text + "','" + GetSNCode.Text + "','" + ma_code.Text + "',");
                         sql.Append("sysdate,'" + User.UserCode + "' from dual");
                         dh.ExecuteSql(sql.GetString(), "insert");
                         DataTable dt = (DataTable)dh.ExecuteSql("select mbp_id,mbp_part from makebadrspart where mbp_mbrid=" + mbr_id, "select");
@@ -870,7 +687,7 @@ namespace UAS_MES_NEW.Make
 
         private void cr_code_UserControlTextChanged(object sender, EventArgs e)
         {
-            cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
+            cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + pr_code.Text + "' order by cd_stepno";
         }
 
         private void Clean_Click(object sender, EventArgs e)
@@ -911,13 +728,13 @@ namespace UAS_MES_NEW.Make
 
         private void ms_prodcode_TextChanged(object sender, EventArgs e)
         {
-            if (ms_prodcode.Text != "")
-                cr_code.Condition = "cr_prodcode='" + ms_prodcode.Text + "'";
+            if (pr_code.Text != "")
+                cr_code.Condition = "cr_prodcode='" + pr_code.Text + "'";
             else
                 cr_code.Condition = "";
-            bd_soncode.Condition = "bd_mothercode='" + ms_prodcode.Text + "' and NVL(bd_usestatus,' ')<>'DISABLE'";
+            bd_soncode.Condition = "bd_mothercode='" + pr_code.Text + "' and NVL(bd_usestatus,' ')<>'DISABLE'";
             //设置工序的条件
-            cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' order by cd_stepno";
+            cd_stepcode.Condition = "ST_STATUSCODE='AUDITED' and cr_code='" + cr_code.Text + "' and cr_prodcode='" + pr_code.Text + "' order by cd_stepno";
         }
 
         public void RefreshData()
@@ -998,7 +815,7 @@ namespace UAS_MES_NEW.Make
 
         private void LoadBadcodeGroup()
         {
-            string pr_code = dh.getFieldDataByCondition("makeserial", "ms_prodcode", "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + macode + "'").ToString();
+            string pr_code = dh.getFieldDataByCondition("makeserial", "ms_prodcode", "ms_sncode='" + ms_sncode.Text + "' and ms_makecode='" + ma_code.Text + "'").ToString();
             sql.Clear();
             sql.Append("select bg_code,bg_name from product left join productkind  on pr_kind =pk_name ");
             sql.Append("left join productbadgroup on pb_kindcode= pk_code left join badgroup on ");
@@ -1048,8 +865,6 @@ namespace UAS_MES_NEW.Make
                 WaitRejectList.Items.Add(lvi);
             }
             WaitRejectList.EndUpdate();
-
-
         }
 
         private void badgroup_SelectedIndexChanged(object sender, EventArgs e)
@@ -1122,12 +937,12 @@ namespace UAS_MES_NEW.Make
                         }
                     }
                     sql.Clear();
-                    sql.Append("insert when (not exists(select 1 from makebad where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + macode + "' and  ");
+                    sql.Append("insert when (not exists(select 1 from makebad where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "' and  ");
                     sql.Append("mb_status=0 and mb_badcode=:bc_code)) then into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,");
                     sql.Append("mb_indate,mb_stepcode,mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_status)");
                     sql.Append("select DISTINCT :id,ma_code,ms_code,ms_sncode,'" + User.UserCode + "' t1,sysdate,'" + User.CurrentStepCode + "' t2,ms_sourcecode,:bd_code,:bg_code,'' t3,");
                     sql.Append("'0' from make left join makeSerial on ms_makecode=ma_code ");
-                    sql.Append(" where ms_sncode='" + ms_sncode.Text + "' and ms_makecode = '" + macode + "'");
+                    sql.Append(" where ms_sncode='" + ms_sncode.Text + "' and ms_makecode = '" + ma_code.Text + "'");
                     dh.BatchInsert(sql.GetString(), new string[] { "bc_code", "id", "bd_code", "bg_code" }, bccode, id, bccode, bgcode);
                     OperatResult.AppendText(">>不良插入成功\n", Color.Green);
                     LoadBadInfTree(sender, e);

+ 12 - 0
UAS_MES_YTDZ/FunctionCode/Make/Make_RepairoffLine.resx

@@ -247,6 +247,18 @@
   <metadata name="DeleteCom.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="mbp_part1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="DeleteCom.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="mbl_loc1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="DeletePos.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="mbl_loc1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>