Ver Fonte

产品重量设置

shim há 8 anos atrás
pai
commit
fa80d650d1

+ 12 - 11
UAS-MES/FunctionCode/Packing/Packing_ProdWeightSet.Designer.cs

@@ -46,7 +46,7 @@
             this.errorValue = new System.Windows.Forms.TextBox();
             this.standardWeight = new System.Windows.Forms.TextBox();
             this.label7 = new System.Windows.Forms.Label();
-            this.label4 = new System.Windows.Forms.Label();
+            this.unit = 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();
@@ -185,7 +185,7 @@
             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.unit);
             this.panel4.Controls.Add(this.label6);
             this.panel4.Controls.Add(this.pr_cartonunit);
             this.panel4.Controls.Add(this.label22);
@@ -224,15 +224,15 @@
             this.label7.TabIndex = 50;
             this.label7.Text = "标准";
             // 
-            // label4
+            // unit
             // 
-            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";
+            this.unit.AutoSize = true;
+            this.unit.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.unit.Location = new System.Drawing.Point(371, 22);
+            this.unit.Name = "unit";
+            this.unit.Size = new System.Drawing.Size(25, 27);
+            this.unit.TabIndex = 47;
+            this.unit.Text = "g";
             // 
             // label6
             // 
@@ -255,6 +255,7 @@
             this.pr_cartonunit.Size = new System.Drawing.Size(46, 38);
             this.pr_cartonunit.TabIndex = 42;
             this.pr_cartonunit.Text = "克";
+            this.pr_cartonunit.Visible = false;
             // 
             // label22
             // 
@@ -494,7 +495,7 @@
         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 unit;
         private System.Windows.Forms.Label label7;
         private System.Windows.Forms.TextBox errorValue;
         private System.Windows.Forms.TextBox standardWeight;

+ 19 - 33
UAS-MES/FunctionCode/Packing/Packing_ProdWeightSet.cs

@@ -37,9 +37,9 @@ namespace UAS_MES.Packing
 
         int samplesCount = 0;
 
-        string maxValue = "";//存储最大值
+        //string maxValue = "";//存储最大值
 
-        string minValue = "";//存储最小值
+        //string minValue = "";//存储最小值
 
         List<string> sncodes = new List<string>();//存序列号
         List<string> indates = new List<string>();//存时间
@@ -47,8 +47,6 @@ namespace UAS_MES.Packing
 
         string recordSW = ""; //存标准重量
         string recordEV = "";//存误差值
-
-        bool isKg = false;//记录单位是否KG
         public Packing_ProdWeightSet()
         {
             InitializeComponent();
@@ -84,20 +82,20 @@ namespace UAS_MES.Packing
             //分条赋值
             lvi.SubItems.Add(index+"");
             lvi.SubItems.Add(palletcode);
-            lvi.SubItems.Add(weigh+pr_cartonunit.Text);
+            lvi.SubItems.Add(weigh);
             lvi.SubItems.Add(time.ToString());
             //添加结果的信息进去
             showResult.Items.Add(lvi);
             //更新已称重量最大值最小值
             if (index > 1)
             {
-                maxValue = double.Parse(weigh) > double.Parse(maxValue) ? weigh : maxValue;
-                minValue = double.Parse(weigh) < double.Parse(minValue) ? weigh : minValue;
+                //maxValue = double.Parse(weigh) > double.Parse(maxValue) ? weigh : maxValue;
+                //minValue = double.Parse(weigh) < double.Parse(minValue) ? weigh : minValue;
             }
             else
             {
-                maxValue = weigh;
-                minValue = weigh;
+                //maxValue = weigh;
+                //minValue = weigh;
                 //每次添加第一条数据的时候清空list的值
                 sncodes.Clear();
                 indates.Clear();
@@ -177,24 +175,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;
+            //double sum = 0;
+            ////点击取平均值
+            //foreach (string s in weights)
+            //{
+            //    sum += double.Parse(s);
+            //}
+            //sum = sum / weights.Count;
             //更新彩盒重量最大值最小值
-            if (isKg)
-            {
-                dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" +Math.Round( (sum + double.Parse(errorValue.Text))/1000) + "', PR_COLORBOXMINW = '" +Math.Round( (sum - double.Parse(errorValue.Text))/1000) + "',PR_COLORBOXUNIT='" + pr_cartonunit.Text + "' where pr_code='" + pr_code.Text + "'", "update");
-                OperateResult.AppendText("<<重量设置成功,最大值" +Math.Round( (sum + double.Parse(errorValue.Text))/1000 )+ "kg,最小值" +Math.Round( (sum - double.Parse(errorValue.Text))/1000 ) + "kg\n", Color.Green);
-            }
-            else
-            {
-                dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" +Math.Round( (sum + double.Parse(errorValue.Text)) ) + "', PR_COLORBOXMINW = '" + Math.Round((sum - double.Parse(errorValue.Text))) + "',PR_COLORBOXUNIT='" + pr_cartonunit.Text + "' where pr_code='" + pr_code.Text + "'", "update");
-                OperateResult.AppendText("<<重量设置成功,最大值"+ Math.Round( (sum + double.Parse(errorValue.Text)) ) + "g,最小值"+ Math.Round((sum - double.Parse(errorValue.Text))) + "g\n", Color.Green);
-            }
+            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");
+            OperateResult.AppendText("<<重量设置成功,最大值" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) + ",最小值" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + "g\n", Color.Green);
             //更新采样记录表
             string serialNum = dh.GetSerialNumberByCaller("ProdWeightSample");
             sql.Clear();
@@ -242,7 +232,8 @@ namespace UAS_MES.Packing
                     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)))
+                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;
@@ -339,7 +330,6 @@ namespace UAS_MES.Packing
         {
             //产品更换的时候
             DataTable d = (DataTable)dh.ExecuteSql("select PR_COLORBOXMAXW,PR_COLORBOXMINW,PR_COLORBOXUNIT from product where pr_code='" + pr_code.Text + "'", "select");
-            isKg = false;
             //给标准重量赋值
             if (d.Rows[0]["PR_COLORBOXMAXW"].ToString() == "" || d.Rows[0]["PR_COLORBOXMINW"].ToString() == "")
             {
@@ -349,12 +339,8 @@ namespace UAS_MES.Packing
             {
                 //取二者平均值来
                 standardWeight.Text = (double.Parse(d.Rows[0]["PR_COLORBOXMAXW"].ToString()) + double.Parse(d.Rows[0]["PR_COLORBOXMINW"].ToString())) / 2 + "";
-                if (d.Rows[0]["PR_COLORBOXUNIT"].ToString()=="kg")
-                {
-                    isKg = true;
-                    standardWeight.Text = double.Parse(standardWeight.Text) * 1000 + "";
-                }
             }
+            unit.Text = d.Rows[0]["PR_COLORBOXUNIT"].ToString();
             //取误差值
             errorValue.Text = dh.GetConfig("prodWeightErrorValue", "MESSetting").ToString();
             //查询重量设置采样个数