private void btnSubmit_Click(object sender, EventArgs e) { if (!check()) { return; } bool result = false; InventoryDTO inv = new InventoryDTO { BookID = txtBookID.Text, Index = txtIndex.Text, InventoryID = txtInventoryID.Text, Status = 0 }; if (inv.InventoryID == String.Empty) { MessageBox.Show(this, "The New Inventory is added fail. InventoryID Can't empty!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (AddOrEdit == 0) { if (cbStatus.Checked) { inv.Status = 1; } result = bus.AddNewInventory(inv); if (result) { MessageBox.Show(this, "The New Inventory is added successful", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); dr = DialogResult.OK; this.Close(); } else { MessageBox.Show(this, "The New Inventory is added fail. InventoryID is existed!!!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { if (cbStatus.Checked) { inv.Status = 1; } result = bus.UpdateInventory(inv, inv.Status); if (result) { MessageBox.Show(this, "The Inventory is updated successful.", "Notification", MessageBoxButtons.OK, MessageBoxIcon.Information); dr = DialogResult.OK; this.Close(); } else { MessageBox.Show(this, "The Inventory is updated fail. Please try again later.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }