private void ManageUsers(User user) { bool wasPlan = false; bool disableButtons = true; for (int i = 0; i < user.Role.Privilages.Count(); i++) { if (user.Role.Privilages.ElementAt(i).Name.Equals("Edycja")) { if (wasPlan == false) { pages.Pages.Add(plancreate); wasPlan = true; disableButtons = false; } } if (user.Role.Privilages.ElementAt(i).Name.Equals("Recenzowanie") && wasPlan == false) pages.Pages.Add(plancreate); if (user.Role.Privilages.ElementAt(i).Name.Equals("Przegl¹danie")) pages.Pages.Add(review); if (user.Role.Privilages.ElementAt(i).Name.Equals("Archiwizacja")) pages.Pages.Add(archive); if (user.Role.Privilages.ElementAt(i).Name.Equals("U¿ytkownicy")) pages.Pages.Add(users); } if (disableButtons) DisableToolbarButtons(); }
public Plans(User user) { InitializeComponent(); FillWithDepartaments(); FillWithFaculties(); FillWithStudiesTypes(); loggedUser = user; ShowButtonsToolTips(); }
public UserEdit(User user) { this.UserID = user.UserID; this.UserName = user.Name; this.Email = user.Email; this.RoleID = user.RoleID; this.Password = string.Empty; this.RepeatPassword = string.Empty; }
public MainForm(User user) { InitializeComponent(); pages.Pages.Remove(plancreate); pages.Pages.Remove(review); pages.Pages.Remove(archive); pages.Pages.Remove(users); ManageUsers(user); lRole.Text += user.Role.Name; lUserName.Text += user.Name; logged = user; CreateSubjectGrid(); FillZoom(); SetButtonsToolTips(); }
public void AddUser(NewUser user) { if (user != null) { User toAdd = new User() { Email = user.Email == null ? string.Empty : user.Email, Name = user.UserName, Password = HashPassword(user.Password), RoleID = user.RoleID, }; SPDatabase.DB.Users.AddObject(toAdd); SPDatabase.DB.SaveChanges(); } }
// Login button event private void bLogin_Click(object sender, EventArgs e) { if (!_anonymous) { lErrors.Text = ""; UserLogin login = new UserLogin() { UserName = tUsername.Text, Password = tPassword.Text }; // if user is valid and exists in databse if (AccountController.Instance.LoginUser(ref login)) { UserLastActive updateActive = new UserLastActive() { LastActiveDate = DateTime.Now, UserID = login.UserId }; //set new last login time AccountController.Instance.UpdateLastActiveUser(updateActive); StudiesPlans.Program.user = AccountController.Instance.GetUser(login); this.DialogResult = DialogResult.OK; } else // if user is not valid show errors foreach (string error in login.Errors) lErrors.Text += error + "\n"; } else { User u = new User() { Name = "Anonim", Role = new Role() { Name = "Anonim" } }; Privilage p = RoleController.Instance.GetPrivilage("Przegl¹danie"); u.Role.Privilages.Add(p); StudiesPlans.Program.user = u; this.DialogResult = DialogResult.OK; } }
public void DeleteUser(User user) { SPDatabase.DB.Users.DeleteObject(user); SPDatabase.DB.SaveChanges(); }
/// <summary> /// Deprecated Method for adding a new object to the Users EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddToUsers(User user) { base.AddObject("Users", user); }
/// <summary> /// Create a new User object. /// </summary> /// <param name="userID">Initial value of the UserID property.</param> /// <param name="name">Initial value of the Name property.</param> /// <param name="password">Initial value of the Password property.</param> /// <param name="roleID">Initial value of the RoleID property.</param> public static User CreateUser(global::System.Int32 userID, global::System.String name, global::System.String password, global::System.Int32 roleID) { User user = new User(); user.UserID = userID; user.Name = name; user.Password = password; user.RoleID = roleID; return user; }