public static void EndConnection() { try { if (SQLSConnection.State == ConnectionState.Open) { SQLSConnection.Close(); } } catch (Exception) { throw; } }
public static void BeginTransaction() { try { ValidateConnection(); SQLSConnection.Open(); SQLSTransaction = SQLSConnection.BeginTransaction(); } catch (Exception) { EndConnection(); throw; } }
public static SqlConnection BeginConnection() { try { ValidateConnection(); SQLSConnection.Open(); return(SQLSConnection); } catch (Exception e) { EndConnection(); throw; } }
public static void RollBackTransaction() { try { if (SQLSTransaction != null) { SQLSTransaction.Rollback(); SQLSConnection.Close(); SQLSTransaction = null; } } catch (Exception) { EndConnection(); throw; } }
public static void CommitTransaction() { try { if (SQLSTransaction != null) { SQLSTransaction.Commit(); SQLSConnection.Close(); SQLSTransaction = null; } } catch (Exception) { EndConnection(); throw; } }
public static SqlCommand AsignProcedure(string procedureName) { try { SqlCommand _command; _command = SQLSConnection.CreateCommand(); _command.CommandText = procedureName; _command.Connection = SQLSConnection; _command.CommandTimeout = SQLSConnection.ConnectionTimeout; _command.CommandType = CommandType.StoredProcedure; return(_command); } catch (Exception) { EndConnection(); throw; } }