Browse Source

添加标签打印功能

callm 2 months ago
parent
commit
80a4324702

+ 104 - 14
UAS_MES_YDCY/FunctionCode/Make/Make_SNLabelCheck.Designer.cs

@@ -28,6 +28,7 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
             System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Make_SNLabelCheck));
             this.mcd_restqty_label = new System.Windows.Forms.Label();
             this.mcd_inqty_label = new System.Windows.Forms.Label();
@@ -49,6 +50,7 @@
             this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.sir_remark = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.StepCount = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SourceStepCount();
             this.ma_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.MaCodeSearchTextBox();
@@ -63,13 +65,18 @@
             this.Confirm = new UAS_MES_NEW.CustomControl.ButtonUtil.NormalButton();
             this.code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.SnCollectionBox();
             this.sn_code = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
-            this.dataGridViewTextBoxColumn5 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.dataGridViewTextBoxColumn6 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.lcd_detno = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.lcd_labeltype = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.lcd_prefix = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.lcd_length = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.lcd_content = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.PrintNum = new UAS_MES_NEW.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.PrintLabel = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.ComboxWithTip(this.components);
+            this.label2 = new System.Windows.Forms.Label();
+            this.PrintLabel_label = new System.Windows.Forms.Label();
+            this.Printer = new UAS_MES_NEW.CustomControl.ComBoxWithFocus.PrinterCombox();
             ((System.ComponentModel.ISupportInitialize)(this.ClearSn_code)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.LabelDataGridView)).BeginInit();
             this.SuspendLayout();
@@ -291,6 +298,7 @@
             this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
             this.dataGridViewTextBoxColumn2.ReadOnly = true;
             this.dataGridViewTextBoxColumn2.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.dataGridViewTextBoxColumn2.Width = 200;
             // 
             // dataGridViewTextBoxColumn3
             // 
@@ -301,6 +309,7 @@
             this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
             this.dataGridViewTextBoxColumn3.ReadOnly = true;
             this.dataGridViewTextBoxColumn3.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.dataGridViewTextBoxColumn3.Width = 200;
             // 
             // dataGridViewTextBoxColumn4
             // 
@@ -313,6 +322,17 @@
             this.dataGridViewTextBoxColumn4.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
             this.dataGridViewTextBoxColumn4.Width = 200;
             // 
+            // dataGridViewTextBoxColumn5
+            // 
+            this.dataGridViewTextBoxColumn5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
+            this.dataGridViewTextBoxColumn5.DataPropertyName = "sp_length";
+            this.dataGridViewTextBoxColumn5.HeaderText = "条码号";
+            this.dataGridViewTextBoxColumn5.MinimumWidth = 300;
+            this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
+            this.dataGridViewTextBoxColumn5.ReadOnly = true;
+            this.dataGridViewTextBoxColumn5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
+            this.dataGridViewTextBoxColumn5.Width = 200;
+            // 
             // sir_remark
             // 
             this.sir_remark.AllPower = null;
@@ -387,6 +407,7 @@
             this.ma_prodcode.Name = "ma_prodcode";
             this.ma_prodcode.Size = new System.Drawing.Size(0, 41);
             this.ma_prodcode.TabIndex = 99;
+            this.ma_prodcode.TextChanged += new System.EventHandler(this.ma_prodcode_TextChanged);
             // 
             // pr_detail
             // 
@@ -519,17 +540,6 @@
             this.sn_code.Str2 = null;
             this.sn_code.TabIndex = 65;
             // 
-            // dataGridViewTextBoxColumn5
-            // 
-            this.dataGridViewTextBoxColumn5.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
-            this.dataGridViewTextBoxColumn5.DataPropertyName = "sp_length";
-            this.dataGridViewTextBoxColumn5.HeaderText = "条码号";
-            this.dataGridViewTextBoxColumn5.MinimumWidth = 300;
-            this.dataGridViewTextBoxColumn5.Name = "dataGridViewTextBoxColumn5";
-            this.dataGridViewTextBoxColumn5.ReadOnly = true;
-            this.dataGridViewTextBoxColumn5.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable;
-            this.dataGridViewTextBoxColumn5.Width = 200;
-            // 
             // dataGridViewTextBoxColumn6
             // 
             this.dataGridViewTextBoxColumn6.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
@@ -542,11 +552,12 @@
             // 
             // lcd_detno
             // 
+            this.lcd_detno.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
             this.lcd_detno.DataPropertyName = "lcd_detno";
             this.lcd_detno.HeaderText = "序号";
-            this.lcd_detno.MinimumWidth = 10;
+            this.lcd_detno.MinimumWidth = 30;
             this.lcd_detno.Name = "lcd_detno";
-            this.lcd_detno.Width = 200;
+            this.lcd_detno.Width = 30;
             // 
             // lcd_labeltype
             // 
@@ -584,11 +595,84 @@
             this.lcd_content.Name = "lcd_content";
             this.lcd_content.Width = 200;
             // 
+            // PrintNum
+            // 
+            this.PrintNum.AllPower = null;
+            this.PrintNum.BackColor = System.Drawing.Color.White;
+            this.PrintNum.Enabled = false;
+            this.PrintNum.ID = null;
+            this.PrintNum.Location = new System.Drawing.Point(1490, 388);
+            this.PrintNum.Margin = new System.Windows.Forms.Padding(6);
+            this.PrintNum.Name = "PrintNum";
+            this.PrintNum.Power = null;
+            this.PrintNum.Size = new System.Drawing.Size(260, 35);
+            this.PrintNum.Str = null;
+            this.PrintNum.Str1 = null;
+            this.PrintNum.Str2 = null;
+            this.PrintNum.TabIndex = 205;
+            // 
+            // label4
+            // 
+            this.label4.AutoSize = true;
+            this.label4.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label4.Location = new System.Drawing.Point(1334, 388);
+            this.label4.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(82, 41);
+            this.label4.TabIndex = 204;
+            this.label4.Text = "份数";
+            // 
+            // PrintLabel
+            // 
+            this.PrintLabel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.PrintLabel.FormattingEnabled = true;
+            this.PrintLabel.Location = new System.Drawing.Point(1490, 312);
+            this.PrintLabel.Margin = new System.Windows.Forms.Padding(4, 2, 4, 2);
+            this.PrintLabel.Name = "PrintLabel";
+            this.PrintLabel.Size = new System.Drawing.Size(260, 32);
+            this.PrintLabel.TabIndex = 203;
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label2.Location = new System.Drawing.Point(1334, 216);
+            this.label2.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(114, 41);
+            this.label2.TabIndex = 202;
+            this.label2.Text = "打印机";
+            // 
+            // PrintLabel_label
+            // 
+            this.PrintLabel_label.AutoSize = true;
+            this.PrintLabel_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.PrintLabel_label.Location = new System.Drawing.Point(1334, 303);
+            this.PrintLabel_label.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0);
+            this.PrintLabel_label.Name = "PrintLabel_label";
+            this.PrintLabel_label.Size = new System.Drawing.Size(82, 41);
+            this.PrintLabel_label.TabIndex = 201;
+            this.PrintLabel_label.Text = "标签";
+            // 
+            // Printer
+            // 
+            this.Printer.Location = new System.Drawing.Point(1490, 216);
+            this.Printer.Margin = new System.Windows.Forms.Padding(8);
+            this.Printer.Name = "Printer";
+            this.Printer.Size = new System.Drawing.Size(262, 50);
+            this.Printer.TabIndex = 200;
+            // 
             // Make_SNLabelCheck
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 24F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1796, 974);
+            this.Controls.Add(this.PrintNum);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.PrintLabel);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.PrintLabel_label);
+            this.Controls.Add(this.Printer);
             this.Controls.Add(this.LabelDataGridView);
             this.Controls.Add(this.NoteForChange);
             this.Controls.Add(this.sir_remark);
@@ -675,5 +759,11 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn lcd_prefix;
         private System.Windows.Forms.DataGridViewTextBoxColumn lcd_length;
         private System.Windows.Forms.DataGridViewTextBoxColumn lcd_content;
+        private CustomControl.TextBoxWithIcon.EnterTextBox PrintNum;
+        private System.Windows.Forms.Label label4;
+        private CustomControl.ComBoxWithFocus.ComboxWithTip PrintLabel;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label PrintLabel_label;
+        private CustomControl.ComBoxWithFocus.PrinterCombox Printer;
     }
 }

+ 72 - 17
UAS_MES_YDCY/FunctionCode/Make/Make_SNLabelCheck.cs

@@ -7,6 +7,8 @@ using UAS_MES_NEW.PublicMethod;
 using System.Drawing;
 using System.Collections.Generic;
 using UAS_MES_NEW.PublicForm;
+using Seagull.BarTender.Print;
+using System.Threading;
 
 namespace UAS_MES_NEW.Make
 {
@@ -41,6 +43,10 @@ namespace UAS_MES_NEW.Make
 
         string ms_firstsn = "";
 
+        Thread InitPrint;
+
+        Engine engine;
+
         DataHelper dh;
         LogStringBuilder sql = new LogStringBuilder();
         DataTable DBFind;
@@ -50,20 +56,30 @@ namespace UAS_MES_NEW.Make
 
         AutoSizeFormClass asc = new AutoSizeFormClass();
 
-        List<string> CollectData = new List<string>();
-
-        List<string> CollectDataSonCode = new List<string>();
-
-        List<string> SPID = new List<string>();
-
         public Make_SNLabelCheck()
         {
             InitializeComponent();
         }
 
+        private void InPrint()
+        {
+            try
+            {
+                engine = new Engine(true);
+            }
+            catch (Exception)
+            {
+                OperateResult.AppendText("未正确安装BarTender软件\n", Color.Red);
+            }
+        }
+
         private void Make_FeedingCollection_Load(object sender, EventArgs e)
         {
             asc.controllInitializeSize(this);
+            InitPrint = new Thread(InPrint);
+            SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
+            BaseUtil.SetFormCenter(stw);
+            stw.ShowDialog();
             LockMakeCode.GetMakeCodeCtl(ma_code);
             ma_code.SetLockCheckBox(LockMakeCode);
             //工单号放大镜配置
@@ -132,7 +148,7 @@ namespace UAS_MES_NEW.Make
                         }
                         else if (sn_code.Text != "")
                         {
-                            bool AllCheck = false;
+                            bool AllCheck = true;
                             //索引超出长度表示内容均已提醒
                             for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
                             {
@@ -153,24 +169,54 @@ namespace UAS_MES_NEW.Make
                                         return;
                                     }
                                     LabelDataGridView.Rows[i].Cells["lcd_content"].Value = code.Text;
+                                    break;
                                 }
                             }
                             //循环所有行,判断是否所有的内容都有值
+                            List<string> labeltype_list = new List<string>();
+                            List<string> prefix_list = new List<string>();
+                            List<string> length_list = new List<string>();
+                            List<string> value = new List<string>();
                             int checkcount = 0;
                             for (int i = 0; i < LabelDataGridView.Rows.Count; i++)
                             {
                                 if (LabelDataGridView.Rows[i].Cells["lcd_content"].Value != null)
                                 {
                                     checkcount = checkcount + 1;
+                                    labeltype_list.Add(LabelDataGridView.Rows[i].Cells["lcd_labeltype"].Value.ToString());
+                                    prefix_list.Add(LabelDataGridView.Rows[i].Cells["lcd_labeltype"].Value.ToString());
+                                    length_list.Add(LabelDataGridView.Rows[i].Cells["lcd_length"].Value.ToString());
+                                    value.Add(LabelDataGridView.Rows[i].Cells["lcd_content"].Value.ToString());
+                                }
+                                else
+                                {
+                                    AllCheck = false;
                                 }
                             }
-                            //如果达到了行数,则判定校验通过
-                            if (checkcount == LabelDataGridView.Rows.Count)
-                            {
-                                AllCheck = true;
-                            }
+                            ////如果达到了行数,则判定校验通过
+                            //if (checkcount == LabelDataGridView.Rows.Count)
+                            //{
+                            //    AllCheck = true;
+                            //}
                             if (AllCheck)
                             {
+                                sql.Clear();
+                                sql.Append("insert into labelchecklog(LCL_ID, LCL_SN, LCL_LABELTYPE, lcl_prefix,lcl_length, LCL_LABELVALUE, LCL_STEPCODE, LCL_SOURCECODE," +
+                                    " LCL_INMAN, LCL_DATE)" +
+                                    "select labelchecklog_seq.nextval,'" + sn_code.Text + "',:LCL_LABELTYPE,:lcl_prefix,:lcl_length,:LCL_LABELVALUE,'" + User.CurrentStepCode + "'" +
+                                    ",'" + User.UserSourceCode + "','" + User.UserCode + "',sysdate from dual");
+                                dh.BatchInsert(sql.GetString(), new string[] { "LCL_LABELTYPE", "lcl_prefix", "lcl_length", "LCL_LABELVALUE" },
+                                    labeltype_list.ToArray(), prefix_list.ToArray(), length_list.ToArray(), value.ToArray());
+                                LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, oMakeCode, User.UserLineCode, User.UserSourceCode, "上料采集", "上料成功", sn_code.Text, "");
+                                if (!Print.BarTender(Tag.ToString(), ref engine, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sn_code.Text, int.Parse(PrintNum.Text), ma_code.Text, ma_prodcode.Text, "机身标", "0", out ErrorMessage))
+                                {
+                                    OperateResult.AppendText(ErrorMessage + "\n", Color.Red);
+                                }
+                                if (!LogicHandler.SetStepResult(ma_code.Text, User.UserSourceCode, sn_code.Text, "标签核对", "标签核对完成", User.UserCode, out ErrorMessage))
+                                {
+                                    OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red, code);
+                                    return;
+                                }
                                 OperateResult.AppendText(">>校验完成\n", Color.Green, code);
                             }
                         }
@@ -289,19 +335,20 @@ namespace UAS_MES_NEW.Make
         private void GetItem()
         {
             dt1 = (DataTable)dh.ExecuteSql("select lcd_detno,LCD_LABELTYPE, nvl(LCD_LENGTH,0)LCD_LENGTH, LCD_PREFIX from LABELCHECKdetail left join labelcheck " +
-                   "on lcd_lcid=lc_id where lc_prodcode='" + ma_prodcode.Text + "' and LCD_LABELTYPE not in (select LCL_LABELVALUE from labelchecklog where " +
+                   "on lcd_lcid=lc_id where lc_prodcode='" + ma_prodcode.Text + "' and LCD_LABELTYPE not in (select LCL_LABELTYPE from labelchecklog where " +
                    "LCL_SN='" + sn_code.Text + "') order by lcd_detno", "select");
+            if (dt1.Rows.Count == 0)
+            {
+                OperateResult.AppendText(">>序列号" + code.Text + "未设置核对类型,或者已核对完成\n", Color.Red, code);
+                sn_code.Clear();
+            }
             BaseUtil.FillDgvWithDataTable(LabelDataGridView, dt1);
         }
 
         private void ClearSn_code_Click(object sender, EventArgs e)
         {
             sn_code.Clear();
-            SPID.Clear();
-            TSN.Clear();
             CheckBarcode.Clear();
-            CollectData.Clear();
-            CollectDataSonCode.Clear();
             if (dt1 != null)
                 BaseUtil.CleanDataTableData(dt1);
             RemainIndex = 0;
@@ -328,5 +375,13 @@ namespace UAS_MES_NEW.Make
                 }
             }
         }
+
+        private void ma_prodcode_TextChanged(object sender, EventArgs e)
+        {
+            DataTable _dt = (DataTable)dh.ExecuteSql("select la_id,la_url,la_isdefault from label where la_prodcode='" + ma_prodcode.Text + "' and la_templatetype='机身标' and la_statuscode='AUDITED' order by la_isdefault", "select");
+            PrintLabel.DataSource = _dt;
+            PrintLabel.DisplayMember = "la_url";
+            PrintLabel.ValueMember = "la_id";
+        }
     }
 }

+ 15 - 0
UAS_MES_YDCY/FunctionCode/Make/Make_SNLabelCheck.resx

@@ -395,4 +395,19 @@
         42a73eNQWtiN/XCAB+GhVilVVUrFSqlfSikrMOzG/u+H6/+yQ4jdXN8e9AAAAABJRU5ErkJggg==
 </value>
   </data>
+  <metadata name="lcd_detno.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="lcd_labeltype.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="lcd_prefix.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="lcd_length.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
+  <metadata name="lcd_content.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
+    <value>True</value>
+  </metadata>
 </root>