Browse Source

生成SN支持打印

callm 4 years ago
parent
commit
28d1f6192d

+ 126 - 85
UAS_MES_ODLF/FunctionCode/Query/Query_SN.Designer.cs

@@ -38,6 +38,15 @@
             this.date = new System.Windows.Forms.DateTimePicker();
             this.label6 = new System.Windows.Forms.Label();
             this.label7 = new System.Windows.Forms.Label();
+            this.label8 = new System.Windows.Forms.Label();
+            this.label9 = new System.Windows.Forms.Label();
+            this.label10 = new System.Windows.Forms.Label();
+            this.label11 = new System.Windows.Forms.Label();
+            this.currentSerial = new System.Windows.Forms.NumericUpDown();
+            this.Printer = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.PrinterCombox();
+            this.Print = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
+            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.BeginMac = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.num = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.status = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.seriallength = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
@@ -45,12 +54,7 @@
             this.color = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.factory = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.Export = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
-            this.BeginMac = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.label8 = new System.Windows.Forms.Label();
-            this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.label9 = new System.Windows.Forms.Label();
-            this.currentSerial = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.label10 = new System.Windows.Forms.Label();
+            ((System.ComponentModel.ISupportInitialize)(this.currentSerial)).BeginInit();
             this.SuspendLayout();
             // 
             // label1
@@ -138,6 +142,114 @@
             this.label7.TabIndex = 19;
             this.label7.Text = "SN数量";
             // 
+            // label8
+            // 
+            this.label8.AutoSize = true;
+            this.label8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label8.Location = new System.Drawing.Point(106, 599);
+            this.label8.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label8.Name = "label8";
+            this.label8.Size = new System.Drawing.Size(157, 41);
+            this.label8.TabIndex = 21;
+            this.label8.Text = "起始MAC";
+            // 
+            // label9
+            // 
+            this.label9.AutoSize = true;
+            this.label9.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label9.Location = new System.Drawing.Point(106, 44);
+            this.label9.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label9.Name = "label9";
+            this.label9.Size = new System.Drawing.Size(114, 41);
+            this.label9.TabIndex = 23;
+            this.label9.Text = "工单号";
+            // 
+            // label10
+            // 
+            this.label10.AutoSize = true;
+            this.label10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label10.Location = new System.Drawing.Point(106, 669);
+            this.label10.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label10.Name = "label10";
+            this.label10.Size = new System.Drawing.Size(146, 41);
+            this.label10.TabIndex = 25;
+            this.label10.Text = "当前流水";
+            // 
+            // label11
+            // 
+            this.label11.AutoSize = true;
+            this.label11.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label11.Location = new System.Drawing.Point(836, 44);
+            this.label11.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label11.Name = "label11";
+            this.label11.Size = new System.Drawing.Size(178, 41);
+            this.label11.TabIndex = 29;
+            this.label11.Text = "打印机列表";
+            // 
+            // currentSerial
+            // 
+            this.currentSerial.Location = new System.Drawing.Point(305, 675);
+            this.currentSerial.Name = "currentSerial";
+            this.currentSerial.Size = new System.Drawing.Size(388, 35);
+            this.currentSerial.TabIndex = 30;
+            // 
+            // Printer
+            // 
+            this.Printer.Location = new System.Drawing.Point(1030, 47);
+            this.Printer.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6);
+            this.Printer.Name = "Printer";
+            this.Printer.Size = new System.Drawing.Size(378, 45);
+            this.Printer.TabIndex = 28;
+            // 
+            // Print
+            // 
+            this.Print.AllPower = null;
+            this.Print.BackColor = System.Drawing.Color.Transparent;
+            this.Print.DownImage = ((System.Drawing.Image)(resources.GetObject("Print.DownImage")));
+            this.Print.Image = null;
+            this.Print.IsShowBorder = true;
+            this.Print.Location = new System.Drawing.Point(519, 742);
+            this.Print.Margin = new System.Windows.Forms.Padding(6);
+            this.Print.MoveImage = ((System.Drawing.Image)(resources.GetObject("Print.MoveImage")));
+            this.Print.Name = "Print";
+            this.Print.NormalImage = ((System.Drawing.Image)(resources.GetObject("Print.NormalImage")));
+            this.Print.Power = null;
+            this.Print.Size = new System.Drawing.Size(150, 56);
+            this.Print.TabIndex = 27;
+            this.Print.Text = "打印";
+            this.Print.UseVisualStyleBackColor = false;
+            this.Print.Click += new System.EventHandler(this.Print_Click);
+            // 
+            // ma_code
+            // 
+            this.ma_code.AllPower = null;
+            this.ma_code.BackColor = System.Drawing.Color.White;
+            this.ma_code.ID = null;
+            this.ma_code.Location = new System.Drawing.Point(305, 47);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(6);
+            this.ma_code.Name = "ma_code";
+            this.ma_code.Power = null;
+            this.ma_code.Size = new System.Drawing.Size(388, 35);
+            this.ma_code.Str = null;
+            this.ma_code.Str1 = null;
+            this.ma_code.Str2 = null;
+            this.ma_code.TabIndex = 24;
+            // 
+            // BeginMac
+            // 
+            this.BeginMac.AllPower = null;
+            this.BeginMac.BackColor = System.Drawing.Color.White;
+            this.BeginMac.ID = null;
+            this.BeginMac.Location = new System.Drawing.Point(305, 601);
+            this.BeginMac.Margin = new System.Windows.Forms.Padding(6);
+            this.BeginMac.Name = "BeginMac";
+            this.BeginMac.Power = null;
+            this.BeginMac.Size = new System.Drawing.Size(388, 35);
+            this.BeginMac.Str = null;
+            this.BeginMac.Str1 = null;
+            this.BeginMac.Str2 = null;
+            this.BeginMac.TabIndex = 22;
+            // 
             // num
             // 
             this.num.AllPower = null;
@@ -251,90 +363,15 @@
             this.Export.UseVisualStyleBackColor = false;
             this.Export.Click += new System.EventHandler(this.Export_Click);
             // 
-            // BeginMac
-            // 
-            this.BeginMac.AllPower = null;
-            this.BeginMac.BackColor = System.Drawing.Color.White;
-            this.BeginMac.ID = null;
-            this.BeginMac.Location = new System.Drawing.Point(305, 601);
-            this.BeginMac.Margin = new System.Windows.Forms.Padding(6);
-            this.BeginMac.Name = "BeginMac";
-            this.BeginMac.Power = null;
-            this.BeginMac.Size = new System.Drawing.Size(388, 35);
-            this.BeginMac.Str = null;
-            this.BeginMac.Str1 = null;
-            this.BeginMac.Str2 = null;
-            this.BeginMac.TabIndex = 22;
-            // 
-            // label8
-            // 
-            this.label8.AutoSize = true;
-            this.label8.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label8.Location = new System.Drawing.Point(106, 599);
-            this.label8.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label8.Name = "label8";
-            this.label8.Size = new System.Drawing.Size(157, 41);
-            this.label8.TabIndex = 21;
-            this.label8.Text = "起始MAC";
-            // 
-            // ma_code
-            // 
-            this.ma_code.AllPower = null;
-            this.ma_code.BackColor = System.Drawing.Color.White;
-            this.ma_code.ID = null;
-            this.ma_code.Location = new System.Drawing.Point(305, 47);
-            this.ma_code.Margin = new System.Windows.Forms.Padding(6);
-            this.ma_code.Name = "ma_code";
-            this.ma_code.Power = null;
-            this.ma_code.Size = new System.Drawing.Size(388, 35);
-            this.ma_code.Str = null;
-            this.ma_code.Str1 = null;
-            this.ma_code.Str2 = null;
-            this.ma_code.TabIndex = 24;
-            // 
-            // label9
-            // 
-            this.label9.AutoSize = true;
-            this.label9.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label9.Location = new System.Drawing.Point(106, 44);
-            this.label9.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label9.Name = "label9";
-            this.label9.Size = new System.Drawing.Size(114, 41);
-            this.label9.TabIndex = 23;
-            this.label9.Text = "工单号";
-            // 
-            // currentSerial
-            // 
-            this.currentSerial.AllPower = null;
-            this.currentSerial.BackColor = System.Drawing.Color.White;
-            this.currentSerial.ID = null;
-            this.currentSerial.Location = new System.Drawing.Point(305, 672);
-            this.currentSerial.Margin = new System.Windows.Forms.Padding(6);
-            this.currentSerial.Name = "currentSerial";
-            this.currentSerial.Power = null;
-            this.currentSerial.Size = new System.Drawing.Size(388, 35);
-            this.currentSerial.Str = null;
-            this.currentSerial.Str1 = null;
-            this.currentSerial.Str2 = null;
-            this.currentSerial.TabIndex = 26;
-            // 
-            // label10
-            // 
-            this.label10.AutoSize = true;
-            this.label10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.label10.Location = new System.Drawing.Point(106, 669);
-            this.label10.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
-            this.label10.Name = "label10";
-            this.label10.Size = new System.Drawing.Size(146, 41);
-            this.label10.TabIndex = 25;
-            this.label10.Text = "当前流水";
-            // 
             // Query_SN
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1494, 1075);
             this.Controls.Add(this.currentSerial);
+            this.Controls.Add(this.label11);
+            this.Controls.Add(this.Printer);
+            this.Controls.Add(this.Print);
             this.Controls.Add(this.label10);
             this.Controls.Add(this.ma_code);
             this.Controls.Add(this.label9);
@@ -361,6 +398,7 @@
             this.Tag = "Query!SpecialReport";
             this.Text = "Query_SpecialReport";
             this.Load += new System.EventHandler(this.Query_SpecialReport_Load);
+            ((System.ComponentModel.ISupportInitialize)(this.currentSerial)).EndInit();
             this.ResumeLayout(false);
             this.PerformLayout();
 
@@ -388,7 +426,10 @@
         private System.Windows.Forms.Label label8;
         private CustomControl.TextBoxWithIcon.EnterTextBox ma_code;
         private System.Windows.Forms.Label label9;
-        private CustomControl.TextBoxWithIcon.EnterTextBox currentSerial;
         private System.Windows.Forms.Label label10;
+        private CustomControl.ButtonUtil.NormalButton Print;
+        private CustomControl.ComBoxWithFocus.PrinterCombox Printer;
+        private System.Windows.Forms.Label label11;
+        private System.Windows.Forms.NumericUpDown currentSerial;
     }
 }

+ 77 - 4
UAS_MES_ODLF/FunctionCode/Query/Query_SN.cs

@@ -1,10 +1,14 @@
-using System;
+using LabelManager2;
+using System;
 using System.Data;
 using System.Security.Cryptography;
 using System.Text;
+using System.Threading;
 using System.Windows.Forms;
 using UAS_MES_NEW.DataOperate;
 using UAS_MES_NEW.Entity;
+using UAS_MES_NEW.PublicForm;
+using UAS_MES_NEW.PublicMethod;
 
 namespace UAS_MES_NEW.Query
 {
@@ -13,6 +17,12 @@ namespace UAS_MES_NEW.Query
 
         DataHelper dh = SystemInf.dh;
 
+        ApplicationClass lbl;
+
+        Thread InitPrint;
+
+        Document doc;
+
         public Query_SN()
         {
             InitializeComponent();
@@ -47,7 +57,7 @@ namespace UAS_MES_NEW.Query
                 string prefix = BeginMac.Text.Substring(0, 8);
                 string suffix = BeginMac.Text.Substring(8, 4);
                 int Number = Int32.Parse(suffix, System.Globalization.NumberStyles.HexNumber);
-                for (int i = 0; i < int.Parse(num.Text); i++)
+                for (decimal i = currentSerial.Value; i < currentSerial.Value + int.Parse(num.Text); i++)
                 {
                     DataRow dr = dt.NewRow();
 
@@ -64,7 +74,7 @@ namespace UAS_MES_NEW.Query
                         + status.Text
                         + lpad(int.Parse(seriallength.Text), (i + 1).ToString());
                     string encode = MD5Encoding(serial + ")G$d");
-                    dr["序列号"] = serial+ encode.Substring(encode.Length-2);
+                    dr["序列号"] = serial + encode.Substring(encode.Length - 2);
                     dt.Rows.Add(dr);
                 }
                 eh.ExportExcel(dt, FolderPath);
@@ -73,7 +83,24 @@ namespace UAS_MES_NEW.Query
 
         private void Query_SpecialReport_Load(object sender, EventArgs e)
         {
-           
+            InitPrint = new Thread(InPrint);
+            SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
+            BaseUtil.SetFormCenter(stw);
+            stw.ShowDialog();
+            doc = lbl.Documents.Open(System.Windows.Forms.Application.StartupPath + @"\SN.lab");
+        }
+
+        private void InPrint()
+        {
+            try
+            {
+                lbl = new ApplicationClass();
+                BaseUtil.WriteLbl();
+            }
+            catch (Exception)
+            {
+                MessageBox.Show("未正确安装CodeSoft软件");
+            }
         }
 
         private static string MD5Encoding(string rawPass)
@@ -295,5 +322,51 @@ namespace UAS_MES_NEW.Query
             }
             return returndate;
         }
+
+        private void Print_Click(object sender, EventArgs e)
+        {
+
+            DataTable dt = new DataTable();
+            dt.Columns.Add("工单号");
+            dt.Columns.Add("序列号");
+            dt.Columns.Add("MAC");
+            dt.Columns.Add("BT");
+            dt.Columns.Add("拓展栏位1");
+            dt.Columns.Add("拓展栏位2");
+            dt.Columns.Add("拓展栏位3");
+            dt.Columns.Add("备注");
+            string prefix = BeginMac.Text.Substring(0, 8);
+            string suffix = BeginMac.Text.Substring(8, 4);
+            int Number = Int32.Parse(suffix, System.Globalization.NumberStyles.HexNumber);
+            for (decimal i = currentSerial.Value; i < currentSerial.Value + int.Parse(num.Text); i++)
+            {
+                DataRow dr = dt.NewRow();
+
+                dr["工单号"] = ma_code.Text;
+                dr["MAC"] = prefix + Number.ToString("X");
+                Number = Number + 1;
+                dr["BT"] = prefix + Number.ToString("X");
+                Number = Number + 1;
+
+                string serial = pr_code.Text
+                    + color.Text
+                    + GetDate(date.Value.ToString("yyyy"), date.Value.ToString("MM"), date.Value.ToString("dd"))
+                    + factory.Text
+                    + status.Text
+                    + lpad(int.Parse(seriallength.Text), (i + 1).ToString());
+                string encode = MD5Encoding(serial + ")G$d");
+                dr["序列号"] = serial + encode.Substring(encode.Length - 2);
+                dt.Rows.Add(dr);
+                for (int j = 0; j < doc.Variables.FormVariables.Count; j++)
+                {
+                    if (doc.Variables.FormVariables.Item(j + 1).Name.ToUpper() == "SN")
+                    {
+                        doc.Variables.FormVariables.Item(j + 1).Value = (serial + encode.Substring(encode.Length - 2));
+                    }
+                }
+                doc.Printer.SwitchTo(Printer.Text);
+                doc.PrintDocument(1);
+            }
+        }
     }
 }

+ 38 - 0
UAS_MES_ODLF/FunctionCode/Query/Query_SN.resx

@@ -121,6 +121,44 @@
     <value>17, 17</value>
   </metadata>
   <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="Print.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFcSURBVFhH5di7UsJAFMbxtDT6QMI76IAFT0npIE0K
+        GcRORxHklpAIBHLfbILV8XxeNsMznJ35F5vu+82kWYuILD4N7oq75roCw27sb/x5WBdc27btntY64o/i
+        DnZjPxy4S6A0R6PHO1WUNHc9ep4uxIXd2D8eP/XZowWUThBG+n3p0stsKbbJ0qFDFFfscQuUbpzm9Pqx
+        Eh8c4PGLkuX0Nl+LDw4GJckUTRaO+OBQo+SKpitXfHAwKClfZuuN+OBgUDJV0NzxxAeHM5TFxhffGUpe
+        aFp5n+KDg0FRfHH8nfjgUKPoktztXnxwMCgFX7xdID441ChlRf7+ID44GBTNl21wFB8capSqot0xFB8c
+        /lE6Wa70IU5oH0Ziw/5cFebpoPUwHPbL04nCJKUgisWF3dgPB3gABc9v7fvBoBcnaVKdvkha2I39cPjx
+        oPrhusndcPinpIXd2N8gIusbTaFspKtR2SQAAAAASUVORK5CYII=
+</value>
+  </data>
+  <data name="Print.MoveImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAFzSURBVFhH5djNSgJRGMZxL2P2gTfQFbZvHSEZFBEW
+        CEIQBEIgVFiS9qXWoDmp4/fHzDmjM2a+vU/QqUVX0DvwXxxn9fwYXJwYEcXWNzIWt83dcq7AsBv7LXgA
+        ZI0r71/aaqjCJf8o7sFu7IcDFwdK4vimrv1oSZXRnArdQFzYjf3pQkOzRxIoVWc6X5X6M7ruBGIr9mbU
+        9MIVe9hAcXvBO125WnxwgMcXSpcPF20tPjgYlI5eUK6lxAcHg9Lmw3nTFx8cDEpLLSjr+OKDg0FpqojO
+        Gp744GBQ3vyITutT8cHBoDheRCe1ifjgYFBe+ZCxJ+KDg0GpT0NKv4zFBweDUpuEdFQdiQ8OBsXmw2Fl
+        JD44/KCM53TwNBQfHAzKMx/2Hgfig8M3SrXYUasUfz67DwOxYf9dV5urg+RWzta4aEnxn83OfV9c2I39
+        cIAHUOJceTNbUfmW94GX0sJu7IcDPH5fXCe4EvfXxe5/D7ux3yKi2CfkPhTy27lqkwAAAABJRU5ErkJg
+        gg==
+</value>
+  </data>
+  <data name="Print.NormalImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
+    <value>
+        iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m
+        dHdhcmUAQWRvYmUgSW1hZ2VSZWFkeXHJZTwAAAGVSURBVFhH5di7agJRFIXhDSKoYBQEC8FCECwEQRBE
+        4uUVEtTiPKVlom2wttM6IfF+15njXHRnL19jD/zFmanWV8zAEDNTp9OJS6/Sm2QUht3YH4cHtdvtF6k7
+        mUwG1tqd3FR3YTf2w0FKUVOu6XT68Xgw3+8PtWH/bDYbCkeLGo1Gz/d9JwzvrL0gCKx49KlerxtIBUGo
+        PjjAg2q1mqDc2fN99cEBHlStVk0oB+t56oMDPKhSqZggDNm1N/XBAR5ULpeNvGD46rrqgwM8qFQqGV8O
+        56ujPjjAg4rFosFL5ni5qA8O8KBCoWBuns/701l9cIAH5fN5QfF4dzipDw7woFwuZ+zN483+oD44wIOy
+        2azB52i13asPDvCgTCZjHGt5sdmqDw7woHQ6bRzX8ny1UR8c4EHJZNJc5fC7XKsPDvCgRCLR2x9Pzt9q
+        zT+Lpdqw/3A6W/HoUywWa32Nx8OL4zwffM8X6sJu7IcDPCgajaak7udoNNjsdgc81BZ2Yz8c4PH8cR2J
+        ROJSU3qXjMKwG/vjzEz/skOI3Zqgv7AAAAAASUVORK5CYII=
+</value>
+  </data>
   <data name="Export.DownImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
     <value>
         iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAABGdBTUEAALGPC/xhBQAAABl0RVh0U29m