Browse Source

产品重量设置修改

shim 8 years ago
parent
commit
b6939dcf27

+ 119 - 61
UAS-MES/FunctionCode/Packing/Packing_ProdWeightSet.Designer.cs

@@ -43,6 +43,9 @@
             this.columnHeader4 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.columnHeader5 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
             this.panel4 = new System.Windows.Forms.Panel();
+            this.label7 = new System.Windows.Forms.Label();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
             this.pr_cartonunit = new System.Windows.Forms.Label();
             this.label22 = new System.Windows.Forms.Label();
             this.weight = new System.Windows.Forms.Label();
@@ -55,6 +58,8 @@
             this.stopWeigh = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
             this.startWeigh = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
             this.ma_code = new UAS_MES.CustomControl.TextBoxWithIcon.SearchTextBox();
+            this.standardWeight = new System.Windows.Forms.TextBox();
+            this.errorValue = new System.Windows.Forms.TextBox();
             this.panel4.SuspendLayout();
             this.SuspendLayout();
             // 
@@ -62,9 +67,10 @@
             // 
             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(22, 12);
+            this.ms_makecode_label.Location = new System.Drawing.Point(33, 18);
+            this.ms_makecode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.ms_makecode_label.Name = "ms_makecode_label";
-            this.ms_makecode_label.Size = new System.Drawing.Size(58, 21);
+            this.ms_makecode_label.Size = new System.Drawing.Size(86, 31);
             this.ms_makecode_label.TabIndex = 212;
             this.ms_makecode_label.Text = "工单号";
             // 
@@ -72,20 +78,18 @@
             // 
             this.pr_code.AutoSize = true;
             this.pr_code.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_code.Location = new System.Drawing.Point(107, 49);
-            this.pr_code.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.pr_code.Location = new System.Drawing.Point(160, 74);
             this.pr_code.Name = "pr_code";
-            this.pr_code.Size = new System.Drawing.Size(0, 21);
+            this.pr_code.Size = new System.Drawing.Size(0, 31);
             this.pr_code.TabIndex = 215;
             // 
             // label2
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label2.Location = new System.Drawing.Point(22, 49);
-            this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label2.Location = new System.Drawing.Point(33, 74);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(74, 21);
+            this.label2.Size = new System.Drawing.Size(110, 31);
             this.label2.TabIndex = 214;
             this.label2.Text = "产品编号";
             // 
@@ -93,20 +97,19 @@
             // 
             this.pr_detail.AutoSize = true;
             this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_detail.Location = new System.Drawing.Point(107, 85);
-            this.pr_detail.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.pr_detail.Location = new System.Drawing.Point(160, 128);
             this.pr_detail.Name = "pr_detail";
-            this.pr_detail.Size = new System.Drawing.Size(0, 21);
+            this.pr_detail.Size = new System.Drawing.Size(0, 31);
             this.pr_detail.TabIndex = 217;
+            this.pr_detail.TextChanged += new System.EventHandler(this.pr_detail_TextChanged);
             // 
             // label3
             // 
             this.label3.AutoSize = true;
             this.label3.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label3.Location = new System.Drawing.Point(22, 85);
-            this.label3.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label3.Location = new System.Drawing.Point(33, 128);
             this.label3.Name = "label3";
-            this.label3.Size = new System.Drawing.Size(74, 21);
+            this.label3.Size = new System.Drawing.Size(110, 31);
             this.label3.TabIndex = 216;
             this.label3.Text = "产品名称";
             // 
@@ -114,21 +117,19 @@
             // 
             this.pr_spec.AutoSize = true;
             this.pr_spec.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_spec.Location = new System.Drawing.Point(107, 121);
-            this.pr_spec.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
-            this.pr_spec.MaximumSize = new System.Drawing.Size(400, 27);
+            this.pr_spec.Location = new System.Drawing.Point(160, 182);
+            this.pr_spec.MaximumSize = new System.Drawing.Size(600, 40);
             this.pr_spec.Name = "pr_spec";
-            this.pr_spec.Size = new System.Drawing.Size(0, 21);
+            this.pr_spec.Size = new System.Drawing.Size(0, 31);
             this.pr_spec.TabIndex = 219;
             // 
             // label5
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label5.Location = new System.Drawing.Point(22, 121);
-            this.label5.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
+            this.label5.Location = new System.Drawing.Point(33, 182);
             this.label5.Name = "label5";
-            this.label5.Size = new System.Drawing.Size(42, 21);
+            this.label5.Size = new System.Drawing.Size(62, 31);
             this.label5.TabIndex = 218;
             this.label5.Text = "规格";
             // 
@@ -141,10 +142,10 @@
             this.columnHeader4,
             this.columnHeader5});
             this.showResult.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.showResult.Location = new System.Drawing.Point(285, 167);
-            this.showResult.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
+            this.showResult.Location = new System.Drawing.Point(428, 250);
+            this.showResult.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.showResult.Name = "showResult";
-            this.showResult.Size = new System.Drawing.Size(440, 206);
+            this.showResult.Size = new System.Drawing.Size(658, 307);
             this.showResult.TabIndex = 220;
             this.showResult.UseCompatibleStateImageBehavior = false;
             this.showResult.View = System.Windows.Forms.View.Details;
@@ -181,24 +182,59 @@
             // panel4
             // 
             this.panel4.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
+            this.panel4.Controls.Add(this.errorValue);
+            this.panel4.Controls.Add(this.standardWeight);
+            this.panel4.Controls.Add(this.label7);
+            this.panel4.Controls.Add(this.label4);
+            this.panel4.Controls.Add(this.label6);
             this.panel4.Controls.Add(this.pr_cartonunit);
             this.panel4.Controls.Add(this.label22);
             this.panel4.Controls.Add(this.weight);
-            this.panel4.Location = new System.Drawing.Point(380, 12);
-            this.panel4.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1);
+            this.panel4.Location = new System.Drawing.Point(570, 18);
+            this.panel4.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
             this.panel4.Name = "panel4";
-            this.panel4.Size = new System.Drawing.Size(344, 105);
+            this.panel4.Size = new System.Drawing.Size(515, 156);
             this.panel4.TabIndex = 221;
             // 
+            // label7
+            // 
+            this.label7.AutoSize = true;
+            this.label7.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label7.Location = new System.Drawing.Point(18, 22);
+            this.label7.Name = "label7";
+            this.label7.Size = new System.Drawing.Size(52, 27);
+            this.label7.TabIndex = 50;
+            this.label7.Text = "标准";
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label4.Location = new System.Drawing.Point(371, 22);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(25, 27);
+            this.label4.TabIndex = 47;
+            this.label4.Text = "g";
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Location = new System.Drawing.Point(202, 22);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(26, 18);
+            this.label6.TabIndex = 44;
+            this.label6.Text = "±";
+            // 
             // pr_cartonunit
             // 
             this.pr_cartonunit.AutoSize = true;
             this.pr_cartonunit.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
             this.pr_cartonunit.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.pr_cartonunit.ForeColor = System.Drawing.SystemColors.ControlLightLight;
-            this.pr_cartonunit.Location = new System.Drawing.Point(303, 43);
+            this.pr_cartonunit.Location = new System.Drawing.Point(452, 86);
+            this.pr_cartonunit.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pr_cartonunit.Name = "pr_cartonunit";
-            this.pr_cartonunit.Size = new System.Drawing.Size(31, 25);
+            this.pr_cartonunit.Size = new System.Drawing.Size(46, 38);
             this.pr_cartonunit.TabIndex = 42;
             this.pr_cartonunit.Text = "克";
             // 
@@ -208,9 +244,10 @@
             this.label22.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
             this.label22.Font = new System.Drawing.Font("微软雅黑", 14.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.label22.ForeColor = System.Drawing.SystemColors.ControlLightLight;
-            this.label22.Location = new System.Drawing.Point(11, 43);
+            this.label22.Location = new System.Drawing.Point(14, 86);
+            this.label22.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label22.Name = "label22";
-            this.label22.Size = new System.Drawing.Size(50, 25);
+            this.label22.Size = new System.Drawing.Size(75, 38);
             this.label22.TabIndex = 20;
             this.label22.Text = "重量";
             // 
@@ -222,18 +259,20 @@
             this.weight.AutoSize = true;
             this.weight.Font = new System.Drawing.Font("微软雅黑", 22.2F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.weight.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(192)))), ((int)(((byte)(0)))));
-            this.weight.Location = new System.Drawing.Point(100, 35);
+            this.weight.Location = new System.Drawing.Point(148, 74);
+            this.weight.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.weight.Name = "weight";
-            this.weight.Size = new System.Drawing.Size(0, 39);
+            this.weight.Size = new System.Drawing.Size(0, 58);
             this.weight.TabIndex = 41;
             // 
             // label1
             // 
             this.label1.AutoSize = true;
             this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label1.Location = new System.Drawing.Point(10, 351);
+            this.label1.Location = new System.Drawing.Point(15, 526);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(58, 21);
+            this.label1.Size = new System.Drawing.Size(86, 31);
             this.label1.TabIndex = 229;
             this.label1.Text = "序列号";
             // 
@@ -243,11 +282,10 @@
             this.sncode.BackColor = System.Drawing.Color.White;
             this.sncode.Font = new System.Drawing.Font("微软雅黑", 9F);
             this.sncode.ID = null;
-            this.sncode.Location = new System.Drawing.Point(73, 351);
-            this.sncode.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.sncode.Location = new System.Drawing.Point(110, 526);
             this.sncode.Name = "sncode";
             this.sncode.Power = null;
-            this.sncode.Size = new System.Drawing.Size(126, 23);
+            this.sncode.Size = new System.Drawing.Size(187, 31);
             this.sncode.Str = null;
             this.sncode.Str1 = null;
             this.sncode.Str2 = null;
@@ -261,13 +299,12 @@
             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(221, 351);
-            this.confirm.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.confirm.Location = new System.Drawing.Point(332, 526);
             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(50, 19);
+            this.confirm.Size = new System.Drawing.Size(75, 28);
             this.confirm.TabIndex = 227;
             this.confirm.Text = "确认";
             this.confirm.UseVisualStyleBackColor = false;
@@ -276,10 +313,10 @@
             // OperateResult
             // 
             this.OperateResult.Font = new System.Drawing.Font("宋体", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.OperateResult.Location = new System.Drawing.Point(14, 165);
-            this.OperateResult.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
+            this.OperateResult.Location = new System.Drawing.Point(21, 248);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.OperateResult.Name = "OperateResult";
-            this.OperateResult.Size = new System.Drawing.Size(223, 171);
+            this.OperateResult.Size = new System.Drawing.Size(332, 254);
             this.OperateResult.TabIndex = 226;
             this.OperateResult.Text = "";
             // 
@@ -287,10 +324,11 @@
             // 
             this.ComList.AutoSize = true;
             this.ComList.CutLength = null;
-            this.ComList.Location = new System.Drawing.Point(636, 152);
-            this.ComList.MaximumSize = new System.Drawing.Size(150, 0);
+            this.ComList.Location = new System.Drawing.Point(954, 228);
+            this.ComList.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ComList.MaximumSize = new System.Drawing.Size(225, 0);
             this.ComList.Name = "ComList";
-            this.ComList.Size = new System.Drawing.Size(47, 12);
+            this.ComList.Size = new System.Drawing.Size(71, 18);
             this.ComList.TabIndex = 225;
             this.ComList.Text = "ComList";
             this.ComList.Visible = false;
@@ -300,12 +338,12 @@
             this.BaudRate.AllPower = null;
             this.BaudRate.BackColor = System.Drawing.Color.White;
             this.BaudRate.ID = null;
-            this.BaudRate.Location = new System.Drawing.Point(641, 129);
-            this.BaudRate.Margin = new System.Windows.Forms.Padding(3, 1, 3, 1);
+            this.BaudRate.Location = new System.Drawing.Point(962, 194);
+            this.BaudRate.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
             this.BaudRate.Name = "BaudRate";
             this.BaudRate.Negative = false;
             this.BaudRate.Power = null;
-            this.BaudRate.Size = new System.Drawing.Size(35, 21);
+            this.BaudRate.Size = new System.Drawing.Size(50, 28);
             this.BaudRate.Str = null;
             this.BaudRate.Str1 = null;
             this.BaudRate.Str2 = null;
@@ -319,13 +357,13 @@
             this.stopWeigh.DownImage = ((System.Drawing.Image)(resources.GetObject("stopWeigh.DownImage")));
             this.stopWeigh.Image = null;
             this.stopWeigh.IsShowBorder = true;
-            this.stopWeigh.Location = new System.Drawing.Point(539, 125);
-            this.stopWeigh.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
+            this.stopWeigh.Location = new System.Drawing.Point(808, 188);
+            this.stopWeigh.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.stopWeigh.MoveImage = ((System.Drawing.Image)(resources.GetObject("stopWeigh.MoveImage")));
             this.stopWeigh.Name = "stopWeigh";
             this.stopWeigh.NormalImage = ((System.Drawing.Image)(resources.GetObject("stopWeigh.NormalImage")));
             this.stopWeigh.Power = null;
-            this.stopWeigh.Size = new System.Drawing.Size(72, 25);
+            this.stopWeigh.Size = new System.Drawing.Size(108, 38);
             this.stopWeigh.TabIndex = 223;
             this.stopWeigh.Text = "停止称重";
             this.stopWeigh.UseVisualStyleBackColor = false;
@@ -338,13 +376,13 @@
             this.startWeigh.DownImage = ((System.Drawing.Image)(resources.GetObject("startWeigh.DownImage")));
             this.startWeigh.Image = null;
             this.startWeigh.IsShowBorder = true;
-            this.startWeigh.Location = new System.Drawing.Point(436, 125);
-            this.startWeigh.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
+            this.startWeigh.Location = new System.Drawing.Point(654, 188);
+            this.startWeigh.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
             this.startWeigh.MoveImage = ((System.Drawing.Image)(resources.GetObject("startWeigh.MoveImage")));
             this.startWeigh.Name = "startWeigh";
             this.startWeigh.NormalImage = ((System.Drawing.Image)(resources.GetObject("startWeigh.NormalImage")));
             this.startWeigh.Power = null;
-            this.startWeigh.Size = new System.Drawing.Size(62, 25);
+            this.startWeigh.Size = new System.Drawing.Size(93, 38);
             this.startWeigh.TabIndex = 222;
             this.startWeigh.Text = "开始称重";
             this.startWeigh.UseVisualStyleBackColor = false;
@@ -358,24 +396,40 @@
             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(111, 12);
+            this.ma_code.Location = new System.Drawing.Point(166, 18);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(4);
             this.ma_code.Name = "ma_code";
             this.ma_code.Power = "";
             this.ma_code.ReturnData = null;
             this.ma_code.SelectField = null;
             this.ma_code.SetValueField = null;
-            this.ma_code.Size = new System.Drawing.Size(141, 23);
+            this.ma_code.Size = new System.Drawing.Size(212, 34);
             this.ma_code.TabIndex = 213;
             this.ma_code.TableName = null;
             this.ma_code.Tag = "makecode";
             this.ma_code.TextBoxEnable = false;
             this.ma_code.UserControlTextChanged += new UAS_MES.CustomControl.TextBoxWithIcon.SearchTextBox.OnTextChange(this.ma_code_UserControlTextChanged);
             // 
+            // standardWeight
+            // 
+            this.standardWeight.Location = new System.Drawing.Point(83, 19);
+            this.standardWeight.Name = "standardWeight";
+            this.standardWeight.Size = new System.Drawing.Size(100, 28);
+            this.standardWeight.TabIndex = 51;
+            this.standardWeight.TextChanged += new System.EventHandler(this.standardWeight_TextChanged);
+            // 
+            // errorValue
+            // 
+            this.errorValue.Location = new System.Drawing.Point(245, 19);
+            this.errorValue.Name = "errorValue";
+            this.errorValue.Size = new System.Drawing.Size(100, 28);
+            this.errorValue.TabIndex = 52;
+            // 
             // Packing_ProdWeightSet
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(747, 397);
+            this.ClientSize = new System.Drawing.Size(1120, 596);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.sncode);
             this.Controls.Add(this.confirm);
@@ -395,7 +449,6 @@
             this.Controls.Add(this.ma_code);
             this.Controls.Add(this.ms_makecode_label);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
             this.Name = "Packing_ProdWeightSet";
             this.Tag = "Packing!ProdWeightSet";
             this.Text = "Packing_ProdWeightSet";
@@ -437,5 +490,10 @@
         private CustomControl.ButtonUtil.NormalButton confirm;
         private CustomControl.TextBoxWithIcon.EnterTextBox sncode;
         private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label6;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label7;
+        private System.Windows.Forms.TextBox errorValue;
+        private System.Windows.Forms.TextBox standardWeight;
     }
 }

+ 38 - 2
UAS-MES/FunctionCode/Packing/Packing_ProdWeightSet.cs

@@ -69,6 +69,8 @@ namespace UAS_MES.Packing
         {
             Dbfind = ma_code.ReturnData;
             BaseUtil.SetFormValue(this.Controls, Dbfind);
+            //取误差值
+            errorValue.Text = dh.GetConfig("prodWeightErrorValue", "MESSetting").ToString();
         }
         private void recordResult(int index,string palletcode, string weigh, DateTime time)
         {
@@ -170,9 +172,16 @@ 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;
             //更新彩盒重量最大值最小值
-            dh.ExecuteSql("update product set PR_COLORBOXMAXW ='"+maxValue+"', PR_COLORBOXMINW = '"+minValue+ "',PR_COLORBOXUNIT='"+pr_cartonunit.Text+"' where pr_code='" + pr_code.Text+"'", "update");
-            OperateResult.AppendText("<<重量设置成功,最大值"+maxValue+pr_cartonunit.Text+",最小值"+minValue+pr_cartonunit.Text+"\n", Color.Green);
+            dh.ExecuteSql("update product set PR_COLORBOXMAXW ='"+(sum+double.Parse(errorValue.Text))+"', PR_COLORBOXMINW = '"+ (sum - double.Parse(errorValue.Text)) + "',PR_COLORBOXUNIT='"+pr_cartonunit.Text+"' where pr_code='" + pr_code.Text+"'", "update");
+            OperateResult.AppendText("<<重量设置成功,最大值"+ (sum + double.Parse(errorValue.Text)) + ",最小值"+ (sum - double.Parse(errorValue.Text)) + "\n", Color.Green);
             //更新采样记录表
             string serialNum = dh.GetSerialNumberByCaller("ProdWeightSample");
             sql.Clear();
@@ -219,6 +228,12 @@ namespace UAS_MES.Packing
                     OperateResult.AppendText("<<序列号" + sncode.Text + "已经称过\n", Color.Red, sncode);
                     return;
                 }
+                //判断称重记录是否满足标准重量+-误差值
+                if (double.Parse(weight.Text)<(double.Parse(standardWeight.Text)- double.Parse(errorValue.Text))|| double.Parse(weight.Text) >(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 = "";
@@ -271,5 +286,26 @@ namespace UAS_MES.Packing
                 thread.Interrupt();
             }
         }
+
+        private void pr_detail_TextChanged(object sender, EventArgs e)
+        {
+            //产品更换的时候
+            DataTable d =  (DataTable)dh.ExecuteSql("select PR_COLORBOXMAXW,PR_COLORBOXMINW from product where pr_code='"+pr_code.Text+"'","select");
+            //给标准重量赋值
+            if (d.Rows[0]["PR_COLORBOXMAXW"].ToString() == "" || d.Rows[0]["PR_COLORBOXMINW"].ToString() == "")
+            {
+                standardWeight.Text = 0 + "";
+            }
+            else
+            {
+                //取二者平均值来
+                standardWeight.Text = (double.Parse(d.Rows[0]["PR_COLORBOXMAXW"].ToString())+ double.Parse(d.Rows[0]["PR_COLORBOXMINW"].ToString()))/2+"";
+            }
+        }
+
+        private void standardWeight_TextChanged(object sender, EventArgs e)
+        {
+            //在采样的时候不能更改
+        }
     }
 }