Exemplo n.º 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="databaseHelper"></param>
        /// <param name="user"></param>
        /// <param name="oldPassword"></param>
        /// <param name="newPassword"></param>
        public void NewPassword(DAODatabaseHelper databaseHelper, string user, string oldPassword, string newPassword)
        {
            this.BeginTransaction();
            System.Data.Common.DbCommand TempCommand_2 = databaseHelper.CreateCommand();
            TempCommand_2.CommandText = String.Format("ALTER LOGIN [{0}] WITH PASSWORD=N'{1}'", user, newPassword);
            TempCommand_2.CommandType = System.Data.CommandType.Text;
            TempCommand_2.Transaction = TransactionManager.GetTransaction(databaseHelper.Connection);
            DbCommand command = TempCommand_2;

            command.ExecuteNonQuery();
            this.CommitTransaction();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a new connection and opens it using the provided connection string.
        /// </summary>
        /// <param name="connectionString">The connection string with the information to connect to a database.</param>
        /// <returns>The newly created DBConnection object.</returns>
        protected DAODatabaseHelper Open(String connectionString)
        {
            DbConnection cn = factory.CreateConnection();

            //cn.ConnectionString = connectionString + Credentials; //SQL
            cn.ConnectionString = connectionString;             //Access
            cn.Open();
            cn.StateChange += new System.Data.StateChangeEventHandler(result_StateChange);
            DAODatabaseHelper daodb = new DAODatabaseHelper(cn);

            connections.Add(daodb);
            return(daodb);
        }
Exemplo n.º 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="databaseHelper"></param>
        /// <param name="OldGroup"></param>
        /// <param name="NewGroup"></param>
        /// <param name="user"></param>
        public void UpdateRole(DAODatabaseHelper databaseHelper, string OldGroup, string NewGroup, string user)
        {
            System.Data.Common.DbCommand TempCommand_2 = databaseHelper.CreateCommand();
            TempCommand_2.CommandText = String.Format("exec sp_droprolemember '{0}', '{1}'", OldGroup, user);
            TempCommand_2.CommandType = System.Data.CommandType.Text;
            TempCommand_2.Transaction = TransactionManager.GetTransaction(databaseHelper.Connection);
            DbCommand command = TempCommand_2;

            command.ExecuteNonQuery();
            TempCommand_2             = databaseHelper.CreateCommand();
            TempCommand_2.CommandText = String.Format("exec sp_addrolemember '{0}', '{1}'", NewGroup, user);
            command = TempCommand_2;
            command.ExecuteNonQuery();
        }
Exemplo n.º 4
0
/// <summary>
        ///
        /// </summary>
        /// <param name="databaseHelper"></param>
        /// <param name="Username"></param>
        public void DeleteUser(DAODatabaseHelper databaseHelper, string Username)
        {
            System.Data.Common.DbCommand TempCommand_2 = databaseHelper.CreateCommand();
            TempCommand_2.CommandText = String.Format("DROP USER {0}", Username);
            TempCommand_2.CommandType = System.Data.CommandType.Text;
            TempCommand_2.Transaction = TransactionManager.GetTransaction(databaseHelper.Connection);
            DbCommand command = TempCommand_2;

            command.ExecuteNonQuery();
            TempCommand_2             = databaseHelper.CreateCommand();
            TempCommand_2.CommandText = String.Format("DROP Login {0}", Username);
            command = TempCommand_2;
            command.ExecuteNonQuery();
        }
Exemplo n.º 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="databaseHelper"></param>
        /// <param name="Username"></param>
        /// <param name="Password"></param>
        /// <param name="UserRole"></param>
        public void CreateUser(DAODatabaseHelper databaseHelper, string Username, string Password, string UserRole)
        {
            this.BeginTransaction();
            System.Data.Common.DbCommand TempCommand_2 = databaseHelper.CreateCommand();
            TempCommand_2.CommandText = "sp_addnewuser";
            TempCommand_2.CommandType = System.Data.CommandType.StoredProcedure;
            TempCommand_2.Transaction = TransactionManager.GetTransaction(databaseHelper.Connection);
            DbCommand command = TempCommand_2;

            ADORecordSetHelper.commandParameterBinding(command, "Username").Value = Username;
            ADORecordSetHelper.commandParameterBinding(command, "Password").Value = Password;
            ADORecordSetHelper.commandParameterBinding(command, "UserRole").Value = UserRole;
            command.ExecuteNonQuery();
            this.CommitTransaction();
        }
Exemplo n.º 6
0
 /// <summary>
 /// Rollbacks a transaction for a specific connection.
 /// </summary>
 /// <param name="connection">The connection to work on.</param>
 private void Rollback(DAODatabaseHelper connection)
 {
     TransactionManager.Rollback(connection.Connection);
 }
Exemplo n.º 7
0
 /// <summary>
 /// Commits a transaction for a specific connection.
 /// </summary>
 /// <param name="connection">The connection where the transaction will be committed.</param>
 private void CommitTransaction(DAODatabaseHelper connection)
 {
     TransactionManager.Commit(connection.Connection);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Closes a transaction for a specific connection.
 /// </summary>
 /// <param name="connection">The connection where the transaction will be close.</param>
 private void Close(DAODatabaseHelper connection)
 {
     TransactionManager.DeEnlist(connection.Connection);
     connection.Close();
 }
Exemplo n.º 9
0
 /// <summary>
 /// Begins a transaction for a specific connection.
 /// </summary>
 /// <param name="connection">The connection where the transaction will be initiated.</param>
 private void BeginTransaction(DAODatabaseHelper connection)
 {
     TransactionManager.Enlist(connection.Connection);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Returns the Transaction object associated to a connection.
 /// </summary>
 /// <param name="dbh">The DAODatabaseHelper to get the transaction from.</param>
 /// <returns>The transaction associated with the parameter.</returns>
 public static DbTransaction GetTransaction(DAO.DAODatabaseHelper dbh)
 {
     return(GetTransaction(dbh.Connection));
 }