private void dgvDanhSach_CellClick(object sender, DataGridViewCellEventArgs e) { if (e.ColumnIndex == 7) { if (phanquyen == "Admin") { SachDTO S = new SachDTO(); S.MaSach = dgvDanhSach.CurrentRow.Cells[0].Value.ToString(); S.TenSach = dgvDanhSach.CurrentRow.Cells[1].Value.ToString(); S.MaTL = dgvDanhSach.CurrentRow.Cells[2].Value.ToString(); S.MaNXB = dgvDanhSach.CurrentRow.Cells[3].Value.ToString(); S.MaTG = dgvDanhSach.CurrentRow.Cells[4].Value.ToString(); frmSuaSach frm = new frmSuaSach(S); frm.ShowDialog(); LoadData(); } else { MessageBox.Show("Bạn không phải là Admin nên không thực hiện được chức năng này.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } else if (e.ColumnIndex == 8) { if (phanquyen == "Admin") { if ((int)dgvDanhSach.CurrentRow.Cells[5].Value > 0) { MessageBox.Show("Sách còn tồn trong kho. Không thể xóa.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } else { if (MessageBox.Show("Bạn có chắc chắn muốn xóa quyển sách này ?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (SachBUS.XoaSach(dgvDanhSach.CurrentRow.Cells[0].Value.ToString()) == true) { LoadData(); } else { MessageBox.Show("Xóa thất bại.", "Lỗi", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } else { MessageBox.Show("Bạn không phải là Admin nên không thực hiện được chức năng này.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } }
private void tsbtnSua_Click(object sender, EventArgs e) { SachDTO S = new SachDTO(); S.MaSach = dgvDanhSach.CurrentRow.Cells[0].Value.ToString(); S.TenSach = dgvDanhSach.CurrentRow.Cells[1].Value.ToString(); S.MaTL = dgvDanhSach.CurrentRow.Cells[2].Value.ToString(); S.MaNXB = dgvDanhSach.CurrentRow.Cells[3].Value.ToString(); S.MaTG = dgvDanhSach.CurrentRow.Cells[4].Value.ToString(); frmSuaSach frm = new frmSuaSach(S); tsbtnXoa.Enabled = false; tsbtnSua.Enabled = false; frm.ShowDialog(); tsbBarcode.Image = null; LoadData(); }