private void buttonUpdate_Click(object sender, EventArgs e) { try { if (Ivaild()) { loaiNguoiDung loainguoidung = new loaiNguoiDung { id = Convert.ToInt32(textBoxID.Text), tenLoaiNguoiDung = textBoxName.Text, moTa = textBoxMota.Text }; if (loainguoidung.update()) { loadLoaiNguoiDung(); } else { MessageBox.Show("fail"); } } else { MessageBox.Show("Dien Du Thong Tin"); } } catch (SqlException ex) { MessageBox.Show("Lỗi SQL exception !\n" + ex.Message); } }
private void buttonDelete_Click(object sender, EventArgs e) { try { if (textBoxID.Text != string.Empty) { loaiNguoiDung loainguoidung = new loaiNguoiDung { id = Convert.ToInt32(textBoxID.Text) }; if (loainguoidung.delete()) { loadLoaiNguoiDung(); } else { MessageBox.Show("fail"); } } else { MessageBox.Show("Dien Du Thong Tin"); } } catch (SqlException ex) { MessageBox.Show("Lỗi SQL exception !\n" + ex.Message); } }
public void loadLoaiNguoiDung() { try { loaiNguoiDung loainguoidung = new loaiNguoiDung(); dataGridViewLoaiNguoiDung.DataSource = loainguoidung.ShowtableNguoiDung(); } catch (SqlException ex) { MessageBox.Show("Lỗi SQL exception !\n" + ex.Message); } }
public void loadNguoiDung() { try { nguoiDung nguoidung = new nguoiDung(); loaiNguoiDung loainguoidung = new loaiNguoiDung(); dataGridViewNguoiDung.DataSource = nguoidung.ShowtableNguoiDung(); comboBoxLoaiNguoiDung.DataSource = loainguoidung.ShowtableNguoiDung(); comboBoxLoaiNguoiDung.ValueMember = "id"; comboBoxLoaiNguoiDung.DisplayMember = "tenLoaiNguoiDung"; } catch (SqlException ex) { MessageBox.Show("Lỗi SQL exception !\n" + ex.Message); } }
public void loadcombox() { loaiNguoiDung loainguoidung = new loaiNguoiDung(); nguoiDung nguoidung = new nguoiDung(); quyen q = new quyen(); quyen Quyen = new quyen(); comboBoxLoaiNguoiDung.DataSource = loainguoidung.ShowtableNguoiDung(); comboBoxLoaiNguoiDung.DisplayMember = "tenLoaiNguoiDung"; comboBoxLoaiNguoiDung.ValueMember = "id"; comboBoxNhomQuyen.DataSource = q.ShowtableQuyen(); comboBoxNhomQuyen.DisplayMember = "tenQuyen"; comboBoxNhomQuyen.ValueMember = "id"; comboBoxUser.DataSource = nguoidung.ShowtableNguoiDung(); comboBoxUser.DisplayMember = "username"; comboBoxUser.ValueMember = "id"; comboBoxQuyen.DataSource = Quyen.ShowtableQuyen(); comboBoxQuyen.DisplayMember = "tenQuyen"; comboBoxQuyen.ValueMember = "id"; }