浏览代码

输入的箱号不正确时箱号框始终保持焦点

章政 8 年之前
父节点
当前提交
05155da33a

+ 44 - 35
UAS-MES/FunctionCode/Packing/Packing_CartonSplit.Designer.cs

@@ -48,9 +48,10 @@
             // 
             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(39, 29);
+            this.label1.Location = new System.Drawing.Point(26, 19);
+            this.label1.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label1.Name = "label1";
-            this.label1.Size = new System.Drawing.Size(62, 31);
+            this.label1.Size = new System.Drawing.Size(42, 21);
             this.label1.TabIndex = 0;
             this.label1.Text = "箱号";
             // 
@@ -58,10 +59,10 @@
             // 
             this.lock_outbox.AutoSize = true;
             this.lock_outbox.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.lock_outbox.Location = new System.Drawing.Point(342, 29);
-            this.lock_outbox.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.lock_outbox.Location = new System.Drawing.Point(249, 19);
+            this.lock_outbox.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
             this.lock_outbox.Name = "lock_outbox";
-            this.lock_outbox.Size = new System.Drawing.Size(88, 35);
+            this.lock_outbox.Size = new System.Drawing.Size(61, 25);
             this.lock_outbox.TabIndex = 2;
             this.lock_outbox.Text = "锁定";
             this.lock_outbox.UseVisualStyleBackColor = true;
@@ -71,9 +72,10 @@
             // 
             this.label2.AutoSize = true;
             this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label2.Location = new System.Drawing.Point(676, 29);
+            this.label2.Location = new System.Drawing.Point(446, 19);
+            this.label2.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label2.Name = "label2";
-            this.label2.Size = new System.Drawing.Size(110, 31);
+            this.label2.Size = new System.Drawing.Size(74, 21);
             this.label2.TabIndex = 3;
             this.label2.Text = "箱内数量";
             // 
@@ -81,18 +83,20 @@
             // 
             this.pa_currentqty.AutoSize = true;
             this.pa_currentqty.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pa_currentqty.Location = new System.Drawing.Point(792, 29);
+            this.pa_currentqty.Location = new System.Drawing.Point(535, 19);
+            this.pa_currentqty.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.pa_currentqty.Name = "pa_currentqty";
-            this.pa_currentqty.Size = new System.Drawing.Size(0, 31);
+            this.pa_currentqty.Size = new System.Drawing.Size(0, 21);
             this.pa_currentqty.TabIndex = 4;
             // 
             // label4
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label4.Location = new System.Drawing.Point(39, 116);
+            this.label4.Location = new System.Drawing.Point(26, 77);
+            this.label4.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label4.Name = "label4";
-            this.label4.Size = new System.Drawing.Size(110, 31);
+            this.label4.Size = new System.Drawing.Size(74, 21);
             this.label4.TabIndex = 5;
             this.label4.Text = "产品编号";
             // 
@@ -100,18 +104,20 @@
             // 
             this.pa_prodcode.AutoSize = true;
             this.pa_prodcode.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pa_prodcode.Location = new System.Drawing.Point(160, 116);
+            this.pa_prodcode.Location = new System.Drawing.Point(106, 77);
+            this.pa_prodcode.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.pa_prodcode.Name = "pa_prodcode";
-            this.pa_prodcode.Size = new System.Drawing.Size(0, 31);
+            this.pa_prodcode.Size = new System.Drawing.Size(0, 21);
             this.pa_prodcode.TabIndex = 6;
             // 
             // label6
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label6.Location = new System.Drawing.Point(669, 116);
+            this.label6.Location = new System.Drawing.Point(446, 77);
+            this.label6.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label6.Name = "label6";
-            this.label6.Size = new System.Drawing.Size(120, 31);
+            this.label6.Size = new System.Drawing.Size(81, 21);
             this.label6.TabIndex = 7;
             this.label6.Text = "工单/合同";
             // 
@@ -119,18 +125,20 @@
             // 
             this.packtype.AutoSize = true;
             this.packtype.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.packtype.Location = new System.Drawing.Point(802, 116);
+            this.packtype.Location = new System.Drawing.Point(535, 77);
+            this.packtype.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.packtype.Name = "packtype";
-            this.packtype.Size = new System.Drawing.Size(0, 31);
+            this.packtype.Size = new System.Drawing.Size(0, 21);
             this.packtype.TabIndex = 8;
             // 
             // label8
             // 
             this.label8.AutoSize = true;
             this.label8.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.label8.Location = new System.Drawing.Point(39, 480);
+            this.label8.Location = new System.Drawing.Point(26, 320);
+            this.label8.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label8.Name = "label8";
-            this.label8.Size = new System.Drawing.Size(86, 31);
+            this.label8.Size = new System.Drawing.Size(58, 21);
             this.label8.TabIndex = 9;
             this.label8.Text = "序列号";
             // 
@@ -138,9 +146,10 @@
             // 
             this.label9.AutoSize = true;
             this.label9.Font = new System.Drawing.Font("微软雅黑", 10F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label9.Location = new System.Drawing.Point(554, 480);
+            this.label9.Location = new System.Drawing.Point(369, 320);
+            this.label9.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.label9.Name = "label9";
-            this.label9.Size = new System.Drawing.Size(52, 27);
+            this.label9.Size = new System.Drawing.Size(37, 20);
             this.label9.TabIndex = 10;
             this.label9.Text = "计数";
             // 
@@ -148,19 +157,19 @@
             // 
             this.count.AutoSize = true;
             this.count.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.count.Location = new System.Drawing.Point(610, 480);
+            this.count.Location = new System.Drawing.Point(407, 320);
+            this.count.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
             this.count.Name = "count";
-            this.count.Size = new System.Drawing.Size(24, 27);
+            this.count.Size = new System.Drawing.Size(17, 20);
             this.count.TabIndex = 12;
             this.count.Text = "0";
             // 
             // OperateResult
             // 
             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(32, 204);
-            this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.OperateResult.Location = new System.Drawing.Point(21, 136);
             this.OperateResult.Name = "OperateResult";
-            this.OperateResult.Size = new System.Drawing.Size(915, 246);
+            this.OperateResult.Size = new System.Drawing.Size(611, 165);
             this.OperateResult.TabIndex = 196;
             this.OperateResult.Text = "";
             // 
@@ -169,11 +178,11 @@
             this.sncode.AllPower = null;
             this.sncode.BackColor = System.Drawing.Color.White;
             this.sncode.ID = null;
-            this.sncode.Location = new System.Drawing.Point(127, 480);
-            this.sncode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.sncode.Location = new System.Drawing.Point(85, 320);
+            this.sncode.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
             this.sncode.Name = "sncode";
             this.sncode.Power = null;
-            this.sncode.Size = new System.Drawing.Size(196, 28);
+            this.sncode.Size = new System.Drawing.Size(132, 21);
             this.sncode.Str = null;
             this.sncode.Str1 = null;
             this.sncode.Str2 = null;
@@ -185,11 +194,11 @@
             this.pa_outboxcode.AllPower = null;
             this.pa_outboxcode.BackColor = System.Drawing.Color.White;
             this.pa_outboxcode.ID = null;
-            this.pa_outboxcode.Location = new System.Drawing.Point(127, 32);
-            this.pa_outboxcode.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.pa_outboxcode.Location = new System.Drawing.Point(106, 21);
+            this.pa_outboxcode.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
             this.pa_outboxcode.Name = "pa_outboxcode";
             this.pa_outboxcode.Power = null;
-            this.pa_outboxcode.Size = new System.Drawing.Size(196, 28);
+            this.pa_outboxcode.Size = new System.Drawing.Size(132, 21);
             this.pa_outboxcode.Str = null;
             this.pa_outboxcode.Str1 = null;
             this.pa_outboxcode.Str2 = null;
@@ -199,9 +208,9 @@
             // 
             // Packing_CartonSplit
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(982, 535);
+            this.ClientSize = new System.Drawing.Size(655, 357);
             this.Controls.Add(this.OperateResult);
             this.Controls.Add(this.count);
             this.Controls.Add(this.sncode);
@@ -217,7 +226,7 @@
             this.Controls.Add(this.pa_outboxcode);
             this.Controls.Add(this.label1);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
-            this.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.Margin = new System.Windows.Forms.Padding(2, 1, 2, 1);
             this.Name = "Packing_CartonSplit";
             this.Tag = "Packing!CartonSplit";
             this.Text = "Packing_CartonSplit";

+ 37 - 24
UAS-MES/FunctionCode/Packing/Packing_CartonSplit.cs

@@ -36,6 +36,7 @@ namespace UAS_MES.Packing
         {
             InitializeComponent();
         }
+
         private void Packing_CartonSplit_Load(object sender, EventArgs e)
         {
             dh = new DataHelper();
@@ -43,10 +44,11 @@ namespace UAS_MES.Packing
             OperateResult.AppendText(">>请输入箱号\n", Color.Black);
             pa_outboxcode.Focus();
         }
+
         private void pa_outboxcode_KeyDown(object sender, KeyEventArgs e)
         {
             //按下回车
-            if (e.KeyCode==Keys.Enter)
+            if (e.KeyCode == Keys.Enter)
             {
                 lKeyDown(false);
             }
@@ -54,13 +56,16 @@ namespace UAS_MES.Packing
 
         private void sncode_KeyDown(object sender, KeyEventArgs e)
         {
-            if (e.KeyCode==Keys.Enter) {
-                if (sncode.Text=="") {
+            if (e.KeyCode == Keys.Enter)
+            {
+                if (sncode.Text == "")
+                {
                     OperateResult.AppendText("<<输入不能为空\n", Color.Red);
                     return;
                 }
                 //判断箱号是否为空
-                if (pa_outboxcode.Text=="") {
+                if (pa_outboxcode.Text == "")
+                {
                     OperateResult.AppendText("<<请先选择箱号\n", Color.Red, sncode);
                     return;
                 }
@@ -69,19 +74,21 @@ namespace UAS_MES.Packing
                 {
                     //验证序列号是否存在,是否装箱,箱号等于页面输入的箱号
                     //select max(ms_id) from makeserial where ms_sncode=?
-                    ms_id = dh.getFieldDataByCondition("makeserial","max(ms_id)","ms_sncode='"+sncode.Text+"'").ToString();
-                    if (ms_id=="") {
+                    ms_id = dh.getFieldDataByCondition("makeserial", "max(ms_id)", "ms_sncode='" + sncode.Text + "'").ToString();
+                    if (ms_id == "")
+                    {
                         OperateResult.AppendText("<<序列号" + sncode.Text + "不存在\n", Color.Red, sncode);
                         return;
                     }
-                    outboxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode","ms_id='"+ms_id+"' and nvl(ms_outboxcode,' ')<>' '").ToString();
-                    if (outboxcode=="") {
+                    outboxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + ms_id + "' and nvl(ms_outboxcode,' ')<>' '").ToString();
+                    if (outboxcode == "")
+                    {
                         OperateResult.AppendText("<<序列号" + sncode.Text + "未装箱\n", Color.Red, sncode);
                         return;
                     }
-                    if (pa_outboxcode.Text!=outboxcode)
+                    if (pa_outboxcode.Text != outboxcode)
                     {
-                        OperateResult.AppendText("<<序列号" + sncode.Text + "箱号为:" + outboxcode+",不在箱号:"+pa_outboxcode.Text+ "中,无法拆箱\n", Color.Red, sncode);
+                        OperateResult.AppendText("<<序列号" + sncode.Text + "箱号为:" + outboxcode + ",不在箱号:" + pa_outboxcode.Text + "中,无法拆箱\n", Color.Red, sncode);
                         return;
                     }
                     //验证箱号
@@ -90,32 +97,32 @@ namespace UAS_MES.Packing
                         return;
                     }
                     //验证是否在箱内
-                    pd_id = dh.getFieldDataByCondition("packagedetail", "pd_id", "pd_outboxcode='"+pa_outboxcode.Text+"' and pd_barcode='"+sncode.Text+"'").ToString();
-                    if (pd_id=="")
+                    pd_id = dh.getFieldDataByCondition("packagedetail", "pd_id", "pd_outboxcode='" + pa_outboxcode.Text + "' and pd_barcode='" + sncode.Text + "'").ToString();
+                    if (pd_id == "")
                     {
-                        OperateResult.AppendText("<<序列号" + sncode.Text + "不在箱号:" + pa_outboxcode.Text+ "内,不允许拆箱\n", Color.Red, sncode);
+                        OperateResult.AppendText("<<序列号" + sncode.Text + "不在箱号:" + pa_outboxcode.Text + "内,不允许拆箱\n", Color.Red, sncode);
                         return;
                     }
                     //进行拆箱处理
                     //删除明细
-                    dh.ExecuteSql("delete from packagedetail where pd_id='"+pd_id+"'", "select");
+                    dh.ExecuteSql("delete from packagedetail where pd_id='" + pd_id + "'", "select");
                     //更新序列号
-                    dh.ExecuteSql("update makeserial set ms_outboxcode='' , ms_nextstepcode=ms_stepcode where ms_id='"+ms_id+"'", "update");
+                    dh.ExecuteSql("update makeserial set ms_outboxcode='' , ms_nextstepcode=ms_stepcode where ms_id='" + ms_id + "'", "update");
                     //更新箱内当前数量
-                    dh.ExecuteSql("update package set pa_currentqty=pa_currentqty-1 where pa_outboxcode='"+pa_outboxcode.Text+"'", "update");
+                    dh.ExecuteSql("update package set pa_currentqty=pa_currentqty-1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
                     //记录拆箱操作日志
-                    LogicHandler.DoCommandLog(Tag.ToString(),User.UserCode,packtype.Text,User.UserLineCode,User.UserSourceCode,"卡通箱拆箱", "卡通箱拆箱成功,序列号:"+sncode.Text+",箱号:"+pa_outboxcode.Text,sncode.Text,"");
+                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, packtype.Text, User.UserLineCode, User.UserSourceCode, "卡通箱拆箱", "卡通箱拆箱成功,序列号:" + sncode.Text + ",箱号:" + pa_outboxcode.Text, sncode.Text, "");
                     //提示拆箱成功
-                    OperateResult.AppendText("<<拆箱成功,序列号:"+sncode.Text+",已从箱号:"+pa_outboxcode.Text+ "内移除\n", Color.Green);
+                    OperateResult.AppendText("<<拆箱成功,序列号:" + sncode.Text + ",已从箱号:" + pa_outboxcode.Text + "内移除\n", Color.Green);
                     //刷新箱内数量
-                    pa_currentqty.Text = int.Parse(pa_currentqty.Text)-1+"";
+                    pa_currentqty.Text = int.Parse(pa_currentqty.Text) - 1 + "";
                     //计数加1
                     count.Text = int.Parse(count.Text) + 1 + "";
                     sncode.Text = "";
                 }
                 else
                 {
-                    OperateResult.AppendText("<<"+error+ "\n", Color.Red, sncode);
+                    OperateResult.AppendText("<<" + error + "\n", Color.Red, sncode);
                 }
             }
         }
@@ -132,10 +139,11 @@ namespace UAS_MES.Packing
             {
                 if (flag)
                 {
-                    MessageBox.Show("箱号"+pa_outboxcode.Text+"不存在");
+                    MessageBox.Show("箱号" + pa_outboxcode.Text + "不存在");
+                    pa_outboxcode.Focus();
                     return false;
                 }
-                OperateResult.AppendText("<<箱号"+pa_outboxcode.Text+"不存在\n", Color.Red, pa_outboxcode);
+                OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "不存在\n", Color.Red, pa_outboxcode);
                 return false;
             }
             //判断是否下地
@@ -144,6 +152,7 @@ namespace UAS_MES.Packing
                 if (flag)
                 {
                     MessageBox.Show("箱号" + pa_outboxcode.Text + "处于下地状态不允许操作");
+                    pa_outboxcode.Focus();
                     return false;
                 }
                 OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "处于下地状态不允许操作\n", Color.Red, pa_outboxcode);
@@ -159,6 +168,7 @@ namespace UAS_MES.Packing
                     if (flag)
                     {
                         MessageBox.Show("箱号" + pa_outboxcode.Text + "处于送检状态,不允许拆箱");
+                        pa_outboxcode.Focus();
                         return false;
                     }
                     OperateResult.AppendText("<<箱号" + pa_outboxcode.Text + "处于送检状态,不允许拆箱\n", Color.Red, pa_outboxcode);
@@ -171,6 +181,7 @@ namespace UAS_MES.Packing
                 if (flag)
                 {
                     MessageBox.Show("<<卡通箱:" + pa_outboxcode.Text + "已装箱,不允许拆箱\n");
+                    pa_outboxcode.Focus();
                     return false;
                 }
                 OperateResult.AppendText("<<卡通箱:" + pa_outboxcode.Text + "已装箱,不允许拆箱\n", Color.Red, sncode);
@@ -188,7 +199,7 @@ namespace UAS_MES.Packing
                     //取消勾选,箱号不可编辑时设置可编辑
                     pa_outboxcode.Enabled = true;
                 }
-                    pa_outboxcode.Focus();
+                pa_outboxcode.Focus();
             }
             else
             {
@@ -204,6 +215,7 @@ namespace UAS_MES.Packing
         {
             asc.controlAutoSize(this);
         }
+
         private bool lKeyDown(bool flag)
         {
             //输入不能为空
@@ -212,6 +224,7 @@ namespace UAS_MES.Packing
                 if (flag)
                 {
                     MessageBox.Show("输入不能为空");
+                    pa_outboxcode.Focus();
                     return false; ;
                 }
                 OperateResult.AppendText("<<输入不能为空\n", Color.Red);
@@ -255,4 +268,4 @@ namespace UAS_MES.Packing
             }
         }
     }
-}
+}