private void saveBtn_Click(object sender, EventArgs e) { MenuItem menuItem = new MenuItem(); ClearDefaults(); if (DataValidation()) { getDate(menuItem); if (saveBtn.Text == "Create") { bool flag = controller.Insert(menuItem); if (flag) { MessageBox.Show(null, "Item has been added to menu successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //refresh table dataGrid.DataSource = controller.ViewAll(); } else { MessageBox.Show(null, "Something wen wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { menuItem.ID = int.Parse(IdText.Text); bool flag = controller.Update(menuItem); if (flag) { MessageBox.Show(null, "Menu item updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //refresh table dataGrid.DataSource = controller.ViewAll(); } else { MessageBox.Show(null, "Something wen wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show(null, "Please check your input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }