Browse Source

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

Hcsy 8 years ago
parent
commit
703084bf78

+ 165 - 53
MES接口/DataHelper.cs

@@ -3,6 +3,7 @@ using System;
 using System.Data;
 using System.Text;
 using System.Configuration;
+using System.Collections.Generic;
 
 namespace MES_Interface
 {
@@ -15,8 +16,10 @@ namespace MES_Interface
         private string ConnectionStrings = ConfigurationManager.ConnectionStrings["MES"].ConnectionString;
         //用户选择的数据库的连接字符串
         public static OracleConnection connection = null;
+        //用户选择的数据库的连接字符串
+        public static string DBConnectionString;
         OracleCommand command = null;
-
+        int ReconnectTime = 0;
         /// <summary>
         /// 执行构造函数的时候打开数据库的链接
         /// </summary>
@@ -37,10 +40,8 @@ namespace MES_Interface
             }
             catch (Exception e)
             {
-                Console.WriteLine(e.Message);
             }
         }
-
         /// <summary>
         /// 根据表名获取该表字段数据类型
         /// </summary>
@@ -48,6 +49,7 @@ namespace MES_Interface
         {
             DataTable dt = new DataTable();
             command = new OracleCommand("select Column_Name,Data_Type from cols where TABLE_name=upper('" + TableName + "')", connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -62,8 +64,8 @@ namespace MES_Interface
         {
             DataTable dt = new DataTable();
             string sql = "select " + Field + " from " + TableName + " where " + Condition;
-            Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter();
             ad.SelectCommand = command;
             ad.Fill(dt);
@@ -123,14 +125,13 @@ namespace MES_Interface
         {
             DataTable dt = new DataTable();
             string sql = "select count(1) from " + TableName + " where " + Condition;
-            Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
             command.Dispose();
-            int count = int.Parse(dt.Rows[0][0].ToString());
-            return count;
+            return int.Parse(dt.Rows[0][0].ToString());
         }
 
         /// <summary>
@@ -143,13 +144,12 @@ namespace MES_Interface
             DataTable dt = new DataTable();
             string sql = "select count(1) from " + TableName;
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
-            Console.WriteLine(sql);
             ad.Fill(dt);
             ad.Dispose();
             command.Dispose();
-            int count = int.Parse(dt.Rows[0][0].ToString());
-            return count;
+            return int.Parse(dt.Rows[0][0].ToString());
         }
 
         /// <summary>
@@ -161,8 +161,8 @@ namespace MES_Interface
             string sql = "select ";
             sql += AddField(Fields);
             sql += " from " + TableName + " where " + Condition + " and rownum=1";
-            Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -209,17 +209,13 @@ namespace MES_Interface
             sql.Append(AddField(caption));
             if (condition.Length > 0)
             {
-                if (condition[0].Trim() != "")
-                {
+                if (condition[0] != null && condition[0].Trim() != "")
                     sql.Append(" from " + TableName + " where " + condition[0] + " ) A where ROWNUM <=" + CurrentPage * PageSize + ") where RN>" + (CurrentPage - 1) * PageSize);
-                }
                 else
-                {
                     sql.Append(" from " + TableName + ") A where ROWNUM <= " + CurrentPage * PageSize + ") where RN> " + (CurrentPage - 1) * PageSize);
-                }
             }
-            Console.WriteLine(sql.ToString());
             command = new OracleCommand(sql.ToString(), connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -242,8 +238,8 @@ namespace MES_Interface
             string sql = "select ";
             sql += AddField(Fields);
             sql += " from " + TableName + " where " + Condition;
-            Console.WriteLine(sql);
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -261,6 +257,7 @@ namespace MES_Interface
             sql += Fields;
             sql += " from " + TableName;
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.SelectCommand = command;
             ad.Fill(dt);
@@ -317,7 +314,6 @@ namespace MES_Interface
                 {
                     //获取参数的个数
                     int paramsNum = sql[0].Split(':').Length - 1;
-
                     //解析参数的数据
                     string[] param = GetParamFromSQL(sql[0]);
                     //新建一个二维数组去
@@ -361,7 +357,6 @@ namespace MES_Interface
                     sb.Append(dc.Caption + "=:" + dc.Caption + ",");
                 }
             }
-
             sb.Remove(sb.Length - 1, 1);
             sb.Append(" where " + PrimaryKey + "=:" + PrimaryKey);
             command = new OracleCommand(sb.ToString(), connection);
@@ -436,8 +431,6 @@ namespace MES_Interface
             }
         }
 
-
-
         /// <summary>
         ///  获取配置列表中的数据,支持DaatList,Form,DetailGrid
         /// </summary>
@@ -570,20 +563,14 @@ namespace MES_Interface
         {
             string sql = "select count(1) from " + TableName + " where " + Condition;
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             DataTable dt = new DataTable();
-            Console.WriteLine(sql);
+            
             ad.Fill(dt);
             ad.Dispose();
             command.Dispose();
-            if (int.Parse(dt.Rows[0][0].ToString()) > 0)
-            {
-                return true;
-            }
-            else
-            {
-                return false;
-            }
+            return int.Parse(dt.Rows[0][0].ToString()) > 0;
         }
 
         /// <summary>
@@ -596,6 +583,7 @@ namespace MES_Interface
         {
             object result = null;
             command = new OracleCommand(SQL, connection);
+            Reconnect(command);
             //用来拼接参数的
             if (names.Length > 0)
             {
@@ -620,18 +608,31 @@ namespace MES_Interface
                     }
                 }
                 for (int i = 0; i < addpar.Length; i++)
-                {
                     command.Parameters.Add(new OracleParameter(addpar[i].ToString(), OracleDbType.Varchar2, names[i], ParameterDirection.Input));
-                }
             }
-            Console.WriteLine(SQL);
+            
             switch (Type.ToUpper())
             {
                 case "SELECT":
                     result = new DataTable();
-                    OracleDataAdapter ad = new OracleDataAdapter(command);
-                    ad.Fill((DataTable)result);
-                    ad.Dispose();
+                    try
+                    {
+                        OracleDataAdapter ad = new OracleDataAdapter(command);
+                        ad.Fill((DataTable)result);
+                        ad.Dispose();
+                        //成功执行后将重复连接数置为0
+                        ReconnectTime = 0;
+                    }
+                    catch (Exception)
+                    {
+                        if (ReconnectTime == 0)
+                        {
+                            //重置的数据库链接后只执行一次
+                            ReconnectTime = ReconnectTime + 1;
+                            connection = new OracleConnection(DBConnectionString);
+                            result = ExecuteSql(SQL, Type, names);
+                        }
+                    }
                     break;
                 case "DELETE":
                     result = command.ExecuteNonQuery();
@@ -663,8 +664,9 @@ namespace MES_Interface
         {
             DataTable dt = new DataTable();
             string sql = "select distinct count('" + Field + "') from " + TableName;
-            Console.WriteLine(sql);
+            
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -693,8 +695,9 @@ namespace MES_Interface
         public void DeleteDataByID(string TableName, string ID, string[] DeleteID)
         {
             string sql = "delete from " + TableName + " where " + ID + " =:DeleteID";
-            Console.WriteLine(sql);
+            
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             command.ArrayBindCount = DeleteID.Length;
             command.Parameters.Add(new OracleParameter("DeleteID", OracleDbType.Long, DeleteID, ParameterDirection.Input));
             command.ExecuteNonQuery();
@@ -713,6 +716,104 @@ namespace MES_Interface
             return dt.Rows[0][0].ToString();
         }
 
+        public void SaveDataTable(DataTable dt, string TableName, string ID, params string[] sql)
+        {
+            if (dt == null)
+            {
+                return;
+            }
+            StringBuilder sb = new StringBuilder();
+            //预防插入的DataTable中存在不属于该表的列,在进行下一步操作之前全部剔除
+            DataTable data = (DataTable)ExecuteSql("select Column_Name,Data_Type from cols where TABLE_name=upper('" + TableName + "')", "select");
+            //将所有的字段拼接起来
+            for (int i = 0; i < data.Rows.Count; i++)
+            {
+                sb.Append("#" + data.Rows[i]["Column_Name"].ToString());
+            }
+            //移除掉所有不属于该表的列
+            for (int i = dt.Columns.Count - 1; i >= 0; i--)
+            {
+                if (!sb.ToString().Contains(dt.Columns[i].ColumnName.ToUpper()))
+                {
+                    dt.Columns.RemoveAt(i);
+                }
+            }
+            sb.Clear();
+            //计算有多少个是新加的行,根据主键为空来进行判断
+            int NewRowCount = 0;
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                if (dt.Rows[i][ID] == null || dt.Rows[i][ID].ToString() == "")
+                {
+                    NewRowCount = NewRowCount + 1;
+                }
+            }
+            if (sql.Length > 0)
+            {
+                if (NewRowCount > 0)
+                {
+                    //获取参数的个数
+                    int paramsNum = sql[0].Split(':').Length - 1;
+                    //解析参数的数据
+                    string[] param = GetParamFromSQL(sql[0]);
+                    //新建一个二维数组去
+                    string[][] param_array = new string[paramsNum][];
+                    //实例化每个一维数组
+                    for (int i = 0; i < paramsNum; i++)
+                    {
+                        param_array[i] = new string[NewRowCount];
+                    }
+                    //设置每列参数的索引
+                    int num = 0;
+                    //变量所有的行,如果有主键为空的则移除,不为空的进行参数的拼接
+                    for (int i = dt.Rows.Count - 1; i >= 0; i--)
+                    {
+                        if (dt.Rows[i][ID] == null || dt.Rows[i][ID].ToString() == "")
+                        {
+                            //当为新添加行的时候才去设置参数,设置过后索引+1
+                            for (int j = 0; j < paramsNum; j++)
+                            {
+                                param_array[j][num] = dt.Rows[i][param[j]].ToString();
+                            }
+                            dt.Rows.RemoveAt(i);
+                            num++;
+                        }
+                    }
+                    BatchInsertDataTable(sql[0], param, param_array);
+                }
+            }
+            sb.Clear();
+            sb.Append("update " + TableName + " set ");
+            int ColumnCount = dt.Columns.Count;
+            int RowCount = dt.Rows.Count;
+            //存数据的参数
+            List<string[]> Parameter = new List<string[]>();
+            //存参数名的参数
+            string[] ParName = new string[ColumnCount];
+            for (int i = 0; i < ColumnCount; i++)
+            {
+                ParName[i] = dt.Columns[i].ColumnName;
+                if (i == dt.Columns.Count - 1)
+                    sb.Append(dt.Columns[i].ColumnName + "=:" + dt.Columns[i].ColumnName);
+                else
+                    sb.Append(dt.Columns[i].ColumnName + "=:" + dt.Columns[i].ColumnName + ",");
+            }
+            sb.Append(" where " + ID + " =:" + ID);
+            //先添加参数
+            Parameter.Add(ParName);
+            //添加参数的具体内容
+            for (int i = 0; i < ColumnCount; i++)
+            {
+                string[] par = new string[RowCount];
+                for (int j = 0; j < RowCount; j++)
+                {
+                    par[j] = dt.Rows[j][i].ToString();
+                }
+                Parameter.Add(par);
+            }
+            BatchInsert(sb.ToString(), Parameter.ToArray());
+        }
+
         /// <summary>
         /// 批量通过SQL来执行插入操作 ,参数的第一个数一个string[]数组,用来传递需要添加的参数的名称
         /// 之后的是名称参数数组对应的 ,所有的插入参数数据长度必须是一致的
@@ -722,8 +823,9 @@ namespace MES_Interface
         public void BatchInsert(string sql, params object[][] names)
         {
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             command.ArrayBindCount = names[1].Length;
-            Console.WriteLine(sql);
+            
             //因为第一个数组保存的是参数的名称,所以循环从1而不是0开始
             //将第一个数组的下标固定为0作为循环添加的参数的名称
             for (int i = 1; i <= names[0].Length; i++)
@@ -737,6 +839,7 @@ namespace MES_Interface
         public void BatchInsertDataTable(string sql, string[] param, params object[][] param1)
         {
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             command.ArrayBindCount = param1[0].Length;
             //因为第一个数组保存的是参数的名称,所以循环从1而不是0开始
             //将第一个数组的下标固定为0作为循环添加的参数的名称
@@ -760,6 +863,7 @@ namespace MES_Interface
             DataTable dt = new DataTable();
             string SQL = " select listagg(dld_field,',') within group (order by dld_id)  from datalistdetail where dld_caller='" + Caller + "'";
             command = new OracleCommand(SQL, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter(command);
             ad.Fill(dt);
             ad.Dispose();
@@ -832,8 +936,9 @@ namespace MES_Interface
         public string UpdateByCondition(string TableName, string update, string condition)
         {
             string sql = "update " + TableName + " set " + update + " where " + condition;
-            Console.WriteLine(sql);
+            
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             command.ExecuteNonQuery();
             command.Dispose();
             return sql;
@@ -842,20 +947,20 @@ namespace MES_Interface
         /// <summary>
         /// 调用存储过程
         /// </summary>
-        /// <param name="ProcedureName"></param>
+        /// <param name="ProcedureName"></param>    
         /// <param name="param"></param>
-        public void CallProcedure(string ProcedureName, params string[] param)
+        public void CallProcedure(string ProcedureName, ref string[] param)
         {
-            command.CommandText = "Execute " + ProcedureName;
-            if (param[0].Length > 0)
-            {
-                command.ArrayBindCount = param[1].Length;
-                for (int i = 1; i <= param[0].Length; i++)
-                {
-                    command.Parameters.Add(new OracleParameter(param[0][i - 1].ToString(), OracleDbType.Varchar2, param[i], ParameterDirection.Input));
-                }
-            }
+            command = new OracleCommand(ProcedureName);
+            command.Connection = connection;
+            Reconnect(command);
+            command.CommandText = ProcedureName;
+            command.CommandType = CommandType.StoredProcedure;
+            for (int i = 0; i < param.Length; i++)
+                command.Parameters.Add(new OracleParameter(param[i].ToString(), OracleDbType.Varchar2, 200, param[i], ParameterDirection.InputOutput));
             command.ExecuteNonQuery();
+            for (int i = 0; i < command.Parameters.Count; i++)
+                param[i] = command.Parameters[i].Value.ToString();
             command.Dispose();
         }
 
@@ -875,6 +980,7 @@ namespace MES_Interface
                 {
                     if (!String.IsNullOrEmpty(sql))
                     {
+                        
                         command.CommandText = sql;
                         command.ExecuteNonQuery();
                     }
@@ -903,7 +1009,6 @@ namespace MES_Interface
             }
             return sql.Substring(0, sql.Length - 1);
         }
-
         /// <summary>
         /// 通过查询的内容获取到字段的描述
         /// </summary>
@@ -938,6 +1043,7 @@ namespace MES_Interface
         {
             DataTable dt = new DataTable();
             command = new OracleCommand(sql, connection);
+            Reconnect(command);
             OracleDataAdapter ad = new OracleDataAdapter();
             ad.SelectCommand = command;
             ad.Fill(dt);
@@ -983,5 +1089,11 @@ namespace MES_Interface
             }
             return param;
         }
+
+        private void Reconnect(OracleCommand cmd)
+        {
+            if (cmd.Connection.State == ConnectionState.Closed)
+                cmd.Connection.Open();
+        }
     }
 }

+ 126 - 309
MES接口/LogicHandler.cs

@@ -22,139 +22,50 @@ namespace MES_Interface
         /// </summary>
         /// <param name="iSnCode"></param>
         /// <param name="iMakeCode"></param>
-        /// <param name="iSource"></param>
+        /// <param name="iSourceCode"></param>
         /// <param name="oErrMessage"></param>
         /// <returns></returns>
-        private bool CheckCurrentStep(string iSnCode, string iMakeCode, string iSource, out string oErrMessage)
+        public bool CheckCurrentStep(string iSnCode, string iMakeCode, string iSourceCode, out string oErrMessage)
         {
-            oErrMessage = "";
-            if (iMakeCode == "")
+            if (GetMakeInfo(iSnCode, out iMakeCode, out oErrMessage))
             {
-                if (!GetMakeInfo(iSnCode, out iMakeCode, out oErrMessage))
+                string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'").ToString();
+                string sourcestepcode = GetStepCodeBySource(iSourceCode);
+                if (nextstepcode == "")
+                {
+                    oErrMessage = "当前序列号已无可执行工序";
                     return false;
-            }
-            string nextstepcode = dh.getFieldDataByCondition("makeserial", "ms_nextstepcode", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'").ToString();
-            string sourcestepcode = GetStepCodeBySource(iSource);
-            if (nextstepcode == "")
-            {
-                oErrMessage = "当前序列号已无可执行工序";
-                return false;
-            }
-            if (nextstepcode == sourcestepcode)
-                return true;
-            else {
-                oErrMessage = "资源" + iSource + "对应的工序是" + sourcestepcode + ",序列号" + iSnCode + "当前工序是" + nextstepcode;
-                return false;
-            }
-
-        }
-
-        private bool CheckMakeStatus(string iMaCode)
-        {
-            if (dh.getFieldDataByCondition(" make ", "ma_statuscode", "ma_code='" + iMaCode + "' ").ToString() == "STARTED")
-                return true;
-            else
-                return false;
-        }
-
-        /// <summary>
-        /// 判断当前工序是否是第一道工序
-        /// </summary>
-        /// <param name="iSnCode"></param>
-        /// <param name="iMakecode"></param>
-        /// <param name="iSourceCode"></param>
-        /// <returns></returns>
-        public bool CheckIfFirstMakeSerial(string iSnCode, string iMakecode, string iSourceCode)
-        {
-            //选取当前的最小的执行顺序
-            string CurrentStep = GetStepCodeBySource(iSourceCode);
-            DataTable dt = (DataTable)dh.ExecuteSql("select  min(mcd_detno) detno from makecraftdetail where mcd_macode='" + iMakecode + "'", "select");
-            string detno = dt.Rows[0]["detno"].ToString();
-            //判断当前最小的执行顺序是否有记录
-            if (dh.getRowCount("makecraftdetail", "mcd_stepcode='" + CurrentStep + "' and mcd_macode='" + iMakecode + "' and mcd_detno ='" + detno + "'") > 0)
-            {
-                if (!dh.CheckExist("MakeSerial", "ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakecode + "'"))
+                }
+                if (nextstepcode == sourcestepcode)
+                    return true;
+                else
                 {
-                    sql.Clear();
-                    sql.Append("Insert into MakeSerial (ms_id, ms_code, ms_sncode ,ms_prodcode, ms_indate,");
-                    sql.Append("ms_wccode,ms_craftcode,ms_craftname,ms_nextstepcode,ms_status,ms_makecode) select MAKESERIAL_SEQ.NEXTVAL,");
-                    sql.Append("'" + iSnCode + "','" + iSnCode + "',ma_prodcode,sysdate,ma_wccode,ma_craftcode,ma_craftname,'" + CurrentStep + "',0,ma_code ");
-                    sql.Append("from make left join makecraftdetail on ma_code =mcd_macode where ma_code='" + iMakecode + "' and mcd_stepcode='" + CurrentStep + "'");
-                    dh.ExecuteSql(sql.ToString(), "insert");
+                    oErrMessage = "资源" + iSourceCode + "对应的工序是" + sourcestepcode + ",序列号" + iSnCode + "当前工序是" + nextstepcode;
+                    return false;
                 }
-                return true;
             }
-            else
-                return false;
+            else return false;
         }
 
         /// <summary>
-        /// 判断下一工序是否是送检工序
+        /// 判断工单是否已经下放
         /// </summary>
+        /// <param name="iMaCode"></param>
         /// <returns></returns>
-        public bool CheckNextStepIfQC(string iSnCode, string iMakeCode, string iStepCode, string iCraftCode, string iUserName, out string oErrorMessage)
+        public bool CheckMakeStatus(string iMaCode, out string ErrorMessage)
         {
-            oErrorMessage = "";
-            string IfQC = dh.getFieldDataByCondition("craft left join  craftdetail on cd_crid=cr_id", "cd_ifoqc", "cr_code='" + iCraftCode + "' and cd_stepcode='" + iStepCode + "'").ToString();
-            if (IfQC != "0" && IfQC != "")
+            string ma_statuscode = dh.getFieldDataByCondition(" make ", "ma_statuscode", "ma_code='" + iMaCode + "' ").ToString();
+            ErrorMessage = "";
+            if (ma_statuscode == "")
             {
-                DataTable dt = dh.getFieldsDataByCondition("make left join product on ma_prodcode=pr_code", new string[] { "ma_nowcheckqty", "pr_qcbatchqty", "ma_checkno", "ma_prodcode", "pr_qualmethod" }, "ma_code='" + iMakeCode + "'");
-                if (dt.Rows.Count > 0)
-                {
-                    string ma_nowcheckqty = dt.Rows[0]["ma_nowcheckqty"].ToString();
-                    string pr_qcbatchqty = dt.Rows[0]["pr_qcbatchqty"].ToString();
-                    string ma_checkno = dt.Rows[0]["ma_checkno"].ToString();
-                    string ma_prodcode = dt.Rows[0]["ma_prodcode"].ToString();
-                    string pr_qualmethod = dt.Rows[0]["pr_qualmethod"].ToString();
-                    if (pr_qcbatchqty != "" && pr_qcbatchqty != "0")
-                    {
-                        //当前批次的送检批数量大于物料资料中的抽检批数或者当前批次编号为空
-                        string checkno = "";
-                        if (int.Parse(ma_nowcheckqty == "" ? "0" : ma_nowcheckqty) >= int.Parse(pr_qcbatchqty) || ma_checkno == "")
-                        {
-                            //原有的抽检批次插入OQCBatch
-                            string ob_id = dh.GetSEQ("OQCBatch_SEQ");
-                            checkno = dh.GetSerialNumberByCaller("Make!CheckQC");
-                            sql.Clear();
-                            sql.Append("insert into OQCBatch  (ob_id, ob_checkno,ob_makecode,ob_source,ob_indate,ob_checkman,ob_batchqty,ob_status,ob_prodcode,ob_projectcode)");
-                            sql.Append(" values('" + ob_id + "','" + checkno + "','" + iMakeCode + "', '工序',sysdate, '" + iUserName + "','" + ma_nowcheckqty + "','UNCHECK','" + ma_prodcode + "','" + pr_qualmethod + "')");
-                            sqls.Add(sql.ToString());
-                            sqls.Add("update makeserial set ms_checkno='" + checkno + "' where ms_makecode='" + iMakeCode + "' and ms_sncode='" + iSnCode + "'");
-                            sqls.Add("update make set ma_checkno='" + checkno + "',ma_nowcheckqty=1 where ma_code='" + iMakeCode + "'");
-                        }
-                        else
-                        {
-                            sqls.Add("update makeserial set ms_checkno='" + ma_checkno + "' where ms_makecode='" + iMakeCode + "' and ms_sncode='" + iSnCode + "'");
-                            sqls.Add("update make set ma_nowcheckqty= ma_nowcheckqty+1  where ma_code='" + iMakeCode + "'");
-                        }
-                        dh.ExecuteSQLTran(sqls.ToArray());
-                        sqls.Clear();
-                        //如果制造单的ma_checkno没有值则新加入一个值
-                        string checkno1 = checkno == "" ? ma_checkno : checkno;
-                        string obd_obid = dh.getFieldDataByCondition("oqcbatch", "ob_id", "ob_checkno='" + checkno1 + "'").ToString();
-                        //插入抽检批次明细表
-                        sql.Clear();
-                        sql.Append("insert into OQCBatchDetail (obd_id,obd_obid,obd_sncode,obd_outboxcode,obd_makecode,obd_checkno,obd_builddate) ");
-                        sql.Append("select OQCBatchDetail_SEQ.nextval,'" + obd_obid + "',ms_sncode,ms_outboxcode,ms_makecode,ms_checkno,");
-                        sql.Append("sysdate from makeserial where  ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
-                        dh.ExecuteSql(sql.ToString(), "insert");
-                        return true;
-                    }
-                    else
-                    {
-                        oErrorMessage = "请维护物料资料的抽检批数";
-                        return false;
-                    }
-                }
-                else
-                {
-                    oErrorMessage = "制造单号不存在";
-                    return false;
-                }
+                ErrorMessage = "工单号" + iMaCode + "不存在";
+                return false;
             }
+            if (ma_statuscode == "STARTED")
+                return true;
             else
             {
-                oErrorMessage = "当前工序的下一工序不是OQC检测";
+                ErrorMessage = "工单必须是已下放状态";
                 return false;
             }
         }
@@ -196,9 +107,10 @@ namespace MES_Interface
             if (dt.Rows.Count > 0)
             {
                 string em_name = dt.Rows[0]["em_name"].ToString();
-                if (dt.Rows[0]["em_type"].ToString() == "admin" && iSourceCode == "")
+                if (iSourceCode == "")
                 {
-                    return true;
+                    oErrorMessage = "岗位资源不允许为空";
+                    return false;
                 }
                 dt = dh.getFieldsDatasByCondition("cs$empgroup left join cs$userresource on ur_groupcode=eg_groupcode left join source on ur_resourcecode=sc_code", new string[] { "ur_resourcecode" }, "eg_emcode = '" + iUserCode + "' and sc_statuscode='AUDITED'");
                 //如果存在该编号
@@ -220,6 +132,33 @@ namespace MES_Interface
             return false;
         }
 
+        public bool CheckStepAttribute(string iCaller, string iSourceCode, out string oErrorMessage)
+        {
+            oErrorMessage = "";
+            string[] param = new string[] { iCaller, iSourceCode, oErrorMessage };
+            dh.CallProcedure("CS_CHECKSTEPATTRIBUTE", ref param);
+            if (oErrorMessage == "" || oErrorMessage == null)
+                return true;
+            else
+                return false;
+        }
+
+        public bool CheckStepSNAndMacode(string iMakeCode, string iSourceCode, string iSN, string iUserCode, out string oMakeCode, out string oMsID, out string oErrorMessage)
+        {
+            oErrorMessage = "";
+            oMakeCode = "";
+            oMsID = "";
+            string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, oMakeCode, oMsID, oErrorMessage };
+            dh.CallProcedure("CS_CHECKSTEPSNANDMACODE", ref param);
+            oMakeCode = param[4];
+            oMsID = param[5];
+            oErrorMessage = param[6];
+            if (oErrorMessage == "" || oErrorMessage == null || oErrorMessage == "null")
+                return true;
+            else
+                return false;
+        }
+
         /// <summary>
         /// 分配Mac地址和BT地址
         /// </summary>
@@ -436,7 +375,7 @@ namespace MES_Interface
                 return true;
             else
             {
-                oErrorMessage = "当前序列号" + iSnCode + "不存在生产记录";
+                oErrorMessage = "序列号:" + iSnCode + " 未归属工单";
                 return false;
             }
         }
@@ -510,38 +449,28 @@ namespace MES_Interface
         /// <summary>
         /// 记录操作日志
         /// </summary>
-        /// <param name="iMakeCode"></param>
         /// <param name="iSnCode"></param>
-        public void InsertMakeProcess(string iSnCode, string iMakeCode, string result, string iUserName)
+        /// <param name="iMakeCode"></param>
+        /// <param name="iMPKind"></param>
+        /// <param name="iResult"></param>
+        /// <param name="iUserName"></param>
+        public void InsertMakeProcess(string iSnCode, string iMakeCode, string iSourceCode, string iMPKind, string iResult, string iUserName)
         {
+            string CurrentStep = "";
+            string LineCode = "";
+            string CurrentStepName = "";
+            GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
             sql.Clear();
             sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");
-            sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode) ");
+            sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode,mp_snstatus,mp_sncheckno,mp_snoutboxcode)");
             sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,mcd_stepcode,mcd_stepname,");
-            sql.Append("ma_craftcode,ma_craftname,ma_kind,'" + result + "',sysdate,'" + iUserName + "',ma_wccode,ma_linecode,''");
-            sql.Append("from make left join makecraftdetail on mcd_macode=ma_code left join makeserial on ms_makecode=ma_code ");
-            sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "'");
-            //插入makeprocess 
+            sql.Append("ma_craftcode,ma_craftname,'" + iMPKind + "','" + iResult + "',sysdate,'" + iUserName + "',ma_wccode,'" + LineCode + "','" + iSourceCode + "',");
+            sql.Append("ms_status,ms_checkno,ms_outboxcode from make left join makecraftdetail on mcd_macode=ma_code left join makeserial on ms_makecode=ma_code ");
+            sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and mcd_stepcode='" + CurrentStep + "'");
             dh.ExecuteSql(sql.ToString(), "insert");
             sql.Clear();
         }
 
-        /// <summary>
-        /// 记录一般操作日志
-        /// </summary>
-        /// <param name="inMan"></param>
-        /// <param name="Content"></param>
-        /// <param name="Result"></param>
-        /// <param name="Search"></param>
-        /// <param name="Code"></param>
-        public void InsertMessageLog(string inMan, string Content, string Result, string Search, string Code)
-        {
-            sql.Clear();
-            sql.Append("insert into messagelog (ml_id,ml_date,ml_man,ml_content,ml_result,ml_search,code) ");
-            sql.Append("values (messagelog_seq.nextval,sysdate,'" + inMan + "','" + Content + "','" + Result + "','" + Search + "','" + Code + "')");
-            dh.ExecuteSql(sql.ToString(), "insert");
-        }
-
         /// <summary>
         /// 保存Mac地址和BT地址
         /// </summary>
@@ -560,12 +489,14 @@ namespace MES_Interface
             {
                 string sql = "update MakeSerial set ms_mac=:iWifi,ms_bt=:iBT,ms_othcode1=:iCode1,ms_othcode2=:iCode2,ms_othcode3=:iCode3 where ms_sncode='" + iSN + "' and ms_makecode='" + MakeCode + "'";
                 dh.ExecuteSql(sql, "update", iWIFI, iBT, iCode1, iCode2, iCode3);
-                if (dh.CheckExist("SnInfo", "si_sn='" + iSN + "'"))
+                DataTable dt = (DataTable)dh.ExecuteSql("select si_sn from SnInfo where si_sn='" + iSN + "' or  si_sn in (select sn from makesnrelation where firstsn='" + iSN + "' or sn='" + iSN + "')", "select");
+                if (dt.Rows.Count > 0)
                 {
-                    sql = "update SnInfo set si_mac=:iMac,si_bt=:iBT,si_othcode1=:iCode1,si_othcode2=:iCode2,si_othcode3=:iCode3 where si_sncode='" + iSN + "'";
+                    sql = "update SnInfo set si_mac=:iMac,si_bt=:iBT,si_othcode1=:iCode1,si_othcode2=:iCode2,si_othcode3=:iCode3 where si_sn='" + dt.Rows[0]["si_sn"].ToString() + "'";
                     dh.ExecuteSql(sql, "update", iWIFI, iBT, iCode1, iCode2, iCode3);
                 }
-                else {
+                else
+                {
                     sql = "insert into SnInfo(si_id,si_sn,si_mac,si_bt,si_othcode1,si_othcode2,si_othcode3) values(SnInfo_seq.nextval,:iSn,:iWifi,:iBt,:iCode1,:iCode2,:iCode3)";
                     dh.ExecuteSql(sql, "insert", iSN, iWIFI, iBT, iCode1, iCode2, iCode3);
                 }
@@ -575,6 +506,31 @@ namespace MES_Interface
                 return false;
         }
 
+        public bool SetStepFinish(string iMakeCode, string iSourceCode, string iSN, string iMPKind, string iResult, string iUserCode, out string oErrorMessage)
+        {
+            oErrorMessage = "";
+            string StepCode = dh.getFieldDataByCondition("Makeserial", "ms_stepcode", "ms_sncode='" + iSN + "'").ToString();
+            string CurrentStep = GetStepCodeBySource(iSourceCode);
+            if (StepCode == CurrentStep)
+            {
+                InsertMakeProcess(iSN, iMakeCode, iSourceCode, iMPKind, iResult, iUserCode);
+                return true;
+            }
+            else {
+                return CS_SetFinish(iMakeCode, iSourceCode, iSN, iUserCode, out oErrorMessage);
+            }
+        }
+
+        private bool CS_SetFinish(string iMakeCode, string iSourceCode, string iSN, string iUserCode, out string oErrorMessage)
+        {
+            oErrorMessage = "";
+            string[] param = new string[] { iMakeCode, iSourceCode, iSN, iUserCode, oErrorMessage };
+            dh.CallProcedure("CS_SETSTEPFINISH", ref param);
+            if (oErrorMessage == "" || oErrorMessage == null)
+                return true;
+            else
+                return false;
+        }
 
         /// <summary>
         /// 方法说明:测试详细信息录入系统,针对一个SN多个测试项目结果可循环调用
@@ -637,43 +593,34 @@ namespace MES_Interface
         /// </summary>
         /// <param name="iSnCode"></param>
         /// <param name="iMakeCode"></param>
-        /// <param name="iUserName"></param>
+        /// <param name="iUserCode"></param>
         /// <param name="iSourceCode"></param>
         /// <param name="iBadCode"></param>
         /// <param name="iBadRemark"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool SetTestNGDetail(string iSnCode, string iMakeCode, string iUserName, string iSourceCode, string iResult, string[] iBadCode, string[] iBadRemark, out string oErrorMessage)
+        public bool SetTestNGDetail(string iSnCode, string iMakeCode, string iUserCode, string iSourceCode, string iResult, string[] iBadGroupCode, string[] iBadCode, string[] iBadRemark, out string oErrorMessage)
         {
             oErrorMessage = "";
             string StepCode = "";
             string StepName = "";
             if (iResult == "" || iResult == null)
-            {
                 iResult = "检查未通过";
-            }
             GetStepCodeAndNameBySource(iSourceCode, ref StepCode, ref StepName);
+            string ms_status = dh.getFieldDataByCondition("makeserial", "ms_status", "ms_sncode='" + iSnCode + "'").ToString();
             sql.Clear();
-            sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,");
-            sql.Append("mb_indate,mb_stepcode,mb_sourcecode,mb_badcode,mb_badtable,mb_soncode,mb_status,mb_badremark)");
-            sql.Append("select makebad_seq.nextval,ma_code,ms_code,ms_sncode,'" + iUserName + "',sysdate,'" + StepCode + "',ms_sourcecode,:bc_code,'',");
+            sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
+            sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_soncode,mb_status,mb_badremark)");
+            sql.Append("select makebad_seq.nextval,ma_code,ms_code,ms_sncode,'" + iUserCode + "',sysdate,'" + StepCode + "',ms_sourcecode,:bc_code,:bg_code,'',");
             sql.Append("sp_soncode,'0',:bc_remark from make left join makeSerial on ms_makecode=ma_code left join stepProduct on ");
             sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + iSnCode + "'");
-            dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "bc_remark" }, iBadCode, iBadRemark);
-            //更新序列号状态,待维修,返修工序
-            string st_rstepcode = dh.getFieldDataByCondition("step", "st_rstepcode", "st_code='" + StepCode + "'").ToString();
-            sql.Clear();
-            sql.Append("update makeserial set ms_status = 3,ms_nextstepcode ='" + st_rstepcode + "', ");
-            sql.Append("ms_stepcode ='" + StepCode + "' where ms_sncode ='" + iSnCode + "' and ms_makecode ='" + iMakeCode + "'");
-            dh.ExecuteSql(sql.ToString(), "update");
-            //更新makecraftdetail 工单采集记录表,根据工单号和工序编号 记录当前测试工序采集数量
-            dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty+1,mcd_outqty = mcd_outqty + 1", "mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "'");
+            dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "bg_code", "bc_remark" }, iBadCode, iBadGroupCode, iBadRemark);
             //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
-            dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + StepCode + "'", "ms_sncode='" + iSnCode + "'");
-            //记录操作日志
-            InsertMakeProcess(iSnCode, iMakeCode, iResult, iUserName);
+            dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + StepCode + "',ms_status=3", "ms_sncode='" + iSnCode + "'");
             //判断当前采集点是否为扣料工序cd_ifreduce =-1 则为扣料工序
-            SetCollectionFinish(iSnCode, iMakeCode, iUserName, iSourceCode, out oErrorMessage);
+            //之前保存的不良就不再调用
+            if (ms_status != "3")
+                SetStepFinish(iMakeCode, iSourceCode, iSnCode, "不良采集", iResult, iUserCode, out oErrorMessage);
             return true;
         }
 
@@ -697,8 +644,8 @@ namespace MES_Interface
                 return false;
             }
             sql.Clear();
-            sql.Append("select nvl(cd_ifreduce,0) cd_ifreduce  from craft left join ");
-            sql.Append("craftdetail on cd_crid=cr_id where cr_code=(select ma_craftcode  from makeserial left join make on ma_code = ms_makecode ");
+            sql.Append("select nvl(cd_ifreduce,0) cd_ifreduce from craft left join craftdetail on cd_crid=cr_id ");
+            sql.Append("where cr_code=(select ma_craftcode  from makeserial left join make on ma_code = ms_makecode ");
             sql.Append("where ms_sncode = '" + iSnCode + "') and cd_stepcode='" + StepCode + "'");
             DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
             sql.Clear();
@@ -708,21 +655,21 @@ namespace MES_Interface
                 if (cd_ifreduce == "-1")
                 {
                     sql.Clear();
-                    sql.Append("select dsl_location,dsl_table, max(dsl_baseqty) baseqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and ");
+                    sql.Append("select dsl_location,dsl_table,max(dsl_baseqty) baseqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and ");
                     sql.Append("dsl_linecode='" + LineCode + "' and dsl_status=0 and dsl_remainqty>0 and dsl_invalidtime is null group by dsl_location,dsl_table");
                     dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                     for (int i = 0; i < dt.Rows.Count; i++)
                     {
                         sql.Clear();
-                        sql.Append("selet dsl_id,dsl_remainqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and dsl_linecode='" + LineCode + "' ");
+                        sql.Append("select dsl_id,dsl_remainqty from devsmtlocation where dsl_makecode='" + iMakeCode + "' and dsl_linecode='" + LineCode + "' ");
                         sql.Append("and dsl_status=0 and dsl_remainqty>0 and dsl_invalidtime is null and rownum<3 order by dsl_id asc ");
                         DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-                        for (int j = 0; j < dt.Rows.Count; j++)
+                        for (int j = 0; j < dt1.Rows.Count; j++)
                         {
                             //外层循环的值dt
                             double baseqty = (double)dt.Rows[i]["baseqty"];
-                            double dsl_remainqty = (double)dt.Rows[i]["dsl_remainqty"];
                             //内层循环的值dt1
+                            double dsl_remainqty = (double)dt1.Rows[j]["dsl_remainqty"];
                             string dsl_id = dt1.Rows[j]["dsl_id"].ToString();
                             if (baseqty > 0)
                             {
@@ -730,21 +677,21 @@ namespace MES_Interface
                                 {
                                     sql.Clear();
                                     sql.Append("update devsmtlocation set dsl_remainqty=0,dsl_invalidtime =sysdate, dsl_validtime =(case when dsl_validtime ");
-                                    sql.Append("is null then sysdate else  dsl_validtime),dsl_status=-1 where dsl_id=" + dsl_id);
+                                    sql.Append("is null then sysdate else  dsl_validtime end),dsl_status=-1 where dsl_id=" + dsl_id);
                                     dh.ExecuteSql(sql.ToString(), "update");
                                     baseqty -= dsl_remainqty;
                                 }
                                 else
                                 {
                                     sql.Clear();
-                                    sql.Append("update devsmtlocation set dsl_remainqty=dsl_remainqty-NVL(dsl_baseqty,0),dsl_efftime=(case when");
-                                    sql.Append("dsl_validtime is null then sysdate else dsl_validtime) where dsl_id=" + dsl_id);
+                                    sql.Append("update devsmtlocation set dsl_remainqty=dsl_remainqty-NVL(dsl_baseqty,0),DSL_INVALIDTIME=(case when");
+                                    sql.Append("dsl_validtime is null then sysdate else dsl_validtime end) where dsl_id=" + dsl_id);
                                     dh.ExecuteSql(sql.ToString(), "update");
                                     baseqty = 0;
                                 }
                             }
                             else
-                                dh.ExecuteSql("update devsmtlocation set dsl_efftime=sysdate where dsl_id=" + dsl_id, "update");
+                                dh.ExecuteSql("update devsmtlocation set DSL_INVALIDTIME=sysdate where dsl_id=" + dsl_id, "update");
                         }
                     }
                     sql.Clear();
@@ -811,7 +758,7 @@ namespace MES_Interface
         /// <param name="iUserName"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool SetMaterialDown(string iSnCode, string iBarCode, string iCurrentStep, string iUserName, out string oErrorMessage)
+        public bool SetMaterialDown(string iSnCode, string iBarCode, string iSourceCode, string iCurrentStep, string iUserName, out string oErrorMessage)
         {
             //序列号不为空的时候
             oErrorMessage = "";
@@ -849,10 +796,10 @@ namespace MES_Interface
                     string cm_stepcode = dt.Rows[0]["cm_stepcode"].ToString();
                     string cm_mccode = dt.Rows[0]["cm_mccode"].ToString();
                     dh.ExecuteSql("delete from Craftmaterial where cm_id=" + cm_id, "delete");
-                    InsertMakeProcess(ms_macode, iSnCode, "下料成功", iUserName);
+                    InsertMakeProcess(ms_macode, iSnCode, iSourceCode, "下料操作", "下料成功", iUserName);
                     int count = dh.getRowCount("craftMaterial", "cm_mccode='" + cm_mccode + "' and cm_stepcode='" + cm_stepcode + "' and cm_sncode='" + iSnCode + "'");
                     if (count == 0)
-                        dh.UpdateByCondition("makecraftdetail", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty = mcd_okqty - 1", "mcd_mccode='" + cm_mccode + "' and mcd_stepcode='" + cm_stepcode + "'");
+                        dh.UpdateByCondition("makecraftdetail ", "mcd_inqty=mcd_inqty-1,mcd_outqty=mcd_outqty-1,mcd_okqty = mcd_okqty - 1", "mcd_mccode='" + cm_mccode + "' and mcd_stepcode='" + cm_stepcode + "'");
                 }
                 return true;
             }
@@ -870,139 +817,9 @@ namespace MES_Interface
         /// <param name="iResult"></param>
         /// <param name="oErrorMessage"></param>
         /// <returns></returns>
-        public bool UpdateMakeMessage(string iSnCode, string iMakeCode, string iSourceCode, string iUserName, string iResult, out string oErrorMessage)
+        public bool UpdateMakeMessage(string iSnCode, string iMakeCode, string iMPKind, string iSourceCode, string iUserCode, string iResult, out string oErrorMessage)
         {
-            oErrorMessage = "";
-            string StepCode = "";
-            string StepName = "";
-            string LineCode = "";
-            if (iResult == "" || iResult == null)
-            {
-                iResult = "测试合格";
-            }
-            GetStepCodeAndNameAndLineBySource(iSourceCode, ref StepCode, ref StepName, ref LineCode);
-            //判断是否上料工序,如果是的话执行该步骤
-            DataTable dt = dh.getFieldsDataByCondition("make left join craft on cr_code=ma_craftcode left join craftdetail on cd_crid=cr_id", new string[] { "cd_ifinput", "cr_code" }, "ma_code='" + iMakeCode + "' and cd_stepcode='" + StepCode + "'");
-            string Yes_No = dh.GetConfig("BatchNumber", "MESSetting").ToString();
-            string cr_code = "";
-            if (dt.Rows.Count > 0)
-            {
-                cr_code = dt.Rows[0]["cr_code"].ToString();
-                if (dt.Rows[0]["cd_ifinput"].ToString() != "0")
-                {
-                    sql.Clear();
-                    sql.Append("select wm_concat(mss_prodcode) code,count(1) cn from (select sum(nvl(mss_remain,0))remain,mss_prodcode,max(mss_baseqty) mss_baseqty ");
-                    sql.Append("from makesourcestock where mss_makecode='" + iMakeCode + "' and mss_stepcode='" + StepCode + "' ");
-                    sql.Append("and mss_linecode='" + LineCode + "' group by mss_prodcode)T where T.remain<mss_baseqty and rownum<20");
-                    dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-                    //如果配置的是Yes
-                    if (Yes_No != "0")
-                    {
-                        //如果批次料不足
-                        if (dt.Rows.Count > 0 && int.Parse(dt.Rows[0]["cn"].ToString()) > 0)
-                        {
-                            oErrorMessage += "批次物料:" + iSnCode + "," + dt.Rows[0]["code"] + "岗位备料不足";
-                            return false;
-                        }
-                    }
-                    //如果配置的是No 或者批次料足够
-                    else if (Yes_No == "0" || dt.Rows.Count == 0)
-                    {
-                        //扣减批次数量,插入数据至用料表
-                        sql.Clear();
-                        sql.Append("select mss_prodcode , max(mss_baseqty) baseqty from makesourcestock ");
-                        sql.Append("mss_makecode='" + iMakeCode + "' and mss_stepcode='" + StepCode + "'  and mss_linecode='" + LineCode + "' group by mss_prodcode");
-                        DataTable dt1 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-                        for (int i = 0; i < dt1.Rows.Count; i++)
-                        {
-                            string prodcode = dt1.Rows[i]["mss_prodcode"].ToString();
-                            //本次上料需要扣除的数量
-                            int baseqty = int.Parse(dt1.Rows[i]["baseqty"].ToString());
-                            sql.Clear();
-                            sql.Append("select mss_remain,mss_useqty,mss_id ,mss_barcode from makesourcestock where mss_makecode='" + iMakeCode + "' and ");
-                            sql.Append("mss_stepcode='" + StepCode + "' and mss_prodcode='" + prodcode + "'  and mss_linecode='" + LineCode + "'  and mss_remain >0 order by mss_id  asc");
-                            DataTable dt2 = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
-                            for (int j = 0; i < dt2.Rows.Count; j++)
-                            {
-                                int remain = int.Parse(dt2.Rows[j]["mss_remain"].ToString());
-                                int useqty = int.Parse(dt2.Rows[j]["mss_useqty"].ToString());
-                                string mss_id = dt2.Rows[j]["mss_id"].ToString();
-                                string barcode = dt2.Rows[j]["mss_barcode"].ToString();
-                                //如果可扣数量大于0
-                                if (baseqty > 0)
-                                {
-                                    //并且可扣数量大于剩余数量
-                                    if (baseqty > remain)
-                                    {
-                                        sql.Clear();
-                                        sql.Append("update makesourcestock set mss_useqty=nvl(mss_useqty,0)+mss_remain,mss_remain = 0 where mss_id='" + mss_id + "' ");
-                                        dh.ExecuteSql(sql.ToString(), "update");
-                                        //扣减剩余数量
-                                        baseqty -= remain;
-                                    }
-                                    else if (remain >= baseqty)
-                                    {
-                                        dh.ExecuteSql("update makesourcestock set mss_remain = mss_remain-baseqty where mss_id =" + mss_id, "select");
-                                        baseqty = 0;
-                                    }
-                                }
-                            }
-                        }
-                    }
-                }
-            }
-            //查询批次和批数量
-            int batchqty = 0;
-            string checkno = "";
-            dt = (DataTable)dh.ExecuteSql("select count(ms_checkno) count,ms_checkno from makeserial where ms_checkno=(select ms_checkno from makeserial where ms_sncode='" + iSnCode + "') group by ms_checkno", "select");
-            if (dt.Rows.Count > 0)
-            {
-                batchqty = int.Parse(dt.Rows[0]["count"].ToString());
-                checkno = dt.Rows[0]["ms_checkno"].ToString();
-            }
-            object nextstepcode = dh.getFieldDataByCondition("makecraftdetail", "mcd_nextstepcode", "mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "'");
-            if (iResult.Contains("批次通过") && dt.Rows.Count > 0)
-            {
-                //更新执行的数量
-                sqls.Add("update makecraftdetail set mcd_inqty=mcd_inqty+" + batchqty + ",mcd_outqty = mcd_outqty + " + batchqty + ",mcd_okqty = mcd_okqty + " + batchqty + " where mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "' ");
-                //更新makeSerial 的下一工序
-                sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_nextstepcode='" + nextstepcode.ToString() + "' where ms_checkno='" + checkno + "'");
-            }
-            else
-            {
-                //更新执行的数量
-                sqls.Add("update makecraftdetail set mcd_inqty=mcd_inqty+1,mcd_outqty = mcd_outqty + 1,mcd_okqty = mcd_okqty + 1 where mcd_macode='" + iMakeCode + "' and mcd_stepcode='" + StepCode + "' ");
-                //更新makeSerial 的下一工序
-                sqls.Add("update makeserial set ms_paststep = ms_paststep || '," + StepCode + "',ms_nextstepcode='" + nextstepcode.ToString() + "' where ms_sncode='" + iSnCode + "' and ms_makecode='" + iMakeCode + "'");
-            }
-            //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
-            dh.ExecuteSQLTran(sqls.ToArray());
-            sqls.Clear();
-            //记录操作日志
-            InsertMakeProcess(iSnCode, iMakeCode, iResult, iUserName);
-            //检测下道工序是否存在,不存在 更新状态为已完成
-            if (nextstepcode == null || nextstepcode.ToString() == "")
-            {
-                if (iResult.Contains("批次通过"))
-                {
-                    sqls.Add("update make set ma_madeqty=ma_madeqty+" + batchqty + " where ma_code='" + iMakeCode + "'");
-                    sqls.Add("update makeserial set ms_status=2 where ms_checkno='" + checkno + "'");
-                }
-                else
-                {
-                    sqls.Add("update make set ma_madeqty=ma_madeqty+1  where ma_code='" + iMakeCode + "'");
-                    sqls.Add("update makeserial set ms_status=2 where ms_sncode='" + iSnCode + "'");
-                }
-                dh.ExecuteSQLTran(sqls.ToArray());
-                sqls.Clear();
-            }
-            else
-            {
-                CheckNextStepIfQC(iSnCode, iMakeCode, nextstepcode.ToString(), cr_code, iUserName, out oErrorMessage);
-            }
-            // 将数据插入craftmaterial表
-            SetCollectionFinish(iSnCode, iMakeCode, iUserName, iSourceCode, out oErrorMessage);
-            return true;
+            return SetStepFinish(iMakeCode, iSourceCode, iSnCode, iMPKind, iResult, iUserCode, out oErrorMessage);
         }
 
         /// <summary>

+ 3 - 2
UAS-MES/CustomControl/RichText/RichTextAutoBottom.cs

@@ -14,6 +14,7 @@ namespace UAS_MES.CustomControl.RichText
         public RichTextAutoBottom()
         {
             InitializeComponent();
+            thread = new Thread(PlaySound);
             TextChanged += RichTextBox_TextChange;
         }
 
@@ -35,8 +36,8 @@ namespace UAS_MES.CustomControl.RichText
             //如果颜色是红色则进行提示音
             if (color == Color.Red && Entity.SystemInf.CheckAudioEnable)
             {
-                thread = new Thread(PlaySound);
                 thread.Start();
+                thread = new Thread(PlaySound);
             }
         }
 
@@ -54,8 +55,8 @@ namespace UAS_MES.CustomControl.RichText
             //如果颜色是红色则进行提示音
             if (color == Color.Red && Entity.SystemInf.CheckAudioEnable)
             {
-                thread = new Thread(PlaySound);
                 thread.Start();
+                thread = new Thread(PlaySound);
             }
         }
 

+ 29 - 24
UAS-MES/FunctionCode/Make/Make_TestCollection.cs

@@ -207,7 +207,7 @@ namespace UAS_MES.Make
 
         private void bc_groupcode_SelectedIndexChanged(object sender, EventArgs e)
         {
-            LoadBadCodeListView();
+            LoadBadCodeListView(false);
         }
 
         /// <summary>
@@ -231,29 +231,8 @@ namespace UAS_MES.Make
         /// <summary>
         /// 加载不良代码的ListView的信息
         /// </summary>
-        private void LoadBadCodeListView()
+        private void LoadBadCodeListView(bool Clear)
         {
-            sql.Clear();
-            sql.Append("select nvl(bg_code,mb_bgcode)||':'||nvl(bg_name,mb_badcode) bg_code,nvl(mb_badcode,bc_code) bc_code,mb_badremark from makebad  ");
-            sql.Append("left join badgroup on mb_bgcode=bg_code left join badcode on mb_badcode=bc_code ");
-            sql.Append(" where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "'");
-            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
-            ChoosedRejectList.Items.Clear();
-            ChoosedRejectList.BeginUpdate();
-            for (int i = 0; i < dt.Rows.Count; i++)
-            {
-                if (!WaitList.Contains(dt.Rows[i]["bc_code"].ToString()))
-                {
-                    ListViewItem lvi = new ListViewItem();
-                    //第一列是勾选列,设置列头文本为空
-                    lvi.Text = "";
-                    ChoosedList.Add(dt.Rows[i]["bc_code"].ToString());
-                    for (int j = 0; j < dt.Columns.Count; j++)
-                        lvi.SubItems.Add(dt.Rows[i][j].ToString());
-                    ChoosedRejectList.Items.Add(lvi);
-                }
-            }
-            ChoosedRejectList.EndUpdate();
             object bg_code = bc_groupcode.SelectedValue;
             sql.Clear();
             sql.Append("select bg_code||':'||bg_name bg_code,bc_code,bc_note ");
@@ -279,6 +258,31 @@ namespace UAS_MES.Make
             WaitRejectList.EndUpdate();
         }
 
+        /// <summary>
+        /// 加载已选不良的ListView
+        /// </summary>
+        private void LoadChoosedBadListView()
+        {
+            sql.Clear();
+            sql.Append("select nvl(bg_code,mb_bgcode)||':'||nvl(bg_name,mb_badcode) bg_code,nvl(mb_badcode,bc_code) bc_code,mb_badremark from makebad  ");
+            sql.Append("left join badgroup on mb_bgcode=bg_code left join badcode on mb_badcode=bc_code ");
+            sql.Append(" where mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ma_code.Text + "'");
+            dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
+            ChoosedRejectList.Items.Clear();
+            ChoosedRejectList.BeginUpdate();
+            for (int i = 0; i < dt.Rows.Count; i++)
+            {
+                ListViewItem lvi = new ListViewItem();
+                //第一列是勾选列,设置列头文本为空
+                lvi.Text = "";
+                ChoosedList.Add(dt.Rows[i]["bc_code"].ToString());
+                for (int j = 0; j < dt.Columns.Count; j++)
+                    lvi.SubItems.Add(dt.Rows[i][j].ToString());
+                ChoosedRejectList.Items.Add(lvi);
+            }
+            ChoosedRejectList.EndUpdate();
+        }
+
         /// <summary>
         /// 设置良品或者不良品的采集结果
         /// </summary>
@@ -288,7 +292,8 @@ namespace UAS_MES.Make
             //如果勾选的是不良品
             if (Reject.Checked)
             {
-                LoadBadCodeListView();
+                LoadBadCodeListView(true);
+                LoadChoosedBadListView();
                 OperateResult.AppendText(">>请采集不良代码\n", Color.Green);
                 bc_code.Focus();
                 //勾选了自动产生代码

+ 1 - 0
UAS-MES/FunctionCode/OQC/OQC_PlanMaintain.cs

@@ -130,6 +130,7 @@ namespace UAS_MES.OQC
                     sql.Clear();
                 }
                 OperateResult.AppendText(">>保存配置成功\n", Color.Green);
+                RefreshConfiguration.PerformClick();
             }
             else
                 OperateResult.AppendText(">>送检批次必须为待检验状态\n", Color.Red);

+ 98 - 84
UAS-MES/FunctionCode/OQC/OQC_SamplingDataCollection.Designer.cs

@@ -47,6 +47,7 @@
             this.ob_aqlcode_label = new System.Windows.Forms.Label();
             this.ob_maxngacceptqty_label = new System.Windows.Forms.Label();
             this.ChooseAll = new System.Windows.Forms.CheckBox();
+            this.ob_projectcode_label = new System.Windows.Forms.Label();
             this.ob_maxngacceptqty = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.ob_aqlcode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.ob_projectcode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
@@ -58,9 +59,19 @@
             this.bg_code1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.bg_name1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.WaitChooseDGV = new UAS_MES.CustomControl.DataGrid_View.DataGridViewExpand();
+            this.Column3 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.bg_code = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.bg_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.ob_remark = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.sncode = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
             this.CheckTypeDGV = new UAS_MES.CustomControl.DataGrid_View.DataGridViewExpand();
+            this.choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
+            this.oi_itemcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.oi_ng = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.oi_leveldefect = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.ois_remark = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.ois_status = new System.Windows.Forms.DataGridViewTextBoxColumn();
+            this.ois_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.ChooseedReject = new UAS_MES.CustomControl.ButtonUtil.ArrowRightButton();
             this.WaitReject = new UAS_MES.CustomControl.ButtonUtil.ArrowLeftButton();
             this.oi_checkqty = new UAS_MES.CustomControl.TextBoxWithIcon.EnterTextBox();
@@ -81,16 +92,6 @@
             this.obd_outboxcode_dgv = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.ob_makecode_dgv = new System.Windows.Forms.DataGridViewTextBoxColumn();
             this.obd_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.choose = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.oi_itemcode = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.oi_ng = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.oi_leveldefect = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.ois_remark = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.ois_status = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.ois_id = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.Column3 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
-            this.bg_code = new System.Windows.Forms.DataGridViewTextBoxColumn();
-            this.bg_name = new System.Windows.Forms.DataGridViewTextBoxColumn();
             ((System.ComponentModel.ISupportInitialize)(this.ChoosedDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.WaitChooseDGV)).BeginInit();
             ((System.ComponentModel.ISupportInitialize)(this.CheckTypeDGV)).BeginInit();
@@ -292,6 +293,18 @@
             this.ChooseAll.Text = "全选";
             this.ChooseAll.UseVisualStyleBackColor = true;
             // 
+            // ob_projectcode_label
+            // 
+            this.ob_projectcode_label.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
+            | System.Windows.Forms.AnchorStyles.Right)));
+            this.ob_projectcode_label.AutoSize = true;
+            this.ob_projectcode_label.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
+            this.ob_projectcode_label.Location = new System.Drawing.Point(641, 72);
+            this.ob_projectcode_label.Name = "ob_projectcode_label";
+            this.ob_projectcode_label.Size = new System.Drawing.Size(74, 21);
+            this.ob_projectcode_label.TabIndex = 218;
+            this.ob_projectcode_label.Text = "检验方案";
+            // 
             // ob_maxngacceptqty
             // 
             this.ob_maxngacceptqty.AllPower = null;
@@ -330,16 +343,15 @@
             this.ob_projectcode.BackColor = System.Drawing.Color.White;
             this.ob_projectcode.Enabled = false;
             this.ob_projectcode.ID = null;
-            this.ob_projectcode.Location = new System.Drawing.Point(95, 2);
+            this.ob_projectcode.Location = new System.Drawing.Point(645, 106);
             this.ob_projectcode.Name = "ob_projectcode";
             this.ob_projectcode.Power = null;
-            this.ob_projectcode.Size = new System.Drawing.Size(116, 21);
+            this.ob_projectcode.Size = new System.Drawing.Size(146, 21);
             this.ob_projectcode.Str = null;
             this.ob_projectcode.Str1 = null;
             this.ob_projectcode.Str2 = null;
             this.ob_projectcode.TabIndex = 213;
             this.ob_projectcode.Tag = "NoAuto";
-            this.ob_projectcode.Visible = false;
             // 
             // Clean
             // 
@@ -448,6 +460,28 @@
             this.WaitChooseDGV.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.WaitChooseDGV_DataError);
             this.WaitChooseDGV.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.WaitChooseDGV_RowHeaderMouseClick);
             // 
+            // Column3
+            // 
+            this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.Column3.HeaderText = "勾选";
+            this.Column3.Name = "Column3";
+            this.Column3.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+            this.Column3.Width = 60;
+            // 
+            // bg_code
+            // 
+            this.bg_code.DataPropertyName = "bg_code";
+            this.bg_code.HeaderText = "不良分组";
+            this.bg_code.Name = "bg_code";
+            this.bg_code.Width = 93;
+            // 
+            // bg_name
+            // 
+            this.bg_name.DataPropertyName = "bg_name";
+            this.bg_name.HeaderText = "分组名称";
+            this.bg_name.Name = "bg_name";
+            this.bg_name.Width = 93;
+            // 
             // ob_remark
             // 
             this.ob_remark.AllPower = null;
@@ -502,6 +536,55 @@
             this.CheckTypeDGV.DataError += new System.Windows.Forms.DataGridViewDataErrorEventHandler(this.CheckTypeDGV_DataError);
             this.CheckTypeDGV.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.CheckTypeDGV_RowHeaderMouseClick);
             // 
+            // choose
+            // 
+            this.choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
+            this.choose.DataPropertyName = "choose";
+            this.choose.HeaderText = "勾选";
+            this.choose.Name = "choose";
+            this.choose.Resizable = System.Windows.Forms.DataGridViewTriState.False;
+            this.choose.Width = 60;
+            // 
+            // oi_itemcode
+            // 
+            this.oi_itemcode.DataPropertyName = "oi_checkkind";
+            this.oi_itemcode.HeaderText = "检验类型";
+            this.oi_itemcode.Name = "oi_itemcode";
+            this.oi_itemcode.Width = 78;
+            // 
+            // oi_ng
+            // 
+            this.oi_ng.DataPropertyName = "oi_count";
+            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
+            this.oi_ng.DefaultCellStyle = dataGridViewCellStyle1;
+            this.oi_ng.HeaderText = "样本数量";
+            this.oi_ng.Name = "oi_ng";
+            this.oi_ng.Width = 78;
+            // 
+            // oi_leveldefect
+            // 
+            this.oi_leveldefect.DataPropertyName = "oi_checkedcount";
+            this.oi_leveldefect.HeaderText = "已检数量";
+            this.oi_leveldefect.Name = "oi_leveldefect";
+            this.oi_leveldefect.Width = 78;
+            // 
+            // ois_remark
+            // 
+            this.ois_remark.HeaderText = "";
+            this.ois_remark.Name = "ois_remark";
+            // 
+            // ois_status
+            // 
+            this.ois_status.HeaderText = "";
+            this.ois_status.Name = "ois_status";
+            // 
+            // ois_id
+            // 
+            this.ois_id.DataPropertyName = "ois_id";
+            this.ois_id.HeaderText = "";
+            this.ois_id.Name = "ois_id";
+            this.ois_id.Visible = false;
+            // 
             // ChooseedReject
             // 
             this.ChooseedReject.Image = ((System.Drawing.Image)(resources.GetObject("ChooseedReject.Image")));
@@ -784,82 +867,12 @@
             this.obd_id.Name = "obd_id";
             this.obd_id.Visible = false;
             // 
-            // choose
-            // 
-            this.choose.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.choose.DataPropertyName = "choose";
-            this.choose.HeaderText = "勾选";
-            this.choose.Name = "choose";
-            this.choose.Resizable = System.Windows.Forms.DataGridViewTriState.False;
-            this.choose.Width = 60;
-            // 
-            // oi_itemcode
-            // 
-            this.oi_itemcode.DataPropertyName = "oi_checkkind";
-            this.oi_itemcode.HeaderText = "检验类型";
-            this.oi_itemcode.Name = "oi_itemcode";
-            this.oi_itemcode.Width = 78;
-            // 
-            // oi_ng
-            // 
-            this.oi_ng.DataPropertyName = "oi_count";
-            dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
-            this.oi_ng.DefaultCellStyle = dataGridViewCellStyle1;
-            this.oi_ng.HeaderText = "样本数量";
-            this.oi_ng.Name = "oi_ng";
-            this.oi_ng.Width = 78;
-            // 
-            // oi_leveldefect
-            // 
-            this.oi_leveldefect.DataPropertyName = "oi_checkedcount";
-            this.oi_leveldefect.HeaderText = "已检数量";
-            this.oi_leveldefect.Name = "oi_leveldefect";
-            this.oi_leveldefect.Width = 78;
-            // 
-            // ois_remark
-            // 
-            this.ois_remark.HeaderText = "";
-            this.ois_remark.Name = "ois_remark";
-            // 
-            // ois_status
-            // 
-            this.ois_status.HeaderText = "";
-            this.ois_status.Name = "ois_status";
-            // 
-            // ois_id
-            // 
-            this.ois_id.DataPropertyName = "ois_id";
-            this.ois_id.HeaderText = "";
-            this.ois_id.Name = "ois_id";
-            this.ois_id.Visible = false;
-            // 
-            // Column3
-            // 
-            this.Column3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.None;
-            this.Column3.HeaderText = "勾选";
-            this.Column3.Name = "Column3";
-            this.Column3.Resizable = System.Windows.Forms.DataGridViewTriState.False;
-            this.Column3.Width = 60;
-            // 
-            // bg_code
-            // 
-            this.bg_code.DataPropertyName = "bg_code";
-            this.bg_code.HeaderText = "不良分组";
-            this.bg_code.Name = "bg_code";
-            this.bg_code.Width = 93;
-            // 
-            // bg_name
-            // 
-            this.bg_name.DataPropertyName = "bg_name";
-            this.bg_name.HeaderText = "分组名称";
-            this.bg_name.Name = "bg_name";
-            this.bg_name.Width = 93;
-            // 
             // OQC_SamplingDataCollection
             // 
             this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
             this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
             this.ClientSize = new System.Drawing.Size(1065, 610);
+            this.Controls.Add(this.ob_projectcode_label);
             this.Controls.Add(this.ob_maxngacceptqty);
             this.Controls.Add(this.ob_maxngacceptqty_label);
             this.Controls.Add(this.ob_aqlcode);
@@ -981,5 +994,6 @@
         private System.Windows.Forms.DataGridViewTextBoxColumn ois_remark;
         private System.Windows.Forms.DataGridViewTextBoxColumn ois_status;
         private System.Windows.Forms.DataGridViewTextBoxColumn ois_id;
+        private System.Windows.Forms.Label ob_projectcode_label;
     }
 }

+ 98 - 57
UAS-MES/FunctionCode/OQC/OQC_SamplingDataCollection.cs

@@ -22,6 +22,8 @@ namespace UAS_MES.OQC
         LogStringBuilder sql = new LogStringBuilder();
         string[] LevelDefect = new string[] { "A#A", "B#B", "C#C", "D#D" };
 
+        DataTable TempForCheckType = new DataTable();
+
         public OQC_SamplingDataCollection()
         {
             InitializeComponent();
@@ -47,12 +49,10 @@ namespace UAS_MES.OQC
             if (ErrorMessage == "")
             {
                 BaseUtil.SetFormValue(Controls, dt[0]);
-                BaseUtil.FillExpandDgvWithDataTable(CheckTypeDGV, dt[1], true);
+                GetBatchTypeGridData();
+                dgvr.Clear();
             }
-            else
-            {
-                BaseUtil.CleanForm(this);
-                OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red); }
+            else OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
         }
 
         private void Clean_Click(object sender, EventArgs e)
@@ -64,44 +64,56 @@ namespace UAS_MES.OQC
         {
             if (e.KeyCode == Keys.Enter)
             {
-                //输入的序列号不能为空
-                if (sncode.Text != "")
+                if (CheckSnCode())
+                {
+                    GetBatchTypeGridData();
+                }
+            }
+        }
+
+        private bool CheckSnCode()
+        {
+            //输入的序列号不能为空
+            if (sncode.Text != "")
+            {
+                //判断当前的检验状态
+                if (ob_status.Text == "待检验" || ob_status.Text == "检验中")
                 {
-                    //判断当前的检验状态
-                    if (ob_status.Text == "待检验" || ob_status.Text == "检验中")
+                    dt = (DataTable)dh.ExecuteSql("select obd_sncode,ob_source,ob_makecode from OQCBatchDetail left join OQCBatch  on ob_id=obd_obid where obd_sncode='" + sncode.Text + "'", "select");
+                    if (dt.Rows.Count > 0)
                     {
-                        dt = (DataTable)dh.ExecuteSql("select obd_sncode,ob_source,ob_makecode from OQCBatchDetail left join OQCBatch on ob_id=obd_obid where obd_sncode='" + sncode.Text + "'", "select");
-                        if (dt.Rows.Count > 0)
+                        if (dt.Rows[0]["ob_source"].ToString() != "工序")
                         {
-                            if (dt.Rows[0]["ob_source"].ToString() != "工序")
-                                GetBatchTypeGridData();
-                            else
-                            {
-                                string ErrorMessage = "";
-                                string oMakeCode = "";
-                                string oMsID = "";
-                                bool ifFirst;
-                                if (LogicHandler.CheckStepSNAndMacode(dt.Rows[0]["ob_makecode"].ToString(), User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
-                                    GetBatchTypeGridData();
-                                else
-                                    OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
-                            }
+                            return true;
                         }
                         else
                         {
-                            BaseUtil.CleanForm(this);
-                            OperateResult.AppendText(">>序列号不属于当前抽检批次\n", Color.Red);
+                            string ErrorMessage = "";
+                            string oMakeCode = "";
+                            string oMsID = "";
+                            if (LogicHandler.CheckStepSNAndMacode(dt.Rows[0]["ob_makecode"].ToString(), User.UserSourceCode, sncode.Text, User.UserCode, out oMakeCode, out oMsID, out ErrorMessage))
+                            {
+                                return true;
+                            }
+                            else {
+                                OperateResult.AppendText(">>" + ErrorMessage + "\n", Color.Red);
+                                return false;
+                            }
                         }
                     }
-                    else
-                    {
-                        BaseUtil.CleanForm(this);
-                        OperateResult.AppendText(">>送检批次必须是待检验或者检验中\n", Color.Red);
+                    else {
+                        OperateResult.AppendText(">>序列号"+sncode.Text+"不属于当前抽检批次\n", Color.Red);
+                        return false;
                     }
                 }
                 else {
-                    BaseUtil.CleanForm(this);
-                    OperateResult.AppendText(">>输入的内容不能为空\n", Color.Red); }
+                    OperateResult.AppendText(">>送检批次必须是待检验或者检验中\n", Color.Red);
+                    return false;
+                }
+            }
+            else {
+                OperateResult.AppendText(">>序列号不能为空\n", Color.Red);
+                return false;
             }
         }
 
@@ -122,9 +134,17 @@ namespace UAS_MES.OQC
             //只能操作检验中或者待检验的批次
             if (ob_status.Text == "待检验" || ob_status.Text == "检验中")
             {
+                if (!CheckSnCode())
+                    return;
                 //判断检验项是否勾选,如勾选取出明细数据
-                DataTable UpdateData = BaseUtil.DGVIfChecked(CheckTypeDGV);
-                if (UpdateData != null)
+                for (int i = TempForCheckType.Rows.Count - 1; i >= 0; i--)
+                {
+                    if (TempForCheckType.Rows[i][0].ToString() == "False")
+                    {
+                        TempForCheckType.Rows.RemoveAt(i);
+                    }
+                }
+                if (TempForCheckType != null && TempForCheckType.Rows.Count>0)
                 {
                     //用于存放更新的数据
                     List<string> ois_ifng_update = new List<string>();
@@ -136,22 +156,23 @@ namespace UAS_MES.OQC
                     List<string> ois_defectlevel_insert = new List<string>();
                     List<string> ois_remark_insert = new List<string>();
                     List<string> oi_itemcode_insert = new List<string>();
-                    for (int i = 0; i < UpdateData.Rows.Count; i++)
+                    for (int i = 0; i < TempForCheckType.Rows.Count; i++)
                     {
                         //将布尔值转换为0,-1
-                        if (UpdateData.Rows[i]["ois_id"].ToString() != "" && UpdateData.Rows[i]["ois_id"].ToString() != "0")
+                        Console.WriteLine(TempForCheckType.Rows[i]["ois_id"].ToString());
+                        if (TempForCheckType.Rows[i]["ois_id"].ToString() != "" && TempForCheckType.Rows[i]["ois_id"].ToString() != "0")
                         {
-                            ois_ifng_update.Add(UpdateData.Rows[i]["oi_ng"].ToString() == "True" ? "-1" : "0");
-                            ois_defectlevel_update.Add(UpdateData.Rows[i]["oi_leveldefect"].ToString());
-                            ois_remark_update.Add(UpdateData.Rows[i]["ois_remark"].ToString());
-                            ois_id_update.Add(UpdateData.Rows[i]["ois_id"].ToString());
+                            ois_ifng_update.Add(TempForCheckType.Rows[i]["oi_ng"].ToString() == "True" ? "-1" : "0");
+                            ois_defectlevel_update.Add(TempForCheckType.Rows[i]["oi_leveldefect"].ToString());
+                            ois_remark_update.Add(TempForCheckType.Rows[i]["ois_remark"].ToString());
+                            ois_id_update.Add(TempForCheckType.Rows[i]["ois_id"].ToString());
                         }
                         else
                         {
-                            oi_itemcode_insert.Add(UpdateData.Rows[i]["oi_itemcode"].ToString());
-                            ois_ifng_insert.Add(UpdateData.Rows[i]["oi_ng"].ToString() == "True" ? "-1" : "0");
-                            ois_defectlevel_insert.Add(UpdateData.Rows[i]["oi_leveldefect"].ToString());
-                            ois_remark_insert.Add(UpdateData.Rows[i]["ois_remark"].ToString());
+                            oi_itemcode_insert.Add(TempForCheckType.Rows[i]["oi_itemcode"].ToString());
+                            ois_ifng_insert.Add(TempForCheckType.Rows[i]["oi_ng"].ToString() == "True" ? "-1" : "0");
+                            ois_defectlevel_insert.Add(TempForCheckType.Rows[i]["oi_leveldefect"].ToString());
+                            ois_remark_insert.Add(TempForCheckType.Rows[i]["ois_remark"].ToString());
                         }
                     }
                     //判断是否含不通过的内容
@@ -161,6 +182,11 @@ namespace UAS_MES.OQC
                         if (ois_ifng_insert[i] == "-1")
                             AllPass = false;
                     }
+                    for (int i = 0; i < ois_ifng_update.Count; i++)
+                    {
+                        if (ois_ifng_update[i] == "-1")
+                            AllPass = false;
+                    }
                     if (ChoosedDGV.RowCount > 0 || AllPass)
                     {
                         //执行批量更新的SQL
@@ -169,13 +195,13 @@ namespace UAS_MES.OQC
                             dh.BatchInsert("update OQCItemSamples set ois_ifng=:ois_ifng,ois_defectlevel=:ois_defectlevel,ois_remark=:ois_remark where ois_id=:ois_id",
                          new string[] { "ois_ifng", "ois_defectlevel", "ois_remark", "ois_id" }, ois_ifng_update.ToArray(), ois_defectlevel_update.ToArray(), ois_remark_update.ToArray(), ois_id_update.ToArray());
                         }
-                        //如果主键为空,并且存在需要插入的数据则执行插入操作
+                        //如果主键为空,并且存在需要插入的数据则执行插入操作 
                         if (oi_itemcode_insert.Count > 0)
                         {
                             sql.Clear();
                             sql.Append("insert into OQCItemSamples (ois_id,ois_checkno,ois_makecode, ois_sncode,ois_projectcode,ois_itemcode,");
                             sql.Append("ois_ifng,ois_defectlevel,ois_remark)values(OQCItemSamples_SEQ.nextval,'" + ob_checkno.Text + "',");
-                            sql.Append("'" + ob_makecode.Text + "','" + sncode.Text + "','',:ois_itemcode,:ois_ifng,:ois_defectlevel,:ois_remark)");
+                            sql.Append("'" + ob_makecode.Text + "','" + sncode.Text + "','" + ob_projectcode.Text + "',:ois_itemcode,:ois_ifng,:ois_defectlevel,:ois_remark)");
                             dh.BatchInsert(sql.GetString(), new string[] { "ois_itemcode", "ois_ifng", "ois_defectlevel", "ois_remark" },
                                 oi_itemcode_insert.ToArray(), ois_ifng_insert.ToArray(), ois_defectlevel_insert.ToArray(), ois_remark_insert.ToArray());
                         }
@@ -200,10 +226,12 @@ namespace UAS_MES.OQC
                         //更新检验状态,如果是待检验的更新为检验中
                         dh.ExecuteSql("update OQCBatch set ob_status='CHECKING' where ob_checkno='" + ob_checkno.Text + "' and ob_status='UNCHECK'", "update");
                         //更新批次中的合格数不合格数:用抽检批检验项目表获取最大的抽检数和不合格数
-                        dh.ExecuteSql("update OQCBATCH set (ob_ngqty,ob_okqty)=(select nvl(max(oi_ngqty), 0), max(oi_checkqty) - nvl(max(oi_ngqty), 0) from OQCItems where oi_checkno ='" + ob_checkno.Text + "') where ob_checkno ='" + ob_checkno.Text + "'", "update");
+                        dh.ExecuteSql("update OQCBATCH set (ob_ngqty,ob_okqty)=(select nvl(max(oi_ngqty),0),max(oi_checkqty)-nvl(max(oi_ngqty),0) from OQCItems where oi_checkno ='" + ob_checkno.Text + "') where ob_checkno ='" + ob_checkno.Text + "'", "update");
                         OperateResult.AppendText(">>操作成功\n", Color.Green);
+                        GetBatchTypeGridData();
+                        TempForCheckType.Clear();
                     }
-                    else OperateResult.AppendText(">>请勾选不良明细\n", Color.Red);
+                    else OperateResult.AppendText(">>含有未通过项请勾选不良明细\n", Color.Red);
                 }
                 else OperateResult.AppendText(">>请勾选送检明细\n", Color.Red);
             }
@@ -230,7 +258,7 @@ namespace UAS_MES.OQC
                     string ErrorMessage;
                     LogicHandler.UpdateMakeMessage(ms_sncode.Text, ob_makecode.Text, "OQC批判过", User.UserSourceCode, User.UserName, "批次通过", out ErrorMessage);
                     //记录操作日志
-                    LogicHandler.InsertMakeProcess(ms_sncode.Text, ob_makecode.Text,User.UserSourceCode, "批结果判定", "批次通过", User.UserName);
+                    LogicHandler.InsertMakeProcess(ms_sncode.Text, ob_makecode.Text, User.UserSourceCode, "批结果判定", "批次通过", User.UserName);
                     GetBatch.PerformClick();
                     OperateResult.AppendText(">>通过批成功\n", Color.Green);
                 }
@@ -290,11 +318,13 @@ namespace UAS_MES.OQC
         {
             if (!dgvr.Contains(CheckTypeDGV.Rows[e.RowIndex]))
             {
+                string checkkind = CheckTypeDGV.Rows[e.RowIndex].Cells["oi_itemcode"].Value.ToString();
                 sql.Clear();
-                sql.Append("select ois_sncode,nvl(ois_id,0) ois_id ,oi_itemcode ,nvl(ois_ifng,1) oi_ng,nvl(ois_defectlevel,'-1')");
+                sql.Append("select oi_checkkind,ois_sncode,nvl(ois_id,0) ois_id ,oi_itemcode ,nvl(ois_ifng,0) oi_ng,nvl(ois_defectlevel,'-1')");
                 sql.Append("oi_leveldefect,ois_remark,case ois_id when 0 then '未检验' else '已检验' end ois_status from OQCItems ");
                 sql.Append("left join OQCItemSamples on  ois_sncode='" + sncode.Text + "' and ois_checkno=oi_checkno and ");
-                sql.Append("ois_itemcode=oi_itemcode and ois_projectcode = oi_projectcode where oi_checkno ='" + ob_checkno.Text + "'");
+                sql.Append("ois_itemcode=oi_itemcode and ois_projectcode = oi_projectcode where oi_checkno ='" + ob_checkno.Text + "' ");
+                sql.Append("and oi_checkkind='" + checkkind + "'");
                 DataTable dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                 DataGridViewRow headerRow = new DataGridViewRow();
 
@@ -331,6 +361,7 @@ namespace UAS_MES.OQC
                     //标记展开的子行
                     dataRow.Tag = "SonRow";
                     DataGridViewCheckBoxCell checkcell = new DataGridViewCheckBoxCell();
+                    checkcell.Tag = "SonRow";
                     dataRow.Cells.Add(checkcell);
 
                     textcell = new DataGridViewTextBoxCell();
@@ -418,8 +449,22 @@ namespace UAS_MES.OQC
         //如果当前行的Cell有修改过就将CheckBox勾选上
         private void CheckTypeDGV_CellValueChanged(object sender, DataGridViewCellEventArgs e)
         {
-            if (e.RowIndex > 0)
+            if (e.RowIndex > 0 && e.ColumnIndex > 0)
                 CheckTypeDGV.Rows[e.RowIndex].Cells[0].Value = true;
+            try
+            {
+                if (e.ColumnIndex == 0)
+                {
+                    if (CheckTypeDGV.Rows[e.RowIndex].Cells[0].Tag != null)
+                    {
+                        if (CheckTypeDGV.Rows[e.RowIndex].Cells[0].Tag.ToString() == "SonRow")
+                            BaseUtil.GetExpandDGVCheckedRow(CheckTypeDGV, TempForCheckType, e.RowIndex, 1);
+                    }
+                }
+            }
+            catch (Exception)
+            {
+            }
         }
 
         private void WaitChooseDGV_DataError(object sender, DataGridViewDataErrorEventArgs e) { }
@@ -432,6 +477,7 @@ namespace UAS_MES.OQC
         private void CheckTypeDGV_CellContentClick(object sender, DataGridViewCellEventArgs e)
         {
             BaseUtil.ExpandDGVCheck(CheckTypeDGV, e);
+
         }
 
         private void bccode_KeyDown(object sender, KeyEventArgs e)
@@ -468,11 +514,6 @@ namespace UAS_MES.OQC
             }
         }
 
-        private void ChooseAll_CheckedChanged(object sender, EventArgs e)
-        {
-
-        }
-
         private void obd_outboxcode_KeyDown(object sender, KeyEventArgs e)
         {
             if (e.KeyCode == Keys.Enter)

+ 28 - 4
UAS-MES/PublicMethod/BaseUtil.cs

@@ -150,7 +150,6 @@ namespace UAS_MES.PublicMethod
                                 {
                                     if (controlName.ToUpper() == dt.Columns[k].Caption.ToUpper())
                                     {
-                                        Console.WriteLine(controlName);
                                         collection[i].Controls[j].Text = dt.Rows[0][k].ToString();
                                     }
                                 }
@@ -786,10 +785,8 @@ namespace UAS_MES.PublicMethod
                         if (dgv.Rows[i].Tag.ToString() == "SonRow")
                         {
                             DataRow dr = dt.NewRow();
-
                             for (int j = 1; j < dgv.ColumnCount; j++)
                             {
-                                Console.WriteLine(dgv.Rows[i].Cells[j].FormattedValue);
                                 dr[dgv.Columns[j].Name] = dgv.Rows[i].Cells[j].FormattedValue;
                             }
                             dt.Rows.Add(dr);
@@ -804,6 +801,34 @@ namespace UAS_MES.PublicMethod
             return dt;
         }
 
+        public static void GetExpandDGVCheckedRow(DataGridView dgv, DataTable dt, int RowIndex, int DistinctColumnIndex)
+        {
+            //第一列是勾选框,排除在循环之外
+            if (dt.Columns.Count == 0)
+            {
+                for (int i = 0; i < dgv.Columns.Count; i++)
+                {
+                    dt.Columns.Add(dgv.Columns[i].Name);
+                }
+            }
+            //是展开的子行的数据
+            if (dgv.Rows[RowIndex].Tag != null && dgv.Rows[RowIndex].Tag.ToString() == "SonRow")
+            {
+                DataRow dr = dt.NewRow();
+                DataRow[] datarow = (dt.Select(dgv.Columns[DistinctColumnIndex].Name + " ='" + dgv.Rows[RowIndex].Cells[DistinctColumnIndex].FormattedValue + "'"));
+                //判断值是否存在,存在移除重新添加
+                if (datarow.Length > 0)
+                {
+                    dt.Rows.Remove(datarow[0]);
+                }
+                for (int j = 0; j < dgv.ColumnCount; j++)
+                {
+                    dr[dgv.Columns[j].Name] = dgv.Rows[RowIndex].Cells[j].FormattedValue;
+                }
+                dt.Rows.Add(dr);
+            }
+        }
+
         /// <summary>
         /// 设置只允许输入数字
         /// </summary>
@@ -837,7 +862,6 @@ namespace UAS_MES.PublicMethod
         {
             //获取筛选条件中的列名,值
             DataRow[] dataRows = dt.Select(condition);
-            Console.WriteLine(dataRows.Length + "");
             DataTable ndt = dt.Clone();
             for (int i = 0; i < dataRows.Length; i++)
             {

+ 9 - 8
UAS-MES/PublicMethod/LogicHandler.cs

@@ -898,7 +898,7 @@ namespace UAS_MES.PublicMethod
                     dh.ExecuteSql(sql.ToString(), "update");
                     //查询Form数据
                     sql.Clear();
-                    sql.Append("select ob_id,ob_makecode,ob_status,ob_prodcode,(select  max(oi_checkqty) oi_checkqty from OQCItems where oi_checkno='" + iCheckNo + "'),");
+                    sql.Append("select ob_id,ob_makecode,ob_status,ob_prodcode,(select max(oi_checkqty)from OQCItems where oi_checkno='" + iCheckNo + "') oi_checkqty,");
                     sql.Append("ob_batchqty,nvl(ob_okqty,0) ob_okqty,nvl(ob_ngqty,0) ob_ngqty,ob_maxngacceptqty,ob_source,ob_checkno,ob_result from OQCBatch where ob_checkno='" + iCheckNo + "'");
                     Form = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
                     if (Form.Rows.Count == 0)
@@ -922,15 +922,17 @@ namespace UAS_MES.PublicMethod
         /// <param name="iUserName"></param>
         public static void InsertMakeProcess(string iSnCode, string iMakeCode,string iSourceCode, string iMPKind, string result, string iUserName)
         {
-            string CurrentStep = GetStepCodeBySource(iSourceCode);
+            string CurrentStep = "";
+            string LineCode = "";
+            string CurrentStepName = "";
+            GetStepCodeAndNameAndLineBySource(iSourceCode,ref CurrentStep,ref CurrentStepName ,ref LineCode);
             sql.Clear();
             sql.Append("insert into MakeProcess(mp_id,mp_makecode,mp_maid, mp_mscode,mp_sncode,mp_stepcode,mp_stepname,");
-            sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode) ");
+            sql.Append("mp_craftcode,mp_craftname,mp_kind,mp_result,mp_indate,mp_inman,mp_wccode,mp_linecode,mp_sourcecode,mp_snstatus,mp_sncheckno,mp_snoutboxcode)");
             sql.Append("select MakeProcess_seq.nextval, ma_code,ma_id,ms_code,ms_sncode,mcd_stepcode,mcd_stepname,");
-            sql.Append("ma_craftcode,ma_craftname,'" + iMPKind + "','" + result + "',sysdate,'" + iUserName + "',ma_wccode,ma_linecode,'"+ iSourceCode + "'");
-            sql.Append("from make left join makecraftdetail on mcd_macode=ma_code left join makeserial on ms_makecode=ma_code ");
+            sql.Append("ma_craftcode,ma_craftname,'" + iMPKind + "','" + result + "',sysdate,'" + iUserName + "',ma_wccode,'"+ LineCode + "','"+ iSourceCode + "',");
+            sql.Append("ms_status,ms_checkno,ms_outboxcode from make left join makecraftdetail on mcd_macode=ma_code left join makeserial on ms_makecode=ma_code ");
             sql.Append("where ms_sncode='" + iSnCode + "' and ma_code='" + iMakeCode + "' and mcd_stepcode='"+ CurrentStep + "'");
-            //插入makeprocess 
             dh.ExecuteSql(sql.ToString(), "insert");
             sql.Clear();
         }
@@ -1098,10 +1100,9 @@ namespace UAS_MES.PublicMethod
             sql.Append("sp_mothercode=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + iSnCode + "'");
             dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "bg_code", "bc_remark" }, iBadCode, iBadGroupCode, iBadRemark);
             //更新序列号已经采集的工序 ms_paststep 已采集数据,更新下一工序
-            dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + StepCode + "'", "ms_sncode='" + iSnCode + "'");
+            dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + StepCode + "',ms_status=3", "ms_sncode='" + iSnCode + "'");
             //判断当前采集点是否为扣料工序cd_ifreduce =-1 则为扣料工序
             //之前保存的不良就不再调用
-            Console.WriteLine("ms_status"+ ms_status);
             if (ms_status != "3")
                 SetStepFinish(iMakeCode, iSourceCode, iSnCode, "不良采集", iResult, iUserCode, out oErrorMessage);
             return true;

+ 1 - 1
UAS-MES/UAS-MES.csproj

@@ -41,7 +41,7 @@
     <MinimumRequiredVersion>1.0.0.201</MinimumRequiredVersion>
     <CreateWebPageOnPublish>true</CreateWebPageOnPublish>
     <WebPage>publish.htm</WebPage>
-    <ApplicationRevision>231</ApplicationRevision>
+    <ApplicationRevision>237</ApplicationRevision>
     <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
     <UseApplicationTrust>true</UseApplicationTrust>
     <CreateDesktopShortcut>true</CreateDesktopShortcut>