private void btnXoa_Click(object sender, EventArgs e) { DataGridViewRow row = dataGVNXB.SelectedRows.Count >= 1 ? dataGVNXB.SelectedRows[0] : null; if (row != null) { int maNXB = Convert.ToInt32(row.Cells["colMaNXB"].Value); string tenNXB = row.Cells["colTenNXB"].Value.ToString(); string message = $"Bạn có muốn xóa nhà xuất bản {tenNXB} không ?"; string caption = "Xóa nhân viên"; if (MessageBox.Show(message, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (NXB_DAO.DeleteNXB(maNXB)) { MessageBox.Show("Xóa thành công"); InitNXB(); } else { MessageBox.Show("Xóa không thành công"); } } } else { MessageBox.Show("Bạn chưa chọn nhà xuất bản để xóa"); } }
private void InitNXB() { List <NXB> nxbGroup = NXB_DAO.LoadNXB(); foreach (NXB item in nxbGroup) { cmbNXB.Items.Add(item.TenNXB); } }
public void InitNXB() { dataGVNXB.Rows.Clear(); List <NXB> list = NXB_DAO.LoadNXB(); foreach (NXB item in list) { dataGVNXB.Rows.Add(item.ItemArray()); } dataGVNXB.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells; }
private void UpdateNXB(int maNXB, string tenNXB) { if (NXB_DAO.UpdateNXB(maNXB, tenNXB)) { MessageBox.Show("Cập nhật thành công"); Dispose(); } else { MessageBox.Show("Cập nhật thất bại"); } }
private void InsertNXB(string tenNXB) { if (NXB_DAO.InsertNXB(tenNXB)) { MessageBox.Show("Thêm thành công"); Dispose(); } else { MessageBox.Show("Thêm thất bại"); } }
private void UpdateSach(string maSach, string tenSach, string tenTacGia, string tenTheLoai, string tenNXB, string gia, string soLuong) { int maNXB = NXB_DAO.GetIdNXBByName(tenNXB); int maTheLoai = TheLoaiDAO.GetIdTheLoaiByName(tenTheLoai); int maTacGia = TacGiaDAO.GetIdTacGiaByName(tenTacGia); if (SachDAO.UpdateSach(maSach, tenSach, maNXB, maTacGia, maTheLoai, Convert.ToDouble(gia), Convert.ToInt32(soLuong))) { MessageBox.Show("Cập nhật thành công"); Dispose(); } else { MessageBox.Show("Cập nhật thất bại"); } }