Browse Source

Merge remote-tracking branch 'refs/remotes/origin/master'

章政 8 years ago
parent
commit
d0f2c236e9

+ 259 - 65
UAS-MES/FunctionCode/Make/Make_Decompose.Designer.cs

@@ -35,7 +35,33 @@
             this.label3 = new System.Windows.Forms.Label();
             this.label4 = new System.Windows.Forms.Label();
             this.label5 = new System.Windows.Forms.Label();
-            this.LabelDataGridView = new UAS_MES.CustomControl.DataGrid_View.DataGridViewWithCheckBox();
+            this.LabelDataGridView = new System.Windows.Forms.DataGridView();
+            this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.dataGridViewCheckBoxColumn2 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewImageColumn1 = new System.Windows.Forms.DataGridViewImageColumn();
+            this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn7 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn8 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn9 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn10 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn11 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.ms_wccode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.ms_craftname = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.ms_craftcode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.deccount = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.ms_makecode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.pr_name = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.ms_prodcode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.ms_sncode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.Close = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.Decompose = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.sn_code = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.OperateResult = new UAS_MES.CustomControl.RichText.RichTextAutoBottom();
             this.Choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.Choose2 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
             this.cm_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -47,15 +73,9 @@
             this.cm_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.New_BarCode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.qqqqq = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.deccount = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
-            this.ms_makecode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
-            this.pr_name = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
-            this.ms_prodcode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
-            this.ms_sncode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
-            this.Close = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
-            this.Decompose = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
-            this.sn_code = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.OperateResult = new UAS_MES.CustomControl.RichText.RichTextAutoBottom();
+            this.cm_maid = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.cm_materialtype = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.cm_sncode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).BeginInit();
             this.SuspendLayout();
             // 
@@ -135,7 +155,10 @@
             this.cm_soncode,
             this.cm_barcode,
             this.New_BarCode,
-            this.qqqqq});
+            this.qqqqq,
+            this.cm_maid,
+            this.cm_materialtype,
+            this.cm_sncode});
             this.LabelDataGridView.Location = new System.Drawing.Point(12, 105);
             this.LabelDataGridView.Name = "LabelDataGridView";
             this.LabelDataGridView.RowTemplate.Height = 23;
@@ -144,80 +167,132 @@
             this.LabelDataGridView.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.LabelDataGridView_CellClick);
             this.LabelDataGridView.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.LabelDataGridView_CellContentClick);
             // 
-            // Choose
+            // dataGridViewCheckBoxColumn1
             // 
-            this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.Choose.HeaderText = "拆解更料";
-            this.Choose.Name = "Choose";
-            this.Choose.Width = 60;
+            this.dataGridViewCheckBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.dataGridViewCheckBoxColumn1.HeaderText = "拆解更料";
+            this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1";
+            this.dataGridViewCheckBoxColumn1.Width = 60;
             // 
-            // Choose2
+            // dataGridViewCheckBoxColumn2
             // 
-            this.Choose2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.Choose2.HeaderText = "拆解";
-            this.Choose2.Name = "Choose2";
-            this.Choose2.Width = 40;
+            this.dataGridViewCheckBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.dataGridViewCheckBoxColumn2.HeaderText = "拆解";
+            this.dataGridViewCheckBoxColumn2.Name = "dataGridViewCheckBoxColumn2";
+            this.dataGridViewCheckBoxColumn2.Width = 40;
             // 
-            // cm_id
+            // dataGridViewTextBoxColumn1
             // 
-            this.cm_id.DataPropertyName = "cm_id";
-            this.cm_id.HeaderText = "cm_id";
-            this.cm_id.Name = "cm_id";
-            this.cm_id.Visible = false;
-            this.cm_id.Width = 5;
+            this.dataGridViewTextBoxColumn1.DataPropertyName = "cm_id";
+            this.dataGridViewTextBoxColumn1.HeaderText = "cm_id";
+            this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
+            this.dataGridViewTextBoxColumn1.Visible = false;
+            this.dataGridViewTextBoxColumn1.Width = 5;
             // 
-            // pr_detail
+            // dataGridViewTextBoxColumn2
             // 
-            this.pr_detail.DataPropertyName = "pr_detail";
-            this.pr_detail.HeaderText = "pr_detail";
-            this.pr_detail.Name = "pr_detail";
-            this.pr_detail.Visible = false;
-            this.pr_detail.Width = 80;
+            this.dataGridViewTextBoxColumn2.DataPropertyName = "pr_detail";
+            this.dataGridViewTextBoxColumn2.HeaderText = "pr_detail";
+            this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
+            this.dataGridViewTextBoxColumn2.Visible = false;
+            this.dataGridViewTextBoxColumn2.Width = 80;
             // 
-            // mb_bgcode
+            // dataGridViewTextBoxColumn3
             // 
-            this.mb_bgcode.HeaderText = "不良代码组编号";
-            this.mb_bgcode.Name = "mb_bgcode";
-            this.mb_bgcode.Visible = false;
-            this.mb_bgcode.Width = 80;
+            this.dataGridViewTextBoxColumn3.HeaderText = "不良代码组编号";
+            this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
+            this.dataGridViewTextBoxColumn3.Visible = false;
+            this.dataGridViewTextBoxColumn3.Width = 80;
             // 
-            // mb_badcode
+            // dataGridViewTextBoxColumn4
             // 
-            this.mb_badcode.HeaderText = "不良代码编号";
-            this.mb_badcode.Name = "mb_badcode";
-            this.mb_badcode.Width = 80;
+            this.dataGridViewTextBoxColumn4.HeaderText = "不良代码";
+            this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
+            this.dataGridViewTextBoxColumn4.Width = 80;
             // 
-            // AddBad
+            // dataGridViewImageColumn1
             // 
-            this.AddBad.HeaderText = "";
-            this.AddBad.Image = global::UAS_MES.Properties.Resources.plus;
-            this.AddBad.Name = "AddBad";
-            this.AddBad.Resizable = System.Windows.Forms.DataGridViewTriState.True;
-            this.AddBad.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
-            this.AddBad.Width = 20;
+            this.dataGridViewImageColumn1.HeaderText = "";
+            this.dataGridViewImageColumn1.Image = global::UAS_MES.Properties.Resources.plus;
+            this.dataGridViewImageColumn1.Name = "dataGridViewImageColumn1";
+            this.dataGridViewImageColumn1.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.dataGridViewImageColumn1.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            this.dataGridViewImageColumn1.Width = 20;
             // 
-            // cm_soncode
+            // dataGridViewTextBoxColumn5
             // 
-            this.cm_soncode.DataPropertyName = "cm_soncode";
-            this.cm_soncode.HeaderText = "子件编号";
-            this.cm_soncode.Name = "cm_soncode";
+            this.dataGridViewTextBoxColumn5.DataPropertyName = "cm_soncode";
+            this.dataGridViewTextBoxColumn5.HeaderText = "子件编号";
+            this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
             // 
-            // cm_barcode
+            // dataGridViewTextBoxColumn6
             // 
-            this.cm_barcode.DataPropertyName = "cm_barcode";
-            this.cm_barcode.HeaderText = "物料批号";
-            this.cm_barcode.Name = "cm_barcode";
+            this.dataGridViewTextBoxColumn6.DataPropertyName = "cm_barcode";
+            this.dataGridViewTextBoxColumn6.HeaderText = "物料批号";
+            this.dataGridViewTextBoxColumn6.Name = "dataGridViewTextBoxColumn6";
             // 
-            // New_BarCode
+            // dataGridViewTextBoxColumn7
             // 
-            this.New_BarCode.HeaderText = "新批号";
-            this.New_BarCode.Name = "New_BarCode";
+            this.dataGridViewTextBoxColumn7.HeaderText = "新批号";
+            this.dataGridViewTextBoxColumn7.Name = "dataGridViewTextBoxColumn7";
             // 
-            // qqqqq
+            // dataGridViewTextBoxColumn8
             // 
-            this.qqqqq.HeaderText = "";
-            this.qqqqq.Name = "qqqqq";
-            this.qqqqq.Width = 5;
+            this.dataGridViewTextBoxColumn8.HeaderText = "";
+            this.dataGridViewTextBoxColumn8.Name = "dataGridViewTextBoxColumn8";
+            this.dataGridViewTextBoxColumn8.Width = 5;
+            // 
+            // dataGridViewTextBoxColumn9
+            // 
+            this.dataGridViewTextBoxColumn9.DataPropertyName = "cm_maid";
+            this.dataGridViewTextBoxColumn9.HeaderText = "";
+            this.dataGridViewTextBoxColumn9.Name = "dataGridViewTextBoxColumn9";
+            this.dataGridViewTextBoxColumn9.Visible = false;
+            // 
+            // dataGridViewTextBoxColumn10
+            // 
+            this.dataGridViewTextBoxColumn10.HeaderText = "";
+            this.dataGridViewTextBoxColumn10.Name = "dataGridViewTextBoxColumn10";
+            this.dataGridViewTextBoxColumn10.Visible = false;
+            // 
+            // dataGridViewTextBoxColumn11
+            // 
+            this.dataGridViewTextBoxColumn11.HeaderText = "";
+            this.dataGridViewTextBoxColumn11.Name = "dataGridViewTextBoxColumn11";
+            this.dataGridViewTextBoxColumn11.Visible = false;
+            // 
+            // ms_wccode
+            // 
+            this.ms_wccode.AutoSize = true;
+            this.ms_wccode.CutLength = null;
+            this.ms_wccode.Location = new System.Drawing.Point(931, 86);
+            this.ms_wccode.MaximumSize = new System.Drawing.Size(200, 0);
+            this.ms_wccode.Name = "ms_wccode";
+            this.ms_wccode.Size = new System.Drawing.Size(0, 12);
+            this.ms_wccode.TabIndex = 191;
+            this.ms_wccode.Visible = false;
+            // 
+            // ms_craftname
+            // 
+            this.ms_craftname.AutoSize = true;
+            this.ms_craftname.CutLength = null;
+            this.ms_craftname.Location = new System.Drawing.Point(856, 87);
+            this.ms_craftname.MaximumSize = new System.Drawing.Size(200, 0);
+            this.ms_craftname.Name = "ms_craftname";
+            this.ms_craftname.Size = new System.Drawing.Size(0, 12);
+            this.ms_craftname.TabIndex = 190;
+            this.ms_craftname.Visible = false;
+            // 
+            // ms_craftcode
+            // 
+            this.ms_craftcode.AutoSize = true;
+            this.ms_craftcode.CutLength = null;
+            this.ms_craftcode.Location = new System.Drawing.Point(720, 87);
+            this.ms_craftcode.MaximumSize = new System.Drawing.Size(200, 0);
+            this.ms_craftcode.Name = "ms_craftcode";
+            this.ms_craftcode.Size = new System.Drawing.Size(0, 12);
+            this.ms_craftcode.TabIndex = 189;
+            this.ms_craftcode.Visible = false;
             // 
             // deccount
             // 
@@ -312,6 +387,7 @@
             this.Decompose.TabIndex = 175;
             this.Decompose.Text = "确定拆解";
             this.Decompose.UseVisualStyleBackColor = true;
+            this.Decompose.Click += new System.EventHandler(this.Decompose_Click);
             // 
             // sn_code
             // 
@@ -337,11 +413,109 @@
             this.OperateResult.TabIndex = 172;
             this.OperateResult.Text = "";
             // 
+            // Choose
+            // 
+            this.Choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.Choose.HeaderText = "拆解更料";
+            this.Choose.Name = "Choose";
+            this.Choose.Width = 60;
+            // 
+            // Choose2
+            // 
+            this.Choose2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.Choose2.HeaderText = "拆解";
+            this.Choose2.Name = "Choose2";
+            this.Choose2.Width = 40;
+            // 
+            // cm_id
+            // 
+            this.cm_id.DataPropertyName = "cm_id";
+            this.cm_id.HeaderText = "cm_id";
+            this.cm_id.Name = "cm_id";
+            this.cm_id.Width = 5;
+            // 
+            // pr_detail
+            // 
+            this.pr_detail.DataPropertyName = "pr_detail";
+            this.pr_detail.HeaderText = "pr_detail";
+            this.pr_detail.Name = "pr_detail";
+            this.pr_detail.Visible = false;
+            this.pr_detail.Width = 80;
+            // 
+            // mb_bgcode
+            // 
+            this.mb_bgcode.HeaderText = "不良代码组编号";
+            this.mb_bgcode.Name = "mb_bgcode";
+            this.mb_bgcode.Visible = false;
+            this.mb_bgcode.Width = 80;
+            // 
+            // mb_badcode
+            // 
+            this.mb_badcode.HeaderText = "不良代码";
+            this.mb_badcode.Name = "mb_badcode";
+            this.mb_badcode.Width = 80;
+            // 
+            // AddBad
+            // 
+            this.AddBad.HeaderText = "";
+            this.AddBad.Image = global::UAS_MES.Properties.Resources.plus;
+            this.AddBad.Name = "AddBad";
+            this.AddBad.Resizable = System.Windows.Forms.DataGridViewTriState.True;
+            this.AddBad.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
+            this.AddBad.Width = 20;
+            // 
+            // cm_soncode
+            // 
+            this.cm_soncode.DataPropertyName = "cm_soncode";
+            this.cm_soncode.HeaderText = "子件编号";
+            this.cm_soncode.Name = "cm_soncode";
+            // 
+            // cm_barcode
+            // 
+            this.cm_barcode.DataPropertyName = "cm_barcode";
+            this.cm_barcode.HeaderText = "物料批号";
+            this.cm_barcode.Name = "cm_barcode";
+            // 
+            // New_BarCode
+            // 
+            this.New_BarCode.HeaderText = "新批号";
+            this.New_BarCode.Name = "New_BarCode";
+            // 
+            // qqqqq
+            // 
+            this.qqqqq.HeaderText = "";
+            this.qqqqq.Name = "qqqqq";
+            this.qqqqq.Width = 5;
+            // 
+            // cm_maid
+            // 
+            this.cm_maid.DataPropertyName = "cm_maid";
+            this.cm_maid.HeaderText = "";
+            this.cm_maid.Name = "cm_maid";
+            this.cm_maid.Visible = false;
+            // 
+            // cm_materialtype
+            // 
+            this.cm_materialtype.DataPropertyName = "cm_materialtype";
+            this.cm_materialtype.HeaderText = "";
+            this.cm_materialtype.Name = "cm_materialtype";
+            this.cm_materialtype.Visible = false;
+            // 
+            // cm_sncode
+            // 
+            this.cm_sncode.DataPropertyName = "cm_sncode";
+            this.cm_sncode.HeaderText = "";
+            this.cm_sncode.Name = "cm_sncode";
+            this.cm_sncode.Visible = false;
+            // 
             // Make_Decompose
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1120, 625);
+            this.Controls.Add(this.ms_wccode);
+            this.Controls.Add(this.ms_craftname);
+            this.Controls.Add(this.ms_craftcode);
             this.Controls.Add(this.LabelDataGridView);
             this.Controls.Add(this.deccount);
             this.Controls.Add(this.ms_makecode);
@@ -387,7 +561,23 @@
         private CustomControl.ValueLabel.ValueLabel pr_name;
         private CustomControl.ValueLabel.ValueLabel ms_makecode;
         private CustomControl.ValueLabel.ValueLabel deccount;
-        private CustomControl.DataGrid_View.DataGridViewWithCheckBox LabelDataGridView;
+        private System.Windows.Forms.DataGridView LabelDataGridView;
+        private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1;
+        private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn2;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
+        private System.Windows.Forms.DataGridViewImageColumn dataGridViewImageColumn1;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn5;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn6;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn7;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn8;
+        private CustomControl.ValueLabel.ValueLabel ms_craftcode;
+        private CustomControl.ValueLabel.ValueLabel ms_craftname;
+        private CustomControl.ValueLabel.ValueLabel ms_wccode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn9;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn10;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose;
         private System.Windows.Forms.DataGridViewCheckBoxColumn Choose2;
         private System.Windows.Forms.DataGridViewTextBoxColumn cm_id;
@@ -399,5 +589,9 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn cm_barcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn New_BarCode;
         private System.Windows.Forms.DataGridViewTextBoxColumn qqqqq;
+        private System.Windows.Forms.DataGridViewTextBoxColumn cm_maid;
+        private System.Windows.Forms.DataGridViewTextBoxColumn cm_materialtype;
+        private System.Windows.Forms.DataGridViewTextBoxColumn cm_sncode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn11;
     }
 }

+ 141 - 20
UAS-MES/FunctionCode/Make/Make_Decompose.cs

@@ -7,6 +7,7 @@ using System.Linq;
 using System.Text;
 using System.Windows.Forms;
 using UAS_MES.DataOperate;
+using UAS_MES.Entity;
 using UAS_MES.PublicMethod;
 
 namespace UAS_MES.Make
@@ -22,10 +23,15 @@ namespace UAS_MES.Make
         DataHelper dh;
         //记录当前序列号的ms_id
         string ms_id;
-
         //采集计数
         int count;
 
+        int rowindex;
+
+        string[] bccode ;
+        string[] bgcode;
+        string[] id ;
+
         public Make_Decompose()
         {
             InitializeComponent();
@@ -46,17 +52,34 @@ namespace UAS_MES.Make
             if (e.KeyCode == Keys.Enter)
             {
                 sql.Clear();
-                sql.Append("select max(ms_id) from makeserial where ms_sncode ='"+sn_code.Text+"' or  exists (select 1");
-                sql.Append(" from  makesnrelation where beforesn='"+ sn_code.Text + "'  and ms_makecode=makecode)");
+                sql.Append("select max(ms_id) from makeserial where ms_sncode ='" + sn_code.Text + "' or  exists (select 1");
+                sql.Append(" from  makesnrelation where beforesn='" + sn_code.Text + "'  and ms_makecode=makecode)");
                 dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                 ms_id = dt.Rows[0][0].ToString();
                 if (ms_id != "")
-                {  
+                {
                     sql.Clear();
-                    sql.Append("select ms_id,ms_status,ms_makecode,ms_prodcode,pr_detail ||',' || pr_spec pr_name ,ms_sncode from makeserial left join product on pr_code=ms_prodcode where ms_id='" + ms_id + "'");
+                    sql.Append("select ms_id,ms_status,ms_makecode,ms_prodcode,pr_detail ||',' || pr_spec pr_name ,ms_sncode,ms_firstsn,ms_craftcode,ms_craftname,ms_wccode from makeserial left join product on pr_code=ms_prodcode where ms_id='" + ms_id + "'");
                     dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-                    BaseUtil.SetFormValue(this.Controls, dt);
-                    LoadData();
+                    if (dt.Rows[0][1].ToString() != "0" && dt.Rows[0][1].ToString() != "1")
+                    {
+                        BaseUtil.SetFormValue(this.Controls, dt);
+                        if (dt.Rows[0][6].ToString() == "")
+                        {
+                            LoadData(ms_makecode.Text);
+                        }
+                        else {
+                            LoadData(dt.Rows[0][6].ToString());
+                        }
+                    }
+                    else
+                    {
+                        OperateResult.AppendText(">>序列号" + sn_code.Text + "必须是非在线状态才能做拆解\n", Color.Red);
+                        sn_code.Text = "";
+                        BaseUtil.CleanForm(this);
+                        sn_code.Focus();
+                        return;
+                    }
                 }
                 else {
                     ms_id = null;
@@ -70,12 +93,11 @@ namespace UAS_MES.Make
         }
 
 
-        private void LoadData()
+        private void LoadData(string sncode)
         {
-           //如果没有任何筛选条件直接选取productlabel的数据
             sql.Clear();
-            sql.Append("select cm_sncode,cm_maprodcode,cm_id,cm_soncode,cm_barcode,pr_detail from craftmaterial left join product on pr_code=cm_soncode where");
-            sql.Append(" cm_sncode='" + ms_sncode.Text + "' and cm_maprodcode='" + ms_prodcode.Text + "' and  nvl(cm_status,0)='0'");
+            sql.Append("select cm_sncode,cm_maprodcode,cm_maid,cm_id,cm_soncode,cm_barcode,pr_detail,cm_materialtype from craftmaterial left join product on pr_code=cm_soncode where");
+            sql.Append(" cm_sncode='" + sncode + "' and cm_maprodcode='" + ms_prodcode.Text + "' and  nvl(cm_status,0)='0'");
             dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             if (dt.Rows.Count > 0)
             {
@@ -103,13 +125,13 @@ namespace UAS_MES.Make
             {
                 if (LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value != null)
                 {
-                    if (LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value is Boolean)
+                    if ((Boolean)LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value == false)
                     {
-                        LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value = 1;
+                        LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value = true;
                     }
-                    if (LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value is int)
+                    if ((Boolean)LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value == true)
                     {
-                        LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value = 0;
+                        LabelDataGridView.Rows[e.RowIndex].Cells["Choose2"].Value = false;
                     }
                 }
             }
@@ -117,20 +139,119 @@ namespace UAS_MES.Make
             {
                 if (LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value != null)
                 {
-                    if (LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value is Boolean)
+                    if ((Boolean)LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value == false)
                     {
-                        LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value = 1;
+                        LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value = true;
                     }
-                    if (LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value is int)
+                    if ((Boolean)LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value == true)
                     {
-                        LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value = 0;
+                        LabelDataGridView.Rows[e.RowIndex].Cells["Choose"].Value = false;
                     }
                 }
             }
             else if (LabelDataGridView.Columns[e.ColumnIndex].Name == "AddBad")
             {
-                MessageBox.Show("点击");
+                if (ms_sncode.Text == "" || ms_makecode.Text == "" )
+                {
+                    OperateResult.AppendText(">>序列号和工单号不允许为空\n", Color.Red);
+                }
+                else
+                {
+                    rowindex = e.RowIndex;
+                    Make_NewBadCode badcode = new Make_NewBadCode(ms_sncode.Text, ms_makecode.Text);
+                    BaseUtil.SetFormCenter(badcode);
+                    badcode.FormClosed += LoadBadcode;
+                    badcode.ShowDialog();
+                }
+            }
+        }
+
+        private void LoadBadcode(object sender, EventArgs e)
+        {
+            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 ");
+            sql.Append("on bg_code=mb_bgcode where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status=0");
+            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+            if (dt.Rows.Count > 0) {
+                sql.Clear();
+                bccode = new string[dt.Rows.Count];
+                bgcode = new string[dt.Rows.Count];
+                id = new string[dt.Rows.Count];
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {     
+                    sql.Append( dt.Rows[i]["mb_bgcode"].ToString()+" : "+dt.Rows[i]["mb_badcode"].ToString()+"  ");
+                    bgcode[i] = dt.Rows[i]["mb_bgcode"].ToString();
+                    bccode[i] = dt.Rows[i]["mb_badcode"].ToString();
+                }            
+                LabelDataGridView.Rows[rowindex].Cells["mb_badcode"].Value = sql.GetString();
+            }
+        }
+
+        private void Decompose_Click(object sender, EventArgs e)
+        {
+
+            for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
+            {
+                if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
+                {
+                    if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose"].Value == true && (LabelDataGridView.Rows[i].Cells["mb_badcode"].Value == null|| LabelDataGridView.Rows[i].Cells["New_BarCode"].Value == null))
+                    {
+                        MessageBox.Show("第" + (i+1) + "行没有采集不良代码或新批号");
+                        return;
+                    }
+                }
+            }
+
+            for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
+            {
+                if (LabelDataGridView.Rows[i].Cells["Choose2"].Value != null || LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
+                {
+                    if (LabelDataGridView.Rows[i].Cells["Choose"].Value != null)
+                    {
+                        if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose"].Value == true)
+                        {
+                            sql.Clear();
+                            sql.Append("update craftmaterial set cm_status=-1,cm_dropman='" + User.UserName + "',");
+                            sql.Append("cm_dropdate =sysdate,cm_dropstep='" + User.CurrentStepName + "',");
+                            sql.Append("cm_dropsccode='" + User.CurrentStepCode + "' where cm_id='" + LabelDataGridView.Rows[i].Cells["cm_id"].Value + "'");
+                            dh.ExecuteSql(sql.GetString(), "update");
+                            //MakeBad表插入物料批号不良信息
+                            sql.Clear();
+                            sql.Append("insert into makebad (mb_id, mb_inman,mb_indate,mb_stepcode,mb_sourcecode,");
+                            sql.Append("mb_bgcode,mb_mscode,mb_sncode, mb_badcode, mb_makecode)");
+                            sql.Append("values (MakeBad_seq.nextval,'"+User.UserName+"',sysdate,'"+User.CurrentStepCode+"','"+User.UserSourceCode+ "',:bg_code ,'"+ LabelDataGridView.Rows[i].Cells["cm_barcode"].Value + "','"+ LabelDataGridView.Rows[i].Cells["cm_barcode"].Value + "',");
+                            sql.Append(":bc_code,'"+ms_makecode.Text+"')");
+                            dh.BatchInsert(sql.GetString(), new string[] { "bg_code", "bc_code" },bgcode,bccode);
+                            //将新批号绑定到序列号中
+                            dt = (DataTable)dh.ExecuteSql("select sp_id from stepproduct where sp_mothercode='" + ms_prodcode.Text + "'", "select");
+                            string sp_id = dt.Rows[0]["sp_id"].ToString();
+                            sql.Clear();
+                            sql.Append("insert into craftmaterial (cm_id, cm_makecode,cm_maid,cm_maprodcode,cm_soncode,cm_mscode,cm_sncode,cm_stepcode,cm_stepname,");
+                            sql.Append("cm_craftcode,cm_craftname,cm_barcode,cm_inqty,cm_indate,cm_inman,cm_linecode,cm_wccode,cm_sourcecode,cm_spid, cm_materialtype,cm_status)");
+                            sql.Append("values(Craftmaterial_seq.nextval,'"+ms_makecode.Text+"','"+ LabelDataGridView.Rows[i].Cells["cm_maid"].Value + "','"+ms_prodcode.Text+ "','" + LabelDataGridView.Rows[i].Cells["cm_soncode"].Value + "'");
+                            sql.Append(",'"+ LabelDataGridView.Rows[i].Cells["cm_sncode"].Value + "','"+ LabelDataGridView.Rows[i].Cells["cm_sncode"].Value + "','"+User.CurrentStepCode+"','"+User.CurrentStepName+"',");
+                            sql.Append("'"+ms_craftcode.Text+"','"+ms_craftname.Text+"','"+ LabelDataGridView.Rows[i].Cells["New_BarCode"].Value + "',1,sysdate,'"+User.UserName+"','"+User.UserLineCode+"','"+ms_wccode.Text+"',");
+                            sql.Append("'"+User.UserSourceCode+"','"+ sp_id + "','"+ LabelDataGridView.Rows[i].Cells["cm_materialtype"].Value + "','0')");
+                            dh.ExecuteSql(sql.GetString(), "insert");
+                            OperateResult.AppendText("物料" + LabelDataGridView.Rows[i].Cells["cm_barcode"].Value + "拆解换料成功\n", Color.Green);
+                        }
+                    }
+                    else if ((Boolean)LabelDataGridView.Rows[i].Cells["Choose2"].Value == true)
+                    {
+                        //craftmaterial解除相应物料绑定
+                        sql.Clear();
+                        sql.Append("update craftmaterial set cm_status=-1,cm_dropman='"+User.UserName+"',");
+                        sql.Append("cm_dropdate =sysdate,cm_dropstep='"+User.CurrentStepName+"',");
+                        sql.Append("cm_dropsccode='" + User.CurrentStepCode + "' where cm_id='"+ LabelDataGridView.Rows[i].Cells["cm_id"].Value + "'");
+                        dh.ExecuteSql(sql.GetString(), "update");
+                        OperateResult.AppendText("物料"+ LabelDataGridView.Rows[i].Cells["cm_barcode"].Value + "拆解成功\n",Color.Green);
+                    }
+                }
             }
+
+
         }
     }
 }
+    

+ 9 - 0
UAS-MES/FunctionCode/Make/Make_Decompose.resx

@@ -147,6 +147,15 @@
   <metadata name="qqqqq.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="cm_maid.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="cm_materialtype.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="cm_sncode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="Close.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>

+ 17 - 5
UAS-MES/FunctionCode/Make/Make_SeqProgramTransform.cs

@@ -271,7 +271,19 @@ namespace UAS_MES.Make
                 code.Text = "";
                 return false;
             }
-            if (!(ListA.Rows[step - 2]["psr_prefix"].ToString() == "" ? true : code.Text.StartsWith(ListA.Rows[step - 2]["psr_prefix"].ToString())))
+            //以|符号分割前缀
+            string[] preFixs = ListA.Rows[step - 2]["psr_prefix"].ToString().Split('|');
+            //只要满足其中一个前缀条件即可
+            bool isfit = false;
+            for (int i=0;i<preFixs.Length;i++) {
+                if (preFixs[i] == "" ? true : code.Text.StartsWith(preFixs[i]))
+                {
+                    //满足其中一条即可
+                    isfit = true;
+                    break;
+                }
+            }
+            if (!isfit)
             {
                 OperateResult.AppendText(">>" + ListA.Rows[step - 2]["psr_type"] + "前缀校验不通过,请重新输入\n", Color.Red);
                 OperateResult.AppendText(">>请重新输入" + ListA.Rows[step - 2]["psr_type"] + "\n", Color.Black);
@@ -310,8 +322,8 @@ namespace UAS_MES.Make
                 case "NETCODE":
                     if (checkExist("MS_" + type + "='" + code.Text + "'"))
                     {
-                        OperateResult.AppendText(">>" + type + ":" + code.Text + "错误,不允许重复\n", Color.Red);
-                        OperateResult.AppendText(">>请输入" + type + "\n", Color.Black);
+                        OperateResult.AppendText(">>" + ListA.Rows[step - 2]["psr_type"].ToString() + ":" + code.Text + "错误,不允许重复\n", Color.Red);
+                        OperateResult.AppendText(">>请输入" + ListA.Rows[step - 2]["psr_type"].ToString() + "\n", Color.Black);
                         code.Text = "";
                         return false;
                     }
@@ -320,7 +332,7 @@ namespace UAS_MES.Make
                     break;
             }
             //满足规则,则采集
-            hs.Add(type, code.Text);
+            hs.Add(ListA.Rows[step - 2]["psr_type"].ToString(), code.Text);
             //说明已经是最后一个校验规则
             if (step == ListA.Rows.Count + 1)
             {
@@ -332,7 +344,7 @@ namespace UAS_MES.Make
                     //遍历判断已采集的信息是否已存在
                     foreach (DictionaryEntry de in hs)
                     {
-                        if (dh.CheckExist("makeserial", "MS_" + de.Key + "='" + de.Value + "'"))
+                        if (dh.CheckExist("makeserial", "MS_" + de.Key=="WIFI"?"MAC":de.Key + "='" + de.Value + "'"))
                         {
                             flag = false;
                             OperateResult.AppendText(">>" + de.Key + "已被使用,请重新输入TSN,重新转换\n", Color.Red);