Browse Source

添加长度校验和自动生成栈板bug

章政 8 years ago
parent
commit
200cbfb140

+ 43 - 11
UAS-MES/FunctionCode/Make/Make_PalletCollection.Designer.cs

@@ -70,6 +70,8 @@
             this.pa_makecode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
             this.pa_totalqty = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
             this.AutoPrint = new UAS_MES.CustomControl.CustomCheckBox.AutoPrintCheckBox();
+            this.OutBoxLength_label = new System.Windows.Forms.Label();
+            this.OutBoxLength = new UAS_MES.CustomControl.TextBoxWithIcon.SnCollectionBox();
             ((System.ComponentModel.ISupportInitialize)(this.PackageInf)).BeginInit();
             this.SuspendLayout();
             // 
@@ -77,7 +79,7 @@
             // 
             this.pa_outboxcode_label.AutoSize = true;
             this.pa_outboxcode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pa_outboxcode_label.Location = new System.Drawing.Point(11, 34);
+            this.pa_outboxcode_label.Location = new System.Drawing.Point(11, 45);
             this.pa_outboxcode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pa_outboxcode_label.Name = "pa_outboxcode_label";
             this.pa_outboxcode_label.Size = new System.Drawing.Size(72, 27);
@@ -99,7 +101,7 @@
             // 
             this.pa_makecode_label.AutoSize = true;
             this.pa_makecode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pa_makecode_label.Location = new System.Drawing.Point(393, 34);
+            this.pa_makecode_label.Location = new System.Drawing.Point(393, 45);
             this.pa_makecode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pa_makecode_label.Name = "pa_makecode_label";
             this.pa_makecode_label.Size = new System.Drawing.Size(92, 27);
@@ -121,7 +123,7 @@
             // 
             this.pa_custcode_label.AutoSize = true;
             this.pa_custcode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pa_custcode_label.Location = new System.Drawing.Point(1004, 34);
+            this.pa_custcode_label.Location = new System.Drawing.Point(1004, 45);
             this.pa_custcode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pa_custcode_label.Name = "pa_custcode_label";
             this.pa_custcode_label.Size = new System.Drawing.Size(52, 27);
@@ -143,7 +145,7 @@
             // 
             this.pa_prodcode_label.AutoSize = true;
             this.pa_prodcode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pa_prodcode_label.Location = new System.Drawing.Point(643, 34);
+            this.pa_prodcode_label.Location = new System.Drawing.Point(643, 45);
             this.pa_prodcode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pa_prodcode_label.Name = "pa_prodcode_label";
             this.pa_prodcode_label.Size = new System.Drawing.Size(92, 27);
@@ -197,10 +199,8 @@
             // AutoOutBoxCode
             // 
             this.AutoOutBoxCode.AutoSize = true;
-            this.AutoOutBoxCode.Checked = true;
-            this.AutoOutBoxCode.CheckState = System.Windows.Forms.CheckState.Checked;
             this.AutoOutBoxCode.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.AutoOutBoxCode.Location = new System.Drawing.Point(262, 35);
+            this.AutoOutBoxCode.Location = new System.Drawing.Point(262, 46);
             this.AutoOutBoxCode.Margin = new System.Windows.Forms.Padding(4);
             this.AutoOutBoxCode.Name = "AutoOutBoxCode";
             this.AutoOutBoxCode.Size = new System.Drawing.Size(100, 27);
@@ -345,7 +345,7 @@
             this.pa_prodcode.AutoSize = true;
             this.pa_prodcode.CutLength = null;
             this.pa_prodcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pa_prodcode.Location = new System.Drawing.Point(784, 34);
+            this.pa_prodcode.Location = new System.Drawing.Point(784, 45);
             this.pa_prodcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pa_prodcode.MaximumSize = new System.Drawing.Size(200, 0);
             this.pa_prodcode.Name = "pa_prodcode";
@@ -405,7 +405,7 @@
             this.pa_outboxcode.AllPower = "ifall";
             this.pa_outboxcode.BackColor = System.Drawing.Color.White;
             this.pa_outboxcode.ID = null;
-            this.pa_outboxcode.Location = new System.Drawing.Point(113, 36);
+            this.pa_outboxcode.Location = new System.Drawing.Point(113, 47);
             this.pa_outboxcode.Margin = new System.Windows.Forms.Padding(4);
             this.pa_outboxcode.Name = "pa_outboxcode";
             this.pa_outboxcode.Power = "ifread";
@@ -480,7 +480,7 @@
             this.pa_custcode.AutoSize = true;
             this.pa_custcode.CutLength = null;
             this.pa_custcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pa_custcode.Location = new System.Drawing.Point(1127, 34);
+            this.pa_custcode.Location = new System.Drawing.Point(1127, 45);
             this.pa_custcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pa_custcode.MaximumSize = new System.Drawing.Size(200, 0);
             this.pa_custcode.Name = "pa_custcode";
@@ -547,7 +547,7 @@
             this.pa_makecode.AutoSize = true;
             this.pa_makecode.CutLength = null;
             this.pa_makecode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.pa_makecode.Location = new System.Drawing.Point(505, 34);
+            this.pa_makecode.Location = new System.Drawing.Point(505, 45);
             this.pa_makecode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.pa_makecode.MaximumSize = new System.Drawing.Size(200, 0);
             this.pa_makecode.Name = "pa_makecode";
@@ -577,11 +577,41 @@
             this.AutoPrint.Size = new System.Drawing.Size(112, 28);
             this.AutoPrint.TabIndex = 191;
             // 
+            // OutBoxLength_label
+            // 
+            this.OutBoxLength_label.AutoSize = true;
+            this.OutBoxLength_label.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.OutBoxLength_label.Location = new System.Drawing.Point(109, 12);
+            this.OutBoxLength_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.OutBoxLength_label.Name = "OutBoxLength_label";
+            this.OutBoxLength_label.Size = new System.Drawing.Size(46, 24);
+            this.OutBoxLength_label.TabIndex = 193;
+            this.OutBoxLength_label.Text = "长度";
+            // 
+            // OutBoxLength
+            // 
+            this.OutBoxLength.AllPower = null;
+            this.OutBoxLength.BackColor = System.Drawing.Color.White;
+            this.OutBoxLength.Font = new System.Drawing.Font("微软雅黑", 9F);
+            this.OutBoxLength.ID = null;
+            this.OutBoxLength.Location = new System.Drawing.Point(180, 12);
+            this.OutBoxLength.Margin = new System.Windows.Forms.Padding(8, 9, 8, 9);
+            this.OutBoxLength.Name = "OutBoxLength";
+            this.OutBoxLength.Power = null;
+            this.OutBoxLength.Size = new System.Drawing.Size(49, 27);
+            this.OutBoxLength.Str = null;
+            this.OutBoxLength.Str1 = null;
+            this.OutBoxLength.Str2 = null;
+            this.OutBoxLength.TabIndex = 192;
+            this.OutBoxLength.KeyDown += new System.Windows.Forms.KeyEventHandler(this.OutBoxLength_KeyDown);
+            // 
             // Make_PalletCollection
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1329, 690);
+            this.Controls.Add(this.OutBoxLength_label);
+            this.Controls.Add(this.OutBoxLength);
             this.Controls.Add(this.AutoPrint);
             this.Controls.Add(this.pd_salecode);
             this.Controls.Add(this.pd_prodcode);
@@ -674,5 +704,7 @@
         private System.Windows.Forms.Label pd_prodcode;
         private System.Windows.Forms.Label pd_salecode;
         private CustomControl.CustomCheckBox.AutoPrintCheckBox AutoPrint;
+        private System.Windows.Forms.Label OutBoxLength_label;
+        private CustomControl.TextBoxWithIcon.SnCollectionBox OutBoxLength;
     }
 }

+ 59 - 5
UAS-MES/FunctionCode/Make/Make_PalletCollection.cs

@@ -71,6 +71,7 @@ namespace UAS_MES.Make
             SetLoadingWindow stw = new SetLoadingWindow(thread, "初始化打印程序");
             BaseUtil.SetFormCenter(stw);
             stw.ShowDialog();
+            OutBoxLength.Text = BaseUtil.GetCacheData("PalletLength").ToString();
             dh = new DataHelper();
         }
 
@@ -92,9 +93,11 @@ namespace UAS_MES.Make
                     BaseUtil.SetFormValue(Controls, dt);
                     LoadGridData();
                     pa_id = dt.Rows[0]["pa_id"].ToString();
+                }
+                if (CheckOutBoxLength())
+                {
                     outboxcode.Focus();
                 }
-                else outboxcode.Focus();
             }
         }
 
@@ -151,8 +154,9 @@ namespace UAS_MES.Make
                         dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                         if (dt.Rows.Count > 0)
                         {
-                            if (dt.Rows[0]["pa_outno"].ToString() != "") {
-                                OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "已被出货单"+ dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
+                            if (dt.Rows[0]["pa_outno"].ToString() != "")
+                            {
+                                OperateResult.AppendText(">>栈板" + pa_outboxcode.Text + "已被出货单" + dt.Rows[0]["pa_outno"].ToString() + "采集,不允许操作\n", Color.Red);
                                 return;
                             }
                             if (dt.Rows[0]["pa_iostatus"].ToString() != "0")
@@ -201,7 +205,7 @@ namespace UAS_MES.Make
                                 pa_outboxcode.Text = LogicHandler.GetOutBoxCode("PALLET", "", pa_prodcode.Text, User.UserCode);
                             }
                         }
-                        else if (pa_outboxcode.Text == "" || pa_status.Text == "1")
+                        else if (pa_outboxcode.Text == "" || pa_status.Text == "1" && AutoOutBoxCode.Checked)
                         {
                             pa_outboxcode.Text = LogicHandler.GetOutBoxCode("PALLET", "", pa_prodcode.Text, User.UserCode);
                         }
@@ -210,6 +214,10 @@ namespace UAS_MES.Make
                             OperateResult.AppendText(">>栈板号不能为空\n", Color.Red);
                             return;
                         }
+                        if (!CheckOutBoxLength())
+                        {
+                            return;
+                        }
                         dt = (DataTable)dh.ExecuteSql("select pa_id from  package where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
                         if (dt.Rows.Count == 0)
                         {
@@ -275,9 +283,10 @@ namespace UAS_MES.Make
                                     if (pa_standardqty.Text == pa_totalqty.Text)
                                     {
                                         dh.ExecuteSql("update package set pa_status=1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
+                                        OperateResult.AppendText("栈板" + pa_outboxcode.Text + "已装满,封栈板成功");
                                         if (AutoPrint.Checked)
                                         {
-                                            OperateResult.AppendText(">>栈板已装满,自动打印!\n", Color.Green);
+                                            OperateResult.AppendText(">>打印栈板" + pa_outboxcode.Text + ",自动打印!\n", Color.Green);
                                             Printlab.PerformClick();
                                         }
                                     }
@@ -511,5 +520,50 @@ namespace UAS_MES.Make
                 pa_standardqty.Text = stantdqty;
             }
         }
+
+        private bool CheckOutBoxLength()
+        {
+            //勾选了检验长度进行校验
+            if (OutBoxLength.Text != "")
+            {
+                try
+                {
+                    int.Parse(OutBoxLength.Text);
+                }
+                catch (Exception)
+                {
+                    MessageBox.Show("请填写正确的箱号长度");
+                    return false;
+                }
+                if (pa_outboxcode.Text.Length != int.Parse(OutBoxLength.Text))
+                {
+                    OperateResult.AppendText(">>箱号长度错误,请重新输入箱号\n", Color.Red);
+                    return false;
+                }
+                else return true;
+            }
+            return true;
+        }
+
+        private void OutBoxLength_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Enter)
+            {
+                try
+                {
+                    if (OutBoxLength.Text != "")
+                    {
+                        int.Parse(OutBoxLength.Text);
+                        BaseUtil.SetCacheData("PalletLength", OutBoxLength.Text);
+                    }
+                    pa_outboxcode.Focus();
+                }
+                catch (Exception)
+                {
+                    OutBoxLength.Clear();
+                    MessageBox.Show("请输入正确的长度");
+                }
+            }
+        }
     }
 }