Exemplo n.º 1
0
        public bool Delete(User user)
        {
            if (user.Id == 0)
                throw new OctopusUserDeleteException(OctopusUserDeleteExceptionEnum.UserIsNull);

            if (user.Id == 1)
                throw new OctopusUserDeleteException(OctopusUserDeleteExceptionEnum.AdministratorUser);

            user.IsDeleted = true;
            _userManager.DeleteUser(user);
            return true;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Save selected user
        /// </summary>
        /// <param name="pUser"></param>
        /// <returns>A struct contains, if necessary, errors occurs</returns>
        public UserErrors SaveUser(User pUser)
        {
            UserErrors userErrors = new UserErrors();

            if (pUser.UserName == null)
            {
                userErrors.FindError = true;
                userErrors.LoginError = true;
               // userErrors.ResultMessage += "\n - " + MultiLanguageStrings.GetString(Ressource.StringRes, "User_Login_Empty.Text");
            }

            if (pUser.Password == null)
            {
                userErrors.FindError = true;
                userErrors.PasswordError = true;
               // userErrors.ResultMessage += "\n - " + MultiLanguageStrings.GetString(Ressource.StringRes, "User_Password_Empty.Text");
            }

            if (pUser.UserRole == null)
            {
                userErrors.FindError = true;
                userErrors.RoleError = true;
               // userErrors.ResultMessage += "\n - " + MultiLanguageStrings.GetString(Ressource.StringRes, "User_Role_Empty.Text");
            }
            if (pUser.UserRole.Id < 1)
            {
                userErrors.FindError = true;
                userErrors.RoleError = true;
               // userErrors.ResultMessage += "\n - " + MultiLanguageStrings.GetString(Ressource.StringRes, "User_Role_Empty.Text");
            }
            if (pUser.FirstName == null)
            {
                userErrors.FindError = true;
                userErrors.FirstNameError = true;
              //  userErrors.ResultMessage += "\n - " + MultiLanguageStrings.GetString(Ressource.StringRes, "User_LastName_Empty.Text");
            }

            if (pUser.LastName == null)
            {
                userErrors.FindError = true;
                userErrors.LastNameError = true;
               // userErrors.ResultMessage += "\n - " + MultiLanguageStrings.GetString(Ressource.StringRes, "User_FirstName_Empty.Text");
            }

            if (pUser.Mail == null)
            {
                userErrors.FindError = true;
                userErrors.MailError = true;
               // userErrors.ResultMessage += "\n - " + MultiLanguageStrings.GetString(Ressource.StringRes, "User_Mail_Empty.Text");
            }

            if (userErrors.FindError) return userErrors;

            if (pUser.Id == 0)
            {
                if (Find(pUser.UserName, pUser.Password) != null)
                {
                    userErrors.FindError = true;
               //     userErrors.ResultMessage += "\n - " + MultiLanguageStrings.GetString(Ressource.StringRes, "User_Save_AlreadyExist.Text");
                }
                else
                {
                    _userManager.AddUser(pUser);
                    if (_users != null) _users.Add(pUser);
                 //   userErrors.ResultMessage = MultiLanguageStrings.GetString(Ressource.StringRes, "User_Save_OK.Text");
                }
            }
            else
            {
                _userManager.UpdateUser(pUser);
                //userErrors.ResultMessage = MultiLanguageStrings.GetString(Ressource.StringRes, "User_Update_OK.Text");
            }

            return userErrors;
        }
Exemplo n.º 3
0
 public void Save(User user)
 {
     if (_subordinateRel != null)
     {
         if (!_subordinateRel.ContainsKey(user.Id))
         {
             _subordinateRel.Add(user.Id, new List<int>());
         }
         foreach (User sub in user.Subordinates)
         {
             _subordinateRel[user.Id].Add(sub.Id);
         }
     }
     if (_branchRel != null)
     {
         if (!_branchRel.ContainsKey(user.Id))
         {
             _branchRel.Add(user.Id, new List<int>());
         }
         _branchRel[user.Id].Clear();
         foreach (Branch b in user.Branches)
         {
             _branchRel[user.Id].Add(b.Id);
         }
     }
     _userManager.Save(user);
 }
Exemplo n.º 4
0
 public List<User> FindAllExcept(User user, bool includeDeleted)
 {
     LoadUsers();
     Debug.Assert(_user != null, "User list is null");
     return _users.FindAll(item => (!item.IsDeleted
         || item.IsDeleted == includeDeleted)
         && !item.Equals(user));
 }
Exemplo n.º 5
0
 public SQLToolServices(User pUser)
 {
     _user = pUser;
     sqlToolManager = new SQLToolManager(pUser);
 }
Exemplo n.º 6
0
        private void RefreshUser(User user)
        {
            foreach (ListViewItem item in lvUsers.Items)
            {
                if (!user.Equals(item.Tag as User)) continue;

                item.SubItems[5].Text = user.SubordinateCount.ToString();
            }
        }
Exemplo n.º 7
0
 public bool HasAsSubordinate(User user)
 {
     return _subordinates.IndexOf(user) > -1;
 }
Exemplo n.º 8
0
 public MFIManager(User pUser)
     : base(pUser)
 {
     _user = pUser;
 }
Exemplo n.º 9
0
 public MFIManager(string testDB, User pUser)
     : base(testDB)
 {
     _user = pUser;
 }
Exemplo n.º 10
0
 public RoleServices(User pUser)
 {
     _roleManager = new RoleManager(pUser);
     _user = pUser;
 }
Exemplo n.º 11
0
 public Role Find(User user)
 {
     // TODO: Refactor
     // Implement some less db intense mechanism for
     // fetching and assigning allowed menu items and actions.
     LoadUserToRole();
     int roleId = _userToRole[user.Id];
     Role role = _roleManager.SelectRole(roleId, true);
     role.SetMenuItems(_roleManager.GetAllowedMenuList(roleId));
     role.SetActionItems(_roleManager.GetAllowedActionList(roleId));
     return role;
 }
Exemplo n.º 12
0
 protected Manager(User pUser)
 {
     _md5 = pUser.Md5;
     _connectionManager = ConnectionManager.GetInstance();
 }
Exemplo n.º 13
0
 private void EraseUser()
 {
     _user = new User();
     InitializeUser();
 }
Exemplo n.º 14
0
 public UserForm()
 {
     _user = new User();
     InitializeComponent();
     InitUsers();
 }
Exemplo n.º 15
0
 public UserServices(User pUser, string pTestDb)
 {
     _user = pUser;
     _userManager = new UserManager(pTestDb, pUser);
 }
Exemplo n.º 16
0
 public ApplicationSettingsManager(User pUser)
     : base(pUser)
 {
     _user = pUser;
 }
Exemplo n.º 17
0
 public UserServices(UserManager pUserManager)
 {
     _user = new User();
     _userManager = pUserManager;
 }
Exemplo n.º 18
0
 public SQLToolManager(User pUser)
     : base(pUser)
 {
 }
Exemplo n.º 19
0
 public void AddSubordinate(User user)
 {
     if (null == user) return;
     if (HasAsSubordinate(user)) return;
     _subordinates.Add(user);
 }
Exemplo n.º 20
0
 public RoleManager(User pUser)
     : base(pUser)
 {
 }
Exemplo n.º 21
0
 public string GenerateProjectCode()
 {
     User user = new User();
     param = ApplicationSettings.GetInstance(user.Md5);
     string year = BeginDate.Year.ToString().Substring(2, 2);
     return string.Format("{0}/{1}/{2}", param.BranchCode, year, _clientCode);
 }
Exemplo n.º 22
0
        private void listViewUsers_Click(object sender, EventArgs e)
        {
            _user = (User) lvUsers.SelectedItems[0].Tag;
            _ChangeAllLabelForeColor(Color.FromArgb(0, 88, 56));

            InitializeUser();
        }