Ver código fonte

UI微调,序列烧录转换代码

shim 8 anos atrás
pai
commit
fa5db1656e

+ 23 - 15
UAS-MES/FunctionCode/Make/Make_SeqProgramTransform.Designer.cs

@@ -78,7 +78,7 @@
             // 
             this.pr_detail_label.AutoSize = true;
             this.pr_detail_label.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_detail_label.Location = new System.Drawing.Point(801, 36);
+            this.pr_detail_label.Location = new System.Drawing.Point(804, 36);
             this.pr_detail_label.Name = "pr_detail_label";
             this.pr_detail_label.Size = new System.Drawing.Size(110, 31);
             this.pr_detail_label.TabIndex = 2;
@@ -108,10 +108,11 @@
             // 
             this.ms_macode.AutoSize = true;
             this.ms_macode.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.ms_macode.Location = new System.Drawing.Point(191, 36);
+            this.ms_macode.Location = new System.Drawing.Point(185, 36);
             this.ms_macode.Name = "ms_macode";
             this.ms_macode.Size = new System.Drawing.Size(0, 31);
             this.ms_macode.TabIndex = 5;
+            this.ms_macode.TextChanged += new System.EventHandler(this.ms_macode_TextChanged);
             // 
             // remain_qty
             // 
@@ -126,7 +127,7 @@
             // 
             this.ma_prodcode.AutoSize = true;
             this.ma_prodcode.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.ma_prodcode.Location = new System.Drawing.Point(570, 36);
+            this.ma_prodcode.Location = new System.Drawing.Point(576, 36);
             this.ma_prodcode.Name = "ma_prodcode";
             this.ma_prodcode.Size = new System.Drawing.Size(0, 31);
             this.ma_prodcode.TabIndex = 7;
@@ -135,16 +136,17 @@
             // 
             this.count.AutoSize = true;
             this.count.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.count.Location = new System.Drawing.Point(558, 91);
+            this.count.Location = new System.Drawing.Point(576, 91);
             this.count.Name = "count";
-            this.count.Size = new System.Drawing.Size(0, 31);
+            this.count.Size = new System.Drawing.Size(28, 31);
             this.count.TabIndex = 8;
+            this.count.Text = "0";
             // 
             // pr_detail
             // 
             this.pr_detail.AutoSize = true;
             this.pr_detail.Font = new System.Drawing.Font("微软雅黑", 12F);
-            this.pr_detail.Location = new System.Drawing.Point(955, 36);
+            this.pr_detail.Location = new System.Drawing.Point(946, 36);
             this.pr_detail.Name = "pr_detail";
             this.pr_detail.Size = new System.Drawing.Size(0, 31);
             this.pr_detail.TabIndex = 9;
@@ -197,12 +199,13 @@
             // 
             this.TSNLength.AllPower = null;
             this.TSNLength.BackColor = System.Drawing.Color.White;
+            this.TSNLength.Font = new System.Drawing.Font("微软雅黑", 10F);
             this.TSNLength.ID = null;
-            this.TSNLength.Location = new System.Drawing.Point(191, 155);
+            this.TSNLength.Location = new System.Drawing.Point(191, 151);
             this.TSNLength.Name = "TSNLength";
             this.TSNLength.Negative = false;
             this.TSNLength.Power = null;
-            this.TSNLength.Size = new System.Drawing.Size(196, 28);
+            this.TSNLength.Size = new System.Drawing.Size(213, 34);
             this.TSNLength.Str = null;
             this.TSNLength.Str1 = null;
             this.TSNLength.Str2 = null;
@@ -212,12 +215,13 @@
             // 
             this.SNLength.AllPower = null;
             this.SNLength.BackColor = System.Drawing.Color.White;
+            this.SNLength.Font = new System.Drawing.Font("微软雅黑", 10F);
             this.SNLength.ID = null;
-            this.SNLength.Location = new System.Drawing.Point(191, 203);
+            this.SNLength.Location = new System.Drawing.Point(191, 197);
             this.SNLength.Name = "SNLength";
             this.SNLength.Negative = false;
             this.SNLength.Power = null;
-            this.SNLength.Size = new System.Drawing.Size(196, 28);
+            this.SNLength.Size = new System.Drawing.Size(213, 34);
             this.SNLength.Str = null;
             this.SNLength.Str1 = null;
             this.SNLength.Str2 = null;
@@ -227,11 +231,12 @@
             // 
             this.TSNPre.AllPower = null;
             this.TSNPre.BackColor = System.Drawing.Color.White;
+            this.TSNPre.Font = new System.Drawing.Font("微软雅黑", 10F);
             this.TSNPre.ID = null;
-            this.TSNPre.Location = new System.Drawing.Point(601, 155);
+            this.TSNPre.Location = new System.Drawing.Point(582, 151);
             this.TSNPre.Name = "TSNPre";
             this.TSNPre.Power = null;
-            this.TSNPre.Size = new System.Drawing.Size(196, 28);
+            this.TSNPre.Size = new System.Drawing.Size(210, 34);
             this.TSNPre.Str = null;
             this.TSNPre.Str1 = null;
             this.TSNPre.Str2 = null;
@@ -241,11 +246,12 @@
             // 
             this.SNPre.AllPower = null;
             this.SNPre.BackColor = System.Drawing.Color.White;
+            this.SNPre.Font = new System.Drawing.Font("微软雅黑", 10F);
             this.SNPre.ID = null;
-            this.SNPre.Location = new System.Drawing.Point(601, 203);
+            this.SNPre.Location = new System.Drawing.Point(582, 200);
             this.SNPre.Name = "SNPre";
             this.SNPre.Power = null;
-            this.SNPre.Size = new System.Drawing.Size(196, 28);
+            this.SNPre.Size = new System.Drawing.Size(210, 34);
             this.SNPre.Str = null;
             this.SNPre.Str1 = null;
             this.SNPre.Str2 = null;
@@ -254,9 +260,10 @@
             // tip
             // 
             this.tip.AutoSize = true;
+            this.tip.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Bold);
             this.tip.Location = new System.Drawing.Point(41, 252);
             this.tip.Name = "tip";
-            this.tip.Size = new System.Drawing.Size(116, 18);
+            this.tip.Size = new System.Drawing.Size(158, 31);
             this.tip.TabIndex = 18;
             this.tip.Text = "采集提示信息";
             // 
@@ -284,6 +291,7 @@
             this.cancel.TabIndex = 20;
             this.cancel.Text = "取消";
             this.cancel.UseVisualStyleBackColor = false;
+            this.cancel.Click += new System.EventHandler(this.cancel_Click);
             // 
             // in_label
             // 

+ 363 - 18
UAS-MES/FunctionCode/Make/Make_SeqProgramTransform.cs

@@ -1,4 +1,5 @@
 using System;
+using System.Collections;
 using System.Collections.Generic;
 using System.ComponentModel;
 using System.Data;
@@ -16,15 +17,25 @@ namespace UAS_MES.FunctionCode.Make
     {
         AutoSizeFormClass asc = new AutoSizeFormClass();
 
+        LogStringBuilder sql = new LogStringBuilder();
+
         DataHelper dh;
         //原序列号
-        string TSN;
+        string TSN="";
         //转换后序列号
-        string SN;
+        string SN="";
         //错误信息
         string errorMessage;
         //存放productsnrelation表中的数据
+        DataTable ListA;
+        //存放工单信息
         DataTable dt;
+        //step  记录检验规则的进度
+        int step=0;
+        //记录采集的IMEI,BT,MAC等信息
+        Hashtable hs;
+        //存放关联信息类型
+        string type;
 
         public Make_SeqProgramTransform()
         {
@@ -51,25 +62,110 @@ namespace UAS_MES.FunctionCode.Make
             {
                 if (code.Text != "")
                 {
-                    OperateResult.AppendText(">>序列号:" + code.Text + " , 发送请求\n", Color.Green);
-                    //判断用户是否锁定输入TSN长度,
-                    if (!checkLengthOrPre(TSNLength_checkBox, TSNLength, "长度")) {
-                        return;
-                    }
-                    //判断用户是否锁定输入TSN前缀,
-                    if (!checkLengthOrPre(TSNPre_checkBox, TSNPre, "前缀")) {
-                        return;
-                    }
-                    string oMakecode="";
-                    string oMsid="";
-                    //核对工序
-                    if (LogicHandler.CheckStepSNAndMacode(ms_macode.Text, User.UserSourceCode, code.Text, User.UserCode, out oMakecode, out oMsid, out errorMessage))
+                    //为0,输入TSN
+                    if (step==0)
                     {
-                        //按照out出的工单号查出工单相关信息,并赋值到相关空间
+                        OperateResult.AppendText(">>序列号:" + code.Text + " , 发送请求\n", Color.Green);
+                        //判断用户是否锁定输入TSN长度,
+                        if (!checkLengthOrPre(TSNLength_checkBox, TSNLength, "长度"))
+                        {
+                            return;
+                        }
+                        //判断用户是否锁定输入TSN前缀,
+                        if (!checkLengthOrPre(TSNPre_checkBox, TSNPre, "前缀"))
+                        {
+                            return;
+                        }
+                        string oMakecode = "";
+                        string oMsid = "";
+                        //核对工序
+                        if (LogicHandler.CheckStepSNAndMacode(ms_macode.Text, User.UserSourceCode, code.Text, User.UserCode, out oMakecode, out oMsid, out errorMessage))
+                        {
+                            //核对TSN是否正确
+                            string beforesn = dh.getFieldDataByCondition("makeserial", "ms_beforesn", "ms_sncode='" + code.Text + "'").ToString().Trim();
+                            if (beforesn == "" || beforesn == null)
+                            {
+                                //按照out出的工单号查出工单相关信息,并赋值到相关控件
+                                sql.Clear();
+                                sql.Append("select ma_code as ms_macode,mcd_okqty,ma_qty,ma_qty-mcd_inqty as remain_qty,pr_detail,pr_code as ma_prodcode");
+                                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", code.Text);
+                                if (dt.Rows.Count > 0)
+                                {
+                                    BaseUtil.SetFormValue(this.Controls, dt);
+                                    //判断用户是否锁定输入TSN长度,
+                                    if (!checkLengthOrPre(TSNLength_checkBox, TSNLength, "长度"))
+                                    {
+                                        return;
+                                    }
+                                    //判断用户是否锁定输入TSN前缀,
+                                    if (!checkLengthOrPre(TSNPre_checkBox, TSNPre, "前缀"))
+                                    {
+                                        return;
+                                    }
+                                }
+                                else
+                                {
+                                    OperateResult.AppendText(">>序列号" + code.Text + "不存在\n", Color.Red);
+                                    return;
+                                }
+                                //获取需要关联采集的信息,以及校验规则
+                                ListA = (DataTable)dh.ExecuteSql("select * from productsnrelation where psr_prodcode='" + ma_prodcode.Text + "' order by psr_detno", "select");
+                                hs = new Hashtable();
+                                step = 1;
 
+                                //记录转换前的序列号
+                                TSN = code.Text;
+                                code.Text = "";
+                                OperateResult.AppendText("<<请输入SN\n", Color.Green);
+                            }
+                            else
+                            //不为空,进行过转换。不勾选修改结果,就不能再修改
+                            {
+                                OperateResult.AppendText(">>序列号" + code.Text + "已进行了转换\n", Color.Red);
+                                code.Text = "";
+                                OperateResult.AppendText("<<请重新输入TSN\n", Color.Green);
+                            }
+                        }
+                        else
+                        {
+                            OperateResult.AppendText(">>" + errorMessage + "\n", Color.Red);
+                        }
                     }
-                    else {
-                        OperateResult.AppendText(">>" + errorMessage + "\n", Color.Red);
+                    else if (step==1)
+                    {
+                        //开始录入SN
+                        if (!dh.CheckExist("makeserial", "ms_sncode='" + code.Text + "'"))
+                        {
+                            //判断用户是否锁定输入SN长度,
+                            if (!checkLengthOrPre(SNLength_checkBox, SNLength, "长度"))
+                            {
+                                return;
+                            }
+                            //判断用户是否锁定输入SN前缀,
+                            if (!checkLengthOrPre(SNPre_checkBox, SNPre, "前缀"))
+                            {
+                                return;
+                            }
+                            //SN校验成功,合法,记录下SN
+                            SN = code.Text;
+                            //开始进行校验规则
+                            OperateResult.AppendText("<<请输入" + ListA.Rows[0]["psr_type"] + "\n", Color.Green);
+                            //step+1
+                            step = 2;
+                        }
+                        else
+                        {
+                            OperateResult.AppendText(">>序列号" + code.Text + "已存在,请输入其他序列号\n", Color.Red);
+                        }
+                    }
+                    else if(step < ListA.Rows.Count + 2)
+                    {
+                        //开始进行校验规则
+                        if (checkRules(step)) {
+                            step += 1;
+                        }
                     }
                 }
                 else {
@@ -115,5 +211,254 @@ namespace UAS_MES.FunctionCode.Make
             }
             return true;
         }
+        /// <summary>
+        /// 关联采集的校验
+        /// </summary>
+        /// <param name="step"></param>
+        private bool checkRules(int step)
+        {
+            type = ListA.Rows[step - 1]["psr_type"].ToString()=="WIFI"?"MAC": ListA.Rows[step - 1]["psr_type"].ToString();
+            //如果前缀和长度都满足的话
+            if ((ListA.Rows[step-1]["psr_length"].ToString() == "" ? true : code.Text.Length == ListA.Rows[step-1]["psr_length"].ToString().Length) && (ListA.Rows[0]["psr_prefix"].ToString() == "" ? true : code.Text.StartsWith(ListA.Rows[0]["psr_prefix"].ToString())))
+            {
+                switch (type)
+                {
+                    case "IMEI1":
+                    case "IMEI2":
+                    case "IMEI3":
+                        if (checkExist("ms_imei1='" + code.Text + "' or ms_imei2 = '" + code.Text + "' or ms_imei3 = '" + code.Text + "'"))
+                        {
+                            return false;
+                        }
+                        else
+                        {
+                            //判断IMEI1,IMEI2,IMEI3中是否已经有这个号了
+                            foreach (DictionaryEntry de in hs) {
+                                if (de.Key.ToString().Contains("IMEI")&&de.Value.ToString()==code.Text) {
+                                    OperateResult.AppendText(">>" + type + ":" + code.Text + "已录,请重新输入\n", Color.Red);
+                                    code.Text = "";
+                                    return false;
+                                }
+                            }
+                        }
+                        break;
+                    case "BT":
+                    case "MAC":
+                    case "NETCODE":
+                        if (checkExist("MS_"+type+"='"+code.Text+"'")) {
+                            return false;
+                        }
+                        break;
+                }
+                //满足规则,则采集
+                hs.Add(type,code.Text);
+                //说明已经是最后一个校验规则
+                if (step == ListA.Rows.Count+1)
+                {
+                    //校验已经完成,此时要再次校验之前的SN和关联采集信息
+                    //再次校验SN
+                    if (!dh.CheckExist("makeserial", "ms_sncode='" + SN + "'"))
+                    {
+                        bool flag = true;
+                        StringBuilder s1 = new StringBuilder();
+                        //再次校验关联采集信息
+                        foreach (DictionaryEntry de in hs)
+                        {
+                            s1.Append("MS_"+ de.Key.ToString()+" = '"+de.Value.ToString()+"',");
+                            if (de.Key.ToString().Contains("IMEI"))
+                            {
+                                if (checkExist("ms_imei1='" + de.Value.ToString() + "' or ms_imei2 = '" + de.Value.ToString() + "' or ms_imei3 = '" + de.Value.ToString() + "'"))
+                                {
+                                    flag = false;
+                                    OperateResult.AppendText(">>"+de.Key.ToString()+":" + de.Value.ToString() + "已存在,请重新输入TSN\n", Color.Red);
+                                    //清空信息
+                                    clearInfo();
+                                    break;
+                                }
+                            }
+                            else
+                            {
+                                if (checkExist("MS_" + de.Key.ToString() + "='" + de.Value.ToString() + "'"))
+                                {
+                                    flag = false;
+                                    OperateResult.AppendText(">>" + de.Key.ToString() + ":" + de.Value.ToString() + "已存在,请重新输入TSN\n", Color.Red);
+                                    //清空信息
+                                    clearInfo();
+                                    break;
+                                }
+                            }
+                        }
+                        //根据flag判断关联采集信息二次校验结果
+                        if (flag=true) {
+                            //说明SN和关联采集信息二次校验通过,则进行转换和采集信息绑定
+                            //查询ms_firstsn
+                            string firstsn = dh.getFieldDataByCondition("makeserial", "ms_firstsn", "ms_sncode='" + TSN + "'").ToString();
+                            //记录本次修改,存入makesnrelation表中
+                            string updateSql = "update makeserial set ms_sncode='" + SN + "', ms_beforesn='" + TSN + "',"+ s1.Remove(s1.Length - 1, 1).ToString() + " where ms_sncode='" + TSN + "'";
+                            string insertSql = "insert into  makesnrelation (BEFORESN,SN,FIRSTSN,MAKECODE,msr_indate, msr_inman)values('" + TSN + "','" + SN + "','" + firstsn + "','" + ms_macode.Text + "', sysdate ,'" + User.UserCode + "')";
+                            dh.ExecuteSQLTran(updateSql, insertSql);
+                            OperateResult.AppendText(">>序列号转换成功\n", Color.Green);
+                            //写入日志
+                            LogManager.DoLog("修改序列号:" + TSN + "为" + SN + "成功!" + "操作人:" + User.UserCode);
+                            //完成该道工序 setFinish
+                            LogicHandler.UpdateMakeMessage(TSN, ms_macode.Text, "序列烧录转换", User.UserSourceCode, User.UserCode, "序列烧录转换成功", out errorMessage);
+
+                            //输出提示用户“>>序列号转换成功”,“>>关联采集成功”
+                            OperateResult.AppendText(">>关联采集成功\n", Color.Green);
+                            //更新页面计数+1
+                            count.Text = int.Parse(count.Text) + 1 + "";
+                        }
+                    }
+                    else
+                    {
+                        OperateResult.AppendText(">>序列号" + SN + "已存在,请重新输入TSN\n", Color.Red);
+                        //清空信息
+                        clearInfo();
+                    }
+                    return false;
+                }
+                else {
+                    OperateResult.AppendText("<<请输入"+ ListA.Rows[step]["psr_type"] + "\n", Color.Green);
+                    return true;
+                }
+            }
+            else {
+                //重新输入
+                OperateResult.AppendText(">>" + ListA.Rows[step-1]["psr_type"] + "校验不通过,请重新输入\n", Color.Red);
+                return false;
+            }
+        }
+        /// <summary>
+        /// 工单号变化时,带出校验规则
+        /// </summary>
+        /// <param name="sender"></param>
+        /// <param name="e"></param>
+        private void ms_macode_TextChanged(object sender, EventArgs e)
+        {
+            //清空
+            TSNPre.Text = "";
+            TSNLength.Text = "";
+            SNPre.Text = "";
+            SNLength.Text = "";
+
+            //取消勾选
+            TSNPre_checkBox.Checked = false;
+            TSNLength_checkBox.Checked = false;
+            SNPre_checkBox.Checked = false;
+            SNLength_checkBox.Checked = false;
+
+            //设置可编辑
+            TSNLength.Enabled = true;
+            TSNPre.Enabled = true;
+            SNLength.Enabled = true;
+            SNPre.Enabled = true;
+
+            //查询表工单序列号防呆规则表
+            dt = (DataTable)dh.ExecuteSql("select msr_type, msr_prefix ,msr_length from makesnrule where msr_makecode='" + ms_macode.Text + "'", "select");
+            if (dt.Rows.Count > 0)
+            {
+                foreach (DataRow dr in dt.Rows)
+                {
+                    //如果有值,则这个字段自动勾选,并且不可编辑
+                    if (dr["msr_type"].ToString().ToLower() == "before")
+                    {
+                        //msr_type=before 的值赋值到转换前
+
+                        //临时变量记录
+                        string length = dr["msr_length"].ToString();
+                        string prefix = dr["msr_prefix"].ToString();
+                        //不为空
+                        if (prefix != "" && prefix != null)
+                        {
+                            //则赋值
+                            TSNPre.Text = prefix;
+                            //设置不可编辑
+                            TSNPre.Enabled = false;
+                            //勾选
+                            TSNPre_checkBox.Checked = true;
+                        }
+                        if (length != "" && length != null)
+                        {
+                            //赋值
+                            TSNLength.Text = length;
+                            //设置不可编辑
+                            TSNLength.Enabled = false;
+                            //勾选
+                            TSNLength_checkBox.Checked = true;
+                        }
+                    }
+                    else if (dr["msr_type"].ToString().ToLower() == "after")
+                    {
+                        //msr_type=after 的值赋值到转换后
+
+                        //临时变量记录
+                        string length = dr["msr_length"].ToString();
+                        string prefix = dr["msr_prefix"].ToString();
+                        //不为空
+                        if (prefix != "" && prefix != null)
+                        {
+                            //则赋值
+                            SNPre.Text = prefix;
+                            //设置不可编辑
+                            SNPre.Enabled = false;
+                            //勾选
+                            SNPre_checkBox.Checked = true;
+                        }
+                        if (length != "" && length != null)
+                        {
+                            //赋值
+                            SNLength.Text = length;
+                            //设置不可编辑
+                            SNLength.Enabled = false;
+                            //勾选
+                            SNLength_checkBox.Checked = true;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                /*	如果转换前没有值,则取 select productsnrule where psr_prodcode=? 产品编号,
+                 *	有值则赋值到 转换前,并且自动勾选不可编辑。*/
+                //dt = (DataTable)dh.ExecuteSql("select psr_prefix ,psr_length from productsnrule where psr_prodcode = " + ma_prodcode.Text, "select");
+                //if (dt.Rows.Count > 0)
+                //{
+                //    //将产品序列号防呆规则查出的数据填充
+                //    beforeTransSNPre.Text = dt.Rows[0]["psr_prefix"].ToString();
+                //    beforeTransSNPre.ReadOnly = true;
+                //    beforeTransSNPre_checkBox.Checked = true;
+                //    beforeTransSNLength.Text = dt.Rows[0]["psr_length"].ToString();
+                //    beforeTransSNLength.ReadOnly = true;
+                //    beforeTransSNLength_checkBox.Checked = true;
+                //}
+            }
+        }
+        
+        private bool checkExist(string fields) {
+            //不存在
+            if (!dh.CheckExist("makeserial", fields))
+            {
+                //则记录
+                return false;
+            }
+            else {
+                OperateResult.AppendText(">>"+type+"错误,不允许重复\n", Color.Red);
+                return true;
+            }
+        }
+        private void clearInfo() {
+            //步骤重置为0
+            step = 0;
+            //关联采集信息清空
+            hs.Clear();
+        }
+
+        private void cancel_Click(object sender, EventArgs e)
+        {
+            //清除已经采集的所有信息
+            clearInfo();
+            //提示用户输入TSN
+            OperateResult.AppendText("<<请输入TSN\n", Color.Green);
+        }
     }
 }

+ 67 - 58
UAS-MES/FunctionCode/Make/Make_SeqTransform.Designer.cs

@@ -58,36 +58,40 @@
             // 
             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(585, 15);
+            this.pr_detail.Location = new System.Drawing.Point(878, 22);
+            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, 21);
+            this.pr_detail.Size = new System.Drawing.Size(0, 31);
             this.pr_detail.TabIndex = 65;
             // 
             // 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(15, 17);
+            this.ms_makecode_label.Location = new System.Drawing.Point(22, 26);
+            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(0, 21);
+            this.ms_makecode_label.Size = new System.Drawing.Size(0, 31);
             this.ms_makecode_label.TabIndex = 61;
             // 
             // ma_prodcode
             // 
             this.ma_prodcode.AutoSize = true;
             this.ma_prodcode.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ma_prodcode.Location = new System.Drawing.Point(355, 15);
+            this.ma_prodcode.Location = new System.Drawing.Point(532, 22);
+            this.ma_prodcode.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.ma_prodcode.Name = "ma_prodcode";
-            this.ma_prodcode.Size = new System.Drawing.Size(0, 21);
+            this.ma_prodcode.Size = new System.Drawing.Size(0, 31);
             this.ma_prodcode.TabIndex = 64;
             // 
             // 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(492, 15);
+            this.pr_detail_label.Location = new System.Drawing.Point(738, 22);
+            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(74, 21);
+            this.pr_detail_label.Size = new System.Drawing.Size(110, 31);
             this.pr_detail_label.TabIndex = 62;
             this.pr_detail_label.Text = "产品名称";
             // 
@@ -95,9 +99,10 @@
             // 
             this.ma_prodcode_label.AutoSize = true;
             this.ma_prodcode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ma_prodcode_label.Location = new System.Drawing.Point(264, 15);
+            this.ma_prodcode_label.Location = new System.Drawing.Point(396, 22);
+            this.ma_prodcode_label.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.ma_prodcode_label.Name = "ma_prodcode_label";
-            this.ma_prodcode_label.Size = new System.Drawing.Size(74, 21);
+            this.ma_prodcode_label.Size = new System.Drawing.Size(110, 31);
             this.ma_prodcode_label.TabIndex = 63;
             this.ma_prodcode_label.Text = "产品编号";
             // 
@@ -105,9 +110,10 @@
             // 
             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(15, 441);
+            this.sncode_label.Location = new System.Drawing.Point(22, 662);
+            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(58, 21);
+            this.sncode_label.Size = new System.Drawing.Size(86, 31);
             this.sncode_label.TabIndex = 68;
             this.sncode_label.Text = "录入框";
             // 
@@ -115,9 +121,10 @@
             // 
             this.ChangeResult.AutoSize = true;
             this.ChangeResult.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ChangeResult.Location = new System.Drawing.Point(296, 441);
+            this.ChangeResult.Location = new System.Drawing.Point(444, 662);
+            this.ChangeResult.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.ChangeResult.Name = "ChangeResult";
-            this.ChangeResult.Size = new System.Drawing.Size(125, 25);
+            this.ChangeResult.Size = new System.Drawing.Size(184, 35);
             this.ChangeResult.TabIndex = 70;
             this.ChangeResult.Text = "修改转换结果";
             this.ChangeResult.UseVisualStyleBackColor = true;
@@ -126,9 +133,10 @@
             // 
             this.changenum_lanel.AutoSize = true;
             this.changenum_lanel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.changenum_lanel.Location = new System.Drawing.Point(439, 441);
+            this.changenum_lanel.Location = new System.Drawing.Point(658, 662);
+            this.changenum_lanel.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
             this.changenum_lanel.Name = "changenum_lanel";
-            this.changenum_lanel.Size = new System.Drawing.Size(74, 21);
+            this.changenum_lanel.Size = new System.Drawing.Size(110, 31);
             this.changenum_lanel.TabIndex = 71;
             this.changenum_lanel.Text = "转换数量";
             // 
@@ -136,10 +144,9 @@
             // 
             this.beforeTransSNLength_checkBox.AutoSize = true;
             this.beforeTransSNLength_checkBox.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.beforeTransSNLength_checkBox.Location = new System.Drawing.Point(20, 63);
-            this.beforeTransSNLength_checkBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.beforeTransSNLength_checkBox.Location = new System.Drawing.Point(30, 94);
             this.beforeTransSNLength_checkBox.Name = "beforeTransSNLength_checkBox";
-            this.beforeTransSNLength_checkBox.Size = new System.Drawing.Size(140, 24);
+            this.beforeTransSNLength_checkBox.Size = new System.Drawing.Size(198, 31);
             this.beforeTransSNLength_checkBox.TabIndex = 81;
             this.beforeTransSNLength_checkBox.Text = "转换前序列号长度";
             this.beforeTransSNLength_checkBox.UseVisualStyleBackColor = true;
@@ -148,10 +155,9 @@
             // 
             this.afterTransSNLength_checkBox.AutoSize = true;
             this.afterTransSNLength_checkBox.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.afterTransSNLength_checkBox.Location = new System.Drawing.Point(20, 96);
-            this.afterTransSNLength_checkBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.afterTransSNLength_checkBox.Location = new System.Drawing.Point(30, 144);
             this.afterTransSNLength_checkBox.Name = "afterTransSNLength_checkBox";
-            this.afterTransSNLength_checkBox.Size = new System.Drawing.Size(140, 24);
+            this.afterTransSNLength_checkBox.Size = new System.Drawing.Size(198, 31);
             this.afterTransSNLength_checkBox.TabIndex = 82;
             this.afterTransSNLength_checkBox.Text = "转换后序列号长度";
             this.afterTransSNLength_checkBox.UseVisualStyleBackColor = true;
@@ -160,10 +166,9 @@
             // 
             this.beforeTransSNPre_checkBox.AutoSize = true;
             this.beforeTransSNPre_checkBox.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.beforeTransSNPre_checkBox.Location = new System.Drawing.Point(421, 62);
-            this.beforeTransSNPre_checkBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.beforeTransSNPre_checkBox.Location = new System.Drawing.Point(632, 93);
             this.beforeTransSNPre_checkBox.Name = "beforeTransSNPre_checkBox";
-            this.beforeTransSNPre_checkBox.Size = new System.Drawing.Size(140, 24);
+            this.beforeTransSNPre_checkBox.Size = new System.Drawing.Size(198, 31);
             this.beforeTransSNPre_checkBox.TabIndex = 83;
             this.beforeTransSNPre_checkBox.Text = "转换前序列号前缀";
             this.beforeTransSNPre_checkBox.UseVisualStyleBackColor = true;
@@ -172,10 +177,9 @@
             // 
             this.afterTransSNPre_checkBox.AutoSize = true;
             this.afterTransSNPre_checkBox.Font = new System.Drawing.Font("微软雅黑", 10F);
-            this.afterTransSNPre_checkBox.Location = new System.Drawing.Point(421, 95);
-            this.afterTransSNPre_checkBox.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.afterTransSNPre_checkBox.Location = new System.Drawing.Point(632, 142);
             this.afterTransSNPre_checkBox.Name = "afterTransSNPre_checkBox";
-            this.afterTransSNPre_checkBox.Size = new System.Drawing.Size(140, 24);
+            this.afterTransSNPre_checkBox.Size = new System.Drawing.Size(198, 31);
             this.afterTransSNPre_checkBox.TabIndex = 84;
             this.afterTransSNPre_checkBox.Text = "转换后序列号前缀";
             this.afterTransSNPre_checkBox.UseVisualStyleBackColor = true;
@@ -186,11 +190,10 @@
             this.afterTransSNPre.BackColor = System.Drawing.Color.White;
             this.afterTransSNPre.Font = new System.Drawing.Font("微软雅黑", 10F);
             this.afterTransSNPre.ID = null;
-            this.afterTransSNPre.Location = new System.Drawing.Point(581, 95);
-            this.afterTransSNPre.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.afterTransSNPre.Location = new System.Drawing.Point(872, 142);
             this.afterTransSNPre.Name = "afterTransSNPre";
             this.afterTransSNPre.Power = null;
-            this.afterTransSNPre.Size = new System.Drawing.Size(168, 25);
+            this.afterTransSNPre.Size = new System.Drawing.Size(250, 34);
             this.afterTransSNPre.Str = null;
             this.afterTransSNPre.Str1 = null;
             this.afterTransSNPre.Str2 = null;
@@ -202,11 +205,10 @@
             this.beforeTransSNPre.BackColor = System.Drawing.Color.White;
             this.beforeTransSNPre.Font = new System.Drawing.Font("微软雅黑", 10F);
             this.beforeTransSNPre.ID = null;
-            this.beforeTransSNPre.Location = new System.Drawing.Point(581, 62);
-            this.beforeTransSNPre.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.beforeTransSNPre.Location = new System.Drawing.Point(872, 93);
             this.beforeTransSNPre.Name = "beforeTransSNPre";
             this.beforeTransSNPre.Power = null;
-            this.beforeTransSNPre.Size = new System.Drawing.Size(168, 25);
+            this.beforeTransSNPre.Size = new System.Drawing.Size(250, 34);
             this.beforeTransSNPre.Str = null;
             this.beforeTransSNPre.Str1 = null;
             this.beforeTransSNPre.Str2 = null;
@@ -216,10 +218,10 @@
             // 
             this.ms_makecode_lock.AutoSize = true;
             this.ms_makecode_lock.Font = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
-            this.ms_makecode_lock.Location = new System.Drawing.Point(20, 17);
-            this.ms_makecode_lock.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.ms_makecode_lock.LeaveEvent = false;
+            this.ms_makecode_lock.Location = new System.Drawing.Point(30, 26);
             this.ms_makecode_lock.Name = "ms_makecode_lock";
-            this.ms_makecode_lock.Size = new System.Drawing.Size(51, 21);
+            this.ms_makecode_lock.Size = new System.Drawing.Size(72, 28);
             this.ms_makecode_lock.TabIndex = 80;
             this.ms_makecode_lock.Text = "锁定";
             this.ms_makecode_lock.UseVisualStyleBackColor = true;
@@ -227,9 +229,10 @@
             // 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(20, 141);
+            this.OperateResult.Location = new System.Drawing.Point(30, 212);
+            this.OperateResult.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.OperateResult.Name = "OperateResult";
-            this.OperateResult.Size = new System.Drawing.Size(812, 287);
+            this.OperateResult.Size = new System.Drawing.Size(1216, 428);
             this.OperateResult.TabIndex = 78;
             this.OperateResult.Text = "";
             // 
@@ -237,11 +240,13 @@
             // 
             this.sncode.AllPower = "ifall";
             this.sncode.BackColor = System.Drawing.Color.White;
+            this.sncode.Font = new System.Drawing.Font("微软雅黑", 10F);
             this.sncode.ID = null;
-            this.sncode.Location = new System.Drawing.Point(95, 441);
+            this.sncode.Location = new System.Drawing.Point(142, 662);
+            this.sncode.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.sncode.Name = "sncode";
             this.sncode.Power = "ifwrite";
-            this.sncode.Size = new System.Drawing.Size(160, 21);
+            this.sncode.Size = new System.Drawing.Size(238, 34);
             this.sncode.Str = null;
             this.sncode.Str1 = null;
             this.sncode.Str2 = null;
@@ -256,12 +261,13 @@
             this.ReCall.DownImage = ((System.Drawing.Image)(resources.GetObject("ReCall.DownImage")));
             this.ReCall.Image = ((System.Drawing.Image)(resources.GetObject("ReCall.Image")));
             this.ReCall.IsShowBorder = true;
-            this.ReCall.Location = new System.Drawing.Point(438, 479);
+            this.ReCall.Location = new System.Drawing.Point(657, 718);
+            this.ReCall.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.ReCall.MoveImage = ((System.Drawing.Image)(resources.GetObject("ReCall.MoveImage")));
             this.ReCall.Name = "ReCall";
             this.ReCall.NormalImage = ((System.Drawing.Image)(resources.GetObject("ReCall.NormalImage")));
             this.ReCall.Power = null;
-            this.ReCall.Size = new System.Drawing.Size(70, 24);
+            this.ReCall.Size = new System.Drawing.Size(105, 36);
             this.ReCall.TabIndex = 74;
             this.ReCall.Text = "撤销输入";
             this.ReCall.UseVisualStyleBackColor = true;
@@ -274,12 +280,13 @@
             this.Confirm.DownImage = ((System.Drawing.Image)(resources.GetObject("Confirm.DownImage")));
             this.Confirm.Image = ((System.Drawing.Image)(resources.GetObject("Confirm.Image")));
             this.Confirm.IsShowBorder = true;
-            this.Confirm.Location = new System.Drawing.Point(340, 479);
+            this.Confirm.Location = new System.Drawing.Point(510, 718);
+            this.Confirm.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.Confirm.MoveImage = ((System.Drawing.Image)(resources.GetObject("Confirm.MoveImage")));
             this.Confirm.Name = "Confirm";
             this.Confirm.NormalImage = ((System.Drawing.Image)(resources.GetObject("Confirm.NormalImage")));
             this.Confirm.Power = null;
-            this.Confirm.Size = new System.Drawing.Size(70, 24);
+            this.Confirm.Size = new System.Drawing.Size(105, 36);
             this.Confirm.TabIndex = 73;
             this.Confirm.Tag = "IfWrite";
             this.Confirm.Text = "确认";
@@ -288,29 +295,29 @@
             // 
             // beforeTransSNLength
             // 
-            this.beforeTransSNLength.Location = new System.Drawing.Point(165, 65);
-            this.beforeTransSNLength.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.beforeTransSNLength.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.beforeTransSNLength.Location = new System.Drawing.Point(269, 90);
             this.beforeTransSNLength.Name = "beforeTransSNLength";
-            this.beforeTransSNLength.Size = new System.Drawing.Size(168, 21);
+            this.beforeTransSNLength.Size = new System.Drawing.Size(250, 34);
             this.beforeTransSNLength.TabIndex = 89;
             this.beforeTransSNLength.Text = "0";
             // 
             // afterTransSNLength
             // 
-            this.afterTransSNLength.Location = new System.Drawing.Point(165, 99);
-            this.afterTransSNLength.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.afterTransSNLength.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.afterTransSNLength.Location = new System.Drawing.Point(269, 140);
             this.afterTransSNLength.Name = "afterTransSNLength";
-            this.afterTransSNLength.Size = new System.Drawing.Size(168, 21);
+            this.afterTransSNLength.Size = new System.Drawing.Size(250, 34);
             this.afterTransSNLength.TabIndex = 90;
             this.afterTransSNLength.Text = "0";
             // 
             // changenum
             // 
             this.changenum.Enabled = false;
-            this.changenum.Location = new System.Drawing.Point(553, 441);
-            this.changenum.Margin = new System.Windows.Forms.Padding(2, 2, 2, 2);
+            this.changenum.Font = new System.Drawing.Font("微软雅黑", 10F);
+            this.changenum.Location = new System.Drawing.Point(830, 662);
             this.changenum.Name = "changenum";
-            this.changenum.Size = new System.Drawing.Size(137, 21);
+            this.changenum.Size = new System.Drawing.Size(204, 34);
             this.changenum.TabIndex = 91;
             this.changenum.Text = "0";
             // 
@@ -321,21 +328,22 @@
             this.ma_code.Condition = null;
             this.ma_code.DBTitle = null;
             this.ma_code.FormName = null;
-            this.ma_code.Location = new System.Drawing.Point(76, 16);
+            this.ma_code.Location = new System.Drawing.Point(114, 24);
+            this.ma_code.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.ma_code.Name = "ma_code";
             this.ma_code.Power = null;
             this.ma_code.SelectField = null;
             this.ma_code.SetValueField = null;
-            this.ma_code.Size = new System.Drawing.Size(163, 22);
+            this.ma_code.Size = new System.Drawing.Size(244, 33);
             this.ma_code.TabIndex = 92;
             this.ma_code.TableName = null;
             this.ma_code.TextBoxEnable = false;
             // 
             // Make_SeqTransform
             // 
-            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+            this.AutoScaleDimensions = new System.Drawing.SizeF(9F, 18F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
-            this.ClientSize = new System.Drawing.Size(849, 512);
+            this.ClientSize = new System.Drawing.Size(1274, 768);
             this.Controls.Add(this.ma_code);
             this.Controls.Add(this.changenum);
             this.Controls.Add(this.afterTransSNLength);
@@ -360,6 +368,7 @@
             this.Controls.Add(this.pr_detail_label);
             this.Controls.Add(this.ma_prodcode_label);
             this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
+            this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
             this.Name = "Make_SeqTransform";
             this.Tag = "Make!SeqTransform";
             this.Text = " ";

+ 87 - 81
UAS-MES/FunctionCode/Make/Make_SeqTransform.cs

@@ -94,6 +94,7 @@ namespace UAS_MES.Make
                                         }
                                         break;
                                     case CheckState.Unchecked:
+
                                         string beforesn = dh.getFieldDataByCondition("makeserial", "ms_beforesn", "ms_sncode='" + sncode.Text + "'").ToString().Trim();
                                         //为空,就说明,没有进行过序列号的转换
                                         if (beforesn == "" || beforesn == null)
@@ -218,88 +219,7 @@ namespace UAS_MES.Make
         /// <param name="e"></param>
         private void ms_makecode_KeyDown(object sender, KeyEventArgs e)
         {
-            if (e.KeyCode == Keys.Enter)
-            {
-                //查询表工单序列号防呆规则表
-                dt = (DataTable)dh.ExecuteSql("select msr_type, msr_prefix ,msr_length from makesnrule where msr_makecode='" + ma_code.Text+"'", "select");
-                if (dt.Rows.Count > 0)
-                {
-                    foreach (DataRow dr in dt.Rows)
-                    {
-                        //如果有值,则这个字段自动勾选,并且不可编辑
-                        if (dr["msr_type"].ToString().ToLower() == "before")
-                        {
-                            //msr_type=before 的值赋值到转换前
 
-                            //临时变量记录
-                            string length = dr["msr_length"].ToString();
-                            string prefix = dr["msr_prefix"].ToString();
-                            //不为空
-                            if (prefix != "" && prefix != null)
-                            {
-                                //则赋值
-                                beforeTransSNPre.Text = prefix;
-                                //设置不可编辑
-                                beforeTransSNPre.ReadOnly = true;
-                                //勾选
-                                beforeTransSNPre_checkBox.Checked = true;
-                            }
-                            if (length != "" && length != null)
-                            {
-                                //赋值
-                                beforeTransSNLength.Text = length;
-                                //设置不可编辑
-                                beforeTransSNLength.ReadOnly = true;
-                                //勾选
-                                beforeTransSNLength_checkBox.Checked = true;
-                            }
-                        }
-                        else if (dr["msr_type"].ToString().ToLower() == "after")
-                        {
-                            //msr_type=after 的值赋值到转换后
-
-                            //临时变量记录
-                            string length = dr["msr_length"].ToString();
-                            string prefix = dr["msr_prefix"].ToString();
-                            //不为空
-                            if (prefix != "" && prefix != null)
-                            {
-                                //则赋值
-                                afterTransSNPre.Text = prefix;
-                                //设置不可编辑
-                                afterTransSNPre.ReadOnly = true;
-                                //勾选
-                                afterTransSNPre_checkBox.Checked = true;
-                            }
-                            if (length != "" && length != null)
-                            {
-                                //赋值
-                                afterTransSNLength.Text = length;
-                                //设置不可编辑
-                                afterTransSNLength.ReadOnly = true;
-                                //勾选
-                                afterTransSNLength_checkBox.Checked = true;
-                            }
-                        }
-                    }
-                }
-                else
-                {
-                    /*	如果转换前没有值,则取 select productsnrule where psr_prodcode=? 产品编号,
-                     *	有值则赋值到 转换前,并且自动勾选不可编辑。*/
-                    //dt = (DataTable)dh.ExecuteSql("select psr_prefix ,psr_length from productsnrule where psr_prodcode = " + ma_prodcode.Text, "select");
-                    //if (dt.Rows.Count > 0)
-                    //{
-                    //    //将产品序列号防呆规则查出的数据填充
-                    //    beforeTransSNPre.Text = dt.Rows[0]["psr_prefix"].ToString();
-                    //    beforeTransSNPre.ReadOnly = true;
-                    //    beforeTransSNPre_checkBox.Checked = true;
-                    //    beforeTransSNLength.Text = dt.Rows[0]["psr_length"].ToString();
-                    //    beforeTransSNLength.ReadOnly = true;
-                    //    beforeTransSNLength_checkBox.Checked = true;
-                    //}
-                }
-            }
         }
         /// <summary>
         /// 如果清空了工单号,或者更换了工单号则将 : 转换前序列号长度,转换前序列号前缀
@@ -320,6 +240,92 @@ namespace UAS_MES.Make
             beforeTransSNLength_checkBox.Checked = false;
             afterTransSNPre_checkBox.Checked = false;
             afterTransSNLength_checkBox.Checked = false;
+
+            //设置可编辑
+            beforeTransSNLength.Enabled = true;
+            beforeTransSNPre.Enabled = true;
+            afterTransSNLength.Enabled = true;
+            afterTransSNPre.Enabled = true;
+
+            //查询表工单序列号防呆规则表
+            dt = (DataTable)dh.ExecuteSql("select msr_type, msr_prefix ,msr_length from makesnrule where msr_makecode='" + ma_code.Text + "'", "select");
+            if (dt.Rows.Count > 0)
+            {
+                foreach (DataRow dr in dt.Rows)
+                {
+                    //如果有值,则这个字段自动勾选,并且不可编辑
+                    if (dr["msr_type"].ToString().ToLower() == "before")
+                    {
+                        //msr_type=before 的值赋值到转换前
+
+                        //临时变量记录
+                        string length = dr["msr_length"].ToString();
+                        string prefix = dr["msr_prefix"].ToString();
+                        //不为空
+                        if (prefix != "" && prefix != null)
+                        {
+                            //则赋值
+                            beforeTransSNPre.Text = prefix;
+                            //设置不可编辑
+                            beforeTransSNPre.Enabled = false;
+                            //勾选
+                            beforeTransSNPre_checkBox.Checked = true;
+                        }
+                        if (length != "" && length != null)
+                        {
+                            //赋值
+                            beforeTransSNLength.Text = length;
+                            //设置不可编辑
+                            beforeTransSNLength.Enabled = false;
+                            //勾选
+                            beforeTransSNLength_checkBox.Checked = true;
+                        }
+                    }
+                    else if (dr["msr_type"].ToString().ToLower() == "after")
+                    {
+                        //msr_type=after 的值赋值到转换后
+
+                        //临时变量记录
+                        string length = dr["msr_length"].ToString();
+                        string prefix = dr["msr_prefix"].ToString();
+                        //不为空
+                        if (prefix != "" && prefix != null)
+                        {
+                            //则赋值
+                            afterTransSNPre.Text = prefix;
+                            //设置不可编辑
+                            afterTransSNPre.Enabled = false;
+                            //勾选
+                            afterTransSNPre_checkBox.Checked = true;
+                        }
+                        if (length != "" && length != null)
+                        {
+                            //赋值
+                            afterTransSNLength.Text = length;
+                            //设置不可编辑
+                            afterTransSNLength.Enabled = false;
+                            //勾选
+                            afterTransSNLength_checkBox.Checked = true;
+                        }
+                    }
+                }
+            }
+            else
+            {
+                /*	如果转换前没有值,则取 select productsnrule where psr_prodcode=? 产品编号,
+                 *	有值则赋值到 转换前,并且自动勾选不可编辑。*/
+                //dt = (DataTable)dh.ExecuteSql("select psr_prefix ,psr_length from productsnrule where psr_prodcode = " + ma_prodcode.Text, "select");
+                //if (dt.Rows.Count > 0)
+                //{
+                //    //将产品序列号防呆规则查出的数据填充
+                //    beforeTransSNPre.Text = dt.Rows[0]["psr_prefix"].ToString();
+                //    beforeTransSNPre.ReadOnly = true;
+                //    beforeTransSNPre_checkBox.Checked = true;
+                //    beforeTransSNLength.Text = dt.Rows[0]["psr_length"].ToString();
+                //    beforeTransSNLength.ReadOnly = true;
+                //    beforeTransSNLength_checkBox.Checked = true;
+                //}
+            }
         }
         /// <summary>
         /// 检验长度或者前缀是否合法