浏览代码

Merge branch 'master' of ssh://10.10.101.21/source/mes-client

Hcsy 8 年之前
父节点
当前提交
69740f6663

+ 11 - 1
UAS-MES/DbFind.cs

@@ -105,6 +105,10 @@ namespace UAS_MES
                 {
                     //先绑定空的结构
                     DbFindGridView.DataSource = dt;
+                    for (int i = 0; i < DbFindGridView.Columns.Count; i++)
+                    {
+                        DbFindGridView.Columns[i].AutoSizeMode = DataGridViewAutoSizeColumnMode.DisplayedCells;
+                    } 
                     //获取查询的字段的拼接语句
                     pagination1.BindDataToNavigator(DbFindGridView, tablename, SelectField, "ID", caller, Condition == null ? "" : Condition);
                     IsAbleDbFind = true;
@@ -259,7 +263,13 @@ namespace UAS_MES
         //列宽发生变化的时候TextBox的宽度也发生变化
         private void DbFindGridView_ColumnWidthChanged(object sender, DataGridViewColumnEventArgs e)
         {
-            ctl[DbFindGridView.Columns.IndexOf(e.Column)].Width = e.Column.Width;
+            try
+            {
+                ctl[DbFindGridView.Columns.IndexOf(e.Column)].Width = e.Column.Width;
+            }
+            catch (Exception)
+            {
+            }
         }
 
         private void DbFindGridView_Scroll(object sender, ScrollEventArgs e)

+ 290 - 0
UAS-MES/FunctionCode/Make/Make_CustomLabelPrint.Designer.cs

@@ -0,0 +1,290 @@
+namespace UAS_MES.Make
+{
+    partial class Make_CustomLabelPrint
+    {
+        /// <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()
+        {
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Make_CustomLabelPrint));
+            this.label1 = new System.Windows.Forms.Label();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label3 = new System.Windows.Forms.Label();
+            this.PrintLabel = new System.Windows.Forms.ComboBox();
+            this.label4 = new System.Windows.Forms.Label();
+            this.label5 = new System.Windows.Forms.Label();
+            this.sncode_label = new System.Windows.Forms.Label();
+            this.label6 = new System.Windows.Forms.Label();
+            this.pr_detail = new System.Windows.Forms.Label();
+            this.pr_spec = new System.Windows.Forms.Label();
+            this.printNum = new UAS_MES.CustomControl.TextBoxWithIcon.NumOnlyTextBox();
+            this.printButton = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.pr_code = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.inputText = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.OperateResult = new UAS_MES.CustomControl.RichText.RichTextAutoBottom();
+            this.Printer = new UAS_MES.CustomControl.ComBoxWithFocus.PrinterCombox();
+            this.SuspendLayout();
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label1.Location = new System.Drawing.Point(55, 37);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(110, 31);
+            this.label1.TabIndex = 0;
+            this.label1.Text = "产品代码";
+            // 
+            // label2
+            // 
+            this.label2.AutoSize = true;
+            this.label2.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label2.Location = new System.Drawing.Point(58, 114);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(110, 31);
+            this.label2.TabIndex = 1;
+            this.label2.Text = "产品名称";
+            // 
+            // label3
+            // 
+            this.label3.AutoSize = true;
+            this.label3.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label3.Location = new System.Drawing.Point(423, 114);
+            this.label3.Name = "label3";
+            this.label3.Size = new System.Drawing.Size(62, 31);
+            this.label3.TabIndex = 2;
+            this.label3.Text = "规格";
+            // 
+            // PrintLabel
+            // 
+            this.PrintLabel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.PrintLabel.FormattingEnabled = true;
+            this.PrintLabel.Location = new System.Drawing.Point(916, 117);
+            this.PrintLabel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.PrintLabel.Name = "PrintLabel";
+            this.PrintLabel.Size = new System.Drawing.Size(190, 26);
+            this.PrintLabel.TabIndex = 185;
+            this.PrintLabel.TextChanged += new System.EventHandler(this.PrintLabel_TextChanged);
+            // 
+            // 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(796, 33);
+            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(86, 31);
+            this.label4.TabIndex = 184;
+            this.label4.Text = "打印机";
+            // 
+            // label5
+            // 
+            this.label5.AutoSize = true;
+            this.label5.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label5.Location = new System.Drawing.Point(807, 110);
+            this.label5.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label5.Name = "label5";
+            this.label5.Size = new System.Drawing.Size(62, 31);
+            this.label5.TabIndex = 183;
+            this.label5.Text = "标签";
+            // 
+            // sncode_label
+            // 
+            this.sncode_label.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left)));
+            this.sncode_label.AutoSize = true;
+            this.sncode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.sncode_label.Location = new System.Drawing.Point(43, 550);
+            this.sncode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.sncode_label.Name = "sncode_label";
+            this.sncode_label.Size = new System.Drawing.Size(86, 31);
+            this.sncode_label.TabIndex = 188;
+            this.sncode_label.Text = "输入框";
+            // 
+            // label6
+            // 
+            this.label6.AutoSize = true;
+            this.label6.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.label6.Location = new System.Drawing.Point(620, 553);
+            this.label6.Name = "label6";
+            this.label6.Size = new System.Drawing.Size(62, 31);
+            this.label6.TabIndex = 189;
+            this.label6.Text = "份数";
+            // 
+            // pr_detail
+            // 
+            this.pr_detail.AutoSize = true;
+            this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.pr_detail.Location = new System.Drawing.Point(174, 112);
+            this.pr_detail.Name = "pr_detail";
+            this.pr_detail.Size = new System.Drawing.Size(0, 31);
+            this.pr_detail.TabIndex = 193;
+            // 
+            // pr_spec
+            // 
+            this.pr_spec.AutoSize = true;
+            this.pr_spec.Font = new System.Drawing.Font("微软雅黑", 12F);
+            this.pr_spec.Location = new System.Drawing.Point(491, 114);
+            this.pr_spec.Name = "pr_spec";
+            this.pr_spec.Size = new System.Drawing.Size(0, 31);
+            this.pr_spec.TabIndex = 194;
+            // 
+            // printNum
+            // 
+            this.printNum.AllPower = null;
+            this.printNum.BackColor = System.Drawing.Color.White;
+            this.printNum.ID = null;
+            this.printNum.Location = new System.Drawing.Point(708, 553);
+            this.printNum.Name = "printNum";
+            this.printNum.Negative = false;
+            this.printNum.Power = null;
+            this.printNum.Size = new System.Drawing.Size(196, 28);
+            this.printNum.Str = null;
+            this.printNum.Str1 = null;
+            this.printNum.Str2 = null;
+            this.printNum.TabIndex = 195;
+            this.printNum.Text = "1";
+            // 
+            // printButton
+            // 
+            this.printButton.AllPower = null;
+            this.printButton.BackColor = System.Drawing.Color.Transparent;
+            this.printButton.DownImage = ((System.Drawing.Image)(resources.GetObject("printButton.DownImage")));
+            this.printButton.Image = null;
+            this.printButton.IsShowBorder = true;
+            this.printButton.Location = new System.Drawing.Point(957, 551);
+            this.printButton.MoveImage = ((System.Drawing.Image)(resources.GetObject("printButton.MoveImage")));
+            this.printButton.Name = "printButton";
+            this.printButton.NormalImage = ((System.Drawing.Image)(resources.GetObject("printButton.NormalImage")));
+            this.printButton.Power = null;
+            this.printButton.Size = new System.Drawing.Size(75, 28);
+            this.printButton.TabIndex = 192;
+            this.printButton.Text = "打印";
+            this.printButton.UseVisualStyleBackColor = false;
+            // 
+            // pr_code
+            // 
+            this.pr_code.AllPower = null;
+            this.pr_code.BackColor = System.Drawing.Color.White;
+            this.pr_code.Font = new System.Drawing.Font("宋体", 9F);
+            this.pr_code.ID = null;
+            this.pr_code.Location = new System.Drawing.Point(180, 40);
+            this.pr_code.Name = "pr_code";
+            this.pr_code.Power = null;
+            this.pr_code.Size = new System.Drawing.Size(252, 28);
+            this.pr_code.Str = null;
+            this.pr_code.Str1 = null;
+            this.pr_code.Str2 = null;
+            this.pr_code.TabIndex = 191;
+            this.pr_code.KeyDown += new System.Windows.Forms.KeyEventHandler(this.pr_code_KeyDown);
+            // 
+            // inputText
+            // 
+            this.inputText.AllPower = "ifall";
+            this.inputText.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left)));
+            this.inputText.BackColor = System.Drawing.Color.White;
+            this.inputText.ID = null;
+            this.inputText.Location = new System.Drawing.Point(167, 553);
+            this.inputText.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.inputText.Name = "inputText";
+            this.inputText.Power = null;
+            this.inputText.Size = new System.Drawing.Size(292, 28);
+            this.inputText.Str = null;
+            this.inputText.Str1 = null;
+            this.inputText.Str2 = null;
+            this.inputText.TabIndex = 187;
+            this.inputText.Tag = "ifwrite";
+            this.inputText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.inputText_KeyDown);
+            // 
+            // OperateResult
+            // 
+            this.OperateResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.OperateResult.Location = new System.Drawing.Point(49, 162);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
+            this.OperateResult.Name = "OperateResult";
+            this.OperateResult.Size = new System.Drawing.Size(1057, 354);
+            this.OperateResult.TabIndex = 186;
+            this.OperateResult.Text = "";
+            // 
+            // Printer
+            // 
+            this.Printer.Location = new System.Drawing.Point(916, 37);
+            this.Printer.Margin = new System.Windows.Forms.Padding(6);
+            this.Printer.Name = "Printer";
+            this.Printer.Size = new System.Drawing.Size(190, 37);
+            this.Printer.TabIndex = 182;
+            // 
+            // Make_CustomLabelPrint
+            // 
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+            this.ClientSize = new System.Drawing.Size(1157, 618);
+            this.Controls.Add(this.printNum);
+            this.Controls.Add(this.pr_spec);
+            this.Controls.Add(this.pr_detail);
+            this.Controls.Add(this.printButton);
+            this.Controls.Add(this.pr_code);
+            this.Controls.Add(this.label6);
+            this.Controls.Add(this.sncode_label);
+            this.Controls.Add(this.inputText);
+            this.Controls.Add(this.OperateResult);
+            this.Controls.Add(this.PrintLabel);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.label5);
+            this.Controls.Add(this.Printer);
+            this.Controls.Add(this.label3);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Name = "Make_CustomLabelPrint";
+            this.Tag = "Make!CustomLabelPrint";
+            this.Text = "Make_CustomLabelPrint";
+            this.Load += new System.EventHandler(this.Make_CustomLablePrint_Load);
+            this.ResumeLayout(false);
+            this.PerformLayout();
+
+        }
+
+        #endregion
+
+        private System.Windows.Forms.Label label1;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label3;
+        private System.Windows.Forms.ComboBox PrintLabel;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label label5;
+        private CustomControl.ComBoxWithFocus.PrinterCombox Printer;
+        private CustomControl.RichText.RichTextAutoBottom OperateResult;
+        private System.Windows.Forms.Label sncode_label;
+        private CustomControl.TextBoxWithIcon.EnterTextBox inputText;
+        private System.Windows.Forms.Label label6;
+        private CustomControl.TextBoxWithIcon.EnterTextBox pr_code;
+        private CustomControl.ButtonUtil.NormalButton printButton;
+        private System.Windows.Forms.Label pr_detail;
+        private System.Windows.Forms.Label pr_spec;
+        private CustomControl.TextBoxWithIcon.NumOnlyTextBox printNum;
+    }
+}

+ 220 - 0
UAS-MES/FunctionCode/Make/Make_CustomLabelPrint.cs

@@ -0,0 +1,220 @@
+using LabelManager2;
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading;
+using System.Windows.Forms;
+using UAS_MES.DataOperate;
+using UAS_MES.PublicForm;
+using UAS_MES.PublicMethod;
+
+namespace UAS_MES.Make
+{
+    public partial class Make_CustomLabelPrint : Form
+    {
+        DataHelper dh;
+
+        LogStringBuilder sql = new LogStringBuilder();
+
+        AutoSizeFormClass asc = new AutoSizeFormClass();
+
+        ApplicationClass lbl;
+
+        Thread InitPrint;
+        //存放产品信息
+        DataTable dt;
+        //存放标签信息
+        DataTable listA;
+        //存放标签参数列表信息
+        DataTable paramsInfo;
+        //记录当前的步骤数
+        int currentIndex = 0;
+
+        Document doc;
+
+        FileInfo info;
+
+        ftpOperater ftp;
+
+        System.DateTime[] indate;
+
+        StringBuilder sb = new StringBuilder();
+        public Make_CustomLabelPrint()
+        {
+            InitializeComponent();
+        }
+
+        private void Make_CustomLablePrint_Load(object sender, EventArgs e)
+        {
+            dh = new DataHelper();
+            inputText.Focus();
+            asc.controllInitializeSize(this);
+            OperateResult.AppendText(">>请输入产品代码\n", Color.Black);
+            InitPrint = new Thread(InPrint);
+            SetLoadingWindow stw = new SetLoadingWindow(InitPrint, "初始化打印程序");
+            BaseUtil.SetFormCenter(stw);
+            stw.ShowDialog();
+        }
+        private void InPrint()
+        {
+            try
+            {
+                lbl = new ApplicationClass();
+                BaseUtil.WriteLbl(lbl);
+            }
+            catch (Exception ex)
+            {
+                OperateResult.AppendText("未正确安装CodeSoft软件\n", Color.Red);
+            }
+        }
+
+        private void pr_code_KeyDown(object sender, KeyEventArgs e)
+        {
+            //按下enter键
+            if (e.KeyCode == Keys.Enter)
+            {
+                //判断产品是否存在
+                dt = (DataTable)dh.ExecuteSql("select pr_code,pr_detail,pr_spec from product where pr_code='" + pr_code.Text + "'  and pr_statuscode ='AUDITED'", "select");
+                //查询没有值,返回提示用户“产品:XXX,不存在或者为审核”,清空产品代码输入框中的值 
+                if (dt.Rows.Count == 0)
+                {
+                    OperateResult.AppendText("<<产品:" + pr_code.Text + ",不存在或者为审核\n", Color.Red);
+                    pr_code.Text = "";
+                    return;
+                }
+                //查询产品是否有自定义的标签模板
+                listA = (DataTable)dh.ExecuteSql("select pl_labelcode ||':'||pl_labelname pl_name,pl_id,pl_labeltype,pl_labelcode,pl_labelurl,pl_isdefault,pl_detno,pl_labelsoft,pl_status,pl_statuscode,pl_labelname,pl_indate from  productlabel where pl_prodcode='" + pr_code.Text + "' and pl_labeltype='自定义' order by pl_isdefault desc", "select");
+                if (listA.Rows.Count == 0)
+                {
+                    OperateResult.AppendText("<<产品:" + pr_code.Text + ",没有维护自定义模板\n", Color.Red);
+                    pr_code.Text = "";
+                    return;
+                }
+                if (listA.Rows[0]["pl_isdefault"].ToString() != "1") {
+                    //说明没有默认的模板,那就取pl_id最大的
+                    listA = (DataTable)dh.ExecuteSql("select pl_labelcode ||':'||pl_labelname pl_name,pl_id,pl_labeltype,pl_labelcode,pl_labelurl,pl_isdefault,pl_detno,pl_labelsoft,pl_status,pl_statuscode,pl_labelname,pl_indate from  productlabel where pl_prodcode='" + pr_code.Text + "' and pl_labeltype='自定义' order by pl_id desc", "select");
+                }
+                //标签显示
+                PrintLabel.DataSource = listA;
+                PrintLabel.DisplayMember = "pl_name";
+                PrintLabel.ValueMember = "pl_labelcode";
+                //下载标签
+                getLabels();
+                //有值,填充界面
+                BaseUtil.SetFormValue(this.Controls, dt);
+                //paramsInfo = (DataTable)dh.ExecuteSql("select lp_detno, lp_name, lp_valuetype,lp_sql from label left join labelparameter on lp_laid=la_id where la_code='"+ listA.Rows[0]["pl_labelcode"].ToString() + "' order by lp_detno asc", "select");
+                if (paramsInfo.Rows.Count > 0)
+                {
+                    //根据查询出来的参数,一次提示用户, “<<SN001 “, 
+                    //“>> 请输入自定义模板的(XXXX参数名称)lp_name”
+                    OperateResult.AppendText("<<" + listA.Rows[0]["pl_labelcode"].ToString() + "\n", Color.Black);
+                    OperateResult.AppendText(">>请输入自定义模板参数名为:" + paramsInfo.Rows[0]["lp_name"].ToString() + "的值\n", Color.Green);
+                    //打开模板路径
+                    doc = lbl.Documents.Open(ftpOperater.DownLoadTo + PrintLabel.Text.Split(':')[1]);
+                    currentIndex = 1;
+                }
+                else
+                {
+                    OperateResult.AppendText("<<标签编号:" + listA.Rows[0]["pl_labelcode"].ToString() + "无标签参数\n", Color.Red);
+                }
+            }
+        }
+
+        private void inputText_KeyDown(object sender, KeyEventArgs e)
+        {
+            //按下enter键
+            if (e.KeyCode == Keys.Enter)
+            {
+                //产品编号为空
+                if (pr_code.Text.Trim() == "")
+                {
+                    OperateResult.AppendText("<<请先输入产品编号\n", Color.Red);
+                    return;
+                }
+                if (inputText.Text.Trim() == "")
+                {
+                    OperateResult.AppendText("<<输入不能为空\n", Color.Red);
+                    return;
+                }
+                if (paramsInfo == null || paramsInfo.Rows.Count == 0)
+                {
+                    OperateResult.AppendText("<<未维护标签参数\n", Color.Red);
+                }
+                else
+                {
+                    if (doc==null) {
+                        OperateResult.AppendText(">>标签无效\n", Color.Red);
+                        return;
+                    }
+                    //将值赋到doc对应的变量
+                    for (int i = 0; i < doc.Variables.FormVariables.Count; i++)
+                    {
+                        //找到对应的变量名
+                        if (doc.Variables.FormVariables.Item(i + 1).Name == paramsInfo.Rows[currentIndex - 1]["lp_name"].ToString())
+                        {
+                            //如果当时采集行的 lp_valuetype=’INPUT’,并且lp_sql 为空,则直接将采集的值赋给标签打印
+                            if (paramsInfo.Rows[currentIndex - 1]["lp_valuetype"].ToString() == "INPUT" && paramsInfo.Rows[currentIndex - 1]["lp_sql"].ToString() == "")
+                            {
+                                doc.Variables.FormVariables.Item(i + 1).Value = inputText.Text;
+                            }
+                            else
+                            {
+                                //取sql拿值赋给变量
+                                string sql = paramsInfo.Rows[currentIndex - 1]["lp_sql"].ToString();
+                                sql = sql.Substring(0, sql.IndexOf("{")) + "'" + inputText.Text + "'";
+                                doc.Variables.FormVariables.Item(i + 1).Value = dh.GetLabelParam(sql).ToString();
+                                sb.AppendLine("打印参数【" + doc.Variables.FormVariables.Item(i + 1).Name + "】赋值," + "取值SQL:" + sql + ",取到值" + doc.Variables.FormVariables.Item(i + 1).Value);
+                            }
+                        }
+                    }
+                    if (currentIndex == paramsInfo.Rows.Count)
+                    {
+                        OperateResult.AppendText("<<输入完成,正在打印\n", Color.Black);
+                        //打印
+                        LogManager.DoLog(sb.ToString());
+                        //保存本次赋值进行打印
+                        doc.Save();
+                        doc.Printer.SwitchTo(Printer.Text);
+                        doc.PrintDocument(int.Parse(printNum.Text));
+                        doc.Close();
+                        //讲文件最后写入时间改成数据库中拿到的时间
+                        info = new FileInfo(ftpOperater.DownLoadTo + PrintLabel.Text.Split(':')[1]);
+                        info.LastWriteTime = indate[PrintLabel.SelectedIndex];
+                        //打印成功
+                        OperateResult.AppendText("<<打印成功\n", Color.Green);
+                        //重置currenIndex为1
+                        currentIndex = 1;
+                        OperateResult.AppendText(">>请输入自定义模板参数名为:" + paramsInfo.Rows[0]["lp_name"].ToString() + "的值\n", Color.Green);
+                    }
+                    else
+                    {
+                        currentIndex++;
+                        OperateResult.AppendText("<<请输入模板参数名为:" + paramsInfo.Rows[currentIndex - 1]["lp_name"].ToString() + "的值\n", Color.Green);
+                    }
+                }
+            }
+        }
+
+        private void getLabels()
+        {
+            ftp = new ftpOperater();
+            indate = new System.DateTime[listA.Rows.Count];
+            for (int i = 0; i < listA.Rows.Count; i++)
+            {
+                BaseUtil.GetPrintLabel(listA.Rows[i]["pl_labelname"].ToString(), listA.Rows[i]["pl_labelurl"].ToString(), listA.Rows[i]["pl_indate"].ToString());
+                indate[i] = Convert.ToDateTime(listA.Rows[i]["pl_indate"].ToString());
+            }
+        }
+
+        private void PrintLabel_TextChanged(object sender, EventArgs e)
+        {
+            paramsInfo = (DataTable)dh.ExecuteSql("select lp_detno, lp_name, lp_valuetype,lp_sql from label left join labelparameter on lp_laid=la_id where la_code='" + PrintLabel.SelectedValue.ToString() + "' order by lp_detno asc", "select");
+        }
+    }
+}

+ 159 - 0
UAS-MES/FunctionCode/Make/Make_CustomLabelPrint.resx

@@ -0,0 +1,159 @@
+<?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>
+  <assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
+  <data name="printButton.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="printButton.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="printButton.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>
+</root>

+ 3 - 1
UAS-MES/FunctionCode/Make/Make_FuselageLabelPrint.cs

@@ -34,6 +34,8 @@ namespace UAS_MES.Make
         Thread InitPrint;
 
         bool pr_change = false;
+
+        ftpOperater ftp;
         public Make_FuselageLabelPrint()
         {
             InitializeComponent();
@@ -195,7 +197,7 @@ namespace UAS_MES.Make
             PrintLabel.DataSource = dt;
             PrintLabel.DisplayMember = "pl_name";
             PrintLabel.ValueMember = "pl_labelcode";
-            ftpOperater ftp = new ftpOperater();
+            ftp = new ftpOperater();
             indate = new System.DateTime[dt.Rows.Count];
             for (int i = 0; i < dt.Rows.Count; i++)
             {

+ 28 - 1
UAS-MES/FunctionCode/Make/Make_PackageCollection.Designer.cs

@@ -66,6 +66,8 @@
             this.AutoGenBoxCode = new System.Windows.Forms.CheckBox();
             this.groupBoxWithBorder2 = new UAS_MES.CustomControl.GroupBoxWithBorder.GroupBoxWithBorder();
             this.Packing = new UAS_MES.CustomControl.ButtonUtil.NormalButton();
+            this.pr_packrule = new System.Windows.Forms.Label();
+            this.pa_status = new System.Windows.Forms.Label();
             this.panel2.SuspendLayout();
             ((System.ComponentModel.ISupportInitialize)(this.PrintNum)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.PackageDetail)).BeginInit();
@@ -452,7 +454,6 @@
             this.pa_currentqty.Name = "pa_currentqty";
             this.pa_currentqty.Size = new System.Drawing.Size(0, 27);
             this.pa_currentqty.TabIndex = 169;
-            this.pa_currentqty.TextChanged += new System.EventHandler(this.pa_packageqty_TextChanged);
             // 
             // pr_outboxinnerqty
             // 
@@ -540,11 +541,35 @@
             this.Packing.UseVisualStyleBackColor = true;
             this.Packing.Click += new System.EventHandler(this.Packing_Click);
             // 
+            // pr_packrule
+            // 
+            this.pr_packrule.AutoSize = true;
+            this.pr_packrule.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_packrule.Location = new System.Drawing.Point(1132, 556);
+            this.pr_packrule.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_packrule.Name = "pr_packrule";
+            this.pr_packrule.Size = new System.Drawing.Size(0, 27);
+            this.pr_packrule.TabIndex = 173;
+            this.pr_packrule.Visible = false;
+            // 
+            // pa_status
+            // 
+            this.pa_status.AutoSize = true;
+            this.pa_status.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pa_status.Location = new System.Drawing.Point(1040, 604);
+            this.pa_status.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pa_status.Name = "pa_status";
+            this.pa_status.Size = new System.Drawing.Size(0, 27);
+            this.pa_status.TabIndex = 174;
+            this.pa_status.Visible = false;
+            // 
             // Make_PackageCollection
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1172, 760);
+            this.Controls.Add(this.pa_status);
+            this.Controls.Add(this.pr_packrule);
             this.Controls.Add(this.groupBoxWithBorder2);
             this.Controls.Add(this.groupBoxWithBorder1);
             this.Controls.Add(this.OperateResult);
@@ -617,5 +642,7 @@
         private CustomControl.GroupBoxWithBorder.GroupBoxWithBorder groupBoxWithBorder2;
         private CustomControl.ButtonUtil.NormalButton Packing;
         private System.Windows.Forms.CheckBox AutoGenBoxCode;
+        private System.Windows.Forms.Label pr_packrule;
+        private System.Windows.Forms.Label pa_status;
     }
 }

+ 64 - 48
UAS-MES/FunctionCode/Make/Make_PackageCollection.cs

@@ -77,13 +77,13 @@ namespace UAS_MES.Make
             if (pa_outboxcode.Text != "")
             {
                 sql.Clear();
-                sql.Append("select pa_outboxcode,pr_detail,pa_packageqty,pr_outboxinnerqty,pa_standardqty,pa_currentqty from package left join product on pa_prodcode=");
+                sql.Append("select pa_outboxcode,pa_status,pr_packrule,pr_detail,pa_packageqty,pr_outboxinnerqty,pa_standardqty,pa_currentqty from package left join product on pa_prodcode=");
                 sql.Append("pr_code where pa_outboxcode='" + pa_outboxcode.Text + "'");
             }
             else
             {
                 sql.Clear();
-                sql.Append("select ms_makecode,pr_code,pr_detail,pr_outboxinnerqty,pa_standardqty,pa_packageqty,pa_currentqty,");
+                sql.Append("select ms_makecode,pa_status,pr_packrule,pr_code,pr_detail,pr_outboxinnerqty,pa_standardqty,pa_packageqty,pa_currentqty,");
                 sql.Append("pa_outboxcode from makeserial left join product on ms_prodcode=pr_code left join packagedetail ");
                 sql.Append("on pd_barcode=ms_sncode left join package on pa_id =pd_paid where ms_sncode='" + sn_code.Text + "'");
             }
@@ -97,9 +97,16 @@ namespace UAS_MES.Make
                 BaseUtil.SetFormValue(this.Controls, dt);
             }
             else OperateResult.AppendText(">>序列号不存在\n", Color.Red);
+
+        }
+
+        private void LoadGridData()
+        {
             //加载Grid数据
             dt = (DataTable)dh.ExecuteSql("select pa_outboxcode,pd_barcode,pd_innerqty,pa_indate from packageDetail left join package on pa_id=pd_paid where pa_outboxcode='" + pa_outboxcode.Text + "'", "select");
             BaseUtil.FillDgvWithDataTable(PackageDetail, dt);
+            //更新界面的采集数量
+            pa_currentqty.Text = dh.getFieldDataByCondition("package", "pa_currentqty", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString();
         }
 
         private void InsertDetail()
@@ -111,7 +118,7 @@ namespace UAS_MES.Make
                 sql.Append("select packagedetail_seq.nextval,pa_id,pa_outboxcode,pa_totalqty,'" + sn_code.Text + "' from package where pa_outboxcode='" + pa_outboxcode.Text + "'");
                 dh.ExecuteSql(sql.GetString(), "insert");
                 dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty+1,pa_currentqty=pa_currentqty+1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
-                dh.UpdateByCondition("makeserial", "ms_outboxcode='" + pa_outboxcode.Text + "'", "ms_sncode='" + sn_code.Text + "' and ms_makecode='" + ms_makecode.Text + "'");
+                dh.UpdateByCondition("makeserial", "ms_outboxcode='" + pa_outboxcode.Text + "'", "ms_id='" + oMsID + "'");
                 if (LogicHandler.SetStepResult(ms_makecode.Text, User.UserSourceCode, sn_code.Text, "包装采集", "装箱成功", User.UserCode, out ErrorMessage))
                 {
                     OperateResult.AppendText(">>序列号" + sn_code.Text + "采集成功!\n", Color.Green);
@@ -119,8 +126,10 @@ namespace UAS_MES.Make
                     if (int.Parse(pa_currentqty.Text == "" ? "0" : pa_currentqty.Text) + 1 == int.Parse(pr_outboxinnerqty.Text))
                     {
                         dh.UpdateByCondition("package", "pa_status=1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
+                        if (AutoPrint.Checked)
+                            Print_Click(new object(), new EventArgs());
                     }
-                    LoadData();
+                    LoadGridData();
                     sn_code.Clear();
                 }
             }
@@ -133,6 +142,7 @@ namespace UAS_MES.Make
             {
                 if (dh.getFieldDataByCondition("package", "pa_status", "pa_outboxcode='" + pa_outboxcode.Text + "'").ToString() == "1")
                 {
+                    dh.ExecuteSql("update package set pa_printcount=pa_printcount+1 where pa_outboxcode='" + pa_outboxcode.Text + "'", "update");
                     OperateResult.AppendText(">>开始打印箱号" + pa_outboxcode.Text + "\n", Color.Green);
                     Print.CodeSoft(lbl, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
                 }
@@ -147,7 +157,7 @@ namespace UAS_MES.Make
             if (e.KeyCode == Keys.Enter)
             {
                 sql.Clear();
-                sql.Append("select pr_code,pr_detail,pr_outboxinnerqty,pa_packageqty from package left join product ");
+                sql.Append("select pr_code,pr_detail,pr_outboxinnerqty,pa_currentqty,pa_packageqty from package left join product ");
                 sql.Append("on pr_code=pa_prodcode where pa_outboxcode='" + pa_outboxcode.Text + "'");
                 dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                 if (dt.Rows.Count > 0)
@@ -169,11 +179,43 @@ namespace UAS_MES.Make
             {
                 if (LogicHandler.CheckStepSNAndMacode(ms_makecode.Text, User.UserSourceCode, sn_code.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
                 {
+                    //按工单核对装箱
+                    switch (pr_packrule.Text)
+                    {
+                        case "M":
+                            if (dh.getFieldDataByCondition("makeserial", "ms_makecode", "ms_id='" + oMsID + "'").ToString() != ms_makecode.Text)
+                            {
+                                OperateResult.AppendText(">>序列号" + sn_code.Text + "所属工单和当前箱号工单不相等\n", Color.Red, sn_code);
+                                return;
+                            }
+                            break;
+                        case "S":
+                            sql.Clear();
+                            sql.Append("select 1 from package left join make on pa_salecode=ma_salecode left join makeserial ");
+                            sql.Append("on ma_code=ms_makecode where pa_outboxcode='" + pa_outboxcode.Text + "' and ms_id='" + oMsID + "'");
+                            DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                            if (dt.Rows.Count == 0)
+                            {
+                                OperateResult.AppendText(">>序列号" + sn_code.Text + "所属订单号和当前箱号订单不相等\n", Color.Red, sn_code);
+                                return;
+                            }
+                            break;
+                        case "":
+                            if (dh.getFieldDataByCondition("makeserial", "ms_prodcode", "ms_id='" + oMsID + "'").ToString() != pr_code.Text)
+                            {
+                                OperateResult.AppendText(">>序列号" + sn_code.Text + "对应物料和该箱所装物料不同\n", Color.Red, sn_code);
+                                return;
+                            }
+                            break;
+                        default:
+                            break;
+                    }
                     if (pa_outboxcode.Text == "")
                     {
                         if (dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString() != "")
                         {
                             LoadData();
+                            LoadGridData();
                         }
                         else
                         {
@@ -190,30 +232,30 @@ namespace UAS_MES.Make
                     //如果未勾选了取消录入
                     if (!Cancel.Checked)
                     {
-                        //满箱之后采集下一个之前自动清除内容,生成新的箱号
-                        if (AutoGenBoxCode.Checked && pa_currentqty.Text != "" && pr_outboxinnerqty.Text == pa_currentqty.Text)
-                        {
-                            pa_currentqty.Text = "";
-                            pa_outboxcode.Text = "";
-                            BaseUtil.CleanDGVData(PackageDetail);
-                            pa_outboxcode.GeneratePaCode_Click(new object(), new EventArgs());
-                        }
                         //判断序列号是否已经装箱
                         if (dh.getFieldDataByCondition("makeserial", "ms_outboxcode", "ms_id='" + oMsID + "'").ToString() != "")
                         {
-                            OperateResult.AppendText(">>序列号" + sn_code.Text + "已经装箱!\n", Color.Red);
-                            sn_code.Clear();
+                            OperateResult.AppendText(">>序列号" + sn_code.Text + "已经装箱!\n", Color.Red, sn_code);
                         }
                         else
                         {
+                            //满箱之后采集下一个之前自动清除内容,生成新的箱号
+                            if ((AutoGenBoxCode.Checked && pa_currentqty.Text != "" && pr_outboxinnerqty.Text == pa_currentqty.Text) || pa_status.Text == "1")
+                            {
+                                pa_currentqty.Text = "";
+                                pa_outboxcode.Text = "";
+                                pa_status.Text = "0";
+                                BaseUtil.CleanDGVData(PackageDetail);
+                                pa_outboxcode.GeneratePaCode_Click(new object(), new EventArgs());
+                            }
                             //箱号不存在的情况
                             if (!dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "'"))
                             {
                                 //插入Package主表箱号信息
                                 sql.Clear();
-                                sql.Append("insert into package (pa_id,pa_outboxcode,pa_packageqty,pa_totalqty,pa_status,pa_indate,pa_makecode,pa_prodcode,pa_salecode,pa_custcode,pa_type)");
-                                sql.Append("select package_seq.nextval,'" + pa_outboxcode.Text + "',0," + pr_outboxinnerqty.Text + ",0,");
-                                sql.Append("sysdate,'" + ms_makecode.Text + "', ma_prodcode,ma_salecode,ma_custcode,1 from make where ma_code = '" + ms_makecode.Text + "'");
+                                sql.Append("insert into package (pa_id,pa_outboxcode,pa_packageqty,pa_totalqty,pa_status,pa_indate,pa_makecode,pa_prodcode,pa_salecode,");
+                                sql.Append("pa_custcode,pa_type,pa_packtype) select package_seq.nextval,'" + pa_outboxcode.Text + "',0," + pr_outboxinnerqty.Text + ",0,");
+                                sql.Append("sysdate,'" + ms_makecode.Text + "', ma_prodcode,ma_salecode,ma_custcode,1,'" + pr_packrule.Text + "' from make where ma_code = '" + ms_makecode.Text + "'");
                                 dh.ExecuteSql(sql.GetString(), "insert");
                                 OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "采集成功!\n", Color.Green);
                                 InsertDetail();
@@ -242,9 +284,9 @@ namespace UAS_MES.Make
                                     //更新已装数 
                                     dh.UpdateByCondition("Package", "pa_packageqty=pa_packageqty-1,pa_currentqty=pa_currentqty-1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
                                     //清除序列号箱号
-                                    dh.UpdateByCondition("makeserial", "ms_outboxcode=''", "ms_sncode='" + sn_code.Text + "' and ms_makecode='" + ms_makecode.Text + "'");
+                                    dh.UpdateByCondition("makeserial", "ms_outboxcode=''", "ms_id='" + oMsID + "'");
                                     OperateResult.AppendText(">>已从该箱中移除序列号" + sn_code.Text + "\n", Color.Green);
-                                    LoadData();
+                                    LoadGridData();
                                 }
                                 else OperateResult.AppendText(">>序列号" + sn_code.Text + "不在箱" + pa_outboxcode.Text + "内\n", Color.Red);
                             }
@@ -262,33 +304,6 @@ namespace UAS_MES.Make
             OperateResult.Clear();
         }
 
-        private void pa_packageqty_TextChanged(object sender, EventArgs e)
-        {
-            if (AutoPrint.Checked)
-            {
-                if (pr_outboxinnerqty.Text == pa_currentqty.Text)
-                {
-                    OperateResult.AppendText(">>打印箱号" + pa_outboxcode.Text + "\n", Color.Green);
-                    if (PrintLabel.Items.Count != 0)
-                    {
-                        Print.CodeSoft(lbl, PrintLabel.Text.Split(':')[1], PrintLabel.SelectedValue.ToString(), PrintList.Text, pa_outboxcode.Text, int.Parse(PrintNum.Text), indate[PrintLabel.SelectedIndex]);
-                    }
-                    else
-                    {
-                        OperateResult.AppendText(">>产品" + pr_code.Text + "未维护打印标签\n", Color.Red);
-                    }
-                }
-            }
-        }
-
-        private void pa_code_IconClick(object sender, EventArgs e)
-        {
-            if (ms_makecode.Text == "")
-            {
-                OperateResult.AppendText(">>请先选择工单号\n", Color.Red);
-            }
-        }
-
         private void pr_code_TextChanged(object sender, EventArgs e)
         {
             pa_outboxcode.MakeCode = ms_makecode.Text;
@@ -317,7 +332,8 @@ namespace UAS_MES.Make
         {
             if (dh.CheckExist("package", "pa_outboxcode='" + pa_outboxcode.Text + "' and pa_status<>1"))
             {
-                dh.UpdateByCondition("package", "pa_status=1", "pa_outboxcode='" + pa_outboxcode.Text + "'");
+                dh.UpdateByCondition("package", "pa_status=1,pa_totalqty=pa_currentqty,pa_packageqty=pa_currentqty", "pa_outboxcode='" + pa_outboxcode.Text + "'");
+                pa_status.Text = "1";
                 OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "封箱成功\n", Color.Green);
             }
             else OperateResult.AppendText(">>箱号" + pa_outboxcode.Text + "错误或者已封箱\n", Color.Red);

+ 3 - 3
UAS-MES/FunctionCode/Make/Make_Repair.cs

@@ -69,9 +69,9 @@ namespace UAS_MES.Make
             cd_stepcode.DbChange += Cd_stepcode_DbChange;
 
             bd_soncode.FormName = Name;
-            bd_soncode.TableName = "bom left join bomdetail on bd_bomid=bo_id";
+            bd_soncode.TableName = "bom left join bomdetail on bd_bomid=bo_id left join product on bd_soncode=pr_code";
             bd_soncode.SetValueField = new string[] { "bd_soncode" };
-            bd_soncode.SelectField = "bd_soncode # 子件编号";
+            bd_soncode.SelectField = "bd_soncode # 子件编号,pr_detail # 物料名称,pr_spec # 物料规格";
             bd_soncode.DBTitle = "不良零件";
             bd_soncode.DbChange += Prodcode_DbChange;
 
@@ -88,7 +88,7 @@ namespace UAS_MES.Make
             {
                 if (mbr_id != "")
                 {
-                    if (!dh.CheckExist("makebadrspart", "mbp_sncode='"+GetSNCode.Text+"' and mbp_part='"+bd_soncode.Text+"'"))
+                    if (!dh.CheckExist("makebadrspart", "mbp_sncode='" + GetSNCode.Text + "' and mbp_part='" + bd_soncode.Text + "'"))
                     {
                         sql.Clear();
                         sql.Append("insert into makebadrspart(mbp_id,mbp_mbrid,mbp_part,mbp_badcode,");

+ 15 - 0
UAS-MES/UAS-MES.csproj

@@ -229,6 +229,12 @@
     <Compile Include="CustomControl\CustomCheckBox\AutoPrintCheckBox.Designer.cs">
       <DependentUpon>AutoPrintCheckBox.cs</DependentUpon>
     </Compile>
+    <Compile Include="CustomControl\CustomCheckBox\CustomCheckBox.cs">
+      <SubType>Component</SubType>
+    </Compile>
+    <Compile Include="CustomControl\CustomCheckBox\CustomCheckBox.Designer.cs">
+      <DependentUpon>CustomCheckBox.cs</DependentUpon>
+    </Compile>
     <Compile Include="CustomControl\CustomCheckBox\LockCheckBox.cs">
       <SubType>Component</SubType>
     </Compile>
@@ -453,6 +459,12 @@
     <Compile Include="FunctionCode\Make\Make_ColorBoxLabelPrint.Designer.cs">
       <DependentUpon>Make_ColorBoxLabelPrint.cs</DependentUpon>
     </Compile>
+    <Compile Include="FunctionCode\Make\Make_CustomLabelPrint.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_CustomLabelPrint.Designer.cs">
+      <DependentUpon>Make_CustomLabelPrint.cs</DependentUpon>
+    </Compile>
     <Compile Include="FunctionCode\Make\Make_Decompose.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -964,6 +976,9 @@
     <EmbeddedResource Include="FunctionCode\Make\Make_ColorBoxLabelPrint.resx">
       <DependentUpon>Make_ColorBoxLabelPrint.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_CustomLabelPrint.resx">
+      <DependentUpon>Make_CustomLabelPrint.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Make\Make_Decompose.resx">
       <DependentUpon>Make_Decompose.cs</DependentUpon>
     </EmbeddedResource>