Преглед на файлове

修改岗位备料,针对已备料的行才允许删除

章政 преди 8 години
родител
ревизия
9b470613c3
променени са 2 файла, в които са добавени 34 реда и са изтрити 33 реда
  1. 11 12
      UAS-MES/FunctionCode/Make/Make_PositionStock.Designer.cs
  2. 23 21
      UAS-MES/FunctionCode/Make/Make_PositionStock.cs

+ 11 - 12
UAS-MES/FunctionCode/Make/Make_PositionStock.Designer.cs

@@ -72,7 +72,7 @@
             this.panel2.Controls.Add(this.label1);
             this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
             this.panel2.Location = new System.Drawing.Point(0, 0);
-            this.panel2.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.panel2.Margin = new System.Windows.Forms.Padding(4);
             this.panel2.Name = "panel2";
             this.panel2.Size = new System.Drawing.Size(1229, 36);
             this.panel2.TabIndex = 31;
@@ -174,7 +174,7 @@
             this.ma_craftcode.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
             this.ma_craftcode.FormattingEnabled = true;
             this.ma_craftcode.Location = new System.Drawing.Point(553, 52);
-            this.ma_craftcode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.ma_craftcode.Margin = new System.Windows.Forms.Padding(4);
             this.ma_craftcode.Name = "ma_craftcode";
             this.ma_craftcode.Size = new System.Drawing.Size(199, 23);
             this.ma_craftcode.TabIndex = 185;
@@ -185,7 +185,7 @@
             this.Lock.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.Lock.LeaveEvent = false;
             this.Lock.Location = new System.Drawing.Point(339, 54);
-            this.Lock.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Lock.Margin = new System.Windows.Forms.Padding(4);
             this.Lock.Name = "Lock";
             this.Lock.Size = new System.Drawing.Size(61, 24);
             this.Lock.TabIndex = 182;
@@ -221,7 +221,7 @@
             this.Clean.Image = ((System.Drawing.Image)(resources.GetObject("Clean.Image")));
             this.Clean.IsShowBorder = true;
             this.Clean.Location = new System.Drawing.Point(1041, 634);
-            this.Clean.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Clean.Margin = new System.Windows.Forms.Padding(4);
             this.Clean.MoveImage = ((System.Drawing.Image)(resources.GetObject("Clean.MoveImage")));
             this.Clean.Name = "Clean";
             this.Clean.NormalImage = ((System.Drawing.Image)(resources.GetObject("Clean.NormalImage")));
@@ -237,7 +237,7 @@
             // 
             this.OperateResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.OperateResult.Location = new System.Drawing.Point(944, 179);
-            this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4);
             this.OperateResult.Name = "OperateResult";
             this.OperateResult.Size = new System.Drawing.Size(271, 440);
             this.OperateResult.TabIndex = 178;
@@ -251,7 +251,7 @@
             this.Confirm.Image = ((System.Drawing.Image)(resources.GetObject("Confirm.Image")));
             this.Confirm.IsShowBorder = true;
             this.Confirm.Location = new System.Drawing.Point(459, 636);
-            this.Confirm.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Confirm.Margin = new System.Windows.Forms.Padding(4);
             this.Confirm.MoveImage = ((System.Drawing.Image)(resources.GetObject("Confirm.MoveImage")));
             this.Confirm.Name = "Confirm";
             this.Confirm.NormalImage = ((System.Drawing.Image)(resources.GetObject("Confirm.NormalImage")));
@@ -271,7 +271,7 @@
             this.pr_batchnum.BackColor = System.Drawing.Color.White;
             this.pr_batchnum.ID = null;
             this.pr_batchnum.Location = new System.Drawing.Point(115, 638);
-            this.pr_batchnum.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.pr_batchnum.Margin = new System.Windows.Forms.Padding(4);
             this.pr_batchnum.Name = "pr_batchnum";
             this.pr_batchnum.Power = null;
             this.pr_batchnum.Size = new System.Drawing.Size(320, 25);
@@ -299,14 +299,14 @@
             this.pr_spec,
             this.DeleteRow});
             this.BatchProductDGV.Location = new System.Drawing.Point(0, 179);
-            this.BatchProductDGV.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.BatchProductDGV.Margin = new System.Windows.Forms.Padding(4);
             this.BatchProductDGV.Name = "BatchProductDGV";
             this.BatchProductDGV.RowTemplate.Height = 23;
             this.BatchProductDGV.Size = new System.Drawing.Size(936, 441);
             this.BatchProductDGV.TabIndex = 174;
-            this.BatchProductDGV.DataSourceChanged += new System.EventHandler(this.BatchProductDGV_DataSourceChanged);
             this.BatchProductDGV.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.BatchProduct_CellContentClick);
             this.BatchProductDGV.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.BatchProductDGV_CellEndEdit);
+            this.BatchProductDGV.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(this.BatchProductDGV_CellFormatting);
             // 
             // sp_soncode
             // 
@@ -320,7 +320,6 @@
             this.mss_id.DataPropertyName = "mss_id";
             this.mss_id.HeaderText = "ID";
             this.mss_id.Name = "mss_id";
-            this.mss_id.Visible = false;
             // 
             // mss_prodcode
             // 
@@ -440,7 +439,7 @@
             this.Screen.Image = ((System.Drawing.Image)(resources.GetObject("Screen.Image")));
             this.Screen.IsShowBorder = true;
             this.Screen.Location = new System.Drawing.Point(828, 104);
-            this.Screen.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Screen.Margin = new System.Windows.Forms.Padding(4);
             this.Screen.MoveImage = ((System.Drawing.Image)(resources.GetObject("Screen.MoveImage")));
             this.Screen.Name = "Screen";
             this.Screen.NormalImage = ((System.Drawing.Image)(resources.GetObject("Screen.NormalImage")));
@@ -478,7 +477,7 @@
             this.Controls.Add(this.Screen);
             this.Controls.Add(this.panel2);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "Make_PositionStock";
             this.Tag = "Make!PositionStock";
             this.Text = "岗位备料";

+ 23 - 21
UAS-MES/FunctionCode/Make/Make_PositionStock.cs

@@ -85,7 +85,7 @@ namespace UAS_MES.Make
                                 string bar_prodcode = dt.Rows[0]["bar_prodcode"].ToString();
                                 sql.Clear();
                                 sql.Append("select * from stepproduct inner join product on pr_code=sp_soncode left join makematerial on mm_prodcode=sp_soncode where ");
-                                sql.Append("sp_craftcode='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' and sp_soncode='" + bar_prodcode + "' and pr_tracekind=2 ");
+                                sql.Append("sp_craftcode='" + ma_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' and sp_soncode='" + bar_prodcode + "' and sp_tracekind=2 ");
                                 dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                                 if (dt.Rows.Count > 0)
                                 {
@@ -205,39 +205,41 @@ namespace UAS_MES.Make
 
         private void BatchProductDGV_CellEndEdit(object sender, DataGridViewCellEventArgs e)
         {
-            string id = BatchProductDGV.Rows[e.RowIndex].Cells["mss_id"].Value.ToString();
-            string qty = "0";
-            if (id != "0")
+            if (BatchProductDGV.Columns[e.ColumnIndex].Name == "mss_qty")
             {
-                try
+                string id = BatchProductDGV.Rows[e.RowIndex].Cells["mss_id"].Value.ToString();
+                string qty = "0";
+                if (id != "0")
                 {
-                    if (int.Parse(BatchProductDGV.Rows[e.RowIndex].Cells["mss_qty"].Value.ToString()) > 0)
+                    try
                     {
-                        qty = BatchProductDGV.Rows[e.RowIndex].Cells["mss_qty"].Value.ToString();
+                        if (int.Parse(BatchProductDGV.Rows[e.RowIndex].Cells["mss_qty"].Value.ToString()) > 0)
+                        {
+                            qty = BatchProductDGV.Rows[e.RowIndex].Cells["mss_qty"].Value.ToString();
+                        }
+                        else
+                        {
+                            OperateResult.AppendText(">>数量必须大于0\n", Color.Red);
+                            return;
+                        }
                     }
-                    else
+                    catch (Exception)
                     {
                         OperateResult.AppendText(">>数量必须大于0\n", Color.Red);
                         return;
                     }
+                    dh.UpdateByCondition("makesourcestock", "mss_qty='" + qty + "'", "mss_id='" + id + "'");
                 }
-                catch (Exception)
-                {
-                    OperateResult.AppendText(">>数量必须大于0\n", Color.Red);
-                    return;
-                }
-                dh.UpdateByCondition("makesourcestock", "mss_qty='" + qty + "'", "mss_id='" + id + "'");
             }
         }
 
-        private void BatchProductDGV_DataSourceChanged(object sender, EventArgs e)
+        private void BatchProductDGV_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
         {
-            for (int i = 0; i < BatchProductDGV.Rows.Count; i++)
-            {
-                if (BatchProductDGV.Rows[i].Cells["mss_id"].Value.ToString() == "0")
-                {
-                    (BatchProductDGV.Columns["DeleteRow"] as DataGridViewImageColumn).Image = Properties.Resources.WhiteImage;
-                }
+            if (BatchProductDGV.Columns[e.ColumnIndex].Name == "DeleteRow") {
+                if (BatchProductDGV.Rows[e.RowIndex].Cells["mss_id"].Value.ToString() == "0")
+                    e.Value = Properties.Resources.WhiteImage;
+                else
+                    e.Value = Properties.Resources.bindingNavigatorDeleteItem_Image;
             }
         }
     }