private void btnXoa_Click(object sender, EventArgs e) { DialogResult dialog = MessageBox.Show("Có chắc chắn xóa thẻ này ?", "Thông báo", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { if (Bus_TimTV.XoaTV(mathe)) { txtMaThe.Text = "null"; txtHoTen.Text = "null"; txtLoaiDG.Text = "null"; txtEmail.Text = "null"; txtDiaChi.Text = "null"; MessageBox.Show("Xóa thành công", "Thông báo"); //cap nhat bang dtDachSach dataSrc = Bus_TimTV.TimTV(txtDocGia.Text); dtDanhsach.DataSource = dataSrc; txtDocGia.Focus(); } else { MessageBox.Show("Không thể xóa thẻ này", "Thông báo"); } } }
internal void open() { this.Focus(); //datatable mac dinh se hien thi tat ca cac DG thu vien hien co dataSrc = Bus_TimTV.TimTV(""); dtDanhsach.DataSource = dataSrc; txtDocGia.Focus(); }
private void btnCapNhat_Click(object sender, EventArgs e) { string _mathe = txtMaThe.Text; string _hoten = txtHoTen.Text; string _email = txtEmail.Text; string _diachi = txtDiaChi.Text; string _ngaylapthe = dtNgayLapThe.Text; string _ngaysinh = dtNgaySinh.Text; string _loaidg = txtLoaiDG.Text; if (_mathe == "" || _hoten == "" || _email == "" || _diachi == "" || _ngaylapthe == "" || _ngaysinh == "" || _loaidg == "") { MessageBox.Show("Vui lòng nhập đầy dủ thông tin", "Thông báo"); } else { DialogResult dialog = MessageBox.Show("Có chắc chắn cập nhật thông tin của thẻ này ?", "Thông báo", MessageBoxButtons.YesNo); if (dialog == DialogResult.Yes) { En_LapThe dg = new En_LapThe(_mathe, _hoten, DateTime.Parse(_ngaysinh), DateTime.Parse(_ngaylapthe), _email, _diachi, _loaidg, int.Parse(taikhoanno)); Bus_TimTV.CapNhatTV(dg); MessageBox.Show("Cập nhật thành công"); //cap nhat bang dtDachSach dataSrc = Bus_TimTV.TimTV(txtDocGia.Text); dtDanhsach.DataSource = dataSrc; dtDanhsach.Rows[0].Selected = false; dtDanhsach.Rows[hangDuocChon].Selected = true; // hien thi button btnSua.Visible = true; btnXoa.Visible = true; dtDanhsach.Enabled = true; btnCapNhat.Visible = false; btnHuy.Visible = false; setTextBoxEnabled(false); txtDocGia.Enabled = true; } else { btnHuy_Click(sender, e); } } }
private void txtDocGia_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { dataSrc = Bus_TimTV.TimTV(txtDocGia.Text); if (dataSrc.Rows.Count <= 0) { btnSua.Visible = false; dtDanhsach.DataSource = null; } else { dtDanhsach.DataSource = dataSrc; } } }