示例#1
0
 private static Role GetRoleFromReader(IDataReader dataReader)
 {
     Role role = new Role();
     role.RoleID = DBHelper.GetInt(dataReader, "RoleID");
     role.Name = DBHelper.GetString(dataReader, "Name");
     return role;
 }
示例#2
0
        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);
        }
示例#3
0
        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;
        }
示例#4
0
 public static void UpdateRole(Role role)
 {
     RoleDB.UpdateRole(role);
 }
示例#5
0
 public static Role InsertRole(Role role)
 {
     return RoleDB.InsertRole(role);
 }