private void btnAdd_Click(object sender, EventArgs e) { if (txtName.Text == "") { MessageBox.Show("Please fill food's name."); return; } DAL.MenuItem newMenuItem = new DAL.MenuItem { Name = txtName.Text, Price = txtPrice.Value, Image = Utilities.UtilsImage.ImageToByteArray(this.pictureBox.Image), MenuID = menu.ID }; MenuItemBLL menuItemBLL = new MenuItemBLL(); if (this.MenuItem == null) { menuItemBLL.CreateMenuItem(newMenuItem); } else { menuItemBLL.Update(this.MenuItem, newMenuItem); } this.DialogResult = DialogResult.OK; this.Close(); }
public AddFood(DAL.Menu menu, DAL.MenuItem menuItem = null) { InitializeComponent(); this.menu = menu; this.MenuItem = menuItem; this.LoadData(); }
private void NewSelectMenuItem(DAL.MenuItem menuItem, int quantity = 1, DAL.OrderDetail orderDetail = null) { SelectMenuItemControl selectMenuItem = new SelectMenuItemControl(menuItem, quantity, orderDetail); selectMenuItem.Width = this.flowLayoutPanelRight.Width - 24; selectMenuItem.Height = (int)((double)selectMenuItem.Width / 3.6); selectMenuItem.OnDecrease += new SelectMenuItemControl.OnDecreaseHandle(this.SelectMenuItemControl_OnDecrease); selectMenuItem.OnRemove += new SelectMenuItemControl.OnRemoveHandle(this.SelectMenuItemControl_OnRemove); this.flowLayoutPanelRight.Controls.Add(selectMenuItem); }
private void menuItemControl_OnDelete(DAL.MenuItem menuItem) { List <TabPage> tabPages = this.tabControl.Controls.OfType <TabPage>().ToList(); for (int i = 0; i < tabPages.Count; i++) { List <FlowLayoutPanel> flowLayouts = tabPages[i].Controls.OfType <FlowLayoutPanel>().ToList(); if (flowLayouts.Count > 0) { List <MenuItemControl> controls = flowLayouts[0].Controls.OfType <MenuItemControl>().ToList(); for (int j = 0; j < controls.Count; j++) { if (controls[j].MenuItem.ID == menuItem.ID) { flowLayouts[0].Controls.RemoveAt(j); } } } } }
private void MenuItem_OnClick(object sender, EventArgs e) { MenuItemControl menuItemControl = (MenuItemControl)sender; DAL.MenuItem menuItem = menuItemControl.MenuItem; List <SelectMenuItemControl> listControls = this.flowLayoutPanelRight.Controls.OfType <SelectMenuItemControl>().ToList(); try { SelectMenuItemControl find = listControls.Where(c => c.OrderDetail == null && c.MenuItem.ID == menuItem.ID).Single(); find.Quantity++; } catch (Exception) { this.NewSelectMenuItem(menuItem, 1); } this.calculateFoodPrice(); }