private void EditUser() { if (listBoxUsers.SelectedIndex == -1) { MessageBox.Show("Please select a user to edit."); return; } string user = (string)listBoxUsers.Items[listBoxUsers.SelectedIndex]; FormMySQLUserEdit formMySQLUserEdit = new FormMySQLUserEdit(user, false, _dataConnection); formMySQLUserEdit.ShowDialog(); if (formMySQLUserEdit.DialogResult != DialogResult.OK) { return; } if (user.ToLower() == _dataConnection.UserCur.ToLower()) { SetUsersEnabled(false); //In case we can't reconnect. string password = formMySQLUserEdit.WasPasswordChanged ? formMySQLUserEdit.NewPassword : textPassword.Text; if (!ConnectToDatabase(formMySQLUserEdit.NewUserName, password)) { return; } } FillUsers(); }
private void butAdd_Click(object sender, EventArgs e) { FormMySQLUserEdit formMySQLUserEdit = new FormMySQLUserEdit("", true, _dataConnection); formMySQLUserEdit.ShowDialog(); if (formMySQLUserEdit.DialogResult != DialogResult.OK) { return; } FillUsers(); }