Browse Source

Merge remote-tracking branch 'refs/remotes/origin/master'

shim 8 years ago
parent
commit
c790e434fa

+ 10 - 1
UAS-MES/Form1.Designer.cs

@@ -34,6 +34,7 @@
             this.button4 = new System.Windows.Forms.Button();
             this.progressBar1 = new System.Windows.Forms.ProgressBar();
             this.textBoxWithPlaceHolder1 = new UAS_MES.CustomControl.TextBoxWithIcon.TextBoxWithPlaceHolder();
+            this.serialPortCombox1 = new UAS_MES.CustomControl.ComBoxWithFocus.SerialPortCombox();
             this.SuspendLayout();
             // 
             // button1
@@ -76,7 +77,6 @@
             this.button4.TabIndex = 2;
             this.button4.Text = "button4";
             this.button4.UseVisualStyleBackColor = true;
-            this.button4.Click += new System.EventHandler(this.button4_Click);
             // 
             // progressBar1
             // 
@@ -96,11 +96,19 @@
             this.textBoxWithPlaceHolder1.Size = new System.Drawing.Size(241, 25);
             this.textBoxWithPlaceHolder1.TabIndex = 4;
             // 
+            // serialPortCombox1
+            // 
+            this.serialPortCombox1.Location = new System.Drawing.Point(398, 61);
+            this.serialPortCombox1.Name = "serialPortCombox1";
+            this.serialPortCombox1.Size = new System.Drawing.Size(186, 25);
+            this.serialPortCombox1.TabIndex = 6;
+            // 
             // Form1
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1239, 738);
+            this.Controls.Add(this.serialPortCombox1);
             this.Controls.Add(this.textBoxWithPlaceHolder1);
             this.Controls.Add(this.progressBar1);
             this.Controls.Add(this.button4);
@@ -125,5 +133,6 @@
         private System.Windows.Forms.Button button4;
         private System.Windows.Forms.ProgressBar progressBar1;
         private CustomControl.TextBoxWithIcon.TextBoxWithPlaceHolder textBoxWithPlaceHolder1;
+        private CustomControl.ComBoxWithFocus.SerialPortCombox serialPortCombox1;
     }
 }

+ 110 - 90
UAS-MES/Form1.cs

@@ -19,133 +19,153 @@ using System.IO;
 using System.Reflection;
 using System.Threading;
 using UAS_MES.CustomControl;
+using System.IO.Ports;
 
 namespace UAS_MES
 {
     public partial class Form1 : Form
     {
-        DataHelper dh;
-        DataTable dt;
-        LogStringBuilder sql = new LogStringBuilder();
-        //经过的步骤
-        string PastStep = "";
-        //拆分后的经过的步骤
-        Dictionary<int, string> Step;
-        //屏幕高度
-        int ScreenWidth;
-        //屏幕宽度
-        int ScreenHeight;
         public Form1()
         {
             InitializeComponent();
         }
 
-        [DllImport("kernel32.dll")]
+        private void Form1_Load(object sender, EventArgs e)
+        {
+            Com.PortName = "COM4";
+            Com.ReadTimeout = 5000;
+            Com.WriteTimeout = 5000;
+            Com.BaudRate = 9600;
+            Com.StopBits = StopBits.One;
+            Com.Parity = Parity.None;
+            Com.Open();
+        }
 
-        public static extern bool d(int freq, int duration);
+        [DllImport("WinIo64.dll")]
+        public static extern bool InitializeWinIo();
+        [DllImport("WinIo64.dll")]
+        public static extern void ShutdownWinIo();
+        [DllImport("WinIo64.dll")]
+        public static extern bool GetPortVal(IntPtr wPortAddr, out int pdwPortVal, byte bSize);
+        [DllImport("WinIo64.dll")]
+        public static extern bool SetPortVal(IntPtr wPortAddr, int dwPortVal, byte bSize);
+        //以下是与并口无关  
+        [DllImport("WinIo64.dll")]
+        public static extern byte MapPhysToLin(byte pbPhysAddr, uint dwPhysSize, IntPtr PhysicalMemoryHandle);
+        [DllImport("WinIo64.dll")]
+        public static extern bool UnmapPhysicalMemory(IntPtr PhysicalMemoryHandle, byte pbLinAddr);
+        [DllImport("WinIo64.dll")]
+        public static extern bool GetPhysLong(IntPtr pbPhysAddr, byte pdwPhysVal);
+        [DllImport("WinIo64.dll")]
+        public static extern bool SetPhysLong(IntPtr pbPhysAddr, byte dwPhysVal);
+        [DllImport("user32.dll")]
+        public static extern int MapVirtualKey(uint Ucode, uint uMapType);
 
-        private void button3_Click(object sender, EventArgs e)
+        public bool online = false;                          //WinIo打开标志  
+        //数据端口共8位,控制端口共4位,可以组成1~12位的任意数字输出端口;  
+        //状态端口共5位,控制端口共4位,可以组成1~9位的任意数字输入端口  
+        private static IntPtr data_port = (IntPtr)0x378;     //数据端口地址 D0-D7 8个端口  
+        private static IntPtr state_port = (IntPtr)0x379;    //状态端口地址 S3-S7 只能读取5位  
+        private static IntPtr control_port = (IntPtr)0x37A;  //控制端口地址 C0-C3 只能控制或输出4位  
+
+        /// <summary>  
+        /// 设定DataPort输出  
+        /// </summary>  
+        /// <param name="WriteValue">设定值:范围为0~255</param>  
+        private void setDateBuff(int WriteValue)
         {
-            d(800, 600);
+            IntPtr m_nport = data_port;                 //数据端口地址data_port  
+
+            int m_nValue = WriteValue;
+
+            //调用WinIo库函数SetPortVal写端口值  
+            SetPortVal(m_nport, m_nValue, 1);           //write a BYTE value to an I/O port  
         }
 
-        private void Form1_Load(object sender, EventArgs e)
+        /// <summary>  
+        /// 设定ControlPort输出  
+        /// 高4位默认设置,请不要修改,因此输出时保持高位值不变,将要输出的值从低4位输出  
+        /// Control端口C2读写正常,C0、C1、C3写入0则输出高电平,写入1输出低电平;读取亦然  
+        /// </summary>  
+        /// <param name="WriteValue">设定值</param>  
+        private void setControlBuff(int WriteValue)
         {
+            IntPtr m_nport = control_port;              //获得控制端口地址  
+            //获得控制端口的值,  
+            int temp_dwPortVal = 0;
+            GetPortVal(m_nport, out temp_dwPortVal, 1); //reads a BYTE value from an I/O port  
+
+            int temp_aa = temp_dwPortVal & 0xF0;        //将低4位置为0;高4位不变  
 
+            int WriValue = WriteValue & 0x0F;           //取设定值低4位;高4位为0  
+            temp_aa = temp_aa | WriteValue;             //合并端口值高4位与设定值低4位  
+            temp_aa = temp_aa ^ 0x0B;                   //将低4位中C0、C1、C3取反(0->1;1->0)(保证设定值与实际电平相吻合)  
+            SetPortVal(m_nport, temp_aa, 1);            //写出的值中,高4位保持端口原来的值不变,低4位实际输出  
         }
 
-        private void button3_Click_1(object sender, EventArgs e)
+        /// <summary>  
+        /// 读取ControlPort值  
+        /// Control端口C2读取正常,C0、C1、C3高电平则读入0,低电平则读入1  
+        /// </summary>  
+        /// <returns>返回C0-C3 四个端口的值:范围为0~15</returns>  
+        private int getControlBuff()
         {
-            // 禁用按钮
-            //this.button1.Enabled = false;
+            IntPtr m_nport = control_port;              //控制端口地址data_port  
+
+            int m_nValue = 0;
+            //调用WinIo库函数SetPortVal写端口值  
+            GetPortVal(m_nport, out m_nValue, 1);      //reads a BYTE value from an I/O port  
 
-            //// 实例化业务对象
-            //PublicMethod.LongTimeWork workder = new PublicMethod.LongTimeWork();
+            int ValueGet = m_nValue ^ 0x0B;            //将低4位中C0、C1、C3取反(0->1;1->0)  
+            ValueGet = ValueGet & 0x0F;                //去掉高4位值  
+            return ValueGet;
+        }
+
+        /// <summary>  
+        /// 读取StatePort值  
+        /// State端口S7高电平则读入0,低电平则读入1;其他正常  
+        /// </summary>  
+        /// <returns>返回S3-S7 五个端口的值:范围0-31</returns>  
+        private int getStateBuff()
+        {
+            IntPtr m_nport = state_port;               //控制端口地址state_port  
 
-            //workder.ValueChanged += new PublicMethod.ValueChangedEventHandler(workder_ValueChanged);
+            int dwPortVal = 0;
+            GetPortVal(m_nport, out dwPortVal, 1);    //reads a BYTE value from an I/O port  
 
-            //// 使用异步方式调用长时间的方法
-            //Action handler = new Action(workder.LongTimeMethod);
-            //handler.BeginInvoke(new AsyncCallback(this.AsyncCallback), handler);
-            WebClient wc = new WebClient();
-            wc.DownloadProgressChanged += Wc_DownloadProgressChanged;
-            wc.DownloadFileAsync(new Uri("http://218.17.158.219:8888/UAS_WinForm.zip"), "UAS_WinForm.zip");
-            //processBar1.Run();
+            int ValueGet = dwPortVal ^ 0x80;          //将S7取反(保证读取与实际电平相吻合)  
+            ValueGet = ValueGet & 0xF8;               //去掉S0 ~S2位;  
+            ValueGet = ValueGet >> 3;                 //右移3位,将S7~S3变为低5位  
+            return ValueGet;
         }
 
-        // 结束异步操作
-        private void AsyncCallback(IAsyncResult ar)
+        public bool OpenWinIo()
         {
-            // 标准的处理步骤
-            Action handler = ar.AsyncState as Action;
-            handler.EndInvoke(ar);
-            MessageBox.Show("工作完成!");
-            System.Windows.Forms.MethodInvoker invoker = () =>
+            if (InitializeWinIo())
             {
-                // 重新启用按钮
-                this.button3.Enabled = true;
-            };
-            if (this.InvokeRequired)
-            {
-                this.Invoke(invoker);
+                this.online = true;
+                return true;
             }
             else
             {
-                invoker();
+                this.online = false;
+                return false;
             }
         }
 
-        private void Wc_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
+        public void CloseWinIo()
         {
-            Action act = () =>
-            {
-                this.progressBar1.Value = e.ProgressPercentage;
-                //this.label1.Text = e.ProgressPercentage + "%";
-            };
-            if (e.ProgressPercentage == 100)
-            {
-                ZipHelper.UnZip(@"H:\UAS_WinForm\UAS-MES\bin\Debug\icsharpcode-SharpZipLib-4ad264b.zip", @"D:\");
-            }
-            this.Invoke(act);
+            ShutdownWinIo();
+            this.online = false;
         }
 
-        //public static void Unzip()
-        //{
-        //    string _appPath = new DirectoryInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName).Parent.FullName;
-        //    string s7z = _appPath + @"\7-Zip\7z.exe";
-        //    System.Diagnostics.Process pNew = new System.Diagnostics.Process();
-        //    pNew.StartInfo.FileName = s7z;
-        //    pNew.StartInfo.Arguments = string.Format(" x \"{0}\\{1}\" -y -o\"{0}\"", _appPath, zipFileFullName);
-        //    //x "1" -y -o"2" 这段7z命令的意思: x是解压的意思 "{0}"的位置写要解压文件路径"{1}"这个1的位置写要解压的文件名 -y是覆盖的意思 -o是要解压的位置
-        //    pNew.Start();
-        //    //等待完成
-        //    pNew.WaitForExit();
-        //    //删除压缩包
-        //    File.Delete(_appPath + @"\" + zipFileFullName);
-        //}
-
-        private void button4_Click(object sender, EventArgs e)
+        SerialPort Com = new SerialPort();
+
+        private void button3_Click_1(object sender, EventArgs e)
         {
-            MessageBox.Show(textBoxWithPlaceHolder1.Text);
+            //byte[] byteArr = new byte[20];
+            //Com.Write(byteArr, 0, byteArr.Length);
+            //CloseWinIo();
         }
     }
-
-    //public class ZipHelper
-    //{
-    //    public static string zipFileFullName = "UAS_WinForm.zip";
-    //    public static void Unzip()
-    //    {
-    //        string _appPath = new DirectoryInfo(Assembly.GetExecutingAssembly().ManifestModule.FullyQualifiedName).Parent.FullName;
-    //        string s7z = _appPath + @"\7z.exe";
-    //        System.Diagnostics.Process pNew = new System.Diagnostics.Process();
-    //        pNew.StartInfo.FileName = s7z;
-    //        pNew.StartInfo.Arguments = string.Format(" x \"{0}\\{1}\" -y -o\"{0}\"", _appPath, zipFileFullName);
-    //        //x "1" -y -o"2" 这段7z命令的意思: x是解压的意思 "{0}"的位置写要解压文件路径"{1}"这个1的位置写要解压的文件名 -y是覆盖的意思 -o是要解压的位置
-    //        pNew.Start();
-    //        //等待完成
-    //        pNew.WaitForExit();
-    //        //删除压缩包
-    //        //File.Delete(_appPath + @"\" + zipFileFullName);
-    //    }
-    //}
 }

+ 21 - 9
UAS-MES/FunctionCode/Make/Make_BigBoxCollection.cs

@@ -86,17 +86,15 @@ namespace UAS_MES.Make
             if (e.KeyCode == Keys.Enter)
             {
                 sql.Clear();
-                sql.Append("select pa_makecode,pa_standardqty,pa_packageqty,pa_prodcode,pa_outboxcode,pa_totalqty,pa_currentqty,pa_custcode,pa_salecode ");
+                sql.Append("select pa_makecode,pa_id,pa_standardqty,pa_id,pa_packageqty,pa_prodcode,pa_outboxcode,pa_totalqty,pa_currentqty,pa_custcode,pa_salecode ");
                 sql.Append("from package where pa_outboxcode='" + pa_outboxcode.Text + "'  and pa_type =2");
                 DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                 if (dt.Rows.Count > 0)
                 {
                     BaseUtil.SetFormValue(Controls, dt);
                     LoadGridData();
-                    dt = dh.getFieldsDataByCondition("Package", new string[] { "pa_id", "pa_standardqty" }, "pa_outboxcode='" + pa_outboxcode.Text + "'");
                     pa_stanqty = int.Parse(dt.Rows[0]["pa_standardqty"].ToString());
                     pa_id = dt.Rows[0]["pa_id"].ToString();
-                    FillPrintLabel();
                     outboxcode.Focus();
                 }
                 else outboxcode.Focus();
@@ -116,18 +114,26 @@ namespace UAS_MES.Make
                         return;
                     }
                     sql.Clear();
-                    sql.Append("select pd_makecode pa_makecode,pa_id,pd_prodcode pa_prodcode,pa_status,pa_mothercode,pa_nextstep,nvl(pr_bigboxinnerqty,0) pa_standardqty from packagedetail ");
-                    sql.Append("left join package on pd_paid=pa_id left join product on pd_prodcode=pr_code where pd_outboxcode='" + outboxcode.Text + "'");
+                    sql.Append("select pd_makecode pa_makecode,nvl(pa_downstatus,0)pa_downstatus,pa_id,pd_prodcode pa_prodcode,pa_status,pa_mothercode,pa_nextstep,nvl(pr_bigboxinnerqty,0) pa_standardqty  ");
+                    sql.Append("from packagedetail left join package on pd_paid=pa_id left join product on pd_prodcode=pr_code where pd_outboxcode='" + outboxcode.Text + "'");
                     dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                     //判断采集的卡通箱是否有明细
                     if (dt.Rows.Count > 0)
                     {
                         BaseUtil.SetFormValue(this.Controls, dt);
+                        if (dt.Rows[0]["pa_downstatus"].ToString() != "0")
+                        {
+                            OperateResult.AppendText(">>箱号" + outboxcode.Text + "下地状态不允许采集\n", Color.Red, outboxcode);
+                            return;
+                        }
                         //之前装过箱加载明细
                         if (dt.Rows[0]["pa_mothercode"].ToString() != "")
                         {
-                            pa_outboxcode.Text = dt.Rows[0]["pa_mothercode"].ToString();
-                            palletcode_KeyDown(sender, e);
+                            if (pa_outboxcode.Text == "")
+                            {
+                                pa_outboxcode.Text = dt.Rows[0]["pa_mothercode"].ToString();
+                                palletcode_KeyDown(sender, e);
+                            }
                         }
                         pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString();
                         pa_stanqty = int.Parse(dt.Rows[0]["pa_standardqty"].ToString());
@@ -138,7 +144,7 @@ namespace UAS_MES.Make
                         }
                         if (pa_nextstep != User.CurrentStepCode && pa_nextstep != "")
                         {
-                            OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "的下一工序不是当前岗位资源对应工序\n", Color.Red, outboxcode);
+                            OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "的下一工序不是当前岗位资源对应工序,下一工序为" + pa_nextstep + "\n", Color.Red, outboxcode);
                             return;
                         }
                         //未空表示线外
@@ -280,7 +286,13 @@ namespace UAS_MES.Make
                             }
                         }
                     }
-                    else OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "已采集\n", Color.Red, outboxcode);
+                    else
+                    {
+                        if (dt.Rows[0]["pa_mothercode"].ToString() == pa_outboxcode.Text)
+                            OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "已在本大箱内\n", Color.Red, outboxcode);
+                        else
+                            OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "已采集至大箱" + dt.Rows[0]["pa_mothercode"].ToString() + "\n", Color.Red, outboxcode);
+                    }
                 }
                 else OperateResult.AppendText(">>卡通箱号" + outboxcode.Text + "尚未封箱\n", Color.Red, outboxcode);
             }

+ 10 - 6
UAS-MES/FunctionCode/Make/Make_PackageCollection.cs

@@ -238,9 +238,13 @@ namespace UAS_MES.Make
                         if (!Cancel.Checked)
                         {
                             //判断序列号是否已经装箱
-                            if (dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString() != "")
+                            string ms_outboxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString();
+                            if (ms_outboxcode != "")
                             {
-                                OperateResult.AppendText(">>序列号" + sn_code.Text + "已经装箱!\n", Color.Red, sn_code);
+                                if (ms_outboxcode == pa_outboxcode.Text)
+                                    OperateResult.AppendText(">>序列号" + sn_code.Text + "已在本箱内\n", Color.Red, sn_code);
+                                else
+                                    OperateResult.AppendText(">>序列号" + sn_code.Text + "已采集至箱" + ms_outboxcode + "\n", Color.Red, sn_code);
                                 LoadData();
                             }
                             else
@@ -262,7 +266,7 @@ namespace UAS_MES.Make
                                         OperateResult.AppendText(">>" + ErrorMessage + "\n");
                                     LastSncode = sn_code.Text;
                                     OperateResult.AppendText(">>序列号" + sn_code.Text + "采集成功!\n", Color.Green);
-                                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "装箱采集", "采集成功", sn_code.Text, "");
+                                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "卡通箱采集", "卡通箱" + pa_outboxcode.Text + "采集成功", sn_code.Text, "");
                                     //满箱更新状态为1
                                     LoadData();
                                     LoadGridData();
@@ -300,7 +304,7 @@ namespace UAS_MES.Make
                         {
                             if (LogicHandler.Packing(sn_code.Text, pa_outboxcode.Text, AutoGenBoxCode.Checked, "标准", User.UserSourceCode, User.UserCode, pr_outboxinnerqty.Text, Cancel.Checked, out oOutBoxCode, out ErrorMessage))
                             {
-                                LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "装箱采集", "取消采集成功", sn_code.Text, "");
+                                LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "卡通箱采集", "卡通箱" + pa_outboxcode.Text + "取消采集成功", sn_code.Text, "");
                                 LoadGridData();
                                 pa_status.Text = "0";
                                 OperateResult.AppendText(">>已从该箱中移除序列号" + sn_code.Text + "\n", Color.Green, sn_code);
@@ -350,7 +354,7 @@ namespace UAS_MES.Make
                     dh.UpdateByCondition("package", "pa_status=1,pa_totalqty=pa_currentqty,pa_packageqty=pa_currentqty", "pa_outboxcode='" + pa_outboxcode.Text + "'");
                     pa_status.Text = "1";
                     pa_standardqty.Text = "";
-                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "装箱采集", "封箱成功", pa_outboxcode.Text, "");
+                    LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "装箱采集", "封箱成功", pa_outboxcode.Text, "");
                     if (PR_CHECKCARTONW != "0")
                     {
                         OperateResult.AppendText(">>卡通箱" + pa_outboxcode.Text + "处于称重工序,请在卡通箱称重界面进行操作\n", Color.Black, sn_code);
@@ -384,7 +388,7 @@ namespace UAS_MES.Make
                 OperateResult.AppendText(">>批次" + ob_checkno.Text + "送检成功\n", Color.Green);
                 LogicHandler.InsertMakeProcess(LastSncode, oMakeCode, User.UserSourceCode, "手动送检", "手动送检成功", User.UserCode);
                 //记录操作日志
-                LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
+                LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, pa_makecode.Text, User.UserLineCode, User.UserSourceCode, "手动送检", "手动送检成功", "", ob_checkno.Text);
                 ob_checkno.Text = "";
             }
             else OperateResult.AppendText(">>必须封箱才能送检\n", Color.Red);

+ 6 - 3
UAS-MES/FunctionCode/Make/Make_PackageCollectionWeigh.cs

@@ -316,10 +316,13 @@ namespace UAS_MES.Make
                         //如果未勾选了取消录入
                         if (!Cancel.Checked)
                         {
-                            //判断序列号是否已经装箱
-                            if (dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString() != "")
+                            string ms_outboxcode = dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString();
+                            if (ms_outboxcode != "")
                             {
-                                OperateResult.AppendText(">>序列号" + sn_code.Text + "已经装箱!\n", Color.Red, sn_code);
+                                if (ms_outboxcode == pa_outboxcode.Text)
+                                    OperateResult.AppendText(">>序列号" + sn_code.Text + "已在本箱内\n", Color.Red, sn_code);
+                                else
+                                    OperateResult.AppendText(">>序列号" + sn_code.Text + "已采集至箱" + ms_outboxcode + "\n", Color.Red, sn_code);
                                 LoadData();
                             }
                             else

+ 24 - 9
UAS-MES/FunctionCode/Make/Make_PalletCollection.cs

@@ -84,17 +84,15 @@ namespace UAS_MES.Make
             if (e.KeyCode == Keys.Enter)
             {
                 sql.Clear();
-                sql.Append("select pa_makecode,pa_standardqty,pa_status,pa_packageqty,pa_currentqty,pa_prodcode,pa_outboxcode,pa_totalqty,pa_custcode,pa_salecode ");
+                sql.Append("select pa_makecode,pa_id,pa_standardqty,pa_status,pa_packageqty,pa_currentqty,pa_prodcode,pa_outboxcode,pa_totalqty,pa_custcode,pa_salecode ");
                 sql.Append("from package where pa_outboxcode='" + pa_outboxcode.Text + "' and pa_type =3");
                 DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                 if (dt.Rows.Count > 0)
                 {
                     BaseUtil.SetFormValue(Controls, dt);
                     LoadGridData();
-                    dt = dh.getFieldsDataByCondition("Package", new string[] { "pa_standardqty", "pa_id" }, "pa_outboxcode='" + pa_outboxcode.Text + "'");
                     pa_stanqty = int.Parse(dt.Rows[0]["pa_standardqty"].ToString());
                     pa_id = dt.Rows[0]["pa_id"].ToString();
-                    FillPrintLabel();
                     outboxcode.Focus();
                 }
                 else outboxcode.Focus();
@@ -114,16 +112,24 @@ namespace UAS_MES.Make
                         return;
                     }
                     sql.Clear();
-                    sql.Append("select pd_makecode pa_makecode,pa_id,pd_prodcode pa_prodcode,pa_mothercode,pa_status,pa_nextstep,nvl(pr_palletqty,0) pa_standardqty  from packagedetail ");
+                    sql.Append("select pd_makecode pa_makecode,nvl(pa_downstatus,0)pa_downstatus,pa_id,pd_prodcode pa_prodcode,pa_mothercode,pa_status,pa_nextstep,nvl(pr_palletqty,0) pa_standardqty  from packagedetail ");
                     sql.Append("left join package on pd_paid=pa_id left join product on pr_code=pd_prodcode where pd_outboxcode='" + outboxcode.Text + "'");
                     dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                     if (dt.Rows.Count > 0)
                     {
                         BaseUtil.SetFormValue(this.Controls, dt);
+                        if (dt.Rows[0]["pa_downstatus"].ToString() != "0")
+                        {
+                            OperateResult.AppendText(">>箱号" + outboxcode.Text + "下地状态不允许采集\n", Color.Red, outboxcode);
+                            return;
+                        }
                         if (dt.Rows[0]["pa_mothercode"].ToString() != "")
                         {
-                            pa_outboxcode.Text = dt.Rows[0]["pa_mothercode"].ToString();
-                            palletcode_KeyDown(sender, e);
+                            if (pa_outboxcode.Text == "")
+                            {
+                                pa_outboxcode.Text = dt.Rows[0]["pa_mothercode"].ToString();
+                                palletcode_KeyDown(sender, e);
+                            }
                         }
                         pa_nextstep = dt.Rows[0]["pa_nextstep"].ToString();
                         pa_stanqty = int.Parse(dt.Rows[0]["pa_standardqty"].ToString());
@@ -250,7 +256,13 @@ namespace UAS_MES.Make
                             }
                             else OperateResult.AppendText(">>箱号" + outboxcode.Text + "尚未封箱\n", Color.Red, outboxcode);
                         }
-                        else OperateResult.AppendText(">>箱号" + outboxcode.Text + "已采集\n", Color.Red, outboxcode);
+                        else
+                        {
+                            if (dt.Rows[0]["pa_mothercode"].ToString() == pa_outboxcode.Text)
+                                OperateResult.AppendText(">>箱号" + outboxcode.Text + "已在本栈板内\n", Color.Red, outboxcode);
+                            else
+                                OperateResult.AppendText(">>箱号" + outboxcode.Text + "已采集至栈板" + dt.Rows[0]["pa_mothercode"].ToString() + "\n", Color.Red, outboxcode);
+                        }
                     }
                     else OperateResult.AppendText(">>箱号" + outboxcode.Text + "不存在\n", Color.Red, outboxcode);
                 }
@@ -314,8 +326,11 @@ namespace UAS_MES.Make
                     OperateResult.AppendText(">>打印箱号" + pa_outboxcode.Text + "\n", Color.Black);
                     doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text);
                     Print.CodeSoft(Tag.ToString(), doc, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), PrinterList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text));
-                    pa_outboxcode.Focus();
-                    pa_outboxcode.SelectAll();
+                    if (!AutoOutBoxCode.Checked)
+                    {
+                        pa_outboxcode.Focus();
+                        pa_outboxcode.SelectAll();
+                    }
                 }
                 else OperateResult.AppendText(">>必须封栈板才能进行打印\n", Color.Red);
             }