Browse Source

Merge remote-tracking branch 'refs/remotes/origin/master'

章政 8 years ago
parent
commit
d46e7bb8ce

+ 284 - 3
UAS-MES/FunctionCode/Make/Make_ColorBoxLabelPrint.Designer.cs

@@ -28,20 +28,301 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
+            this.PrintLabel = new System.Windows.Forms.ComboBox();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.Printer = new UAS_MES.CustomControl.ComBoxWithFocus.PrinterCombox();
+            this.mcd_remainqty = new UAS_MES.CustomControl.ValueLabel.ValueNumLabel(this.components);
+            this.mcd_okqty = new UAS_MES.CustomControl.ValueLabel.ValueNumLabel(this.components);
+            this.pr_code = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.pr_detail = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.ms_makecode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.PrintNum = new UAS_MES.CustomControl.TextBoxWithIcon.NumOnlyTextBox();
+            this.pr_detail_label = new System.Windows.Forms.Label();
+            this.sncode_label = new System.Windows.Forms.Label();
+            this.sncode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.OperateResult = new UAS_MES.CustomControl.RichText.RichTextAutoBottom();
+            this.label4 = new System.Windows.Forms.Label();
+            this.mcd_remainqty_label = new System.Windows.Forms.Label();
+            this.mcd_okqty_label = new System.Windows.Forms.Label();
+            this.pr_code_label = new System.Windows.Forms.Label();
+            this.ms_makecode_label = new System.Windows.Forms.Label();
             this.SuspendLayout();
             // 
+            // PrintLabel
+            // 
+            this.PrintLabel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.PrintLabel.FormattingEnabled = true;
+            this.PrintLabel.Location = new System.Drawing.Point(1116, 113);
+            this.PrintLabel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.PrintLabel.Name = "PrintLabel";
+            this.PrintLabel.Size = new System.Drawing.Size(201, 23);
+            this.PrintLabel.TabIndex = 181;
+            // 
+            // 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(1013, 50);
+            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(72, 27);
+            this.label2.TabIndex = 180;
+            this.label2.Text = "打印机";
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(1013, 113);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(52, 27);
+            this.label1.TabIndex = 179;
+            this.label1.Text = "标签";
+            // 
+            // Printer
+            // 
+            this.Printer.Location = new System.Drawing.Point(1116, 50);
+            this.Printer.Margin = new System.Windows.Forms.Padding(5);
+            this.Printer.Name = "Printer";
+            this.Printer.Size = new System.Drawing.Size(203, 31);
+            this.Printer.TabIndex = 178;
+            // 
+            // mcd_remainqty
+            // 
+            this.mcd_remainqty.AutoSize = true;
+            this.mcd_remainqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.mcd_remainqty.Location = new System.Drawing.Point(483, 113);
+            this.mcd_remainqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.mcd_remainqty.Name = "mcd_remainqty";
+            this.mcd_remainqty.Size = new System.Drawing.Size(24, 27);
+            this.mcd_remainqty.TabIndex = 177;
+            this.mcd_remainqty.Text = "0";
+            // 
+            // mcd_okqty
+            // 
+            this.mcd_okqty.AutoSize = true;
+            this.mcd_okqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.mcd_okqty.Location = new System.Drawing.Point(189, 113);
+            this.mcd_okqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.mcd_okqty.Name = "mcd_okqty";
+            this.mcd_okqty.Size = new System.Drawing.Size(24, 27);
+            this.mcd_okqty.TabIndex = 176;
+            this.mcd_okqty.Text = "0";
+            // 
+            // pr_code
+            // 
+            this.pr_code.AutoSize = true;
+            this.pr_code.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_code.Location = new System.Drawing.Point(483, 52);
+            this.pr_code.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_code.Name = "pr_code";
+            this.pr_code.Size = new System.Drawing.Size(0, 27);
+            this.pr_code.TabIndex = 175;
+            // 
+            // pr_detail
+            // 
+            this.pr_detail.AutoSize = true;
+            this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_detail.Location = new System.Drawing.Point(777, 52);
+            this.pr_detail.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_detail.Name = "pr_detail";
+            this.pr_detail.Size = new System.Drawing.Size(0, 27);
+            this.pr_detail.TabIndex = 174;
+            // 
+            // ms_makecode
+            // 
+            this.ms_makecode.AutoSize = true;
+            this.ms_makecode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ms_makecode.Location = new System.Drawing.Point(189, 52);
+            this.ms_makecode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ms_makecode.Name = "ms_makecode";
+            this.ms_makecode.Size = new System.Drawing.Size(0, 27);
+            this.ms_makecode.TabIndex = 173;
+            // 
+            // PrintNum
+            // 
+            this.PrintNum.AllPower = null;
+            this.PrintNum.BackColor = System.Drawing.Color.White;
+            this.PrintNum.ID = null;
+            this.PrintNum.Location = new System.Drawing.Point(775, 113);
+            this.PrintNum.Margin = new System.Windows.Forms.Padding(4);
+            this.PrintNum.Name = "PrintNum";
+            this.PrintNum.Negative = false;
+            this.PrintNum.Power = null;
+            this.PrintNum.Size = new System.Drawing.Size(219, 25);
+            this.PrintNum.Str = null;
+            this.PrintNum.Str1 = null;
+            this.PrintNum.Str2 = null;
+            this.PrintNum.TabIndex = 172;
+            // 
+            // pr_detail_label
+            // 
+            this.pr_detail_label.AutoSize = true;
+            this.pr_detail_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_detail_label.Location = new System.Drawing.Point(648, 52);
+            this.pr_detail_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_detail_label.Name = "pr_detail_label";
+            this.pr_detail_label.Size = new System.Drawing.Size(92, 27);
+            this.pr_detail_label.TabIndex = 171;
+            this.pr_detail_label.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(64, 561);
+            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(72, 27);
+            this.sncode_label.TabIndex = 170;
+            this.sncode_label.Text = "序列号";
+            // 
+            // sncode
+            // 
+            this.sncode.AllPower = "ifall";
+            this.sncode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left)));
+            this.sncode.BackColor = System.Drawing.Color.White;
+            this.sncode.ID = null;
+            this.sncode.Location = new System.Drawing.Point(183, 562);
+            this.sncode.Margin = new System.Windows.Forms.Padding(4);
+            this.sncode.Name = "sncode";
+            this.sncode.Power = null;
+            this.sncode.Size = new System.Drawing.Size(260, 25);
+            this.sncode.Str = null;
+            this.sncode.Str1 = null;
+            this.sncode.Str2 = null;
+            this.sncode.TabIndex = 169;
+            this.sncode.Tag = "ifwrite";
+            // 
+            // 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(69, 163);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4);
+            this.OperateResult.Name = "OperateResult";
+            this.OperateResult.Size = new System.Drawing.Size(940, 380);
+            this.OperateResult.TabIndex = 168;
+            this.OperateResult.Text = "";
+            // 
+            // 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(648, 113);
+            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(92, 27);
+            this.label4.TabIndex = 167;
+            this.label4.Text = "打印张数";
+            // 
+            // mcd_remainqty_label
+            // 
+            this.mcd_remainqty_label.AutoSize = true;
+            this.mcd_remainqty_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.mcd_remainqty_label.Location = new System.Drawing.Point(356, 113);
+            this.mcd_remainqty_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.mcd_remainqty_label.Name = "mcd_remainqty_label";
+            this.mcd_remainqty_label.Size = new System.Drawing.Size(72, 27);
+            this.mcd_remainqty_label.TabIndex = 166;
+            this.mcd_remainqty_label.Text = "剩余数";
+            // 
+            // mcd_okqty_label
+            // 
+            this.mcd_okqty_label.AutoSize = true;
+            this.mcd_okqty_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.mcd_okqty_label.Location = new System.Drawing.Point(64, 113);
+            this.mcd_okqty_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.mcd_okqty_label.Name = "mcd_okqty_label";
+            this.mcd_okqty_label.Size = new System.Drawing.Size(92, 27);
+            this.mcd_okqty_label.TabIndex = 165;
+            this.mcd_okqty_label.Text = "打印计数";
+            // 
+            // pr_code_label
+            // 
+            this.pr_code_label.AutoSize = true;
+            this.pr_code_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_code_label.Location = new System.Drawing.Point(356, 52);
+            this.pr_code_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_code_label.Name = "pr_code_label";
+            this.pr_code_label.Size = new System.Drawing.Size(92, 27);
+            this.pr_code_label.TabIndex = 164;
+            this.pr_code_label.Text = "产品编号";
+            // 
+            // ms_makecode_label
+            // 
+            this.ms_makecode_label.AutoSize = true;
+            this.ms_makecode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ms_makecode_label.Location = new System.Drawing.Point(64, 52);
+            this.ms_makecode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ms_makecode_label.Name = "ms_makecode_label";
+            this.ms_makecode_label.Size = new System.Drawing.Size(92, 27);
+            this.ms_makecode_label.TabIndex = 163;
+            this.ms_makecode_label.Text = "归属工单";
+            // 
             // Make_ColorBoxLabelPrint
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(284, 261);
+            this.ClientSize = new System.Drawing.Size(1344, 651);
+            this.Controls.Add(this.PrintLabel);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.Printer);
+            this.Controls.Add(this.mcd_remainqty);
+            this.Controls.Add(this.mcd_okqty);
+            this.Controls.Add(this.pr_code);
+            this.Controls.Add(this.pr_detail);
+            this.Controls.Add(this.ms_makecode);
+            this.Controls.Add(this.PrintNum);
+            this.Controls.Add(this.pr_detail_label);
+            this.Controls.Add(this.sncode_label);
+            this.Controls.Add(this.sncode);
+            this.Controls.Add(this.OperateResult);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.mcd_remainqty_label);
+            this.Controls.Add(this.mcd_okqty_label);
+            this.Controls.Add(this.pr_code_label);
+            this.Controls.Add(this.ms_makecode_label);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "Make_ColorBoxLabelPrint";
             this.Tag = "Make!ColorBoxLabelPrint";
-            this.Text = "Make_ColorBoxLabelPrint";
+            this.Text = "标签打印";
+            this.Activated += new System.EventHandler(this.Make_ColorBoxLabelPrint_Activated);
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Make_ColorBoxLabelPrint_FormClosing);
+            this.Load += new System.EventHandler(this.Make_ColorBoxLabelPrint_Load);
+            this.SizeChanged += new System.EventHandler(this.Make_ColorBoxLabelPrint_SizeChanged);
             this.ResumeLayout(false);
+            this.PerformLayout();
 
         }
 
         #endregion
+
+        private System.Windows.Forms.ComboBox PrintLabel;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label1;
+        private CustomControl.ComBoxWithFocus.PrinterCombox Printer;
+        private CustomControl.ValueLabel.ValueNumLabel mcd_remainqty;
+        private CustomControl.ValueLabel.ValueNumLabel mcd_okqty;
+        private CustomControl.ValueLabel.ValueLabel pr_code;
+        private CustomControl.ValueLabel.ValueLabel pr_detail;
+        private CustomControl.ValueLabel.ValueLabel ms_makecode;
+        private CustomControl.TextBoxWithIcon.NumOnlyTextBox PrintNum;
+        private System.Windows.Forms.Label pr_detail_label;
+        private System.Windows.Forms.Label sncode_label;
+        private CustomControl.TextBoxWithIcon.EnterTextBox sncode;
+        private CustomControl.RichText.RichTextAutoBottom OperateResult;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label mcd_remainqty_label;
+        private System.Windows.Forms.Label mcd_okqty_label;
+        private System.Windows.Forms.Label pr_code_label;
+        private System.Windows.Forms.Label ms_makecode_label;
     }
 }

+ 263 - 4
UAS-MES/FunctionCode/Make/Make_ColorBoxLabelPrint.cs

@@ -1,19 +1,278 @@
 using System;
-using System.Collections.Generic;
-using System.ComponentModel;
 using System.Data;
 using System.Drawing;
-using System.Linq;
 using System.Text;
 using System.Windows.Forms;
+using UAS_MES.DataOperate;
+using UAS_MES.PublicMethod;
+using UAS_MES.Entity;
+using LabelManager2;
 
 namespace UAS_MES.Make
 {
     public partial class Make_ColorBoxLabelPrint : Form
     {
+        DataHelper dh;
+        DataTable dt;
+        LogStringBuilder sql = new LogStringBuilder();
+        AutoSizeFormClass asc = new AutoSizeFormClass();
+        //保存StepProduct查询出来的数据
+        DataTable ListA = new DataTable();
+        //保存make left join makecraftdetail left join product的数据
+        // DataTable ListB;
+        //保存ProductLabel数据
+        DataTable ListC;
+        //工序编号
+        string stepcode;
+        //下一工序编号
+        string nextstepcode;
+        //工艺路线编号
+        string craftcode;
+        //制造单号
+        string ma_code;
+        //当前工单的序列号
+        string sn_code;
+        //当前提示的索引
+        int RemainIndex = 0;
+
+        string Step = "Loading";
+
+        ApplicationClass lbl;
+
         public Make_ColorBoxLabelPrint()
         {
             InitializeComponent();
         }
+
+        private void Make_ColorBoxLabelPrint_Load(object sender, EventArgs e)
+        {
+            dh = new DataHelper();
+            lbl = new ApplicationClass();
+            sncode.Focus();
+            asc.controllInitializeSize(this);
+        }
+
+        private void sn_code_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Enter)
+            {
+                if (sncode.Text == "")
+                {
+                    OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
+                    return;
+                }
+                //通过输入指定字符来设置当前执行的步骤
+                if (sncode.Text == "L")
+                {
+                    Step = " ";
+                    OperateResult.AppendText(">>开始执行上料工序\n", Color.Green);
+                    sncode.Text = "";
+                    return;
+                }
+                else if (sncode.Text == "R")
+                {
+                    Step = "UnLoading";
+                    OperateResult.AppendText(">>开始执行下料工序\n", Color.Green);
+                    sncode.Text = "";
+                    return;
+                }
+                //判断如果该序列号的归属工单和之前查询的是一致的话,就不进行重复数据的查询
+                ma_code = dh.getFieldDataByCondition("makeserial", "ms_makecode", "ms_sncode='" + sncode.Text + "'").ToString();
+                if (ms_makecode.Text != ma_code || ma_code == "")
+                {
+                    //ma_code不为空的时候表示不是第一次加载,提示用户切换工单
+                    if (ma_code != "" && ms_makecode.Text != "")
+                    {
+                        OperateResult.AppendText(">>切换工单至工单号" + ma_code + "\n", Color.Red);
+                    }
+                    sql.Clear();
+                    sql.Append("select ma_code,mcd_okqty,ma_qty,ma_qty-mcd_inqty as mcd_remainqty,pr_detail,pr_code ");
+                    sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on ");
+                    sql.Append("ms_prodcode=pr_code left join makecraftdetail on ms_makecode=mcd_macode where ms_sncode=:sncode");
+                    dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", sncode.Text);
+                    if (dt.Rows.Count > 0)
+                    {
+                        BaseUtil.SetFormValue(this.Controls, dt);
+                        sn_code = sncode.Text;
+                    }
+                    else
+                    {
+                        OperateResult.AppendText(">>序列号" + sncode.Text + "不存在\n", Color.Red);
+                        return;
+                    }
+
+                    //判断当前的执行状态 ,Loading表示执行上料操作,UnLoading表示执行下料操作
+                    if (Step == "Loading")
+                    {
+                        sql.Clear();
+                        sql.Append("select ma_code,ma_craftcode,ms_nextstepcode, ms_status,ms_stepcode from makeserial ");
+                        sql.Append("left join make on ma_code=ms_makecode where ms_sncode=:sncode or ms_psn=:sncode");
+                        dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", sncode.Text, sncode.Text);
+                        //记录一些变量
+                        stepcode = dt.Rows[0]["ms_stepcode"].ToString();
+                        nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
+                        craftcode = dt.Rows[0]["ma_craftcode"].ToString();
+                        string ErrorMessage;
+                        bool ifFirst;
+                        //检测当前序列号和岗位资源是否对应
+                        if (LogicHandler.CheckCurrentStepAndIfFirst(sncode.Text, ms_makecode.Text, User.UserSourceCode, Tag.ToString(), out ifFirst, out ErrorMessage))
+                        {
+                            //判断当前工序是否是上料工序cd_ifinput或者是否是测试工序cd_iftest
+                            sql.Clear();
+                            sql.Append("select cr_code,cd_stepcode,cd_ifinput,cd_iftest from makeserial left join  craft on ms_craftcode=cr_code left join craftdetail on cd_crid=cr_id and ");
+                            sql.Append("cd_stepcode=ms_nextstepcode where ms_sncode='" + sncode.Text + "' and ms_makecode='" + ms_makecode.Text + "'");
+                            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                            if (dt.Rows.Count > 0)
+                            {
+                                //如果是上料工序
+                                if (dt.Rows[0]["cd_ifinput"].ToString() != "0")
+                                {
+                                    // 查询没有结果,提示该上料工序没有需要上料的数据,请先维护对应的数据
+                                    sql.Clear();
+                                    sql.Append("select sp_id,sp_description,sp_soncode,pr_detail,pr_spec,sp_repcode,pr_id,sp_type,");
+                                    sql.Append("'未采集' sp_ifpick ,sp_prefix,sp_length,sp_regex,sp_regex,sp_ifforsn from stepproduct ");
+                                    sql.Append("left join product on pr_code=sp_soncode  where sp_craftcode='" + dt.Rows[0]["cd_ifinput"].ToString() + "' and sp_stepcode='" + dt.Rows[0]["cd_stepcode"].ToString() + "' ");
+                                    sql.Append("And sp_mothercode='" + pr_code.Text + "' and ((sp_type='物料' and pr_tracekind<>2)or sp_type<>'物料') ");
+                                    sql.Append("order by SP_DETNO asc");
+                                    ListA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                                    //获取对应 产品的机身标的打印模板
+                                    if (ListA.Rows.Count > 0)
+                                    {
+                                        OperateResult.AppendText(">>请采集" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "的条码\n", Color.Green);
+                                    }
+                                    //未查询到数据时标识是测试工序
+                                    else
+                                    {
+                                        DoTestProcedure();
+                                    }
+                                }
+                                //同上,如果,iftest不等于0也进入测试工序
+                                else if (dt.Rows[0]["cd_iftest"].ToString() != "0")
+                                {
+                                    DoTestProcedure();
+                                }
+                            }
+                        }
+                        else
+                        {
+                            Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text);
+                            OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
+                        }
+                    }
+                    //如果执行的是下料操作
+                    else if (Step == "UnLoading")
+                    {
+                        string ErrorMessage1 = "";
+                        if (LogicHandler.SetMaterialDown(sn_code, sncode.Text, User.CurrentStepCode, User.UserName, out ErrorMessage1))
+                        {
+                            OperateResult.AppendText(">>条码" + sncode.Text + "下料成功\n", Color.Green);
+                        }
+                        else
+                        {
+                            OperateResult.AppendText(">>" + ErrorMessage1 + "\n", Color.Red);
+                        }
+                    }
+                }
+                else
+                {
+                    //如果ListA中没有数据执行的是测试工序
+                    if (ListA.Rows.Count == 0)
+                    {
+                        DoTestProcedure();
+                    }
+                    //存在数据执行的是上料采集
+                    else
+                    {
+                        //如果当前的索引和长度相等则表示采集完成
+                        if (RemainIndex == ListA.Rows.Count - 1)
+                        {
+                            OperateResult.AppendText(">>序列号对应的工单已经采集完成\n", Color.Green);
+                            sn_code = "";
+                            return;
+                        }
+                        string ErrorMessage;
+                        //获取上料需要传递的参数,sp_soncode,sp_id
+                        string soncode = ListA.Rows[RemainIndex]["sp_soncode"].ToString();
+                        string sonID = ListA.Rows[RemainIndex]["sp_id"].ToString();
+                        //执行上料
+                        if (LogicHandler.SetMaterialUp(sn_code, ms_makecode.Text, sncode.Text, soncode, User.UserSourceCode, User.UserName, sonID, out ErrorMessage))
+                        {
+                            RemainIndex = RemainIndex + 1;
+                            OperateResult.AppendText(">>请采集物料编号为" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "的条码\n", Color.Green);
+                        }
+                        else
+                        {
+                            OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
+                        }
+                    }
+                }
+            }
+        }
+
+     
+
+        //执行测试工序
+        private void DoTestProcedure()
+        {
+            //局部变量ErrorMessage1
+            string ErrorMessage1;
+            //由于打印驱动暂时不可用,暂时注释打印方法
+            if (LogicHandler.SetCollectionFinish(sncode.Text, ms_makecode.Text, User.UserName, User.UserSourceCode, out ErrorMessage1))
+            {
+                sncode.Text = "";
+                //如果值为空默认设置为0
+                if (int.Parse(mcd_remainqty.Text) > 0)
+                {
+                    dh.UpdateByCondition("makecraftdetail", "mcd_okqty=mcd_okqty+1,mcd_inqty=mcd_inqty+1", "mcd_macode='" + ms_makecode.Text + "'");
+                    sql.Clear();
+                    sql.Append("select mcd_okqty,ma_qty-mcd_inqty mcd_remainqty from makecraftdetail left join make on ");
+                    sql.Append("ma_code=mcd_macode where mcd_macode='" + ms_makecode.Text + "'");
+                    dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                    BaseUtil.SetFormValue(this.Controls, dt);
+                    if (mcd_remainqty.Text == "0")
+                    {
+                        OperateResult.AppendText(">>工单" + ms_makecode.Text + "采集完成\n", Color.Green);
+                        BaseUtil.CleanForm(this);
+                    }
+                }
+                else
+                {
+                    BaseUtil.CleanForm(this);
+                    OperateResult.AppendText(">>该序列号所属工单" + ms_makecode.Text + "已全部采集完成\n", Color.Green);
+                }
+            }
+            else
+                MessageBox.Show(ErrorMessage1);
+        }
+
+     
+
+        private void pr_code_TextChanged(object sender, EventArgs e)
+        {
+            dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode from productlabel where pl_prodcode='" + pr_code.Text + "'", "select");
+            PrintLabel.DataSource = dt;
+            PrintLabel.DisplayMember = "pl_labelname";
+            PrintLabel.ValueMember = "pl_labelcode";
+            ftpOperater ftp = new ftpOperater();
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                ftp.Download(dt.Rows[i]["pl_labelname"].ToString());
+            }
+        }
+
+        private void Make_ColorBoxLabelPrint_Activated(object sender, EventArgs e)
+        {
+            sncode.Focus();
+        }
+
+        private void Make_ColorBoxLabelPrint_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            lbl.Quit();
+        }
+
+        private void Make_ColorBoxLabelPrint_SizeChanged(object sender, EventArgs e)
+        {
+            asc.controlAutoSize(this);
+        }
     }
-}
+}

+ 283 - 2
UAS-MES/FunctionCode/Make/Make_FuselageLabelPrint.Designer.cs

@@ -28,20 +28,301 @@
         /// </summary>
         private void InitializeComponent()
         {
+            this.components = new System.ComponentModel.Container();
+            this.PrintLabel = new System.Windows.Forms.ComboBox();
+            this.label2 = new System.Windows.Forms.Label();
+            this.label1 = new System.Windows.Forms.Label();
+            this.Printer = new UAS_MES.CustomControl.ComBoxWithFocus.PrinterCombox();
+            this.mcd_remainqty = new UAS_MES.CustomControl.ValueLabel.ValueNumLabel(this.components);
+            this.mcd_okqty = new UAS_MES.CustomControl.ValueLabel.ValueNumLabel(this.components);
+            this.pr_code = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.pr_detail = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.ms_makecode = new UAS_MES.CustomControl.ValueLabel.ValueLabel();
+            this.PrintNum = new UAS_MES.CustomControl.TextBoxWithIcon.NumOnlyTextBox();
+            this.pr_detail_label = new System.Windows.Forms.Label();
+            this.sncode_label = new System.Windows.Forms.Label();
+            this.sncode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
+            this.OperateResult = new UAS_MES.CustomControl.RichText.RichTextAutoBottom();
+            this.label4 = new System.Windows.Forms.Label();
+            this.mcd_remainqty_label = new System.Windows.Forms.Label();
+            this.mcd_okqty_label = new System.Windows.Forms.Label();
+            this.pr_code_label = new System.Windows.Forms.Label();
+            this.ms_makecode_label = new System.Windows.Forms.Label();
             this.SuspendLayout();
             // 
+            // PrintLabel
+            // 
+            this.PrintLabel.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+            this.PrintLabel.FormattingEnabled = true;
+            this.PrintLabel.Location = new System.Drawing.Point(1078, 117);
+            this.PrintLabel.Margin = new System.Windows.Forms.Padding(3, 2, 3, 2);
+            this.PrintLabel.Name = "PrintLabel";
+            this.PrintLabel.Size = new System.Drawing.Size(201, 23);
+            this.PrintLabel.TabIndex = 181;
+            // 
+            // 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(975, 54);
+            this.label2.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label2.Name = "label2";
+            this.label2.Size = new System.Drawing.Size(72, 27);
+            this.label2.TabIndex = 180;
+            this.label2.Text = "打印机";
+            // 
+            // label1
+            // 
+            this.label1.AutoSize = true;
+            this.label1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.label1.Location = new System.Drawing.Point(975, 117);
+            this.label1.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label1.Name = "label1";
+            this.label1.Size = new System.Drawing.Size(52, 27);
+            this.label1.TabIndex = 179;
+            this.label1.Text = "标签";
+            // 
+            // Printer
+            // 
+            this.Printer.Location = new System.Drawing.Point(1078, 54);
+            this.Printer.Margin = new System.Windows.Forms.Padding(5);
+            this.Printer.Name = "Printer";
+            this.Printer.Size = new System.Drawing.Size(203, 31);
+            this.Printer.TabIndex = 178;
+            // 
+            // mcd_remainqty
+            // 
+            this.mcd_remainqty.AutoSize = true;
+            this.mcd_remainqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.mcd_remainqty.Location = new System.Drawing.Point(445, 117);
+            this.mcd_remainqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.mcd_remainqty.Name = "mcd_remainqty";
+            this.mcd_remainqty.Size = new System.Drawing.Size(24, 27);
+            this.mcd_remainqty.TabIndex = 177;
+            this.mcd_remainqty.Text = "0";
+            // 
+            // mcd_okqty
+            // 
+            this.mcd_okqty.AutoSize = true;
+            this.mcd_okqty.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.mcd_okqty.Location = new System.Drawing.Point(151, 117);
+            this.mcd_okqty.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.mcd_okqty.Name = "mcd_okqty";
+            this.mcd_okqty.Size = new System.Drawing.Size(24, 27);
+            this.mcd_okqty.TabIndex = 176;
+            this.mcd_okqty.Text = "0";
+            // 
+            // pr_code
+            // 
+            this.pr_code.AutoSize = true;
+            this.pr_code.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_code.Location = new System.Drawing.Point(445, 56);
+            this.pr_code.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_code.Name = "pr_code";
+            this.pr_code.Size = new System.Drawing.Size(0, 27);
+            this.pr_code.TabIndex = 175;
+            // 
+            // pr_detail
+            // 
+            this.pr_detail.AutoSize = true;
+            this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_detail.Location = new System.Drawing.Point(739, 56);
+            this.pr_detail.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_detail.Name = "pr_detail";
+            this.pr_detail.Size = new System.Drawing.Size(0, 27);
+            this.pr_detail.TabIndex = 174;
+            // 
+            // ms_makecode
+            // 
+            this.ms_makecode.AutoSize = true;
+            this.ms_makecode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ms_makecode.Location = new System.Drawing.Point(151, 56);
+            this.ms_makecode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ms_makecode.Name = "ms_makecode";
+            this.ms_makecode.Size = new System.Drawing.Size(0, 27);
+            this.ms_makecode.TabIndex = 173;
+            // 
+            // PrintNum
+            // 
+            this.PrintNum.AllPower = null;
+            this.PrintNum.BackColor = System.Drawing.Color.White;
+            this.PrintNum.ID = null;
+            this.PrintNum.Location = new System.Drawing.Point(737, 117);
+            this.PrintNum.Margin = new System.Windows.Forms.Padding(4);
+            this.PrintNum.Name = "PrintNum";
+            this.PrintNum.Negative = false;
+            this.PrintNum.Power = null;
+            this.PrintNum.Size = new System.Drawing.Size(219, 25);
+            this.PrintNum.Str = null;
+            this.PrintNum.Str1 = null;
+            this.PrintNum.Str2 = null;
+            this.PrintNum.TabIndex = 172;
+            // 
+            // pr_detail_label
+            // 
+            this.pr_detail_label.AutoSize = true;
+            this.pr_detail_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_detail_label.Location = new System.Drawing.Point(610, 56);
+            this.pr_detail_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_detail_label.Name = "pr_detail_label";
+            this.pr_detail_label.Size = new System.Drawing.Size(92, 27);
+            this.pr_detail_label.TabIndex = 171;
+            this.pr_detail_label.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(26, 565);
+            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(72, 27);
+            this.sncode_label.TabIndex = 170;
+            this.sncode_label.Text = "序列号";
+            // 
+            // sncode
+            // 
+            this.sncode.AllPower = "ifall";
+            this.sncode.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
+            | System.Windows.Forms.AnchorStyles.Left)));
+            this.sncode.BackColor = System.Drawing.Color.White;
+            this.sncode.ID = null;
+            this.sncode.Location = new System.Drawing.Point(145, 566);
+            this.sncode.Margin = new System.Windows.Forms.Padding(4);
+            this.sncode.Name = "sncode";
+            this.sncode.Power = null;
+            this.sncode.Size = new System.Drawing.Size(260, 25);
+            this.sncode.Str = null;
+            this.sncode.Str1 = null;
+            this.sncode.Str2 = null;
+            this.sncode.TabIndex = 169;
+            this.sncode.Tag = "ifwrite";
+            // 
+            // 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(31, 167);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4);
+            this.OperateResult.Name = "OperateResult";
+            this.OperateResult.Size = new System.Drawing.Size(940, 380);
+            this.OperateResult.TabIndex = 168;
+            this.OperateResult.Text = "";
+            // 
+            // 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(610, 117);
+            this.label4.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.label4.Name = "label4";
+            this.label4.Size = new System.Drawing.Size(92, 27);
+            this.label4.TabIndex = 167;
+            this.label4.Text = "打印张数";
+            // 
+            // mcd_remainqty_label
+            // 
+            this.mcd_remainqty_label.AutoSize = true;
+            this.mcd_remainqty_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.mcd_remainqty_label.Location = new System.Drawing.Point(318, 117);
+            this.mcd_remainqty_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.mcd_remainqty_label.Name = "mcd_remainqty_label";
+            this.mcd_remainqty_label.Size = new System.Drawing.Size(72, 27);
+            this.mcd_remainqty_label.TabIndex = 166;
+            this.mcd_remainqty_label.Text = "剩余数";
+            // 
+            // mcd_okqty_label
+            // 
+            this.mcd_okqty_label.AutoSize = true;
+            this.mcd_okqty_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.mcd_okqty_label.Location = new System.Drawing.Point(26, 117);
+            this.mcd_okqty_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.mcd_okqty_label.Name = "mcd_okqty_label";
+            this.mcd_okqty_label.Size = new System.Drawing.Size(92, 27);
+            this.mcd_okqty_label.TabIndex = 165;
+            this.mcd_okqty_label.Text = "打印计数";
+            // 
+            // pr_code_label
+            // 
+            this.pr_code_label.AutoSize = true;
+            this.pr_code_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.pr_code_label.Location = new System.Drawing.Point(318, 56);
+            this.pr_code_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.pr_code_label.Name = "pr_code_label";
+            this.pr_code_label.Size = new System.Drawing.Size(92, 27);
+            this.pr_code_label.TabIndex = 164;
+            this.pr_code_label.Text = "产品编号";
+            // 
+            // ms_makecode_label
+            // 
+            this.ms_makecode_label.AutoSize = true;
+            this.ms_makecode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ms_makecode_label.Location = new System.Drawing.Point(26, 56);
+            this.ms_makecode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
+            this.ms_makecode_label.Name = "ms_makecode_label";
+            this.ms_makecode_label.Size = new System.Drawing.Size(92, 27);
+            this.ms_makecode_label.TabIndex = 163;
+            this.ms_makecode_label.Text = "归属工单";
+            // 
             // Make_FuselageLabelPrint
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(284, 261);
+            this.ClientSize = new System.Drawing.Size(1323, 637);
+            this.Controls.Add(this.PrintLabel);
+            this.Controls.Add(this.label2);
+            this.Controls.Add(this.label1);
+            this.Controls.Add(this.Printer);
+            this.Controls.Add(this.mcd_remainqty);
+            this.Controls.Add(this.mcd_okqty);
+            this.Controls.Add(this.pr_code);
+            this.Controls.Add(this.pr_detail);
+            this.Controls.Add(this.ms_makecode);
+            this.Controls.Add(this.PrintNum);
+            this.Controls.Add(this.pr_detail_label);
+            this.Controls.Add(this.sncode_label);
+            this.Controls.Add(this.sncode);
+            this.Controls.Add(this.OperateResult);
+            this.Controls.Add(this.label4);
+            this.Controls.Add(this.mcd_remainqty_label);
+            this.Controls.Add(this.mcd_okqty_label);
+            this.Controls.Add(this.pr_code_label);
+            this.Controls.Add(this.ms_makecode_label);
+            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(4);
             this.Name = "Make_FuselageLabelPrint";
             this.Tag = "Make!FuselageLabelPrint";
             this.Text = "Make_FuselageLabelPrint";
+            this.Activated += new System.EventHandler(this.Make_FuselageLabelPrint_Activated);
+            this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Make_FuselageLabelPrint_FormClosing);
+            this.Load += new System.EventHandler(this.Make_FuselageLabelPrint_Load);
+            this.SizeChanged += new System.EventHandler(this.Make_FuselageLabelPrint_SizeChanged);
             this.ResumeLayout(false);
+            this.PerformLayout();
 
         }
 
         #endregion
+
+        private System.Windows.Forms.ComboBox PrintLabel;
+        private System.Windows.Forms.Label label2;
+        private System.Windows.Forms.Label label1;
+        private CustomControl.ComBoxWithFocus.PrinterCombox Printer;
+        private CustomControl.ValueLabel.ValueNumLabel mcd_remainqty;
+        private CustomControl.ValueLabel.ValueNumLabel mcd_okqty;
+        private CustomControl.ValueLabel.ValueLabel pr_code;
+        private CustomControl.ValueLabel.ValueLabel pr_detail;
+        private CustomControl.ValueLabel.ValueLabel ms_makecode;
+        private CustomControl.TextBoxWithIcon.NumOnlyTextBox PrintNum;
+        private System.Windows.Forms.Label pr_detail_label;
+        private System.Windows.Forms.Label sncode_label;
+        private CustomControl.TextBoxWithIcon.EnterTextBox sncode;
+        private CustomControl.RichText.RichTextAutoBottom OperateResult;
+        private System.Windows.Forms.Label label4;
+        private System.Windows.Forms.Label mcd_remainqty_label;
+        private System.Windows.Forms.Label mcd_okqty_label;
+        private System.Windows.Forms.Label pr_code_label;
+        private System.Windows.Forms.Label ms_makecode_label;
     }
 }

+ 274 - 4
UAS-MES/FunctionCode/Make/Make_FuselageLabelPrint.cs

@@ -1,19 +1,289 @@
 using System;
-using System.Collections.Generic;
-using System.ComponentModel;
 using System.Data;
 using System.Drawing;
-using System.Linq;
 using System.Text;
 using System.Windows.Forms;
+using UAS_MES.DataOperate;
+using UAS_MES.PublicMethod;
+using UAS_MES.Entity;
+using LabelManager2;
 
 namespace UAS_MES.Make
 {
     public partial class Make_FuselageLabelPrint : Form
     {
+        DataHelper dh;
+        DataTable dt;
+        LogStringBuilder sql = new LogStringBuilder();
+        AutoSizeFormClass asc = new AutoSizeFormClass();
+        //保存StepProduct查询出来的数据
+        DataTable ListA = new DataTable();
+        //保存make left join makecraftdetail left join product的数据
+        // DataTable ListB;
+        //保存ProductLabel数据
+        DataTable ListC;
+        //工序编号
+        string stepcode;
+        //下一工序编号
+        string nextstepcode;
+        //工艺路线编号
+        string craftcode;
+        //制造单号
+        string ma_code;
+        //当前工单的序列号
+        string sn_code;
+        //当前提示的索引
+        int RemainIndex = 0;
+
+        string Step = "Loading";
+
+        ApplicationClass lbl;
+
         public Make_FuselageLabelPrint()
         {
             InitializeComponent();
         }
+
+        private void Make_FuselageLabelPrint_Load(object sender, EventArgs e)
+        {
+            dh = new DataHelper();
+            lbl = new ApplicationClass();
+            sncode.Focus();
+            asc.controllInitializeSize(this);
+        }
+
+        private void sn_code_KeyDown(object sender, KeyEventArgs e)
+        {
+            if (e.KeyCode == Keys.Enter)
+            {
+                if (sncode.Text == "")
+                {
+                    OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
+                    return;
+                }
+                //通过输入指定字符来设置当前执行的步骤
+                if (sncode.Text == "L")
+                {
+                    Step = " ";
+                    OperateResult.AppendText(">>开始执行上料工序\n", Color.Green);
+                    sncode.Text = "";
+                    return;
+                }
+                else if (sncode.Text == "R")
+                {
+                    Step = "UnLoading";
+                    OperateResult.AppendText(">>开始执行下料工序\n", Color.Green);
+                    sncode.Text = "";
+                    return;
+                }
+                //判断如果该序列号的归属工单和之前查询的是一致的话,就不进行重复数据的查询
+                ma_code = dh.getFieldDataByCondition("makeserial", "ms_makecode", "ms_sncode='" + sncode.Text + "'").ToString();
+                if (ms_makecode.Text != ma_code || ma_code == "")
+                {
+                    //ma_code不为空的时候表示不是第一次加载,提示用户切换工单
+                    if (ma_code != "" && ms_makecode.Text != "")
+                    {
+                        OperateResult.AppendText(">>切换工单至工单号" + ma_code + "\n", Color.Red);
+                    }
+                    sql.Clear();
+                    sql.Append("select ma_code,mcd_okqty,ma_qty,ma_qty-mcd_inqty as mcd_remainqty,pr_detail,pr_code ");
+                    sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on ");
+                    sql.Append("ms_prodcode=pr_code left join makecraftdetail on ms_makecode=mcd_macode where ms_sncode=:sncode");
+                    dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", sncode.Text);
+                    if (dt.Rows.Count > 0)
+                    {
+                        BaseUtil.SetFormValue(this.Controls, dt);
+                        sn_code = sncode.Text;
+                    }
+                    else
+                    {
+                        OperateResult.AppendText(">>序列号" + sncode.Text + "不存在\n", Color.Red);
+                        return;
+                    }
+
+                    //判断当前的执行状态 ,Loading表示执行上料操作,UnLoading表示执行下料操作
+                    if (Step == "Loading")
+                    {
+                        sql.Clear();
+                        sql.Append("select ma_code,ma_craftcode,ms_nextstepcode, ms_status,ms_stepcode from makeserial ");
+                        sql.Append("left join make on ma_code=ms_makecode where ms_sncode=:sncode or ms_psn=:sncode");
+                        dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select", sncode.Text, sncode.Text);
+                        //记录一些变量
+                        stepcode = dt.Rows[0]["ms_stepcode"].ToString();
+                        nextstepcode = dt.Rows[0]["ms_nextstepcode"].ToString();
+                        craftcode = dt.Rows[0]["ma_craftcode"].ToString();
+                        string ErrorMessage;
+                        bool ifFirst;
+                        //检测当前序列号和岗位资源是否对应
+                        if (LogicHandler.CheckCurrentStepAndIfFirst(sncode.Text, ms_makecode.Text, User.UserSourceCode, Tag.ToString(), out ifFirst, out ErrorMessage))
+                        {
+                            //判断当前工序是否是上料工序cd_ifinput或者是否是测试工序cd_iftest
+                            sql.Clear();
+                            sql.Append("select cr_code,cd_stepcode,cd_ifinput,cd_iftest from makeserial left join  craft on ms_craftcode=cr_code left join craftdetail on cd_crid=cr_id and ");
+                            sql.Append("cd_stepcode=ms_nextstepcode where ms_sncode='" + sncode.Text + "' and ms_makecode='" + ms_makecode.Text + "'");
+                            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                            if (dt.Rows.Count > 0)
+                            {
+                                //如果是上料工序
+                                if (dt.Rows[0]["cd_ifinput"].ToString() != "0")
+                                {
+                                    // 查询没有结果,提示该上料工序没有需要上料的数据,请先维护对应的数据
+                                    sql.Clear();
+                                    sql.Append("select sp_id,sp_description,sp_soncode,pr_detail,pr_spec,sp_repcode,pr_id,sp_type,");
+                                    sql.Append("'未采集' sp_ifpick ,sp_prefix,sp_length,sp_regex,sp_regex,sp_ifforsn from stepproduct ");
+                                    sql.Append("left join product on pr_code=sp_soncode  where sp_craftcode='" + dt.Rows[0]["cd_ifinput"].ToString() + "' and sp_stepcode='" + dt.Rows[0]["cd_stepcode"].ToString() + "' ");
+                                    sql.Append("And sp_mothercode='" + pr_code.Text + "' and ((sp_type='物料' and pr_tracekind<>2)or sp_type<>'物料') ");
+                                    sql.Append("order by SP_DETNO asc");
+                                    ListA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                                    //获取对应 产品的机身标的打印模板
+                                    if (ListA.Rows.Count > 0)
+                                    {
+                                        OperateResult.AppendText(">>请采集" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "的条码\n", Color.Green);
+                                    }
+                                    //未查询到数据时标识是测试工序
+                                    else
+                                    {
+                                        DoTestProcedure();
+                                    }
+                                }
+                                //同上,如果,iftest不等于0也进入测试工序
+                                else if (dt.Rows[0]["cd_iftest"].ToString() != "0")
+                                {
+                                    DoTestProcedure();
+                                }
+                            }
+                        }
+                        else
+                        {
+                            Print.CodeSoft(lbl, PrintLabel.Text, PrintLabel.SelectedValue.ToString(), Printer.Text, sncode.Text);
+                            OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
+                        }
+                    }
+                    //如果执行的是下料操作
+                    else if (Step == "UnLoading")
+                    {
+                        string ErrorMessage1 = "";
+                        if (LogicHandler.SetMaterialDown(sn_code, sncode.Text, User.CurrentStepCode, User.UserName, out ErrorMessage1))
+                        {
+                            OperateResult.AppendText(">>条码" + sncode.Text + "下料成功\n", Color.Green);
+                        }
+                        else
+                        {
+                            OperateResult.AppendText(">>" + ErrorMessage1 + "\n", Color.Red);
+                        }
+                    }
+                }
+                else
+                {
+                    //如果ListA中没有数据执行的是测试工序
+                    if (ListA.Rows.Count == 0)
+                    {
+                        DoTestProcedure();
+                    }
+                    //存在数据执行的是上料采集
+                    else
+                    {
+                        //如果当前的索引和长度相等则表示采集完成
+                        if (RemainIndex == ListA.Rows.Count - 1)
+                        {
+                            OperateResult.AppendText(">>序列号对应的工单已经采集完成\n", Color.Green);
+                            sn_code = "";
+                            return;
+                        }
+                        string ErrorMessage;
+                        //获取上料需要传递的参数,sp_soncode,sp_id
+                        string soncode = ListA.Rows[RemainIndex]["sp_soncode"].ToString();
+                        string sonID = ListA.Rows[RemainIndex]["sp_id"].ToString();
+                        //执行上料
+                        if (LogicHandler.SetMaterialUp(sn_code, ms_makecode.Text, sncode.Text, soncode, User.UserSourceCode, User.UserName, sonID, out ErrorMessage))
+                        {
+                            RemainIndex = RemainIndex + 1;
+                            OperateResult.AppendText(">>请采集物料编号为" + ListA.Rows[RemainIndex]["sp_soncode"].ToString() + "的条码\n", Color.Green);
+                        }
+                        else
+                        {
+                            OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
+                        }
+                    }
+                }
+            }
+        }
+
+        private void 标签打印_SizeChanged(object sender, EventArgs e)
+        {
+            asc.controlAutoSize(this);
+        }
+
+        //执行测试工序
+        private void DoTestProcedure()
+        {
+            //局部变量ErrorMessage1
+            string ErrorMessage1;
+            //由于打印驱动暂时不可用,暂时注释打印方法
+            if (LogicHandler.SetCollectionFinish(sncode.Text, ms_makecode.Text, User.UserName, User.UserSourceCode, out ErrorMessage1))
+            {
+                sncode.Text = "";
+                //如果值为空默认设置为0
+                if (int.Parse(mcd_remainqty.Text) > 0)
+                {
+                    dh.UpdateByCondition("makecraftdetail", "mcd_okqty=mcd_okqty+1,mcd_inqty=mcd_inqty+1", "mcd_macode='" + ms_makecode.Text + "'");
+                    sql.Clear();
+                    sql.Append("select mcd_okqty,ma_qty-mcd_inqty mcd_remainqty from makecraftdetail left join make on ");
+                    sql.Append("ma_code=mcd_macode where mcd_macode='" + ms_makecode.Text + "'");
+                    dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+                    BaseUtil.SetFormValue(this.Controls, dt);
+                    if (mcd_remainqty.Text == "0")
+                    {
+                        OperateResult.AppendText(">>工单" + ms_makecode.Text + "采集完成\n", Color.Green);
+                        BaseUtil.CleanForm(this);
+                    }
+                }
+                else
+                {
+                    BaseUtil.CleanForm(this);
+                    OperateResult.AppendText(">>该序列号所属工单" + ms_makecode.Text + "已全部采集完成\n", Color.Green);
+                }
+            }
+            else
+                MessageBox.Show(ErrorMessage1);
+        }
+
+        private void 标签打印_Activated(object sender, EventArgs e)
+        {
+            sncode.Focus();
+        }
+
+        private void pr_code_TextChanged(object sender, EventArgs e)
+        {
+            dt = (DataTable)dh.ExecuteSql("select pl_labelname,pl_labelcode from productlabel where pl_prodcode='" + pr_code.Text + "'", "select");
+            PrintLabel.DataSource = dt;
+            PrintLabel.DisplayMember = "pl_labelname";
+            PrintLabel.ValueMember = "pl_labelcode";
+            ftpOperater ftp = new ftpOperater();
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                ftp.Download(dt.Rows[i]["pl_labelname"].ToString());
+            }
+        }
+
+        private void 标签打印_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            lbl.Quit();
+        }
+
+        private void Make_FuselageLabelPrint_Activated(object sender, EventArgs e)
+        {
+            sncode.Focus();
+        }
+
+        private void Make_FuselageLabelPrint_FormClosing(object sender, FormClosingEventArgs e)
+        {
+            lbl.Quit();
+        }
+
+        private void Make_FuselageLabelPrint_SizeChanged(object sender, EventArgs e)
+        {
+            asc.controlAutoSize(this);
+        }
     }
-}
+}

+ 9 - 9
UAS-MES/UAS-MES.csproj

@@ -411,6 +411,12 @@
     <Compile Include="FunctionCode\Make\Make_ColorBoxLabelPrint.Designer.cs">
       <DependentUpon>Make_ColorBoxLabelPrint.cs</DependentUpon>
     </Compile>
+    <Compile Include="FunctionCode\Make\Make_ColorBoxLoadPrint.cs">
+      <SubType>Form</SubType>
+    </Compile>
+    <Compile Include="FunctionCode\Make\Make_ColorBoxLoadPrint.Designer.cs">
+      <DependentUpon>Make_ColorBoxLoadPrint.cs</DependentUpon>
+    </Compile>
     <Compile Include="FunctionCode\Make\Make_FuselageLabelPrint.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -599,12 +605,6 @@
     <Compile Include="FunctionCode\Make\Make_NewPallet.Designer.cs">
       <DependentUpon>Make_NewPallet.cs</DependentUpon>
     </Compile>
-    <Compile Include="FunctionCode\Make\Make_ColorBoxLoadPrint.cs">
-      <SubType>Form</SubType>
-    </Compile>
-    <Compile Include="FunctionCode\Make\Make_ColorBoxLoadPrint.Designer.cs">
-      <DependentUpon>Make_ColorBoxLoadPrint.cs</DependentUpon>
-    </Compile>
     <Compile Include="FunctionCode\Make\Make_PalletWeigh.cs">
       <SubType>Form</SubType>
     </Compile>
@@ -870,6 +870,9 @@
     <EmbeddedResource Include="FunctionCode\Make\Make_ColorBoxLabelPrint.resx">
       <DependentUpon>Make_ColorBoxLabelPrint.cs</DependentUpon>
     </EmbeddedResource>
+    <EmbeddedResource Include="FunctionCode\Make\Make_ColorBoxLoadPrint.resx">
+      <DependentUpon>Make_ColorBoxLoadPrint.cs</DependentUpon>
+    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Make\Make_FuselageLabelPrint.resx">
       <DependentUpon>Make_FuselageLabelPrint.cs</DependentUpon>
     </EmbeddedResource>
@@ -959,9 +962,6 @@
     <EmbeddedResource Include="FunctionCode\Make\Make_NewPallet.resx">
       <DependentUpon>Make_NewPallet.cs</DependentUpon>
     </EmbeddedResource>
-    <EmbeddedResource Include="FunctionCode\Make\Make_ColorBoxLoadPrint.resx">
-      <DependentUpon>Make_ColorBoxLoadPrint.cs</DependentUpon>
-    </EmbeddedResource>
     <EmbeddedResource Include="FunctionCode\Make\Make_PalletWeigh.resx">
       <DependentUpon>Make_PalletWeigh.cs</DependentUpon>
     </EmbeddedResource>