private static Role GetRoleFromReader(IDataReader dataReader) { Role role = new Role(); role.RoleID = DBHelper.GetInt(dataReader, "RoleID"); role.Name = DBHelper.GetString(dataReader, "Name"); return role; }
public static void UpdateRole(Role role) { string sqlQuery = "UPDATE ROLE SET Name=@Name WHERE RoleID=" + role.RoleID; Database db = new SqlDatabase(DBHelper.GetConnectionString()); DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery); db.AddInParameter(dbCommand, "Name", DbType.String, role.Name); db.ExecuteNonQuery(dbCommand); }
public static Role InsertRole(Role role) { string sqlQuery = "INSERT INTO ROLE(Name) VALUES(@Name);SELECT @@Identity"; Database db = new SqlDatabase(DBHelper.GetConnectionString()); DbCommand dbCommand = db.GetSqlStringCommand(sqlQuery); db.AddInParameter(dbCommand, "Name", DbType.String, role.Name); role.RoleID = Convert.ToInt32(db.ExecuteScalar(dbCommand)); return role; }
public static void UpdateRole(Role role) { RoleDB.UpdateRole(role); }
public static Role InsertRole(Role role) { return RoleDB.InsertRole(role); }