callm пре 3 година
родитељ
комит
0c6dc16d9f

+ 6 - 0
UAS-出货标签管理(CKD)/App.config

@@ -71,6 +71,12 @@
       <setting name="FTPNET" serializeAs="String">
         <value>False</value>
       </setting>
+      <setting name="PortName" serializeAs="String">
+        <value />
+      </setting>
+      <setting name="BaudRate" serializeAs="String">
+        <value />
+      </setting>
     </UAS_LabelMachine.Properties.Settings>
   </userSettings>
 </configuration>

+ 116 - 0
UAS-出货标签管理(CKD)/ComInfoSet.Designer.cs

@@ -0,0 +1,116 @@
+namespace UAS_LabelMachine
+{
+    partial class ComInfoSet
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary>
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Windows Form Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.label8 = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.BaudRate = new UAS_LabelMachine.CustomControl.EnterTextBox();
+            this.Confirm = new System.Windows.Forms.Button();
+            this.PortName = new UAS_LabelMachine.CustomControl.SerialPortCombox();
+            this.SuspendLayout();
+            // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label8.Location = new System.Drawing.Point(51, 35);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(37, 20);
+            this.label8.TabIndex = 107;
+            this.label8.Text = "串口";
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(51, 80);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(51, 20);
+            this.label1.TabIndex = 108;
+            this.label1.Text = "波特率";
+            // 
+            // BaudRate
+            // 
+            this.BaudRate.ID = null;
+            this.BaudRate.Location = new System.Drawing.Point(138, 79);
+            this.BaudRate.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.BaudRate.Name = "BaudRate";
+            this.BaudRate.Size = new System.Drawing.Size(109, 21);
+            this.BaudRate.Str = null;
+            this.BaudRate.Str1 = null;
+            this.BaudRate.Str2 = null;
+            this.BaudRate.TabIndex = 109;
+            // 
+            // Confirm
+            // 
+            this.Confirm.Location = new System.Drawing.Point(138, 118);
+            this.Confirm.Name = "Confirm";
+            this.Confirm.Size = new System.Drawing.Size(75, 23);
+            this.Confirm.TabIndex = 111;
+            this.Confirm.Text = "确认";
+            this.Confirm.UseVisualStyleBackColor = true;
+            // 
+            // PortName
+            // 
+            this.PortName.Location = new System.Drawing.Point(138, 35);
+            this.PortName.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.PortName.Name = "PortName";
+            this.PortName.SelectedText = "";
+            this.PortName.SelectedValue = null;
+            this.PortName.Size = new System.Drawing.Size(109, 20);
+            this.PortName.TabIndex = 112;
+            // 
+            // ComInfoSet
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(348, 153);
+            this.Controls.Add(this.PortName);
+            this.Controls.Add(this.Confirm);
+            this.Controls.Add(this.BaudRate);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.label8);
+            this.Name = "ComInfoSet";
+            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
+            this.Text = "ComInfoSet";
+            this.Load += new System.EventHandler(this.ComInfoSet_Load);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label label8;
+        private System.Windows.Forms.Label label1;
+        private CustomControl.EnterTextBox BaudRate;
+        private System.Windows.Forms.Button Confirm;
+        private CustomControl.SerialPortCombox PortName;
+    }
+}

+ 24 - 0
UAS-出货标签管理(CKD)/ComInfoSet.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace UAS_LabelMachine
+{
+    public partial class ComInfoSet : Form
+    {
+        public ComInfoSet()
+        {
+            InitializeComponent();
+        }
+
+        private void ComInfoSet_Load(object sender, EventArgs e)
+        {
+            BaudRate.Text = Properties.Settings.Default.BaudRate;
+        }
+    }
+}

+ 120 - 0
UAS-出货标签管理(CKD)/ComInfoSet.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 60 - 0
UAS-出货标签管理(CKD)/CustomControl/SerialPortCombox.Designer.cs

@@ -0,0 +1,60 @@
+namespace UAS_LabelMachine.CustomControl
+{
+    partial class SerialPortCombox
+    {
+        /// <summary> 
+        /// 必需的设计器变量。
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary> 
+        /// 清理所有正在使用的资源。
+        /// </summary>
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region 组件设计器生成的代码
+
+        /// <summary> 
+        /// 设计器支持所需的方法 - 不要修改
+        /// 使用代码编辑器修改此方法的内容。
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.ComCombox = new System.Windows.Forms.ComboBox();
+            this.SuspendLayout();
+            // 
+            // ComCombox
+            // 
+            this.ComCombox.Dock = System.Windows.Forms.DockStyle.Fill;
+            this.ComCombox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.ComCombox.FormattingEnabled = true;
+            this.ComCombox.Location = new System.Drawing.Point(0, 0);
+            this.ComCombox.Name = "ComCombox";
+            this.ComCombox.Size = new System.Drawing.Size(186, 23);
+            this.ComCombox.TabIndex = 0;
+            // 
+            // SerialPortCombox
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.Controls.Add(this.ComCombox);
+            this.Name = "SerialPortCombox";
+            this.Size = new System.Drawing.Size(186, 25);
+            this.Load += new System.EventHandler(this.SerialPortCombox_Load);
+            this.ResumeLayout(false);
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.ComboBox ComCombox;
+    }
+}

+ 76 - 0
UAS-出货标签管理(CKD)/CustomControl/SerialPortCombox.cs

@@ -0,0 +1,76 @@
+using System;
+using System.Windows.Forms;
+using System.IO.Ports;
+
+namespace UAS_LabelMachine.CustomControl
+{
+    public partial class SerialPortCombox : UserControl
+    {
+        public SerialPortCombox()
+        {
+            InitializeComponent();
+        }
+
+        public override string Text
+        {
+            get
+            {
+                return ComCombox.Text;
+            }
+
+            set
+            {
+                ComCombox.Text = value;
+            }
+
+        }
+
+        public string SelectedText
+        {
+            get
+            {
+                return ComCombox.SelectedText;
+            }
+
+            set
+            {
+                ComCombox.SelectedText = value;
+            }
+        }
+
+        public object SelectedValue
+        {
+            get
+            {
+                return ComCombox.SelectedValue;
+            }
+
+            set
+            {
+                ComCombox.SelectedValue = value;
+            }
+        }
+
+
+        public object Items
+        {
+            get
+            {
+                return ComCombox.Items;
+            }
+        }
+
+        private void SerialPortCombox_Load(object sender, EventArgs e)
+        {
+            ComCombox.Items.AddRange(SerialPort.GetPortNames());
+            foreach (var item in ComCombox.Items)
+            {
+                if (item.ToString() == Properties.Settings.Default.PortName)
+                {
+                    ComCombox .SelectedIndex= ComCombox.Items.IndexOf(item);
+                    return;
+                }
+            }
+        }
+    }
+}

+ 120 - 0
UAS-出货标签管理(CKD)/CustomControl/SerialPortCombox.resx

@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<root>
+  <!-- 
+    Microsoft ResX Schema 
+    
+    Version 2.0
+    
+    The primary goals of this format is to allow a simple XML format 
+    that is mostly human readable. The generation and parsing of the 
+    various data types are done through the TypeConverter classes 
+    associated with the data types.
+    
+    Example:
+    
+    ... ado.net/XML headers & schema ...
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
+    <resheader name="version">2.0</resheader>
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
+    </data>
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
+        <comment>This is a comment</comment>
+    </data>
+                
+    There are any number of "resheader" rows that contain simple 
+    name/value pairs.
+    
+    Each data row contains a name, and value. The row also contains a 
+    type or mimetype. Type corresponds to a .NET class that support 
+    text/value conversion through the TypeConverter architecture. 
+    Classes that don't support this are serialized and stored with the 
+    mimetype set.
+    
+    The mimetype is used for serialized objects, and tells the 
+    ResXResourceReader how to depersist the object. This is currently not 
+    extensible. For a given mimetype the value must be set accordingly:
+    
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
+    that the ResXResourceWriter will generate, however the reader can 
+    read any of the formats listed below.
+    
+    mimetype: application/x-microsoft.net.object.binary.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
+            : and then encoded with base64 encoding.
+    
+    mimetype: application/x-microsoft.net.object.soap.base64
+    value   : The object must be serialized with 
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
+            : and then encoded with base64 encoding.
+
+    mimetype: application/x-microsoft.net.object.bytearray.base64
+    value   : The object must be serialized into a byte array 
+            : using a System.ComponentModel.TypeConverter
+            : and then encoded with base64 encoding.
+    -->
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
+    <xsd:element name="root" msdata:IsDataSet="true">
+      <xsd:complexType>
+        <xsd:choice maxOccurs="unbounded">
+          <xsd:element name="metadata">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
+              </xsd:sequence>
+              <xsd:attribute name="name" use="required" type="xsd:string" />
+              <xsd:attribute name="type" type="xsd:string" />
+              <xsd:attribute name="mimetype" type="xsd:string" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="assembly">
+            <xsd:complexType>
+              <xsd:attribute name="alias" type="xsd:string" />
+              <xsd:attribute name="name" type="xsd:string" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="data">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
+              <xsd:attribute ref="xml:space" />
+            </xsd:complexType>
+          </xsd:element>
+          <xsd:element name="resheader">
+            <xsd:complexType>
+              <xsd:sequence>
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
+              </xsd:sequence>
+              <xsd:attribute name="name" type="xsd:string" use="required" />
+            </xsd:complexType>
+          </xsd:element>
+        </xsd:choice>
+      </xsd:complexType>
+    </xsd:element>
+  </xsd:schema>
+  <resheader name="resmimetype">
+    <value>text/microsoft-resx</value>
+  </resheader>
+  <resheader name="version">
+    <value>2.0</value>
+  </resheader>
+  <resheader name="reader">
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+  <resheader name="writer">
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
+  </resheader>
+</root>

+ 6 - 0
UAS-出货标签管理(CKD)/Properties/Settings.settings

@@ -35,5 +35,11 @@
     <Setting Name="FTPNET" Type="System.Boolean" Scope="User">
       <Value Profile="(Default)">False</Value>
     </Setting>
+    <Setting Name="PortName" Type="System.String" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
+    <Setting Name="BaudRate" Type="System.String" Scope="User">
+      <Value Profile="(Default)" />
+    </Setting>
   </Settings>
 </SettingsFile>

+ 24 - 0
UAS-出货标签管理(CKD)/Properties/Settings1.Designer.cs

@@ -154,5 +154,29 @@ namespace UAS_LabelMachine.Properties {
                 this["FTPNET"] = value;
             }
         }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("")]
+        public string PortName {
+            get {
+                return ((string)(this["PortName"]));
+            }
+            set {
+                this["PortName"] = value;
+            }
+        }
+        
+        [global::System.Configuration.UserScopedSettingAttribute()]
+        [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+        [global::System.Configuration.DefaultSettingValueAttribute("")]
+        public string BaudRate {
+            get {
+                return ((string)(this["BaudRate"]));
+            }
+            set {
+                this["BaudRate"] = value;
+            }
+        }
     }
 }

+ 35 - 0
UAS-出货标签管理(CKD)/PublicMethod/DataHelper.cs

@@ -140,6 +140,41 @@ namespace UAS_LabelMachine
             connection.Dispose();
         }
 
+        /// <summary>
+        /// 获取第一行第一列的信息
+        /// </summary>
+        public object getFieldDataByConditionForUpdate(string TableName, string Field, string Condition, string Wait)
+        {
+            DataTable dt = new DataTable();
+            string sql = "select " + Field + " from " + TableName + " where " + Condition + "  for " + Wait;
+            command = new OracleCommand(sql, connection);
+            OracleDataAdapter ad = new OracleDataAdapter();
+            ad.SelectCommand = command;
+            try
+            {
+                ad.Fill(dt);
+            }
+            catch (Exception)
+            {
+                connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command = new OracleCommand(sql, connection);
+                ad = new OracleDataAdapter();
+                ad.SelectCommand = command;
+                ad.Fill(dt);
+            }
+            ad.Dispose();
+
+            if (dt.Rows.Count > 0)
+            {
+                return dt.Rows[0][0];
+            }
+            else
+            {
+                return "";
+            }
+        }
+
         /// <summary>
         /// 根据表名获取该表字段数据类型
         /// </summary>

+ 3 - 3
UAS-出货标签管理(CKD)/PublicMethod/LogManager.cs

@@ -7,9 +7,9 @@ namespace UAS_LabelMachine.PublicMethod
     {
         public static void DoLog(string Message)
         {
-            //StreamWriter sw = File.AppendText("Log/" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
-            //sw.WriteLine("\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + Message + "\n");
-            //sw.Close();
+            StreamWriter sw = File.AppendText("Log/" + DateTime.Now.ToString("yyyy-MM-dd") + ".txt");
+            sw.WriteLine("\n" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + " " + Message + "\n");
+            sw.Close();
         }
     }
 }

+ 18 - 0
UAS-出货标签管理(CKD)/UAS-出货标签管理(CKD).csproj

@@ -158,6 +158,12 @@
     <Compile Include="ChangeMaster.Designer.cs">
       <DependentUpon>ChangeMaster.cs</DependentUpon>
     </Compile>
+    <Compile Include="ComInfoSet.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="ComInfoSet.Designer.cs">
+      <DependentUpon>ComInfoSet.cs</DependentUpon>
+    </Compile>
     <Compile Include="CustomControl\BlurSearch.cs">
       <SubType>UserControl</SubType>
     </Compile>
@@ -236,6 +242,12 @@
     <Compile Include="CustomControl\SearchTextBox.Designer.cs">
       <DependentUpon>SearchTextBox.cs</DependentUpon>
     </Compile>
+    <Compile Include="CustomControl\SerialPortCombox.cs">
+      <SubType>UserControl</SubType>
+    </Compile>
+    <Compile Include="CustomControl\SerialPortCombox.Designer.cs">
+      <DependentUpon>SerialPortCombox.cs</DependentUpon>
+    </Compile>
     <Compile Include="CustomerRule.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -367,6 +379,9 @@
     <EmbeddedResource Include="ChangeMaster.resx">
       <DependentUpon>ChangeMaster.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="ComInfoSet.resx">
+      <DependentUpon>ComInfoSet.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="CustomControl\BlurSearch.resx">
       <DependentUpon>BlurSearch.cs</DependentUpon>
     </EmbeddedResource>
@@ -394,6 +409,9 @@
     <EmbeddedResource Include="CustomControl\SearchTextBox.resx">
       <DependentUpon>SearchTextBox.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="CustomControl\SerialPortCombox.resx">
+      <DependentUpon>SerialPortCombox.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="CustomerRule.resx">
       <DependentUpon>CustomerRule.cs</DependentUpon>
     </EmbeddedResource>

+ 203 - 67
UAS-出货标签管理(CKD)/UAS_出货标签管理.Designer.cs

@@ -102,6 +102,7 @@
             this.ImportExcel = new System.Windows.Forms.OpenFileDialog();
             this.pi_class = new System.Windows.Forms.Label();
             this.CustBarCode = new System.Windows.Forms.Button();
+            this.FTPModel = new System.Windows.Forms.CheckBox();
             this.cu_code = new UAS_LabelMachine.CustomControl.SearchTextBox();
             this.groupBoxWithBorder1 = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.Order_Prod = new System.Windows.Forms.RadioButton();
@@ -141,7 +142,7 @@
             this.pib_pdno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_ordercode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.pr_orispeccode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.pr_vendprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_brand = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_madein = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pr_zxbzs = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -154,6 +155,7 @@
             this.pib_qty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_barcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_custbarcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.PIB_CUSTMIDBOXCODE = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pib_custoutboxcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_pocode = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_custprodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -203,7 +205,15 @@
             this.OutboxCapacity = new System.Windows.Forms.NumericUpDown();
             this.OutBoxLabelPrint = new System.Windows.Forms.Button();
             this.OutBoxCombox = new System.Windows.Forms.ComboBox();
-            this.FTPModel = new System.Windows.Forms.CheckBox();
+            this.groupBoxWithBorder3 = new UAS_LabelMachine.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
+            this.label20 = new System.Windows.Forms.Label();
+            this.pib_size = new System.Windows.Forms.ComboBox();
+            this.ButtonMidWeigh = new System.Windows.Forms.Button();
+            this.CloseSerialPort = new System.Windows.Forms.Button();
+            this.ConnectCom = new System.Windows.Forms.Button();
+            this.ButtonWeigh = new System.Windows.Forms.Button();
+            this.Weight = new System.Windows.Forms.Label();
+            this.Com = new System.IO.Ports.SerialPort(this.components);
             ((System.ComponentModel.ISupportInitialize)(this.Si_ItemDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.MidSource)).BeginInit();
             this.ShowMenu.SuspendLayout();
@@ -216,6 +226,7 @@
             this.OutBoxLabel.SuspendLayout();
             this.groupBoxWithBorder2.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).BeginInit();
+            this.groupBoxWithBorder3.SuspendLayout();
             this.SuspendLayout();
             // 
             // pi_inoutno_label
@@ -869,6 +880,19 @@
             this.CustBarCode.UseVisualStyleBackColor = true;
             this.CustBarCode.Click += new System.EventHandler(this.CustBarCode_Click);
             // 
+            // FTPModel
+            // 
+            this.FTPModel.AutoSize = true;
+            this.FTPModel.Font = new System.Drawing.Font("微软雅黑", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.FTPModel.Location = new System.Drawing.Point(462, 308);
+            this.FTPModel.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.FTPModel.Name = "FTPModel";
+            this.FTPModel.Size = new System.Drawing.Size(158, 31);
+            this.FTPModel.TabIndex = 92;
+            this.FTPModel.Text = "FTP被动模式";
+            this.FTPModel.UseVisualStyleBackColor = true;
+            this.FTPModel.CheckedChanged += new System.EventHandler(this.FTPModel_CheckedChanged);
+            // 
             // cu_code
             // 
             this.cu_code.AllPower = null;
@@ -905,16 +929,17 @@
             this.groupBoxWithBorder1.Margin = new System.Windows.Forms.Padding(4);
             this.groupBoxWithBorder1.Name = "groupBoxWithBorder1";
             this.groupBoxWithBorder1.Padding = new System.Windows.Forms.Padding(4);
-            this.groupBoxWithBorder1.Size = new System.Drawing.Size(302, 500);
+            this.groupBoxWithBorder1.Size = new System.Drawing.Size(302, 10);
             this.groupBoxWithBorder1.TabIndex = 81;
             this.groupBoxWithBorder1.TabStop = false;
             this.groupBoxWithBorder1.Text = " 打印参数设置";
+            this.groupBoxWithBorder1.Visible = false;
             // 
             // Order_Prod
             // 
             this.Order_Prod.AutoSize = true;
             this.Order_Prod.Checked = true;
-            this.Order_Prod.Location = new System.Drawing.Point(54, 365);
+            this.Order_Prod.Location = new System.Drawing.Point(59, 370);
             this.Order_Prod.Name = "Order_Prod";
             this.Order_Prod.Size = new System.Drawing.Size(149, 28);
             this.Order_Prod.TabIndex = 92;
@@ -926,7 +951,7 @@
             // Order_Detno
             // 
             this.Order_Detno.AutoSize = true;
-            this.Order_Detno.Location = new System.Drawing.Point(54, 422);
+            this.Order_Detno.Location = new System.Drawing.Point(59, 427);
             this.Order_Detno.Name = "Order_Detno";
             this.Order_Detno.Size = new System.Drawing.Size(149, 28);
             this.Order_Detno.TabIndex = 91;
@@ -938,7 +963,7 @@
             // 
             this.label18.AutoSize = true;
             this.label18.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label18.Location = new System.Drawing.Point(145, 283);
+            this.label18.Location = new System.Drawing.Point(150, 288);
             this.label18.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label18.Name = "label18";
             this.label18.Size = new System.Drawing.Size(24, 31);
@@ -973,7 +998,7 @@
             // 
             this.label16.AutoSize = true;
             this.label16.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label16.Location = new System.Drawing.Point(143, 137);
+            this.label16.Location = new System.Drawing.Point(148, 142);
             this.label16.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label16.Name = "label16";
             this.label16.Size = new System.Drawing.Size(24, 31);
@@ -1008,7 +1033,7 @@
             // 
             this.label12.AutoSize = true;
             this.label12.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label12.Location = new System.Drawing.Point(27, 229);
+            this.label12.Location = new System.Drawing.Point(32, 234);
             this.label12.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label12.Name = "label12";
             this.label12.Size = new System.Drawing.Size(110, 31);
@@ -1019,7 +1044,7 @@
             // 
             this.label7.AutoSize = true;
             this.label7.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label7.Location = new System.Drawing.Point(27, 87);
+            this.label7.Location = new System.Drawing.Point(32, 92);
             this.label7.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label7.Name = "label7";
             this.label7.Size = new System.Drawing.Size(110, 31);
@@ -1073,7 +1098,7 @@
             // 
             this.Capacity.AutoSize = true;
             this.Capacity.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Capacity.Location = new System.Drawing.Point(125, 143);
+            this.Capacity.Location = new System.Drawing.Point(130, 148);
             this.Capacity.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.Capacity.Name = "Capacity";
             this.Capacity.Size = new System.Drawing.Size(0, 31);
@@ -1083,7 +1108,7 @@
             // 
             this.Process_midboxcode.AutoSize = true;
             this.Process_midboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_midboxcode.Location = new System.Drawing.Point(125, 231);
+            this.Process_midboxcode.Location = new System.Drawing.Point(130, 236);
             this.Process_midboxcode.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.Process_midboxcode.Name = "Process_midboxcode";
             this.Process_midboxcode.Size = new System.Drawing.Size(28, 31);
@@ -1094,7 +1119,7 @@
             // 
             this.Process_outboxcode.AutoSize = true;
             this.Process_outboxcode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process_outboxcode.Location = new System.Drawing.Point(125, 183);
+            this.Process_outboxcode.Location = new System.Drawing.Point(130, 188);
             this.Process_outboxcode.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.Process_outboxcode.Name = "Process_outboxcode";
             this.Process_outboxcode.Size = new System.Drawing.Size(28, 31);
@@ -1106,7 +1131,7 @@
             this.TotalCount.AutoSize = true;
             this.TotalCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.TotalCount.ForeColor = System.Drawing.Color.Blue;
-            this.TotalCount.Location = new System.Drawing.Point(193, 47);
+            this.TotalCount.Location = new System.Drawing.Point(198, 52);
             this.TotalCount.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.TotalCount.Name = "TotalCount";
             this.TotalCount.Size = new System.Drawing.Size(28, 31);
@@ -1117,7 +1142,7 @@
             // 
             this.label17.AutoSize = true;
             this.label17.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label17.Location = new System.Drawing.Point(165, 47);
+            this.label17.Location = new System.Drawing.Point(170, 52);
             this.label17.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label17.Name = "label17";
             this.label17.Size = new System.Drawing.Size(24, 31);
@@ -1129,7 +1154,7 @@
             this.CollectedCount.AutoSize = true;
             this.CollectedCount.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
             this.CollectedCount.ForeColor = System.Drawing.Color.Red;
-            this.CollectedCount.Location = new System.Drawing.Point(129, 47);
+            this.CollectedCount.Location = new System.Drawing.Point(134, 52);
             this.CollectedCount.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.CollectedCount.Name = "CollectedCount";
             this.CollectedCount.Size = new System.Drawing.Size(28, 31);
@@ -1140,7 +1165,7 @@
             // 
             this.label14.AutoSize = true;
             this.label14.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label14.Location = new System.Drawing.Point(25, 183);
+            this.label14.Location = new System.Drawing.Point(30, 188);
             this.label14.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label14.Name = "label14";
             this.label14.Size = new System.Drawing.Size(62, 31);
@@ -1151,7 +1176,7 @@
             // 
             this.label11.AutoSize = true;
             this.label11.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label11.Location = new System.Drawing.Point(25, 229);
+            this.label11.Location = new System.Drawing.Point(30, 234);
             this.label11.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label11.Name = "label11";
             this.label11.Size = new System.Drawing.Size(62, 31);
@@ -1162,7 +1187,7 @@
             // 
             this.label13.AutoSize = true;
             this.label13.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label13.Location = new System.Drawing.Point(25, 103);
+            this.label13.Location = new System.Drawing.Point(30, 108);
             this.label13.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label13.Name = "label13";
             this.label13.Size = new System.Drawing.Size(86, 31);
@@ -1173,7 +1198,7 @@
             // 
             this.Installed.AutoSize = true;
             this.Installed.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Installed.Location = new System.Drawing.Point(125, 103);
+            this.Installed.Location = new System.Drawing.Point(130, 108);
             this.Installed.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.Installed.Name = "Installed";
             this.Installed.Size = new System.Drawing.Size(0, 31);
@@ -1183,7 +1208,7 @@
             // 
             this.Process.AutoSize = true;
             this.Process.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.Process.Location = new System.Drawing.Point(25, 47);
+            this.Process.Location = new System.Drawing.Point(30, 52);
             this.Process.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.Process.Name = "Process";
             this.Process.Size = new System.Drawing.Size(86, 31);
@@ -1274,7 +1299,7 @@
             this.pib_pdno,
             this.pib_prodcode,
             this.pd_ordercode,
-            this.pr_orispeccode,
+            this.pr_vendprodcode,
             this.pib_brand,
             this.pib_madein,
             this.pr_zxbzs,
@@ -1287,6 +1312,7 @@
             this.pib_qty,
             this.pib_barcode,
             this.pib_custbarcode,
+            this.PIB_CUSTMIDBOXCODE,
             this.pib_custoutboxcode,
             this.pd_pocode,
             this.pd_custprodcode,
@@ -1300,6 +1326,7 @@
             this.LabelInf.RowTemplate.Height = 23;
             this.LabelInf.Size = new System.Drawing.Size(2502, 666);
             this.LabelInf.TabIndex = 27;
+            this.LabelInf.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.LabelInf_CellClick);
             this.LabelInf.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.LabelInf_CellEndEdit);
             this.LabelInf.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.LabelInf_CellMouseClick);
             this.LabelInf.CellPainting += new System.Windows.Forms.DataGridViewCellPaintingEventHandler(this.LabelInf_CellPainting);
@@ -1371,13 +1398,13 @@
             this.pd_ordercode.Name = "pd_ordercode";
             this.pd_ordercode.Width = 151;
             // 
-            // pr_orispeccode
+            // pr_vendprodcode
             // 
-            this.pr_orispeccode.DataPropertyName = "pr_orispeccode";
-            this.pr_orispeccode.HeaderText = "MPN";
-            this.pr_orispeccode.Name = "pr_orispeccode";
-            this.pr_orispeccode.ReadOnly = true;
-            this.pr_orispeccode.Width = 91;
+            this.pr_vendprodcode.DataPropertyName = "pr_vendprodcode";
+            this.pr_vendprodcode.HeaderText = "MPN";
+            this.pr_vendprodcode.Name = "pr_vendprodcode";
+            this.pr_vendprodcode.ReadOnly = true;
+            this.pr_vendprodcode.Width = 91;
             // 
             // pib_brand
             // 
@@ -1473,10 +1500,17 @@
             this.pib_custbarcode.ReadOnly = true;
             this.pib_custbarcode.Width = 151;
             // 
+            // PIB_CUSTMIDBOXCODE
+            // 
+            this.PIB_CUSTMIDBOXCODE.DataPropertyName = "PIB_CUSTMIDBOXCODE";
+            this.PIB_CUSTMIDBOXCODE.HeaderText = "卡通箱条码";
+            this.PIB_CUSTMIDBOXCODE.Name = "PIB_CUSTMIDBOXCODE";
+            this.PIB_CUSTMIDBOXCODE.Width = 175;
+            // 
             // pib_custoutboxcode
             // 
             this.pib_custoutboxcode.DataPropertyName = "pib_custoutboxcode";
-            this.pib_custoutboxcode.HeaderText = "外箱条码";
+            this.pib_custoutboxcode.HeaderText = "栈板条码";
             this.pib_custoutboxcode.Name = "pib_custoutboxcode";
             this.pib_custoutboxcode.Width = 151;
             // 
@@ -1559,13 +1593,13 @@
             this.SingleLabel.Size = new System.Drawing.Size(312, 500);
             this.SingleLabel.TabIndex = 77;
             this.SingleLabel.TabStop = false;
-            this.SingleLabel.Text = "单盘标签";
+            this.SingleLabel.Text = "最小包";
             // 
             // LabelSpace
             // 
             this.LabelSpace.AutoSize = true;
             this.LabelSpace.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.LabelSpace.Location = new System.Drawing.Point(25, 285);
+            this.LabelSpace.Location = new System.Drawing.Point(30, 290);
             this.LabelSpace.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.LabelSpace.Name = "LabelSpace";
             this.LabelSpace.Size = new System.Drawing.Size(142, 35);
@@ -1578,7 +1612,7 @@
             // 
             this.label8.AutoSize = true;
             this.label8.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label8.Location = new System.Drawing.Point(17, 47);
+            this.label8.Location = new System.Drawing.Point(22, 52);
             this.label8.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label8.Name = "label8";
             this.label8.Size = new System.Drawing.Size(102, 35);
@@ -1588,7 +1622,7 @@
             // SingleDocRefresh
             // 
             this.SingleDocRefresh.AutoSize = true;
-            this.SingleDocRefresh.Location = new System.Drawing.Point(125, 47);
+            this.SingleDocRefresh.Location = new System.Drawing.Point(130, 52);
             this.SingleDocRefresh.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.SingleDocRefresh.Name = "SingleDocRefresh";
             this.SingleDocRefresh.Size = new System.Drawing.Size(82, 41);
@@ -1611,7 +1645,7 @@
             // 
             this.SingleLabelPrint.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
             this.SingleLabelPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelPrint.Location = new System.Drawing.Point(132, 416);
+            this.SingleLabelPrint.Location = new System.Drawing.Point(38, 414);
             this.SingleLabelPrint.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.SingleLabelPrint.Name = "SingleLabelPrint";
             this.SingleLabelPrint.Size = new System.Drawing.Size(136, 52);
@@ -1624,7 +1658,7 @@
             // 
             this.SingleLabelAutoPrint.AutoSize = true;
             this.SingleLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(27, 229);
+            this.SingleLabelAutoPrint.Location = new System.Drawing.Point(32, 234);
             this.SingleLabelAutoPrint.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.SingleLabelAutoPrint.Name = "SingleLabelAutoPrint";
             this.SingleLabelAutoPrint.Size = new System.Drawing.Size(142, 35);
@@ -1667,12 +1701,12 @@
             this.MidLabel.Size = new System.Drawing.Size(316, 500);
             this.MidLabel.TabIndex = 78;
             this.MidLabel.TabStop = false;
-            this.MidLabel.Text = "内盒标签";
+            this.MidLabel.Text = "卡通箱";
             // 
             // MidLabelPreView
             // 
             this.MidLabelPreView.AutoSize = true;
-            this.MidLabelPreView.Location = new System.Drawing.Point(203, 47);
+            this.MidLabelPreView.Location = new System.Drawing.Point(208, 52);
             this.MidLabelPreView.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.MidLabelPreView.Name = "MidLabelPreView";
             this.MidLabelPreView.Size = new System.Drawing.Size(82, 41);
@@ -1697,7 +1731,7 @@
             // 
             this.label9.AutoSize = true;
             this.label9.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label9.Location = new System.Drawing.Point(17, 47);
+            this.label9.Location = new System.Drawing.Point(22, 52);
             this.label9.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label9.Name = "label9";
             this.label9.Size = new System.Drawing.Size(102, 35);
@@ -1707,7 +1741,7 @@
             // MidDocRefresh
             // 
             this.MidDocRefresh.AutoSize = true;
-            this.MidDocRefresh.Location = new System.Drawing.Point(121, 47);
+            this.MidDocRefresh.Location = new System.Drawing.Point(126, 52);
             this.MidDocRefresh.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.MidDocRefresh.Name = "MidDocRefresh";
             this.MidDocRefresh.Size = new System.Drawing.Size(82, 41);
@@ -1733,7 +1767,7 @@
             // 
             this.label5.AutoSize = true;
             this.label5.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label5.Location = new System.Drawing.Point(23, 355);
+            this.label5.Location = new System.Drawing.Point(28, 360);
             this.label5.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label5.Name = "label5";
             this.label5.Size = new System.Drawing.Size(62, 31);
@@ -1744,7 +1778,7 @@
             // 
             this.label4.AutoSize = true;
             this.label4.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label4.Location = new System.Drawing.Point(23, 293);
+            this.label4.Location = new System.Drawing.Point(28, 298);
             this.label4.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label4.Name = "label4";
             this.label4.Size = new System.Drawing.Size(62, 31);
@@ -1765,7 +1799,7 @@
             // 
             this.label15.AutoSize = true;
             this.label15.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label15.Location = new System.Drawing.Point(205, 295);
+            this.label15.Location = new System.Drawing.Point(210, 300);
             this.label15.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label15.Name = "label15";
             this.label15.Size = new System.Drawing.Size(38, 31);
@@ -1798,7 +1832,7 @@
             // 
             this.MidLabelAutoPrint.AutoSize = true;
             this.MidLabelAutoPrint.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.MidLabelAutoPrint.Location = new System.Drawing.Point(17, 219);
+            this.MidLabelAutoPrint.Location = new System.Drawing.Point(22, 224);
             this.MidLabelAutoPrint.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.MidLabelAutoPrint.Name = "MidLabelAutoPrint";
             this.MidLabelAutoPrint.Size = new System.Drawing.Size(142, 35);
@@ -1841,13 +1875,13 @@
             this.OutBoxLabel.Size = new System.Drawing.Size(356, 500);
             this.OutBoxLabel.TabIndex = 79;
             this.OutBoxLabel.TabStop = false;
-            this.OutBoxLabel.Text = "外箱标签";
+            this.OutBoxLabel.Text = "栈板";
             // 
             // DiffCustOutBoxCode
             // 
             this.DiffCustOutBoxCode.AutoSize = true;
             this.DiffCustOutBoxCode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.DiffCustOutBoxCode.Location = new System.Drawing.Point(201, 339);
+            this.DiffCustOutBoxCode.Location = new System.Drawing.Point(206, 344);
             this.DiffCustOutBoxCode.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.DiffCustOutBoxCode.Name = "DiffCustOutBoxCode";
             this.DiffCustOutBoxCode.Size = new System.Drawing.Size(142, 35);
@@ -1876,7 +1910,7 @@
             // 
             this.cu_print_ordercode.AutoSize = true;
             this.cu_print_ordercode.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_ordercode.Location = new System.Drawing.Point(19, 141);
+            this.cu_print_ordercode.Location = new System.Drawing.Point(24, 146);
             this.cu_print_ordercode.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.cu_print_ordercode.Name = "cu_print_ordercode";
             this.cu_print_ordercode.Size = new System.Drawing.Size(142, 35);
@@ -1888,7 +1922,7 @@
             // 
             this.cu_print_outpo.AutoSize = true;
             this.cu_print_outpo.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_outpo.Location = new System.Drawing.Point(19, 95);
+            this.cu_print_outpo.Location = new System.Drawing.Point(24, 100);
             this.cu_print_outpo.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.cu_print_outpo.Name = "cu_print_outpo";
             this.cu_print_outpo.Size = new System.Drawing.Size(142, 35);
@@ -1900,7 +1934,7 @@
             // 
             this.cu_print_outdc.AutoSize = true;
             this.cu_print_outdc.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_outdc.Location = new System.Drawing.Point(19, 237);
+            this.cu_print_outdc.Location = new System.Drawing.Point(24, 242);
             this.cu_print_outdc.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.cu_print_outdc.Name = "cu_print_outdc";
             this.cu_print_outdc.Size = new System.Drawing.Size(80, 35);
@@ -1912,7 +1946,7 @@
             // 
             this.cu_print_outlotno.AutoSize = true;
             this.cu_print_outlotno.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_outlotno.Location = new System.Drawing.Point(19, 187);
+            this.cu_print_outlotno.Location = new System.Drawing.Point(24, 192);
             this.cu_print_outlotno.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.cu_print_outlotno.Name = "cu_print_outlotno";
             this.cu_print_outlotno.Size = new System.Drawing.Size(117, 35);
@@ -1924,7 +1958,7 @@
             // 
             this.cu_print_outprod.AutoSize = true;
             this.cu_print_outprod.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.cu_print_outprod.Location = new System.Drawing.Point(19, 45);
+            this.cu_print_outprod.Location = new System.Drawing.Point(24, 50);
             this.cu_print_outprod.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
             this.cu_print_outprod.Name = "cu_print_outprod";
             this.cu_print_outprod.Size = new System.Drawing.Size(142, 35);
@@ -1936,7 +1970,7 @@
             // 
             this.label19.AutoSize = true;
             this.label19.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.label19.Location = new System.Drawing.Point(13, 49);
+            this.label19.Location = new System.Drawing.Point(18, 54);
             this.label19.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label19.Name = "label19";
             this.label19.Size = new System.Drawing.Size(102, 35);
@@ -1946,7 +1980,7 @@
             // OutDocRefresh
             // 
             this.OutDocRefresh.AutoSize = true;
-            this.OutDocRefresh.Location = new System.Drawing.Point(119, 49);
+            this.OutDocRefresh.Location = new System.Drawing.Point(124, 54);
             this.OutDocRefresh.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.OutDocRefresh.Name = "OutDocRefresh";
             this.OutDocRefresh.Size = new System.Drawing.Size(82, 41);
@@ -1958,7 +1992,7 @@
             // LogingOut
             // 
             this.LogingOut.AutoSize = true;
-            this.LogingOut.Location = new System.Drawing.Point(201, 49);
+            this.LogingOut.Location = new System.Drawing.Point(206, 54);
             this.LogingOut.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.LogingOut.Name = "LogingOut";
             this.LogingOut.Size = new System.Drawing.Size(146, 41);
@@ -1996,7 +2030,7 @@
             // 
             this.label10.AutoSize = true;
             this.label10.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(193, 291);
+            this.label10.Location = new System.Drawing.Point(198, 296);
             this.label10.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label10.Name = "label10";
             this.label10.Size = new System.Drawing.Size(62, 31);
@@ -2007,7 +2041,7 @@
             // 
             this.label6.AutoSize = true;
             this.label6.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label6.Location = new System.Drawing.Point(191, 231);
+            this.label6.Location = new System.Drawing.Point(196, 236);
             this.label6.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
             this.label6.Name = "label6";
             this.label6.Size = new System.Drawing.Size(62, 31);
@@ -2063,18 +2097,107 @@
             this.OutBoxCombox.TabIndex = 78;
             this.OutBoxCombox.SelectedIndexChanged += new System.EventHandler(this.OutBoxCombox_SelectedIndexChanged);
             // 
-            // FTPModel
-            // 
-            this.FTPModel.AutoSize = true;
-            this.FTPModel.Font = new System.Drawing.Font("微软雅黑", 7.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.FTPModel.Location = new System.Drawing.Point(462, 308);
-            this.FTPModel.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
-            this.FTPModel.Name = "FTPModel";
-            this.FTPModel.Size = new System.Drawing.Size(158, 31);
-            this.FTPModel.TabIndex = 92;
-            this.FTPModel.Text = "FTP被动模式";
-            this.FTPModel.UseVisualStyleBackColor = true;
-            this.FTPModel.CheckedChanged += new System.EventHandler(this.FTPModel_CheckedChanged);
+            // groupBoxWithBorder3
+            // 
+            this.groupBoxWithBorder3.Controls.Add(this.label20);
+            this.groupBoxWithBorder3.Controls.Add(this.pib_size);
+            this.groupBoxWithBorder3.Controls.Add(this.ButtonMidWeigh);
+            this.groupBoxWithBorder3.Controls.Add(this.CloseSerialPort);
+            this.groupBoxWithBorder3.Controls.Add(this.ConnectCom);
+            this.groupBoxWithBorder3.Controls.Add(this.ButtonWeigh);
+            this.groupBoxWithBorder3.Controls.Add(this.Weight);
+            this.groupBoxWithBorder3.Location = new System.Drawing.Point(1202, 26);
+            this.groupBoxWithBorder3.Margin = new System.Windows.Forms.Padding(4);
+            this.groupBoxWithBorder3.Name = "groupBoxWithBorder3";
+            this.groupBoxWithBorder3.Padding = new System.Windows.Forms.Padding(4);
+            this.groupBoxWithBorder3.Size = new System.Drawing.Size(296, 486);
+            this.groupBoxWithBorder3.TabIndex = 114;
+            this.groupBoxWithBorder3.TabStop = false;
+            this.groupBoxWithBorder3.Text = "称重";
+            // 
+            // label20
+            // 
+            this.label20.AutoSize = true;
+            this.label20.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label20.Location = new System.Drawing.Point(25, 32);
+            this.label20.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label20.Name = "label20";
+            this.label20.Size = new System.Drawing.Size(62, 31);
+            this.label20.TabIndex = 102;
+            this.label20.Text = "尺寸";
+            this.label20.Visible = false;
+            // 
+            // pib_size
+            // 
+            this.pib_size.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.pib_size.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pib_size.Location = new System.Drawing.Point(94, 25);
+            this.pib_size.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.pib_size.Name = "pib_size";
+            this.pib_size.Size = new System.Drawing.Size(158, 39);
+            this.pib_size.TabIndex = 102;
+            this.pib_size.Visible = false;
+            // 
+            // ButtonMidWeigh
+            // 
+            this.ButtonMidWeigh.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ButtonMidWeigh.Location = new System.Drawing.Point(9, 259);
+            this.ButtonMidWeigh.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.ButtonMidWeigh.Name = "ButtonMidWeigh";
+            this.ButtonMidWeigh.Size = new System.Drawing.Size(132, 52);
+            this.ButtonMidWeigh.TabIndex = 116;
+            this.ButtonMidWeigh.Text = "称量通重";
+            this.ButtonMidWeigh.UseVisualStyleBackColor = true;
+            this.ButtonMidWeigh.Click += new System.EventHandler(this.ButtonMidWeigh_Click);
+            // 
+            // CloseSerialPort
+            // 
+            this.CloseSerialPort.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.CloseSerialPort.Location = new System.Drawing.Point(176, 195);
+            this.CloseSerialPort.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.CloseSerialPort.Name = "CloseSerialPort";
+            this.CloseSerialPort.Size = new System.Drawing.Size(110, 52);
+            this.CloseSerialPort.TabIndex = 115;
+            this.CloseSerialPort.Text = "关闭";
+            this.CloseSerialPort.UseVisualStyleBackColor = true;
+            this.CloseSerialPort.Click += new System.EventHandler(this.CloseSerialPort_Click);
+            // 
+            // ConnectCom
+            // 
+            this.ConnectCom.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ConnectCom.Location = new System.Drawing.Point(9, 195);
+            this.ConnectCom.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.ConnectCom.Name = "ConnectCom";
+            this.ConnectCom.Size = new System.Drawing.Size(160, 52);
+            this.ConnectCom.TabIndex = 114;
+            this.ConnectCom.Text = "连接电子秤";
+            this.ConnectCom.UseVisualStyleBackColor = true;
+            this.ConnectCom.Click += new System.EventHandler(this.ConnectCom_Click);
+            // 
+            // ButtonWeigh
+            // 
+            this.ButtonWeigh.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ButtonWeigh.Location = new System.Drawing.Point(147, 259);
+            this.ButtonWeigh.Margin = new System.Windows.Forms.Padding(6, 4, 6, 4);
+            this.ButtonWeigh.Name = "ButtonWeigh";
+            this.ButtonWeigh.Size = new System.Drawing.Size(132, 52);
+            this.ButtonWeigh.TabIndex = 97;
+            this.ButtonWeigh.Text = "称量箱重";
+            this.ButtonWeigh.UseVisualStyleBackColor = true;
+            this.ButtonWeigh.Visible = false;
+            this.ButtonWeigh.Click += new System.EventHandler(this.ButtonWeigh_Click);
+            // 
+            // Weight
+            // 
+            this.Weight.AutoSize = true;
+            this.Weight.Font = new System.Drawing.Font("微软雅黑", 25F);
+            this.Weight.ForeColor = System.Drawing.Color.Red;
+            this.Weight.Location = new System.Drawing.Point(45, 98);
+            this.Weight.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.Weight.Name = "Weight";
+            this.Weight.Size = new System.Drawing.Size(132, 88);
+            this.Weight.TabIndex = 113;
+            this.Weight.Text = "1.5";
             // 
             // UAS_出货标签打印
             // 
@@ -2082,6 +2205,7 @@
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(229)))), ((int)(((byte)(233)))), ((int)(((byte)(206)))));
             this.ClientSize = new System.Drawing.Size(2520, 1450);
+            this.Controls.Add(this.groupBoxWithBorder3);
             this.Controls.Add(this.FTPModel);
             this.Controls.Add(this.CustBarCode);
             this.Controls.Add(this.pi_class);
@@ -2151,6 +2275,8 @@
             this.groupBoxWithBorder2.ResumeLayout(true);
             this.groupBoxWithBorder2.PerformLayout();
             ((System.ComponentModel.ISupportInitialize)(this.OutboxCapacity)).EndInit();
+            this.groupBoxWithBorder3.ResumeLayout(true);
+            this.groupBoxWithBorder3.PerformLayout();
             this.ResumeLayout(true);
             this.PerformLayout();
 
@@ -2311,7 +2437,7 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_pdno;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_prodcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_ordercode;
-        private System.Windows.Forms.DataGridViewTextBoxColumn pr_orispeccode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn pr_vendprodcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_brand;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_madein;
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_zxbzs;
@@ -2324,6 +2450,7 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_qty;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_barcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_custbarcode;
+        private System.Windows.Forms.DataGridViewTextBoxColumn PIB_CUSTMIDBOXCODE;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_custoutboxcode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_pocode;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_custprodcode;
@@ -2331,5 +2458,14 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode1;
         private System.Windows.Forms.DataGridViewTextBoxColumn pib_outboxcode2;
+        private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder groupBoxWithBorder3;
+        private System.Windows.Forms.Label label20;
+        private System.Windows.Forms.ComboBox pib_size;
+        private System.Windows.Forms.Button ButtonMidWeigh;
+        private System.Windows.Forms.Button CloseSerialPort;
+        private System.Windows.Forms.Button ConnectCom;
+        private System.Windows.Forms.Button ButtonWeigh;
+        private System.Windows.Forms.Label Weight;
+        private System.IO.Ports.SerialPort Com;
     }
 }

+ 307 - 9
UAS-出货标签管理(CKD)/UAS_出货标签管理.cs

@@ -16,6 +16,7 @@ using System.IO;
 using System.Globalization;
 using System.Reflection;
 using Seagull.BarTender.Print;
+using UAS_LabelMachine.CustomControl;
 
 namespace UAS_LabelMachine
 {
@@ -75,7 +76,6 @@ namespace UAS_LabelMachine
         /// <summary>
         /// 正则表达式用于项目匹配
         /// </summary>
-        Regex reg;
         /*标识供应商物料编号采集是否通过*/
         bool CollectVeProdCodePass = true;
 
@@ -280,7 +280,7 @@ namespace UAS_LabelMachine
                     MessageLog.AppendText(ex.Message + ex.StackTrace);
                     //MessageBox.Show(ex.Message + ex.StackTrace);
                 }
-              
+
             }
             pi_inoutno.BringToFront();
             LogicHandler.CustInit("0");
@@ -536,11 +536,10 @@ namespace UAS_LabelMachine
                     string year = "0";
                     string month = "0";
                     string day = "0";
-                    string date = "";
                     string lotno = LabelInf.Rows[CurrentRowIndex].Cells["pib_lotno"].Value.ToString();
                     string datecode = LabelInf.Rows[CurrentRowIndex].Cells["pib_datecode"].Value.ToString();
                     string pr_brand = LabelInf.Rows[CurrentRowIndex].Cells["pib_brand"].Value.ToString();
-                    LogicHandler.GetTimeFromDatecode(datecode, pr_brand, out year, out month, out day, out date);
+                    //LogicHandler.GetTimeFromDatecode(datecode, pr_brand, out year, out month, out day, out date);
                     if (CollectionUnit.Text == "盒")
                     {
                         for (int i = 0; i < LabelInf.RowCount; i++)
@@ -863,12 +862,11 @@ namespace UAS_LabelMachine
                 string year = "";
                 string month = "";
                 string day = "";
-                string date = "";
                 string pr_brand = LabelInf.Rows[CurrentRowIndex].Cells["pib_brand"].Value.ToString();
-                LogicHandler.GetTimeFromDatecode(DateCode, pr_brand, out year, out month, out day, out date);
+                //LogicHandler.GetTimeFromDatecode(DateCode, pr_brand, out year, out month, out day, out date);
                 sql.Append(",pib_datecode='" + DateCode + "',pib_year='" + year + "',pib_month='" + month + "',pib_day='" + day + "' ");
             }
-            sql.Append("where pib_id='" + pib_id + "'");
+            sql.Append(" where pib_id='" + pib_id + "'");
             sdh.ExecuteSql(sql.ToString(), "update");
             //添加外箱号,如果外箱号的箱内容量不为0并且已经采集完成
             SetOutBoxCode2(false);
@@ -1477,10 +1475,46 @@ namespace UAS_LabelMachine
                 MessageBox.Show("未维护中盒模板");
         }
 
+        int MaxNum = 0;
+        int NumLength = 0;
+
+        private void PackMidBox_Click(object sender, EventArgs e)
+        {
+            DataTable dt = (DataTable)dh.ExecuteSql("select distinct pib_outboxcode2 from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' and pib_outboxcode2='" + OutBoxNum.Text + "' order by pib_outboxcode2", "select");
+            GetBarCodeRule(out Prefix, out Suffix, out MaxNum, out NumLength, out Radix, 1);
+            if (Radix > 0)
+            {
+                //生成中盒条码
+                int pib_outboxcode1 = int.Parse(dh.getFieldDataByCondition("prodiobarcode", "max(to_number(nvl(pib_outboxcode1,0)))", "pib_inoutno='" + pi_inoutno.Text + "'").ToString())+1;
+                List<string> MidBoxCode = new List<string>();
+                List<string> PIBID = new List<string>();
+                List<string> PIBOUTBOXCODE1 = new List<string>();
+                MaxNum = MaxNum - 1;
+                for (int i = 0; i < LabelInf.Rows.Count; i++)
+                {
+                    if (LabelInf.Rows[i].Cells["pib_ifpick"].FormattedValue.ToString() == "True" && LabelInf.Rows[i].Cells["pib_custmidboxcode"].Value.ToString() == "")
+                    {
+                        string serialcode = BaseUtil.DToAny(MaxNum, Radix);
+                        for (int k = serialcode.ToString().Length; k < NumLength; k++)
+                        {
+                            serialcode = "0" + serialcode;
+                        }
+                        MidBoxCode.Add(Prefix + serialcode + Suffix);
+                        PIBID.Add(LabelInf.Rows[i].Cells["pib_id1"].Value.ToString());
+                        PIBOUTBOXCODE1.Add(pib_outboxcode1.ToString());
+                    }
+                }
+                dh.BatchInsert("update prodiobarcode set pib_custmidboxcode=:pib_custmidboxcode,pib_outboxcode1=:pib_outboxcode1,pib_ifpick=-1 where pib_id=:pib_id and pib_custmidboxcode is null", new string[] { "pib_custmidboxcode", "pib_outboxcode1", "pib_id" }, MidBoxCode.ToArray(), PIBOUTBOXCODE1.ToArray(), PIBID.ToArray());
+                MidLabelNum.Text = "";
+            }
+            LoadGridData(sender, e);
+        }
+
         private void MidLabelPrint_Click(object sender, EventArgs e)
         {
             if (MidLabelCombox.Text != "")
             {
+                PackMidBox_Click(sender, e);
                 thread = new Thread(MidBoxLabelPrint);
                 stw = new SetLoadingWindow(thread, "正在打印中盒");
                 BaseUtil.SetFormCenter(stw);
@@ -1736,7 +1770,7 @@ namespace UAS_LabelMachine
             AllCollect = sender.Equals(true);
             //查询Oracle数据库
             sql.Clear();
-            sql.Append("select t.*,rownum from prodiobarcode_view t where pib_inoutno='" + pi_inoutno.Text + "' ");
+            sql.Append("select t.*,rownum from prodiobarcode_view t where pib_inoutno='" + pi_inoutno.Text + "' order by PIB_OUTBOXCODE1,pib_custbarcode");
             LabelInfDataTable = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             //查询本地数据库
             sql.Clear();
@@ -1775,7 +1809,7 @@ namespace UAS_LabelMachine
                 //sdh.BatchInsert("prodiobarcode", LabelInfDataTable);
             }
             sql.Clear();
-            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by cast(pib_outboxcode1 as int)");
+            sql.Append("select * from prodiobarcode where pib_inoutno='" + pi_inoutno.Text + "' order by pib_custbarcode,PIB_OUTBOXCODE1");
             LabelInfDataTable = (DataTable)sdh.ExecuteSql(sql.ToString(), "select");
             bindingsource(LabelInf, LabelInfDataTable);
             //有数据的话默认取第一条的品牌去取采集策略
@@ -2873,5 +2907,269 @@ namespace UAS_LabelMachine
                 SystemInf.FTPModel = false;
             }
         }
+
+        Regex reg = new Regex(@"\d+.\d+");
+        ComInfoSet cis;
+        private void ConnectCom_Click(object sender, EventArgs e)
+        {
+            cis = new ComInfoSet();
+            (cis.Controls["PortName"] as SerialPortCombox).SelectedValue = Properties.Settings.Default.PortName;
+            cis.Controls["BaudRate"].Text = Properties.Settings.Default.BaudRate;
+            cis.Controls["Confirm"].Click += UAS_出货标签打印_Click;
+            cis.ShowDialog();
+        }
+
+        private void CloseSerialPort_Click(object sender, EventArgs e)
+        {
+            if (Com.IsOpen)
+            {
+                Com.Close();
+                Com.DataReceived -= Com_DataReceived;
+            }
+        }
+
+        private void ButtonMidWeigh_Click(object sender, EventArgs e)
+        {
+            if (Weight.Text != "" && Weight.Text != "0.000")
+            {
+                string pib_outboxcode1 = LabelInf.Rows[SelectRowIndex].Cells["pib_outboxcode1"].Value.ToString();
+                sql.Clear();
+                sql.Append("update prodiobarcode set pib_midboxweight='" + Weight.Text + "' where pib_inoutno='" + pi_inoutno.Text + "' ");
+                sql.Append(" and pib_outboxcode2='" + OutBoxNum.Text + "' and pib_outboxcode1='" + pib_outboxcode1 + "'");
+                dh.ExecuteSql(sql.ToString(), "update");
+                LoadGridData(sender, e);
+            }
+            else
+            {
+                MessageBox.Show("请先连接电子秤!");
+            }
+        }
+
+        private void ButtonWeigh_Click(object sender, EventArgs e)
+        {
+            if (Weight.Text != "" && Weight.Text != "0.000")
+            {
+                sql.Clear();
+                sql.Append("update prodiobarcode set pib_boxweight='" + Weight.Text + "' where pib_inoutno='" + pi_inoutno.Text + "' ");
+                sql.Append(" and pib_outboxcode2='" + OutBoxNum.Text + "'");
+                dh.ExecuteSql(sql.ToString(), "update");
+                LoadGridData(sender, e);
+            }
+            else
+            {
+                MessageBox.Show("请先连接电子秤!");
+            }
+        }
+
+        private void UAS_出货标签打印_Click(object sender, EventArgs e)
+        {
+            if (Com.IsOpen && Com.PortName == cis.Controls["PortName"].Text)
+            {
+                MessageBox.Show("串口" + Com.PortName + "已打开");
+                return;
+            }
+            else
+            {
+                if (Com.IsOpen)
+                {
+                    Com.Close();
+                }
+            }
+            int BaudRate = 0;
+            Com.PortName = cis.Controls["PortName"].Text;
+            if (int.TryParse(cis.Controls["BaudRate"].Text, out BaudRate))
+            {
+                Com.BaudRate = BaudRate;
+            }
+            Properties.Settings.Default.BaudRate = BaudRate.ToString();
+            Properties.Settings.Default.PortName = cis.Controls["PortName"].Text;
+            Properties.Settings.Default.Save();
+            Com.DataReceived += Com_DataReceived;
+            Com.Open();
+            cis.Close();
+        }
+
+        private void Com_DataReceived(object sender, System.IO.Ports.SerialDataReceivedEventArgs e)
+        {
+            try
+            {
+                int len = Com.BytesToRead;
+                byte[] readBuffer = new byte[len];
+                Com.Read(readBuffer, 0, len); //将数据读入缓存
+                string value = reg.Match(Encoding.ASCII.GetString(readBuffer, 0, len)).Value;
+                if (value != "")
+                {
+                    Weight.Text = value;
+                }
+                //读不到数据的时间删掉
+            }
+            catch (Exception)
+            {
+                return;
+            }
+        }
+
+        int SelectRowIndex = -1;
+        private void LabelInf_CellClick(object sender, DataGridViewCellEventArgs e)
+        {
+            if (e.RowIndex >= 0)
+            {
+                LabelInf.Rows[e.RowIndex].Selected = true;
+                SelectRowIndex = e.RowIndex;
+            }
+        }
+
+        string ShareRule;
+        string ReSetType = "";
+        private void GetBarCodeRule(out string Prefix, out string Suffix, out int MaxNum, out int SerialNumLength, out int Radix, int Count)
+        {
+            //获取编码规则
+            Prefix = "";
+            Suffix = "";
+            NrCode = "";
+            MaxNum = 0;
+            SerialNumLength = 0;
+            Radix = 0;
+            DataTable Nr = (DataTable)dh.ExecuteSql("select nvl(nr_resettype,' ')nr_resettype,nr_sharerule,nr_code,nrd_detno,nrd_name,nrd_type,nrd_radix,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode='" + cu_code.Text + "'  order by nrd_detno", "select");
+            //如果没有则取公共规则
+            if (Nr.Rows.Count == 0)
+                Nr = (DataTable)dh.ExecuteSql("select nvl(nr_resettype,' ')nr_resettype,nr_sharerule,nr_code,nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_custcode is null  and nr_isdefault <> 0 order by nrd_detno", "select");
+            //用于过滤参数的正则表达式
+            ReSetType = "";
+            if (Nr.Rows.Count > 0)
+            {
+                ShareRule = Nr.Rows[0]["nr_sharerule"].ToString();
+                DataTable dt1 = (DataTable)dh.ExecuteSql("select nvl(nr_resettype,' ')nr_resettype,nr_sharerule,nr_code,nrd_detno,nrd_name,nrd_radix,nrd_type,nrd_sql,nrd_length from NoRuleDetail left join norule on nrd_nrid=nr_id where nr_code='" + ShareRule + "' order by nrd_detno", "select");
+                if (dt1.Rows.Count > 0)
+                {
+                    Nr = dt1;
+                }
+                else
+                {
+                    if (ShareRule != "")
+                    {
+                        MessageBox.Show("共享规则" + ShareRule + "不存在");
+                        return;
+                    }
+                }
+            }
+            if (Nr.Rows.Count > 0)
+            {
+                switch (Nr.Rows[0]["nr_resettype"].ToString())
+                {
+                    case "Year":
+                        sql.Clear();
+                        sql.Append("to_char(sysdate,'yyyy')");
+                        break;
+                    case "Month":
+                        sql.Clear();
+                        sql.Append("to_char(sysdate,'yyyyMM')");
+                        break;
+                    case "Week":
+                        sql.Clear();
+                        sql.Append("to_char(sysdate,'yyyyiw')");
+                        break;
+                    case "Day":
+                        sql.Clear();
+                        sql.Append("to_char(sysdate,'yyyyMMdd')");
+                        break;
+                    case " ":
+                        sql.Clear();
+                        sql.Append("' '");
+                        break;
+                    default:
+                        break;
+                }
+                ReSetType = dh.getFieldDataByCondition("dual", sql.ToString(), "1=1").ToString();
+            }
+            Regex match = new Regex("{\\w+}");
+            //用于存放每一项的明细的数据
+            string[] NrData = new string[Nr.Rows.Count];
+            //流水长度
+            Dictionary<int, string> NrDic = new Dictionary<int, string>();
+            for (int m = 0; m < Nr.Rows.Count; m++)
+            {
+                NrCode = Nr.Rows[m]["nr_code"].ToString();
+                switch (Nr.Rows[m]["nrd_type"].ToString())
+                {
+                    //常量直接进行拼接
+                    case "常量":
+                        Prefix += Nr.Rows[m]["nrd_sql"].ToString();
+                        Suffix += Nr.Rows[m]["nrd_sql"].ToString();
+                        break;
+                    case "SQL":
+                        string SQL = Nr.Rows[m]["nrd_sql"].ToString();
+                        DataTable Temp;
+                        //如果不包含参数替换
+                        if (SQL.IndexOf("{") == 0)
+                        {
+                            Temp = (DataTable)dh.ExecuteSql(SQL, "select");
+                        }
+                        else
+                        {
+                            //替换参数后重新执行SQL
+                            foreach (Match mch in match.Matches(SQL))
+                            {
+                                SQL = SQL.Replace(mch.Value.Trim(), "'" + pi_inoutno.Text + "'");
+                            }
+                            Temp = (DataTable)dh.ExecuteSql(SQL, "select");
+                        }
+                        if (Temp.Rows.Count > 0)
+                        {
+                            Prefix += Temp.Rows[0][0].ToString();
+                            Suffix += Temp.Rows[0][0].ToString();
+                        }
+                        break;
+                    //流水需要通过MaxNumber去取
+                    case "流水":
+                        string maxnum = "";
+                        if (ReSetType != " ")
+                        {
+                            maxnum = dh.getFieldDataByConditionForUpdate("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and nvl(rmn_type,' ')='" + ReSetType + "'", "update of rmn_maxnumber  nowait").ToString();
+                        }
+                        else
+                        {
+                            maxnum = dh.getFieldDataByConditionForUpdate("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' ", "update of rmn_maxnumber  nowait").ToString();
+                        }
+                        //设置当前流水
+                        if (maxnum == "")
+                        {
+                            if (ReSetType != " ")
+                            {
+                                maxnum = dh.getFieldDataByConditionForUpdate("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and nvl(rmn_type,' ')='" + ReSetType + "'", "update of rmn_maxnumber  nowait").ToString();
+                            }
+                            else
+                            {
+                                maxnum = dh.getFieldDataByConditionForUpdate("RuleMaxNum", "rmn_maxnumber", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "' ", "update of rmn_maxnumber  nowait").ToString();
+                            }
+                            if (maxnum == "")
+                            {
+                                maxnum = "1";
+                            }
+                            Count = int.Parse(maxnum) + Count;
+                            dh.ExecuteSql("insert into RuleMaxNum(rmn_id,rmn_nrcode,rmn_prefix,rmn_maxnumber,rmn_type) values(RuleMaxNum_seq.nextval,'" + (NrCode == "" ? "Default" : NrCode) + "','" + Prefix + "','" + Count + "','" + ReSetType + "')", "insert");
+                            MaxNum = int.Parse(maxnum);
+                        }
+                        else
+                        {
+                            MaxNum = int.Parse(maxnum);
+                            if (ReSetType != " ")
+                            {
+                                dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + Count) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and nvl(rmn_type,' ')='" + ReSetType + "'");
+                            }
+                            else
+                            {
+                                dh.UpdateByCondition("RULEMAXNUM", "rmn_maxnumber='" + (MaxNum + Count) + "'", "rmn_nrcode='" + (NrCode == "" ? "Default" : NrCode) + "' and rmn_prefix='" + Prefix + "'");
+                            }
+                        }
+                        SerialNumLength = int.Parse(Nr.Rows[m]["nrd_length"].ToString());
+                        Radix = int.Parse(Nr.Rows[m]["nrd_radix"].ToString());
+                        Suffix = "";
+                        break;
+                    default:
+                        break;
+                }
+            }
+        }
     }
 }

+ 6 - 0
UAS-出货标签管理(CKD)/UAS_出货标签管理.resx

@@ -180,6 +180,9 @@
   <metadata name="pib_custbarcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="PIB_CUSTMIDBOXCODE.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
   <metadata name="pib_custoutboxcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
@@ -192,6 +195,9 @@
   <metadata name="pr_spec.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
+  <metadata name="Com.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
+    <value>739, 17</value>
+  </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
   <data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>