Exemple #1
0
        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();
        }
Exemple #2
0
 public AddFood(DAL.Menu menu, DAL.MenuItem menuItem = null)
 {
     InitializeComponent();
     this.menu     = menu;
     this.MenuItem = menuItem;
     this.LoadData();
 }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
                        }
                    }
                }
            }
        }
Exemple #5
0
        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();
        }