private void btnLuu_Click(object sender, EventArgs e) { int flag = 0; //Kiểm tra text box if (!checkSoLuong()) { return; } DanhMucSP Target = getProductCategory(); if (btnThem.Enabled == true) { if (_service.CreateCategory(Target)) { MessageBox.Show("Thêm thành công"); } else { flag = 1; } } if (btnSua.Enabled == true) { if (_service.EditCategory(Target)) { MessageBox.Show("Sửa thành công"); } else { flag = 1; } } if (btnXoa.Enabled == true) { DialogResult dlr = MessageBox.Show("Bạn có muốn xóa hóa đơn", "Thông báo", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dlr == DialogResult.Yes) { if (_service.DeleteCategory(Target)) { MessageBox.Show("Xóa thành công"); } else { flag = 1; } } } if (flag == 0) { View(); HienChiTiet(false); btnThem.Enabled = true; btnXoa.Enabled = true; btnSua.Enabled = true; XoaTrangChiTiet(); } else { ViewErrors(); } }