private void saveBtn_Click(object sender, EventArgs e) { if (nameText.Text == "Enter category name") { nameText.Text = ""; } Menu menu = new Menu(); getDate(menu); if (Validation.IsName(menu.Name)) { if (saveBtn.Text == "Create") { bool flag = controller.Insert(menu); if (flag) { MessageBox.Show(null, "Category inserted successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //refresh table dataGrid.DataSource = controller.ViewAll(); } else { MessageBox.Show(null, "Something went wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { menu.ID = int.Parse(IdText.Text); bool flag = controller.Update(menu); if (flag) { MessageBox.Show(null, "Category updated successfully", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); //refresh table dataGrid.DataSource = controller.ViewAll(); } else { MessageBox.Show(null, "Something went wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show(null, "Please check your input", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void itemssBtn_Click(object sender, EventArgs e) { Menu menuType = controller.GetMenuType(int.Parse(IdText.Text)); MenuItemForm menuItemForm = new MenuItemForm(menuType) { TopLevel = false }; this.Controls.Clear(); this.Controls.Add(menuItemForm); menuItemForm.FormBorderStyle = FormBorderStyle.None; menuItemForm.Dock = DockStyle.Fill; menuItemForm.Show(); }
private void getDate(Menu menu) { menu.Name = nameText.Text.Trim(); }
public MenuItemForm(Menu menu = null) { InitializeComponent(); this.menu = menu; }