private void btnCreate_Click(object sender, EventArgs e) { CreateUser u = new CreateUser() { NomJoueur = txtUsername.Text, Courriel = txtEmail.Text, Prenom = txtFirstName.Text, Nom = txtLastName.Text, TypeUtilisateur = (TypeUtilisateur)comboUserType.SelectedItem, MotDePasse = txtPassword.Text, MotDePasseConfirmation = txtPasswordConfirmation.Text }; var result = createUserValidator.Validate(u); if (!result.IsValid) { MessageBox.Show(string.Join("\n", result.Errors.ToList()), "Errors", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { string resultat = CompteJoueursCRUD.CreerJoueur(u.NomJoueur, u.Courriel, u.Prenom, u.Nom, (int)u.TypeUtilisateur, u.MotDePasse); if (resultat == "SUCCESS") { MessageBox.Show("The user has been created", "Success!", MessageBoxButtons.OK, MessageBoxIcon.None); this.Close(); } else { MessageBox.Show("An error has occured with the creation of the user", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void btnLogin_Click(object sender, EventArgs e) { if (CompteJoueursCRUD.ValideAdmin(txtUserName.Text, txtPwd.Text) == "SUCCESS") { EstConnecte = true; mainForm.ConnectionReussie(); this.Close(); } else { MessageBox.Show("The username or password is incorrect!\r\nOr you are not an administrator!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void btnSubmit_Click(object sender, EventArgs e) { ModifAdmin u = new ModifAdmin() { NomJoueur = txtPlayerName.Text, Nom = txtFirstName.Text, Prenom = txtLastName.Text, Courriel = txtEmail.Text, MotDePasse = txtPassword.Text }; var result = ModifAdminValidator.Validate(u); if (!result.IsValid) { MessageBox.Show(string.Join("\n", result.Errors.ToList()), "Errors", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } else { string resultat = CompteJoueursCRUD.ModifCompteJoueur( Int32.Parse(txtId.Text), txtPlayerName.Text, txtEmail.Text, txtFirstName.Text, txtLastName.Text, TypeUtilisateur.Admin, txtPassword.Text); if (resultat == "SUCCESS") { MessageBox.Show("The admin has been modified", "Success!", MessageBoxButtons.OK, MessageBoxIcon.None); this.Close(); } else { MessageBox.Show("An error has occured with the modification of the admin", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }