protected override void OnPropertyChanged(string fieldName) { if (fieldName.EqualIgnoreCase(__.ParentID, __.Deleted)) { _Parent = null; Dirtys.Remove("Parent"); } base.OnPropertyChanged(fieldName); }
/// <summary>验证</summary> /// <param name="isNew"></param> public override void Valid(Boolean isNew) { base.Valid(isNew); if (Name.IsNullOrEmpty()) { throw new ArgumentNullException(__.Name, "用户名不能为空!"); } //if (RoleID < 1) throw new ArgumentNullException(__.RoleID, "没有指定角色!"); var pass = Password; if (isNew) { if (!pass.IsNullOrEmpty() && pass.Length != 32) { Password = pass.MD5(); } } else { // 编辑修改密码 if (Dirtys[__.Password]) { if (!pass.IsNullOrEmpty()) { Password = pass.MD5(); } else { Dirtys.Remove(__.Password); } } } // 重新整理角色 var ids = GetRoleIDs(); if (ids.Length > 0) { RoleID = ids[0]; var str = ids.Skip(1).Join(); if (!str.IsNullOrEmpty()) { str = "," + str + ","; } RoleIDs = str; } }
/// <summary>验证</summary> /// <param name="isNew"></param> public override void Valid(Boolean isNew) { base.Valid(isNew); if (String.IsNullOrEmpty(Name)) { throw new ArgumentNullException(__.Name, "用户名不能为空!"); } if (RoleID < 1) { throw new ArgumentNullException(__.RoleID, "没有指定角色!"); } var pass = Password; if (isNew) { if (!pass.IsNullOrEmpty() && pass.Length != 32) { Password = pass.MD5(); } } else { // 编辑修改密码 if (Dirtys[__.Password]) { if (!pass.IsNullOrEmpty()) { Password = pass.MD5(); } else { Dirtys.Remove(__.Password); } } } }