Browse Source

入库条码打印调整

callm 1 year ago
parent
commit
42f008481e

+ 2 - 2
UAS_BARCODEIO/BaseForm.cs

@@ -20,8 +20,8 @@ namespace UAS_BARCODEIO
         {
             if (!DesignMode)
             {
-                Main main = Application.OpenForms["Main"] as Main;
-                main.TopMost = false;
+                //Main main = Application.OpenForms["Main"] as Main;
+                //main.TopMost = false;
             }
         }
 

+ 4 - 2
UAS_BARCODEIO/DataHelper.cs

@@ -11,7 +11,7 @@ namespace UAS_BARCODEIO
         //系统默认的的连接字符串
         private string ConnectionStrings = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=SENGWILL;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11598)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         //用户选择的数据库的连接字符串
-        public static string DBConnectionString= "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=SENGWILL;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11598)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
+        public static string DBConnectionString = "Connection Timeout=0;Pooling=false;Password=select!#%*(;User ID=SENGWILL;Pooling=false;Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.81.208)(PORT=11598)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=orcl)));";
         public static OracleConnection connection = null;
         OracleCommand command = null;
         int ReconnectTime = 0;
@@ -29,7 +29,8 @@ namespace UAS_BARCODEIO
                     connection = new OracleConnection(DBConnectionString);
                 connection.Open();
             }
-            catch (Exception e) {
+            catch (Exception e)
+            {
 
             }
         }
@@ -509,6 +510,7 @@ namespace UAS_BARCODEIO
         {
             object result = null;
             //Console.WriteLine(SQL);
+            Console.WriteLine(SQL);
             command = new OracleCommand(SQL, connection);
             Reconnect(command);
             //用来拼接参数的

+ 31 - 0
UAS_BARCODEIO/GlobalEventsHandler.cs

@@ -0,0 +1,31 @@
+using System.Data;
+using System.Windows.Forms;
+
+namespace UAS_BARCODEIO
+{
+    /// <summary>
+    /// Author zhangz   2016/12/30
+    /// 全局事件处理,通过句柄获取触发事件的控件
+    /// 结合捕获的全局的键盘事件来验证用户进行的操作
+    /// </summary>
+    class GlobalEventsHandler : IMessageFilter
+    {
+        DataHelper dh;
+        //鼠标左键点击
+        public const int WM_LBUTTONDOWN = 0x0201;
+        //键盘敲击事件
+        public const int WM_KEYDOWN = 0x100;
+
+        public bool PreFilterMessage(ref Message m)
+        {
+            return true;
+        }
+
+        /// <summary>
+        /// 返回True表示消息已处理,不再往后传递
+        /// 返回False表示消息未处理,后续程序处理此事件
+        /// </summary>
+        /// <param name="c"></param>
+        /// <returns></returns>
+    }
+}

+ 2 - 2
UAS_BARCODEIO/Pagination.Designer.cs

@@ -134,7 +134,7 @@
             // 
             this.Add.AllPower = null;
             this.Add.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.Add.Image = global::UAS_BARCODEIO.Properties.Resources.bindingNavigatorAddNewItem_Image;
+            this.Add.Image = global::UAS_BARCODEIO.Properties.Resources.preview_16px_25980_easyicon_net1;
             this.Add.Location = new System.Drawing.Point(484, 10);
             this.Add.Margin = new System.Windows.Forms.Padding(4);
             this.Add.Name = "Add";
@@ -260,7 +260,7 @@
             this.FirstPage.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
             | System.Windows.Forms.AnchorStyles.Left)));
             this.FirstPage.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.FirstPage.Image = global::UAS_BARCODEIO.Resources.bindingNavigatorMoveFirstItem_Image;
+            this.FirstPage.Image = global::UAS_BARCODEIO.Properties.Resources.bindingNavigatorMoveFirstItem_Image;
             this.FirstPage.Location = new System.Drawing.Point(19, 10);
             this.FirstPage.Margin = new System.Windows.Forms.Padding(4);
             this.FirstPage.Name = "FirstPage";

+ 1 - 1
UAS_BARCODEIO/PaginationDbFind.Designer.cs

@@ -167,7 +167,7 @@
             // 
             this.ExportExcel.AllPower = null;
             this.ExportExcel.Cursor = System.Windows.Forms.Cursors.Hand;
-            this.ExportExcel.Image = Properties.Resources.Excel_2010_16px_1180011_easyicon_net;
+            this.ExportExcel.Image = UAS_BARCODEIO.Properties.Resources.Excel_2010_16px_1180011_easyicon_net;
             this.ExportExcel.Location = new System.Drawing.Point(532, 10);
             this.ExportExcel.Margin = new System.Windows.Forms.Padding(4);
             this.ExportExcel.Name = "ExportExcel";

+ 70 - 21
UAS_BARCODEIO/Program.cs

@@ -1,8 +1,7 @@
 using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Security.Principal;
+using System.Text;
 using System.Windows.Forms;
+using System.Security.Principal;
 
 namespace UAS_BARCODEIO
 {
@@ -14,27 +13,77 @@ namespace UAS_BARCODEIO
         [STAThread]
         static void Main()
         {
-            WindowsIdentity identity = WindowsIdentity.GetCurrent();
-            WindowsPrincipal principal = new WindowsPrincipal(identity);
-            Application.EnableVisualStyles();
-            Application.SetCompatibleTextRenderingDefault(false);
-            //如果是管理员的身份
-            if (principal.IsInRole(WindowsBuiltInRole.Administrator))
+            try
+            {
+                WindowsIdentity identity = WindowsIdentity.GetCurrent();
+                WindowsPrincipal principal = new WindowsPrincipal(identity);
+                //设置应用程序处理异常方式:ThreadException处理
+                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
+                //处理UI线程异常
+                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
+                //处理非UI线程异常
+                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
+                #region 应用程序的主入口点
+                Application.EnableVisualStyles();
+                Application.SetCompatibleTextRenderingDefault(false);
+                //启用异常记录日志的操作
+                GlobalEventsHandler g = new GlobalEventsHandler();
+                //添加全局事件的监听
+                Application.AddMessageFilter(g);
+                //如果是管理员的身份
+                if (principal.IsInRole(WindowsBuiltInRole.Administrator))
+                {
+                    Application.Run(new 入库条码规则解析());
+                }
+                else
+                {
+                    //创建启动对象 
+                    System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
+                    // 设置运行文件
+                    startInfo.FileName = Application.ExecutablePath;
+                    //设置启动动作,确保以管理员身份运行
+                    startInfo.Verb = "runas";
+                    //如果不是管理员,则启动UAC 
+                    System.Diagnostics.Process.Start(startInfo);
+                    //退出 System.Windows.Forms.Application.Exit(); 
+                }
+                #endregion
+            }
+            catch (Exception ex)
             {
-                Application.Run(new 入库条码规则解析());
+                string str = GetExceptionMsg(ex, string.Empty);
+                MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
             }
-            else
+        }
+
+        static void Application_ThreadException(object sender, System.Threading.ThreadExceptionEventArgs e)
+        {
+            string str = GetExceptionMsg(e.Exception, e.ToString());
+            MessageBox.Show(str, "操作异常", MessageBoxButtons.OK, MessageBoxIcon.Stop);
+        }
+        //未处理的异常统一通过这里返回
+        static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
+        {
+            string str = GetExceptionMsg(e.ExceptionObject as Exception, e.ToString());
+            MessageBox.Show(str, "操作异常", MessageBoxButtons.OK, MessageBoxIcon.Stop);
+        }
+
+        /// <summary>
+        /// 生成自定义异常消息
+        /// </summary>
+        /// <param name="ex">异常对象</param>
+        /// <param name="backStr">备用异常消息:当ex为null时有效</param>
+        /// <returns>异常字符串文本</returns>
+        static string GetExceptionMsg(Exception ex, string backStr)
+        {
+            StringBuilder sb = new StringBuilder();
+            if (ex != null)
             {
-                //创建启动对象 
-                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
-                // 设置运行文件
-                startInfo.FileName = Application.ExecutablePath;
-                //设置启动动作,确保以管理员身份运行
-                startInfo.Verb = "runas";
-                //如果不是管理员,则启动UAC 
-                System.Diagnostics.Process.Start(startInfo);
-                //退出 System.Windows.Forms.Application.Exit(); 
+                sb.AppendLine(ex.Message);
+                //sb.AppendLine(ex.StackTrace);
+                //sb.AppendLine("【异常方法】:" + ex.TargetSite);
             }
+            return sb.ToString();
         }
     }
-}
+}

+ 1 - 1
UAS_BARCODEIO/Properties/Resources.Designer.cs

@@ -8,7 +8,7 @@
 // </auto-generated>
 //------------------------------------------------------------------------------
 
-namespace UAS_BARCODEIO{
+namespace UAS_BARCODEIO.Properties {
     using System;
     
     

+ 2 - 1
UAS_BARCODEIO/SearchTextBox.Designer.cs

@@ -40,7 +40,8 @@ namespace UAS_BARCODEIO
             this.Search_Icon.AllPower = null;
             this.Search_Icon.Cursor = System.Windows.Forms.Cursors.Hand;
             this.Search_Icon.Dock = System.Windows.Forms.DockStyle.Right;
-           // this.Search_Icon.Image = Resources
+            this.Search_Icon.ErrorImage = global::UAS_BARCODEIO.Properties.Resources.preview_16px_25980_easyicon_net1;
+            this.Search_Icon.Image = global::UAS_BARCODEIO.Properties.Resources.preview_16px_25980_easyicon_net1;
             this.Search_Icon.Location = new System.Drawing.Point(183, 0);
             this.Search_Icon.Name = "Search_Icon";
             this.Search_Icon.Power = "";

+ 25 - 2
UAS_BARCODEIO/UAS_BARCODEIO.csproj

@@ -7,11 +7,26 @@
     <ProjectGuid>{01C2A10B-D6AF-4417-B189-E85466BE08B9}</ProjectGuid>
     <OutputType>WinExe</OutputType>
     <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>UAS_PRINT</RootNamespace>
-    <AssemblyName>UAS_PRINT</AssemblyName>
+    <RootNamespace>UAS_BARCODEIO</RootNamespace>
+    <AssemblyName>UAS_BARCODEIO</AssemblyName>
     <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
     <FileAlignment>512</FileAlignment>
     <TargetFrameworkProfile />
+    <PublishUrl>publish\</PublishUrl>
+    <Install>true</Install>
+    <InstallFrom>Disk</InstallFrom>
+    <UpdateEnabled>false</UpdateEnabled>
+    <UpdateMode>Foreground</UpdateMode>
+    <UpdateInterval>7</UpdateInterval>
+    <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+    <UpdatePeriodically>false</UpdatePeriodically>
+    <UpdateRequired>false</UpdateRequired>
+    <MapFileExtensions>true</MapFileExtensions>
+    <ApplicationRevision>0</ApplicationRevision>
+    <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+    <IsWebBootstrapper>false</IsWebBootstrapper>
+    <UseApplicationTrust>false</UseApplicationTrust>
+    <BootstrapperEnabled>true</BootstrapperEnabled>
   </PropertyGroup>
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
     <PlatformTarget>AnyCPU</PlatformTarget>
@@ -101,6 +116,7 @@
       <DependentUpon>EnterTextBox.cs</DependentUpon>
     </Compile>
     <Compile Include="ftpOperater.cs" />
+    <Compile Include="GlobalEventsHandler.cs" />
     <Compile Include="LockCheckBox.cs">
       <SubType>Component</SubType>
     </Compile>
@@ -502,6 +518,13 @@
   <ItemGroup>
     <None Include="Resources\系统设置.png" />
   </ItemGroup>
+  <ItemGroup>
+    <BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
+      <Visible>False</Visible>
+      <ProductName>.NET Framework 3.5 SP1</ProductName>
+      <Install>false</Install>
+    </BootstrapperPackage>
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
        Other similar extension points exist, see Microsoft.Common.targets.

+ 92 - 56
UAS_BARCODEIO/入库条码规则解析.Designer.cs

@@ -30,7 +30,6 @@
         {
             this.label2 = new System.Windows.Forms.Label();
             this.pi_inoutno = new System.Windows.Forms.TextBox();
-            this.textBox1 = new System.Windows.Forms.TextBox();
             this.label1 = new System.Windows.Forms.Label();
             this.Prodiodetail = new System.Windows.Forms.DataGridView();
             this.pd_prodcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
@@ -38,21 +37,24 @@
             this.pr_spec = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.pd_inqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.bi_inqty = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.textBox2 = new System.Windows.Forms.TextBox();
+            this.PR_CODE = new System.Windows.Forms.TextBox();
             this.label3 = new System.Windows.Forms.Label();
-            this.textBox3 = new System.Windows.Forms.TextBox();
+            this.INQTY = new System.Windows.Forms.TextBox();
             this.label4 = new System.Windows.Forms.Label();
-            this.textBox4 = new System.Windows.Forms.TextBox();
+            this.DC = new System.Windows.Forms.TextBox();
             this.label5 = new System.Windows.Forms.Label();
-            this.textBox5 = new System.Windows.Forms.TextBox();
+            this.LOTNO = new System.Windows.Forms.TextBox();
             this.label6 = new System.Windows.Forms.Label();
             this.dataGridView1 = new System.Windows.Forms.DataGridView();
             this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.textBox6 = new System.Windows.Forms.TextBox();
+            this.ZXBZ = new System.Windows.Forms.TextBox();
             this.label7 = new System.Windows.Forms.Label();
+            this.Barcode = new System.Windows.Forms.TextBox();
+            this.label8 = new System.Windows.Forms.Label();
+            this.es_custcode = new UAS_BARCODEIO.SearchTextBox();
             ((System.ComponentModel.ISupportInitialize)(this.Prodiodetail)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
             this.SuspendLayout();
@@ -77,14 +79,6 @@
             this.pi_inoutno.TabIndex = 16;
             this.pi_inoutno.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pi_inoutnokeydown);
             // 
-            // textBox1
-            // 
-            this.textBox1.Location = new System.Drawing.Point(168, 108);
-            this.textBox1.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
-            this.textBox1.Name = "textBox1";
-            this.textBox1.Size = new System.Drawing.Size(436, 35);
-            this.textBox1.TabIndex = 18;
-            // 
             // label1
             // 
             this.label1.AutoSize = true;
@@ -154,13 +148,13 @@
             this.bi_inqty.Name = "bi_inqty";
             this.bi_inqty.Width = 200;
             // 
-            // textBox2
+            // PR_CODE
             // 
-            this.textBox2.Location = new System.Drawing.Point(168, 771);
-            this.textBox2.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
-            this.textBox2.Name = "textBox2";
-            this.textBox2.Size = new System.Drawing.Size(436, 35);
-            this.textBox2.TabIndex = 21;
+            this.PR_CODE.Location = new System.Drawing.Point(168, 771);
+            this.PR_CODE.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.PR_CODE.Name = "PR_CODE";
+            this.PR_CODE.Size = new System.Drawing.Size(436, 35);
+            this.PR_CODE.TabIndex = 21;
             // 
             // label3
             // 
@@ -173,13 +167,13 @@
             this.label3.TabIndex = 20;
             this.label3.Text = "物料编号";
             // 
-            // textBox3
+            // INQTY
             // 
-            this.textBox3.Location = new System.Drawing.Point(168, 851);
-            this.textBox3.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
-            this.textBox3.Name = "textBox3";
-            this.textBox3.Size = new System.Drawing.Size(436, 35);
-            this.textBox3.TabIndex = 23;
+            this.INQTY.Location = new System.Drawing.Point(168, 851);
+            this.INQTY.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.INQTY.Name = "INQTY";
+            this.INQTY.Size = new System.Drawing.Size(436, 35);
+            this.INQTY.TabIndex = 23;
             // 
             // label4
             // 
@@ -192,13 +186,13 @@
             this.label4.TabIndex = 22;
             this.label4.Text = "入库数量";
             // 
-            // textBox4
+            // DC
             // 
-            this.textBox4.Location = new System.Drawing.Point(168, 929);
-            this.textBox4.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
-            this.textBox4.Name = "textBox4";
-            this.textBox4.Size = new System.Drawing.Size(436, 35);
-            this.textBox4.TabIndex = 25;
+            this.DC.Location = new System.Drawing.Point(168, 929);
+            this.DC.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.DC.Name = "DC";
+            this.DC.Size = new System.Drawing.Size(436, 35);
+            this.DC.TabIndex = 25;
             // 
             // label5
             // 
@@ -211,13 +205,13 @@
             this.label5.TabIndex = 24;
             this.label5.Text = "DC";
             // 
-            // textBox5
+            // LOTNO
             // 
-            this.textBox5.Location = new System.Drawing.Point(168, 1013);
-            this.textBox5.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
-            this.textBox5.Name = "textBox5";
-            this.textBox5.Size = new System.Drawing.Size(436, 35);
-            this.textBox5.TabIndex = 27;
+            this.LOTNO.Location = new System.Drawing.Point(168, 1013);
+            this.LOTNO.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.LOTNO.Name = "LOTNO";
+            this.LOTNO.Size = new System.Drawing.Size(436, 35);
+            this.LOTNO.TabIndex = 27;
             // 
             // label6
             // 
@@ -279,13 +273,13 @@
             this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
             this.dataGridViewTextBoxColumn4.Width = 200;
             // 
-            // textBox6
+            // ZXBZ
             // 
-            this.textBox6.Location = new System.Drawing.Point(168, 1097);
-            this.textBox6.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
-            this.textBox6.Name = "textBox6";
-            this.textBox6.Size = new System.Drawing.Size(436, 35);
-            this.textBox6.TabIndex = 30;
+            this.ZXBZ.Location = new System.Drawing.Point(168, 1097);
+            this.ZXBZ.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.ZXBZ.Name = "ZXBZ";
+            this.ZXBZ.Size = new System.Drawing.Size(436, 35);
+            this.ZXBZ.TabIndex = 30;
             // 
             // label7
             // 
@@ -298,24 +292,64 @@
             this.label7.TabIndex = 29;
             this.label7.Text = "最小包数";
             // 
+            // Barcode
+            // 
+            this.Barcode.Location = new System.Drawing.Point(844, 108);
+            this.Barcode.Margin = new System.Windows.Forms.Padding(4, 3, 4, 3);
+            this.Barcode.Name = "Barcode";
+            this.Barcode.Size = new System.Drawing.Size(436, 35);
+            this.Barcode.TabIndex = 32;
+            this.Barcode.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Barcode_KeyDown);
+            // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Font = new System.Drawing.Font("微软雅黑", 10.8F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label8.Location = new System.Drawing.Point(712, 111);
+            this.label8.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(104, 38);
+            this.label8.TabIndex = 33;
+            this.label8.Text = "扫码框";
+            // 
+            // es_custcode
+            // 
+            this.es_custcode.AllPower = null;
+            this.es_custcode.Caller = null;
+            this.es_custcode.Condition = null;
+            this.es_custcode.DBTitle = null;
+            this.es_custcode.FormName = null;
+            this.es_custcode.Location = new System.Drawing.Point(167, 108);
+            this.es_custcode.Name = "es_custcode";
+            this.es_custcode.Power = null;
+            this.es_custcode.ReturnData = null;
+            this.es_custcode.SelectField = null;
+            this.es_custcode.SetValueField = null;
+            this.es_custcode.Size = new System.Drawing.Size(437, 35);
+            this.es_custcode.TabIndex = 31;
+            this.es_custcode.TableName = null;
+            this.es_custcode.TextBoxEnable = false;
+            // 
             // 入库条码规则解析
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(2025, 1225);
-            this.Controls.Add(this.textBox6);
+            this.Controls.Add(this.label8);
+            this.Controls.Add(this.Barcode);
+            this.Controls.Add(this.es_custcode);
+            this.Controls.Add(this.ZXBZ);
             this.Controls.Add(this.label7);
             this.Controls.Add(this.dataGridView1);
-            this.Controls.Add(this.textBox5);
+            this.Controls.Add(this.LOTNO);
             this.Controls.Add(this.label6);
-            this.Controls.Add(this.textBox4);
+            this.Controls.Add(this.DC);
             this.Controls.Add(this.label5);
-            this.Controls.Add(this.textBox3);
+            this.Controls.Add(this.INQTY);
             this.Controls.Add(this.label4);
-            this.Controls.Add(this.textBox2);
+            this.Controls.Add(this.PR_CODE);
             this.Controls.Add(this.label3);
             this.Controls.Add(this.Prodiodetail);
-            this.Controls.Add(this.textBox1);
             this.Controls.Add(this.label1);
             this.Controls.Add(this.pi_inoutno);
             this.Controls.Add(this.label2);
@@ -334,7 +368,6 @@
         #endregion
         private System.Windows.Forms.Label label2;
         private System.Windows.Forms.TextBox pi_inoutno;
-        private System.Windows.Forms.TextBox textBox1;
         private System.Windows.Forms.Label label1;
         private System.Windows.Forms.DataGridView Prodiodetail;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_prodcode;
@@ -342,21 +375,24 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn pr_spec;
         private System.Windows.Forms.DataGridViewTextBoxColumn pd_inqty;
         private System.Windows.Forms.DataGridViewTextBoxColumn bi_inqty;
-        private System.Windows.Forms.TextBox textBox2;
+        private System.Windows.Forms.TextBox PR_CODE;
         private System.Windows.Forms.Label label3;
-        private System.Windows.Forms.TextBox textBox3;
+        private System.Windows.Forms.TextBox INQTY;
         private System.Windows.Forms.Label label4;
-        private System.Windows.Forms.TextBox textBox4;
+        private System.Windows.Forms.TextBox DC;
         private System.Windows.Forms.Label label5;
-        private System.Windows.Forms.TextBox textBox5;
+        private System.Windows.Forms.TextBox LOTNO;
         private System.Windows.Forms.Label label6;
         private System.Windows.Forms.DataGridView dataGridView1;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
         private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;
-        private System.Windows.Forms.TextBox textBox6;
+        private System.Windows.Forms.TextBox ZXBZ;
         private System.Windows.Forms.Label label7;
+        private SearchTextBox es_custcode;
+        private System.Windows.Forms.TextBox Barcode;
+        private System.Windows.Forms.Label label8;
     }
 }
 

+ 59 - 10
UAS_BARCODEIO/入库条码规则解析.cs

@@ -1,13 +1,5 @@
-using Microsoft.Win32;
-using System;
-using System.Collections.Generic;
+using System;
 using System.Data;
-using System.Diagnostics;
-using System.IO;
-using System.Net;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading;
 using System.Windows.Forms;
 
 namespace UAS_BARCODEIO
@@ -17,6 +9,7 @@ namespace UAS_BARCODEIO
 
         DataHelper dh = new DataHelper();
 
+        DataTable Dbfind;
 
         public 入库条码规则解析()
         {
@@ -25,9 +18,21 @@ namespace UAS_BARCODEIO
 
         private void Form1_Load(object sender, EventArgs e)
         {
-
+            es_custcode.TableName = "CS_EXPORTSETTING   ";
+            es_custcode.SelectField = "es_custcode # 品牌";
+            es_custcode.FormName = Name;
+            es_custcode.DBTitle = "解析规则查询";
+            es_custcode.SetValueField = new string[] { "es_custcode" };
+            es_custcode.Condition = "";
+            es_custcode.DbChange += nr_rule_DBChange;
+            SystemInf.dh = dh;
         }
 
+        private void nr_rule_DBChange(object sender, EventArgs e)
+        {
+            Dbfind = es_custcode.ReturnData;
+            BaseUtil.SetFormValue(this.Controls, Dbfind);
+        }
 
         private void pi_inoutnokeydown(object sender, KeyEventArgs e)
         {
@@ -40,5 +45,49 @@ namespace UAS_BARCODEIO
                 BaseUtil.FillDgvWithDataTable(Prodiodetail, dt);
             }
         }
+
+        private void Barcode_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Enter)
+            {
+                DataTable dt = (DataTable)dh.ExecuteSql("select esd_caption,esd_enable,el_type from cs_exportsettingdetail left join CS_EXPORTSETTING" +
+                    " on es_id=esd_esid where es_custcode='" + es_custcode.Text + "'", "select");
+                if (dt.Rows.Count == 0)
+                {
+                    MessageBox.Show("无条码解析规则");
+                    return;
+                }
+                string split = dt.Rows[0]["el_type"].ToString();
+                string[] str = Barcode.Text.Split(split.ToCharArray()[0]);
+                //分割后的字符串数组需要大于设置的参数解析
+                if (str.Length < dt.Rows.Count)
+                {
+                    MessageBox.Show("无条码解析规则");
+                    return;
+                }
+                for (int i = 0; i < dt.Rows.Count; i++)
+                {
+                    string name = dt.Rows[i]["esd_caption"].ToString();
+                    string index = dt.Rows[i]["esd_enable"].ToString();
+                    switch (name)
+                    {
+                        case "LOTNO":
+                            LOTNO.Text = str[int.Parse(index) - 1];
+                            break;
+                        case "DC":
+                            DC.Text = str[int.Parse(index) - 1];
+                            break;
+                        case "PROD":
+                            PR_CODE.Text = str[int.Parse(index) - 1];
+                            break;
+                        case "QTY":
+                            INQTY.Text = str[int.Parse(index) - 1];
+                            break;
+                        default:
+                            break;
+                    }
+                }
+            }
+        }
     }
 }

+ 0 - 27
UAS_BARCODEIO/入库条码规则解析.resx

@@ -132,33 +132,6 @@
   <metadata name="bi_inqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>
-  <metadata name="pd_prodcode.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pr_detail.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pr_spec.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="pd_inqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="bi_inqty.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="dataGridViewTextBoxColumn2.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="dataGridViewTextBoxColumn3.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
-  <metadata name="dataGridViewTextBoxColumn4.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
-    <value>True</value>
-  </metadata>
   <metadata name="dataGridViewTextBoxColumn1.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
     <value>True</value>
   </metadata>