private void RegisterUser() { if (IsRegistrationValidationCorrect()) { bool isAdmin; if (FalseChBox.Checked) { isAdmin = false; } else { isAdmin = true; } User user = new User() { Name = nameTxtBox.Text, Surname = surnameTxtBox.Text, Login = LoginTxtBox.Text, Password = PasswordTxtBox.Text, IsAdmin = isAdmin }; UsersDb usersDb = new UsersDb("Users.txt"); usersDb.WriteToFile(user); MessageBox.Show("New user has successfuly registered"); this.Dispose(); } }
private void RefreshUsersListBox() { usersDb = new UsersDb("Users.txt"); users = usersDb.Users; EditBtn.Enabled = users.Count != 0; UsersListBox.DataSource = users; }
public LoginResult CheckUser(LoginData data) { LoginResult loginResult = new LoginResult { Result = true, ErrorPassword = false, ErrorLogin = false, Message = "" }; IUsersDB userDb = new UsersDb(ConstValue.UsersTable + ConstValue.CurrentExtensionDatabase); var user = userDb.GetUser(data); if (user == null) { loginResult.ErrorPassword = true; loginResult.ErrorLogin = true; } else { if (user.Login != data.Login) { loginResult.ErrorLogin = true; } if (user.Password != data.Password) { loginResult.ErrorPassword = true; } if (!loginResult.ErrorLogin && !loginResult.ErrorPassword) { loginResult.User = user.ToUserDto(); return(loginResult); } } loginResult.Message = CreateErrorMessage(loginResult); loginResult.Result = false; return(loginResult); }