Эх сурвалжийг харах

调整数据库链接重置

章政 6 жил өмнө
parent
commit
034b48aa4a

+ 49 - 38
UAS-出货标签管理(吉利通)/PublicMethod/DataHelper.cs

@@ -853,7 +853,9 @@ namespace UAS_LabelMachine
                     }
                     catch (Exception)
                     {
-                        command.Connection = new OracleConnection(DBConnectionString);
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
                         result = new DataTable();
                         OracleDataAdapter ad = new OracleDataAdapter(command);
                         ad.Fill((DataTable)result);
@@ -862,13 +864,43 @@ namespace UAS_LabelMachine
                     //成功执行后将重复连接数置为0
                     break;
                 case "DELETE":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
+                        command.ExecuteNonQuery();
+                    }
                     break;
                 case "UPDATE":
-                    result = command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
+                        command.ExecuteNonQuery();
+                    }
                     break;
                 case "INSERT":
-                    command.ExecuteNonQuery();
+                    try
+                    {
+                        result = command.ExecuteNonQuery();
+                    }
+                    catch (Exception)
+                    {
+                        connection = new OracleConnection(DBConnectionString);
+                        connection.Open();
+                        command.Connection = connection;
+                        command.ExecuteNonQuery();
+                    }
                     break;
             }
 
@@ -876,31 +908,6 @@ namespace UAS_LabelMachine
             return result;
         }
 
-        /// <summary>
-        /// 为了同步BS端的条码维护,检测时允许问号的存在,在检测时默认将问号换成:Param参数
-        /// </summary>
-        /// <param name="SQL"></param>
-        public bool CheckSQL(string SQL, out string ErrorMessage)
-        {
-            ErrorMessage = "";
-            try
-            {
-                SQL = SQL.Replace("?", ":Param");
-                command = new OracleCommand(SQL, connection);
-                command.ExecuteNonQuery();
-                command.Dispose();
-                return true;
-            }
-            catch (Exception e)
-            {
-                command.Dispose();
-                ErrorMessage = e.Message;
-                return false;
-            }
-        }
-
-
-
         public int GetDistinctRowCount(string TableName, string Field)
         {
             DataTable dt = new DataTable();
@@ -992,8 +999,9 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                command.Connection = new OracleConnection(DBConnectionString);
-                command.Connection.Open();
+                connection= new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
                 command.ExecuteNonQuery();
             }
             command.Dispose();
@@ -1131,13 +1139,14 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                command.Connection = new OracleConnection(DBConnectionString);
-                command.Connection.Open();
+                connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
                 command.ExecuteNonQuery();
             }
             command.Dispose();
         }
-
+        int count = 0;
         /// <summary>
         /// 调用存储过程
         /// </summary>
@@ -1157,8 +1166,9 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                command.Connection = new OracleConnection(DBConnectionString);
-                command.Connection.Open();
+                connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
                 command.ExecuteNonQuery();
             }
             for (int i = 0; i < command.Parameters.Count; i++)
@@ -1185,8 +1195,9 @@ namespace UAS_LabelMachine
             }
             catch (Exception)
             {
-                command.Connection = new OracleConnection(DBConnectionString);
-                command.Connection.Open();
+                 connection = new OracleConnection(DBConnectionString);
+                connection.Open();
+                command.Connection = connection;
                 command.ExecuteNonQuery();
             }
             command.Dispose();

+ 3 - 2
UAS-出货标签管理(吉利通)/UAS_出货标签管理.cs

@@ -617,7 +617,7 @@ namespace UAS_LabelMachine
             MessageLog.AppendText(msg + "\n");
             string[] msgArr = msg.Split(back_sg_separator.Text.ToCharArray());
             //如果包含则分隔符则需要解析,如果不包含则直接前端解析
-            if (msg.Contains(back_sg_separator.Text))
+            if (!cu_print_checkonly.Checked)
             {
                 //需要校验2项数据,完成校验后此项的值需要为2则表示校验成功
                 List<string> CheckItem = new List<string>();
@@ -1706,7 +1706,7 @@ namespace UAS_LabelMachine
                     }
                     if (LabelInf.Rows[e.RowIndex].Cells["pib_ifrecheck"].FormattedValue.ToString() == "True")
                     {
-                        if (LabelInf.Columns[e.ColumnIndex].Name == "pib_custbarcode")
+                        if (LabelInf.Columns[e.ColumnIndex].Name == "pib_barcode")
                         {
                             SolidBrush solidBrush = new SolidBrush(Color.FromArgb(51, 153, 255));
                             e.Graphics.FillRectangle(Brushes.CadetBlue, e.CellBounds);
@@ -2298,6 +2298,7 @@ namespace UAS_LabelMachine
             {
                 dh.ExecuteSql("delete from prodiobarcode  where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
                 adh.ExecuteSql("delete from prodiobarcode  where pib_inoutno='" + pi_inoutno.Text + "'", "delete");
+                LoadGridData();
             }
         }