Browse Source

产品重量设置修改

shim 7 years ago
parent
commit
0b90b3dc41

+ 20 - 19
UAS-MES/FunctionCode/Packing/Packing_ProdWeightSet.Designer.cs

@@ -45,6 +45,7 @@
             this.panel4 = new System.Windows.Forms.Panel();
             this.errorValue = new System.Windows.Forms.TextBox();
             this.standardWeight = new System.Windows.Forms.TextBox();
+            this.confirm = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
             this.label7 = new System.Windows.Forms.Label();
             this.unit = new System.Windows.Forms.Label();
             this.label6 = new System.Windows.Forms.Label();
@@ -53,7 +54,6 @@
             this.weight = new System.Windows.Forms.Label();
             this.label1 = new System.Windows.Forms.Label();
             this.sncode = new UAS_MES.CustomControl.TextBoxWithIcon.SnCollectionBox();
-            this.confirm = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
             this.OperateResult = new UAS_MES.CustomControl.RichText.RichTextAutoBottom();
             this.ComList = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
             this.BaudRate = new UAS_MES.CustomControl.TextBoxWithIcon.NumOnlyTextBox();
@@ -208,6 +208,7 @@
             // 
             // standardWeight
             // 
+            this.standardWeight.Enabled = false;
             this.standardWeight.Location = new System.Drawing.Point(83, 19);
             this.standardWeight.Name = "standardWeight";
             this.standardWeight.Size = new System.Drawing.Size(100, 28);
@@ -215,6 +216,24 @@
             this.standardWeight.Enter += new System.EventHandler(this.standardWeight_Enter);
             this.standardWeight.Leave += new System.EventHandler(this.standardWeight_Leave);
             // 
+            // confirm
+            // 
+            this.confirm.AllPower = null;
+            this.confirm.BackColor = System.Drawing.Color.Transparent;
+            this.confirm.DownImage = ((System.Drawing.Image)(resources.GetObject("confirm.DownImage")));
+            this.confirm.Image = null;
+            this.confirm.IsShowBorder = true;
+            this.confirm.Location = new System.Drawing.Point(370, 86);
+            this.confirm.MoveImage = ((System.Drawing.Image)(resources.GetObject("confirm.MoveImage")));
+            this.confirm.Name = "confirm";
+            this.confirm.NormalImage = ((System.Drawing.Image)(resources.GetObject("confirm.NormalImage")));
+            this.confirm.Power = null;
+            this.confirm.Size = new System.Drawing.Size(75, 28);
+            this.confirm.TabIndex = 227;
+            this.confirm.Text = "保存";
+            this.confirm.UseVisualStyleBackColor = false;
+            this.confirm.Click += new System.EventHandler(this.confirm_Click);
+            // 
             // label7
             // 
             this.label7.AutoSize = true;
@@ -312,24 +331,6 @@
             this.sncode.TabIndex = 228;
             this.sncode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.sncode_KeyDown);
             // 
-            // confirm
-            // 
-            this.confirm.AllPower = null;
-            this.confirm.BackColor = System.Drawing.Color.Transparent;
-            this.confirm.DownImage = ((System.Drawing.Image)(resources.GetObject("confirm.DownImage")));
-            this.confirm.Image = null;
-            this.confirm.IsShowBorder = true;
-            this.confirm.Location = new System.Drawing.Point(370, 86);
-            this.confirm.MoveImage = ((System.Drawing.Image)(resources.GetObject("confirm.MoveImage")));
-            this.confirm.Name = "confirm";
-            this.confirm.NormalImage = ((System.Drawing.Image)(resources.GetObject("confirm.NormalImage")));
-            this.confirm.Power = null;
-            this.confirm.Size = new System.Drawing.Size(75, 28);
-            this.confirm.TabIndex = 227;
-            this.confirm.Text = "保存";
-            this.confirm.UseVisualStyleBackColor = false;
-            this.confirm.Click += new System.EventHandler(this.confirm_Click);
-            // 
             // OperateResult
             // 
             this.OperateResult.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));

+ 17 - 16
UAS-MES/FunctionCode/Packing/Packing_ProdWeightSet.cs

@@ -180,19 +180,20 @@ namespace UAS_MES.Packing
                 OperateResult.AppendText("<<采样个数不足\n", Color.Red);
                 return;
             }
-            //double sum = 0;
-            ////点击取平均值
-            //foreach (string s in weights)
-            //{
-            //    sum += double.Parse(s);
-            //}
-            //sum = sum / weights.Count;
+            double sum = 0;
+            //点击取平均值
+            foreach (string s in weights)
+            {
+                sum += double.Parse(s);
+            }
+            sum = Math.Round(sum / weights.Count,3);
+            standardWeight.Text = sum + "";
             //更新彩盒重量最大值最小值
-            dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) + "', PR_COLORBOXMINW = '" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + "' where pr_code='" + pr_code.Text + "'", "update");
+            dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" + (sum + double.Parse(errorValue.Text)) + "', PR_COLORBOXMINW = '" + (sum - double.Parse(errorValue.Text)) + "' where pr_code='" + pr_code.Text + "'", "update");
             //更新此产品需要检测彩盒重量
             dh.ExecuteSql("update product set pr_checkcolorboxw = 1 where pr_code='" + pr_code.Text + "'", "update");
-            OperateResult.AppendText("<<重量设置成功,最大值" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) +unit.Text+ ",最小值" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + unit.Text+"\n", Color.Green);
-            LogicHandler.DoCommandLog(Tag.ToString(),User.UserCode,"",User.UserLineCode,User.UserSourceCode,"产品重量设置","产品编号"+pr_code.Text+",最大"+ (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text))+unit.Text+"最小"+ (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text))+unit.Text,"","");
+            OperateResult.AppendText("<<重量设置成功,最大值" + (sum + double.Parse(errorValue.Text)) +unit.Text+ ",最小值" + (sum - double.Parse(errorValue.Text)) + unit.Text+"\n", Color.Green);
+            LogicHandler.DoCommandLog(Tag.ToString(),User.UserCode,"",User.UserLineCode,User.UserSourceCode,"产品重量设置","产品编号"+pr_code.Text+",最大"+ (sum + double.Parse(errorValue.Text))+unit.Text+"最小"+ (sum - double.Parse(errorValue.Text))+unit.Text,"","");
             //更新采样记录表
             string serialNum = dh.GetSerialNumberByCaller("ProdWeightSample");
             sql.Clear();
@@ -240,12 +241,12 @@ namespace UAS_MES.Packing
                     return;
                 }
                 //判断称重记录是否满足标准重量+-误差值
-                double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text.Replace("kg", "").Trim());
-                if (ActualWeight < (double.Parse(standardWeight.Text)- double.Parse(errorValue.Text))|| ActualWeight > (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)))
-                {
-                    OperateResult.AppendText("<<序列号" + sncode.Text + "重量不在预设范围内\n", Color.Red, sncode);
-                    return;
-                }
+                //double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text.Replace("kg", "").Trim());
+                //if (ActualWeight < (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) || ActualWeight > (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)))
+                //{
+                //    //OperateResult.AppendText("<<序列号" + sncode.Text + "重量不在预设范围内\n", Color.Red, sncode);
+                //    return;
+                //}
                 //记录重量
                 recordResult(showResult.Items.Count+1,sncode.Text, weight.Text, System.DateTime.Now);
                 sncode.Text = "";