浏览代码

修改ListView绑定数据的BUG,导致保存的时候Code没保存上

章政 8 年之前
父节点
当前提交
2438d4d9ae
共有 2 个文件被更改,包括 49 次插入52 次删除
  1. 40 34
      UAS-MES/FunctionCode/Make/Make_NewMatainInf.Designer.cs
  2. 9 18
      UAS-MES/FunctionCode/Make/Make_NewMatainInf.cs

+ 40 - 34
UAS-MES/FunctionCode/Make/Make_NewMatainInf.Designer.cs

@@ -68,9 +68,10 @@
             listViewItem1,
             listViewItem2,
             listViewItem3});
-            this.mbc_component_lsv.Location = new System.Drawing.Point(12, 159);
+            this.mbc_component_lsv.Location = new System.Drawing.Point(9, 127);
+            this.mbc_component_lsv.Margin = new System.Windows.Forms.Padding(2);
             this.mbc_component_lsv.Name = "mbc_component_lsv";
-            this.mbc_component_lsv.Size = new System.Drawing.Size(291, 190);
+            this.mbc_component_lsv.Size = new System.Drawing.Size(219, 153);
             this.mbc_component_lsv.TabIndex = 1;
             this.mbc_component_lsv.UseCompatibleStateImageBehavior = false;
             this.mbc_component_lsv.View = System.Windows.Forms.View.Details;
@@ -89,9 +90,10 @@
             this.nrg_name_lsv.Cursor = System.Windows.Forms.Cursors.Default;
             this.nrg_name_lsv.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.nrg_name_lsv.FullRowSelect = true;
-            this.nrg_name_lsv.Location = new System.Drawing.Point(309, 159);
+            this.nrg_name_lsv.Location = new System.Drawing.Point(232, 127);
+            this.nrg_name_lsv.Margin = new System.Windows.Forms.Padding(2);
             this.nrg_name_lsv.Name = "nrg_name_lsv";
-            this.nrg_name_lsv.Size = new System.Drawing.Size(264, 190);
+            this.nrg_name_lsv.Size = new System.Drawing.Size(199, 153);
             this.nrg_name_lsv.TabIndex = 2;
             this.nrg_name_lsv.UseCompatibleStateImageBehavior = false;
             this.nrg_name_lsv.View = System.Windows.Forms.View.Details;
@@ -99,7 +101,7 @@
             // 
             // nrg_code
             // 
-            this.nrg_code.Text = "";
+            this.nrg_code.Text = "不良原因组代码";
             this.nrg_code.Width = 0;
             // 
             // nrg_name
@@ -115,9 +117,10 @@
             this.nr_groupcode});
             this.nr_name_lsv.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.nr_name_lsv.FullRowSelect = true;
-            this.nr_name_lsv.Location = new System.Drawing.Point(581, 159);
+            this.nr_name_lsv.Location = new System.Drawing.Point(436, 127);
+            this.nr_name_lsv.Margin = new System.Windows.Forms.Padding(2);
             this.nr_name_lsv.Name = "nr_name_lsv";
-            this.nr_name_lsv.Size = new System.Drawing.Size(241, 381);
+            this.nr_name_lsv.Size = new System.Drawing.Size(182, 306);
             this.nr_name_lsv.TabIndex = 3;
             this.nr_name_lsv.UseCompatibleStateImageBehavior = false;
             this.nr_name_lsv.View = System.Windows.Forms.View.Details;
@@ -125,6 +128,7 @@
             // 
             // nr_code
             // 
+            this.nr_code.Text = "不良原因代码";
             this.nr_code.Width = 0;
             // 
             // nr_name
@@ -143,9 +147,10 @@
             this.nd_name});
             this.mbr_dutycode_lsv.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.mbr_dutycode_lsv.FullRowSelect = true;
-            this.mbr_dutycode_lsv.Location = new System.Drawing.Point(12, 355);
+            this.mbr_dutycode_lsv.Location = new System.Drawing.Point(9, 284);
+            this.mbr_dutycode_lsv.Margin = new System.Windows.Forms.Padding(2);
             this.mbr_dutycode_lsv.Name = "mbr_dutycode_lsv";
-            this.mbr_dutycode_lsv.Size = new System.Drawing.Size(291, 185);
+            this.mbr_dutycode_lsv.Size = new System.Drawing.Size(219, 149);
             this.mbr_dutycode_lsv.TabIndex = 5;
             this.mbr_dutycode_lsv.UseCompatibleStateImageBehavior = false;
             this.mbr_dutycode_lsv.View = System.Windows.Forms.View.Details;
@@ -168,9 +173,10 @@
             this.so_name});
             this.mbr_solutioncode_lsv.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.mbr_solutioncode_lsv.FullRowSelect = true;
-            this.mbr_solutioncode_lsv.Location = new System.Drawing.Point(309, 355);
+            this.mbr_solutioncode_lsv.Location = new System.Drawing.Point(232, 284);
+            this.mbr_solutioncode_lsv.Margin = new System.Windows.Forms.Padding(2);
             this.mbr_solutioncode_lsv.Name = "mbr_solutioncode_lsv";
-            this.mbr_solutioncode_lsv.Size = new System.Drawing.Size(264, 185);
+            this.mbr_solutioncode_lsv.Size = new System.Drawing.Size(199, 149);
             this.mbr_solutioncode_lsv.TabIndex = 6;
             this.mbr_solutioncode_lsv.UseCompatibleStateImageBehavior = false;
             this.mbr_solutioncode_lsv.View = System.Windows.Forms.View.Details;
@@ -193,12 +199,13 @@
             this.Cancel.DownImage = ((System.Drawing.Image)(resources.GetObject("Cancel.DownImage")));
             this.Cancel.Image = null;
             this.Cancel.IsShowBorder = true;
-            this.Cancel.Location = new System.Drawing.Point(435, 563);
+            this.Cancel.Location = new System.Drawing.Point(326, 450);
+            this.Cancel.Margin = new System.Windows.Forms.Padding(2);
             this.Cancel.MoveImage = ((System.Drawing.Image)(resources.GetObject("Cancel.MoveImage")));
             this.Cancel.Name = "Cancel";
             this.Cancel.NormalImage = ((System.Drawing.Image)(resources.GetObject("Cancel.NormalImage")));
             this.Cancel.Power = null;
-            this.Cancel.Size = new System.Drawing.Size(80, 35);
+            this.Cancel.Size = new System.Drawing.Size(60, 28);
             this.Cancel.TabIndex = 58;
             this.Cancel.Text = "取消";
             this.Cancel.UseVisualStyleBackColor = false;
@@ -211,12 +218,13 @@
             this.Save.DownImage = ((System.Drawing.Image)(resources.GetObject("Save.DownImage")));
             this.Save.Image = null;
             this.Save.IsShowBorder = true;
-            this.Save.Location = new System.Drawing.Point(317, 563);
+            this.Save.Location = new System.Drawing.Point(238, 450);
+            this.Save.Margin = new System.Windows.Forms.Padding(2);
             this.Save.MoveImage = ((System.Drawing.Image)(resources.GetObject("Save.MoveImage")));
             this.Save.Name = "Save";
             this.Save.NormalImage = ((System.Drawing.Image)(resources.GetObject("Save.NormalImage")));
             this.Save.Power = null;
-            this.Save.Size = new System.Drawing.Size(80, 35);
+            this.Save.Size = new System.Drawing.Size(60, 28);
             this.Save.TabIndex = 57;
             this.Save.Text = "保存";
             this.Save.UseVisualStyleBackColor = false;
@@ -231,9 +239,11 @@
             this.groupBoxWithBorder1.Controls.Add(this.bg_name_label);
             this.groupBoxWithBorder1.Dock = System.Windows.Forms.DockStyle.Top;
             this.groupBoxWithBorder1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.groupBoxWithBorder1.Location = new System.Drawing.Point(0, 40);
+            this.groupBoxWithBorder1.Location = new System.Drawing.Point(0, 32);
+            this.groupBoxWithBorder1.Margin = new System.Windows.Forms.Padding(2);
             this.groupBoxWithBorder1.Name = "groupBoxWithBorder1";
-            this.groupBoxWithBorder1.Size = new System.Drawing.Size(832, 100);
+            this.groupBoxWithBorder1.Padding = new System.Windows.Forms.Padding(2);
+            this.groupBoxWithBorder1.Size = new System.Drawing.Size(624, 80);
             this.groupBoxWithBorder1.TabIndex = 4;
             this.groupBoxWithBorder1.TabStop = false;
             this.groupBoxWithBorder1.Text = "工单信息";
@@ -249,11 +259,10 @@
             this.bc_name.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.bc_name.ForeColor = System.Drawing.Color.Black;
             this.bc_name.ID = null;
-            this.bc_name.Location = new System.Drawing.Point(538, 42);
-            this.bc_name.Margin = new System.Windows.Forms.Padding(4);
+            this.bc_name.Location = new System.Drawing.Point(404, 34);
             this.bc_name.Name = "bc_name";
             this.bc_name.Power = null;
-            this.bc_name.Size = new System.Drawing.Size(187, 27);
+            this.bc_name.Size = new System.Drawing.Size(141, 23);
             this.bc_name.Str = null;
             this.bc_name.Str1 = null;
             this.bc_name.Str2 = null;
@@ -264,10 +273,9 @@
             // 
             this.bc_name_label.AutoSize = true;
             this.bc_name_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.bc_name_label.Location = new System.Drawing.Point(411, 42);
-            this.bc_name_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.bc_name_label.Location = new System.Drawing.Point(308, 34);
             this.bc_name_label.Name = "bc_name_label";
-            this.bc_name_label.Size = new System.Drawing.Size(92, 27);
+            this.bc_name_label.Size = new System.Drawing.Size(74, 21);
             this.bc_name_label.TabIndex = 101;
             this.bc_name_label.Text = "不良代码";
             // 
@@ -281,11 +289,10 @@
             this.bg_name.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.bg_name.ForeColor = System.Drawing.Color.Black;
             this.bg_name.ID = null;
-            this.bg_name.Location = new System.Drawing.Point(170, 42);
-            this.bg_name.Margin = new System.Windows.Forms.Padding(4);
+            this.bg_name.Location = new System.Drawing.Point(128, 34);
             this.bg_name.Name = "bg_name";
             this.bg_name.Power = null;
-            this.bg_name.Size = new System.Drawing.Size(187, 27);
+            this.bg_name.Size = new System.Drawing.Size(141, 23);
             this.bg_name.Str = null;
             this.bg_name.Str1 = null;
             this.bg_name.Str2 = null;
@@ -296,10 +303,9 @@
             // 
             this.bg_name_label.AutoSize = true;
             this.bg_name_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.bg_name_label.Location = new System.Drawing.Point(25, 42);
-            this.bg_name_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.bg_name_label.Location = new System.Drawing.Point(19, 34);
             this.bg_name_label.Name = "bg_name_label";
-            this.bg_name_label.Size = new System.Drawing.Size(112, 27);
+            this.bg_name_label.Size = new System.Drawing.Size(90, 21);
             this.bg_name_label.TabIndex = 99;
             this.bg_name_label.Text = "不良代码组";
             // 
@@ -308,17 +314,16 @@
             this.headBar1.BackColor = System.Drawing.SystemColors.ControlDarkDark;
             this.headBar1.Dock = System.Windows.Forms.DockStyle.Top;
             this.headBar1.Location = new System.Drawing.Point(0, 0);
-            this.headBar1.Margin = new System.Windows.Forms.Padding(4);
             this.headBar1.Name = "headBar1";
-            this.headBar1.Size = new System.Drawing.Size(832, 40);
+            this.headBar1.Size = new System.Drawing.Size(624, 32);
             this.headBar1.TabIndex = 0;
             this.headBar1.Title = "新增维修信息";
             // 
             // Make_NewMatainInf
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(832, 610);
+            this.ClientSize = new System.Drawing.Size(624, 488);
             this.Controls.Add(this.Cancel);
             this.Controls.Add(this.Save);
             this.Controls.Add(this.mbr_solutioncode_lsv);
@@ -329,6 +334,7 @@
             this.Controls.Add(this.mbc_component_lsv);
             this.Controls.Add(this.headBar1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(2);
             this.Name = "Make_NewMatainInf";
             this.Tag = "ShowDialogWindow";
             this.Text = "Make_NewMatainInf";
@@ -358,11 +364,11 @@
         private System.Windows.Forms.ColumnHeader nd_code;
         private System.Windows.Forms.ColumnHeader so_code;
         private System.Windows.Forms.ColumnHeader nr_name;
-        private System.Windows.Forms.ColumnHeader nrg_code;
         private System.Windows.Forms.ColumnHeader nr_code;
         private System.Windows.Forms.ColumnHeader nr_groupcode;
         private System.Windows.Forms.ColumnHeader nd_name;
         private System.Windows.Forms.ColumnHeader so_name;
         private System.Windows.Forms.ColumnHeader columnHeader1;
+        private System.Windows.Forms.ColumnHeader nrg_code;
     }
 }

+ 9 - 18
UAS-MES/FunctionCode/Make/Make_NewMatainInf.cs

@@ -107,10 +107,9 @@ namespace UAS_MES.Make
             lsv.BeginUpdate();
             for (int i = 0; i < dt.Rows.Count; i++)
             {
-                ListViewItem lvi = new ListViewItem();
+                ListViewItem lvi = new ListViewItem(dt.Rows[i][0].ToString());
                 //第一列是勾选列,设置列头文本为空
-                lvi.Text = "";
-                for (int j = 0; j < dt.Columns.Count; j++)
+                for (int j = 1; j < dt.Columns.Count; j++) 
                     lvi.SubItems.Add(dt.Rows[i][j].ToString());
                 lsv.Items.Add(lvi);
             }
@@ -136,14 +135,12 @@ namespace UAS_MES.Make
 
         private string GetListViewSelectedItemText(ListView lsv)
         {
-            string Text = "";
-            //已存在在ListView中的Item是不能添加到其他ListView中的,需要调用其克隆的方法
             for (int i = lsv.Items.Count - 1; i >= 0; i--)
             {
                 if (lsv.Items[i].Selected)
-                    Text = lsv.Items[i].SubItems[0].Text;
+                    return lsv.Items[i].SubItems[0].Text;
             }
-            return Text;
+            return null;
         }
 
         private void Save_Click(object sender, EventArgs e)
@@ -171,15 +168,10 @@ namespace UAS_MES.Make
             {
                 ErrorMessage = "";
                 string mbccomponent = GetListViewSelectedItemText(mbc_component_lsv);
-                string nrgname = GetListViewSelectedItemText(nrg_name_lsv);
-                string nrname = GetListViewSelectedItemText(nr_name_lsv);
+                string nrgcode = GetListViewSelectedItemText(nrg_name_lsv);
+                string nrcode = GetListViewSelectedItemText(nr_name_lsv);
                 string mbrdutycode = GetListViewSelectedItemText(mbr_dutycode_lsv);
                 string mbrsolutioncode = GetListViewSelectedItemText(mbr_solutioncode_lsv);
-                Console.WriteLine(mbccomponent);
-                Console.WriteLine(nrgname);
-                Console.WriteLine(nrname);
-                Console.WriteLine(mbrdutycode);
-                Console.WriteLine(mbrsolutioncode);
                 dt = (DataTable)dh.ExecuteSql("select ms_makecode from makeserial where ms_id='" + msid + "' and ms_sncode='" + sncode + "' and ms_status=3", "select");
                 if (dt.Rows.Count > 0)
                 {
@@ -190,9 +182,8 @@ namespace UAS_MES.Make
                         sql.Clear();
                         sql.Append("insert into makebadreason (mbr_mbid,mbr_id,mbr_brcode,mbr_solutioncode,");
                         sql.Append("mbr_dutycode,mbr_brgcode,mbr_badcode,mbr_sncode,mbr_makecode,mbr_indate,");
-                        sql.Append("mbr_inman) select '" + mbid + "'," + mbr_id + ",'" + nrgname + "',");
-                        sql.Append("'" + mbrsolutioncode + "','" + mbrdutycode + "','" + nrgname + "','" + bccode
-                            + "',");
+                        sql.Append("mbr_inman) select '" + mbid + "'," + mbr_id + ",'" + nrgcode + "',");
+                        sql.Append("'" + mbrsolutioncode + "','" + mbrdutycode + "','" + nrcode + "','" + bccode+ "',");
                         sql.Append("'" + sncode + "','" + macode + "',sysdate,'" + User.UserCode + "' from dual");
                         dh.ExecuteSql(sql.GetString(), "insert");
                     }
@@ -205,7 +196,7 @@ namespace UAS_MES.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,'" + mbid + "' ,'" + mbccomponent + "',");
-                            sql.Append("'" + bccode + "','" + nrname + "','" + sncode + "','" + macode + "',sysdate,'" + User.UserCode + "')");
+                            sql.Append("'" + bccode + "','" + nrcode + "','" + sncode + "','" + macode + "',sysdate,'" + User.UserCode + "')");
                             dh.ExecuteSql(sql.GetString(), "insert");
                         }
                         else ErrorMessage += "序列号" + sncode + "已存在不良组件" + mbccomponent;