private void btTerug_Click(object sender, RoutedEventArgs e) { UserCMS form = new UserCMS(user); form.Show(); this.Close(); }
//Functie voor het updaten van het account public void safeAccount(string user, string fName, string lName, string gName, string WW, string userID, AccountWijzigen form) { db_connection(); MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "UPDATE users SET Username=@sUsername, Password=@sPassword, firstName=@sfName, lastName=@slName WHERE userID=" + userID; cmd.Parameters.AddWithValue("@sUsername", gName); //Parameter with Username cmd.Parameters.AddWithValue("@sPassword", WW); //Parameter with Password cmd.Parameters.AddWithValue("@sfName", fName); //Parameter with Firstname cmd.Parameters.AddWithValue("@slName", lName); //Parameter with Lastname cmd.Connection = connect; try { cmd.ExecuteNonQuery(); MessageBox.Show("Het account van: " + fName + " " + lName + " is succesvol gewijzigd.", "Succes!"); UserCMS newForm = new UserCMS(user); newForm.Show(); form.Close(); } catch //Foutafhandeling { MessageBox.Show("Er is iets mis gegaan met het opslaan van het nieuwe account, probeer het nog eens ", "Error!"); } finally //Close database connection { connect.Close(); } }
private void btUser_Click(object sender, RoutedEventArgs e) { UserCMS ac = new UserCMS(user); ac.Show(); this.Close(); }
//Functie voor het aanmaken van een nieuw account public void newAccount(string user, string rolID, string fName, string lName, string gName, string WW, AccountToevoeg form) { db_connection(); MySqlCommand cmd = new MySqlCommand(); cmd.CommandText = "insert into users (Username, Password, firstName, lastName, rolID) VALUES (@sUsername, @sPassword, @sfName, @slName, @srolID)"; cmd.Parameters.AddWithValue("@sUsername", gName); //Parameter with Username cmd.Parameters.AddWithValue("@sPassword", WW); //Parameter with Password cmd.Parameters.AddWithValue("@sfName", fName); //Parameter with Firstname cmd.Parameters.AddWithValue("@slName", lName); //Parameter with Lastname cmd.Parameters.AddWithValue("@srolID", rolID); //Parameter with RolID cmd.Connection = connect; try { cmd.ExecuteNonQuery(); MessageBox.Show("Het account van: " + fName + " " + lName + " is succesvol aangemaakt.", "Succes!"); UserCMS newForm = new UserCMS(user); newForm.Show(); form.Close(); } catch //Foutafhandeling { MessageBox.Show("Er is iets mis gegaan met het opslaan van het nieuwe account, probeer het nog eens ", "Error!"); } finally //Close database connection { connect.Close(); } }