浏览代码

良品采集成不良时对Steppassed
表进行修改

章政 8 年之前
父节点
当前提交
81a1886cce
共有 2 个文件被更改,包括 19 次插入8 次删除
  1. 18 8
      UAS-MES/DataOperate/DataHelper.cs
  2. 1 0
      UAS-MES/FunctionCode/Make/Make_TestCollection.cs

+ 18 - 8
UAS-MES/DataOperate/DataHelper.cs

@@ -17,8 +17,7 @@ namespace UAS_MES.DataOperate
         //用户选择的数据库的连接字符串
         public static string DBConnectionString;
         public static OracleConnection connection = null;
-        OracleCommand command = null;
-        int ReconnectTime = 0;
+        OracleCommand command = new OracleCommand();
         /// <summary>
         /// 执行构造函数的时候打开数据库的链接
         /// </summary>
@@ -32,11 +31,20 @@ namespace UAS_MES.DataOperate
                 else
                     connection = new OracleConnection(DBConnectionString);
                 connection.Open();
-                command = new OracleCommand();
                 command.Connection = connection;
                 command.CommandTimeout = 0;
             }
-            catch (Exception e) { LogManager.DoLog(e.Message); }
+            catch (Exception e)
+            {
+                if (DBConnectionString == null || DBConnectionString == ConnectionStrings)
+                    connection = new OracleConnection(ConnectionStrings);
+                else
+                    connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
+                command.CommandTimeout = 0;
+                LogManager.DoLog(e.Message);
+            }
         }
 
         /// <summary>
@@ -417,7 +425,7 @@ namespace UAS_MES.DataOperate
             ad.UpdateCommand = command;
             ad.Update(DataTable);
             ad.Dispose();
-           
+
         }
 
         /// <summary>
@@ -898,7 +906,7 @@ namespace UAS_MES.DataOperate
             }
             for (int i = 0; i < command.Parameters.Count; i++)
                 param[i] = command.Parameters[i].Value.ToString();
-            
+
         }
 
         /// <summary>
@@ -1048,8 +1056,10 @@ namespace UAS_MES.DataOperate
 
         public void Dispose()
         {
-            command.Dispose();
-            connection.Dispose();
+            if (command != null)
+                command.Dispose();
+            if (connection != null)
+                connection.Dispose();
         }
 
         private void Reconnect(OracleCommand cmd)

+ 1 - 0
UAS-MES/FunctionCode/Make/Make_TestCollection.cs

@@ -447,6 +447,7 @@ namespace UAS_MES.Make
                     string status = dt.Rows[0]["ms_status"].ToString();
                     if (status == "1" || status == "2")
                     {
+                        dh.UpdateByCondition("steppassed", "sp_result='不良品',sp_ifng=-1,sp_ymd=to_char(sysdate,'yyyymmdd'),sp_hm=to_char(sysdate,'hh24miss')", "sp_id=(select max(sp_id) from steppassed where sp_sncode='"+ms_sncode.Text+"')");
                         dh.UpdateByCondition("makecraftdetail", "mcd_okqty=mcd_okqty-1", "mcd_macode='" + ma_code.Text + "' and mcd_stepcode='" + User.CurrentStepCode + "'");
                         dh.UpdateByCondition("makeserial", "ms_nextstepcode=''", "ms_sncode='" + ms_sncode.Text + "'");
                         LogicHandler.DoCommandLog(User.UserCode, ma_code.Text, User.UserLineCode, User.UserSourceCode, "采集不良", "采集不良成功", ms_sncode.Text, ob_checkno.Text);