public int Insert() { SqlConnection connection = new SqlConnection(SPHelper.GetConnectionString()); try { connection.Open(); SqlTransaction trans = null; try { trans = connection.BeginTransaction(); Insert(trans); trans.Commit(); } catch (Exception) { if (trans != null) { trans.Rollback(); } throw; } } finally { connection.Close(); } return(ID); }
public static void Delete(int id) { SqlConnection connection = new SqlConnection(SPHelper.GetConnectionString()); try { connection.Open(); SqlTransaction trans = null; try { trans = connection.BeginTransaction(); Delete(trans, id); trans.Commit(); } catch (Exception) { if (trans != null) { trans.Rollback(); } throw; } } finally { connection.Close(); } }
public void Update() { SqlConnection connection = new SqlConnection(SPHelper.GetConnectionString()); try { connection.Open(); SqlTransaction trans = null; try { trans = connection.BeginTransaction(); this.Update(trans); trans.Commit(); } catch (Exception e) { trans.Rollback(); throw (e); } } finally { connection.Close(); } }
public static IEnumerable <Post> GetPosts(Post postFilter) { IEnumerable <Post> posts; SqlConnection connection = new SqlConnection(SPHelper.GetConnectionString()); try { connection.Open(); SqlTransaction trans = null; try { trans = connection.BeginTransaction(); posts = GetPosts(trans, postFilter); trans.Commit(); } catch (Exception) { if (trans != null) { trans.Rollback(); } throw; } } finally { connection.Close(); } return(posts); }
public static List <DocumentFile> GetList(int documentID) { List <DocumentFile> list; SqlConnection connection = new SqlConnection(SPHelper.GetConnectionString()); try { connection.Open(); SqlTransaction trans = null; try { trans = connection.BeginTransaction(); list = GetList(trans, documentID); trans.Commit(); } catch (Exception) { if (trans != null) { trans.Rollback(); } throw; } } finally { connection.Close(); } return(list); }
public static void Replace(int organizationId, int toOrganizationId) { SqlConnection connection = new SqlConnection(SPHelper.GetConnectionString()); try { connection.Open(); SqlTransaction trans = null; try { trans = connection.BeginTransaction(); Replace(trans, organizationId, toOrganizationId); trans.Commit(); } catch (Exception) { if (trans != null) { trans.Rollback(); } throw; } } finally { connection.Close(); } }
public static bool IsExist(int documentId, int departmentId) { bool result = false; SqlConnection connection = new SqlConnection(SPHelper.GetConnectionString()); try { connection.Open(); SqlTransaction trans = null; try { trans = connection.BeginTransaction(); result = IsExist(trans, documentId, departmentId); trans.Commit(); } catch (Exception) { if (trans != null) { trans.Rollback(); } throw; } } finally { connection.Close(); } return(result); }