private void button1_Click(object sender, EventArgs e) { if (!this.textBox1.Text.Equals("") && !this.textBox2.Text.Equals("") && this.comboBox1.SelectedIndex != -1) { foreach (var i in CurrentUser.Usersname) { if (i.Equals(this.textBox2.Text)) { MessageBox.Show("No puedes agregar un nombre de usuario que ya agregaste!"); return; } } UserDAO.AddNew($"'{this.textBox1.Text}', '{this.textBox2.Text}', '{this.textBox2.Text}', " + $"{this.comboBox1.SelectedItem}"); CurrentUser.AddUsername(this.textBox2.Text); this.textBox1.Text = ""; this.textBox2.Text = ""; this.comboBox1.SelectedIndex = -1; this.dataGridView1.DataSource = UserDAO.SelectFromUsuario(); resetComboBox2(); } else { MessageBox.Show("Completa los campos"); } }
public UserManage() { InitializeComponent(); this.dataGridView1.DataSource = UserDAO.SelectFromUsuario(); users = UserDAO.GetList(); removeTextInit = this.label5.Text; var bools = new object[] { false, true }; this.comboBox1.Items.AddRange(bools); resetComboBox2(); }
private void button2_Click(object sender, EventArgs e) { int num = this.comboBox2.SelectedIndex; if (num != -1) { UserDAO.RemoveUser(users[num].id); resetComboBox2(); this.dataGridView1.DataSource = UserDAO.SelectFromUsuario(); } else { MessageBox.Show("Selecciona una opcion antes de eliminar"); } }