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(); }
private void deleteToolStripMenuItem_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Are you sure to delete \"" + this.MenuItem.Name + "\"", "Confirm", MessageBoxButtons.YesNo); if (dr == DialogResult.Yes) { MenuItemBLL menuItemBLL = new MenuItemBLL(); menuItemBLL.Delete(this.MenuItem); // fire event if (this.OnDelete != null) { this.OnDelete(this.MenuItem); } } }
private void LoadData() { MenuBLL menuBLL = new MenuBLL(); List <DAL.Menu> menus = menuBLL.ListMenu(); //lsCategory.DataSource = listMenuItem; problem this.tabControl.Controls.Clear(); foreach (DAL.Menu menu in menus) { var t = new TabPage(); t.Location = new Point(4, 22); //t.Name = menu.Name; t.Name = menu.Name; t.Padding = new Padding(3); t.Size = new Size(597, 257); t.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); t.Text = menu.Name; t.UseVisualStyleBackColor = true; t.AutoScroll = true; t.Tag = menu; this.tabControl.Controls.Add(t); // add layout FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel(); flowLayoutPanel.Dock = DockStyle.Fill; flowLayoutPanel.AutoScroll = true; t.Controls.Add(flowLayoutPanel); // add menu item MenuItemBLL menuItemBLL = new MenuItemBLL(); //List<DAL.MenuItem> menuItems = menuItemBLL.FindByMenuID(menu); List <DAL.MenuItem> menuItems = menuItemBLL.FindByMenuID(menu); //lsCategory.DataSource = listMenuItem; for (int i = 0; i < menuItems.Count; i++) { MenuItemControl menuItemControl = new MenuItemControl(menuItems[i], false); menuItemControl.Tag = i; menuItemControl.OnEdit += new MenuItemControl.OnEditHandler(this.menuItemControl_OnEdit); menuItemControl.OnDelete += new MenuItemControl.OnDeleteHandler(this.menuItemControl_OnDelete); flowLayoutPanel.Controls.Add(menuItemControl); //menuItemControl.Click += new EventHandler(this.MenuItem_OnClick); } } }
private void LoadData() { this.lbTable.Text = this.getTableName(); // Get order if (this.Tables[0].Status != 0) { // had created order OrderBLL orderBLL = new OrderBLL(); this.order = orderBLL.GetCurrentOrderByTable(this.Tables[0]); if (order != null) { foreach (OrderDetail od in this.order.OrderDetails) { this.NewSelectMenuItem(od.MenuItem, (int)od.Quantity, od); } // get order tables this.Tables.Clear(); foreach (var od in this.order.OrderTables) { this.Tables.Add(od.Table); } this.lbTable.Text = this.getTableName(); this.OldTables = new List <Table>(this.Tables); } this.txtCustomerName.Text = this.order.CustomerName; this.calculateFoodPrice(); this.calculateDiscount(); this.Extra = this.order.Extra == null ? 0 : (decimal)this.order.Extra; if (this.order.VAT != null) { this.VAT = (decimal)this.order.VAT; } } // Load menu MenuBLL menuBLL = new MenuBLL(); List <DAL.Menu> menus = menuBLL.ListMenu(); this.tabControl.Controls.Clear(); foreach (DAL.Menu menu in menus) { var t = new TabPage(); t.Location = new Point(4, 22); t.Name = menu.Name; t.Padding = new Padding(3); t.Size = new Size(597, 257); t.Font = new Font("Microsoft Sans Serif", 8.25F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(0))); t.Text = menu.Name; t.UseVisualStyleBackColor = true; t.AutoScroll = true; this.tabControl.Controls.Add(t); // add layout FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel(); flowLayoutPanel.Dock = DockStyle.Fill; flowLayoutPanel.AutoScroll = true; t.Controls.Add(flowLayoutPanel); // add menu item MenuItemBLL menuItemBLL = new MenuItemBLL(); List <DAL.MenuItem> menuItems = menuItemBLL.FindByMenuID(menu); for (int i = 0; i < menuItems.Count; i++) { MenuItemControl menuItemControl = new MenuItemControl(menuItems[i]); menuItemControl.Tag = i; flowLayoutPanel.Controls.Add(menuItemControl); menuItemControl.Click += new EventHandler(this.MenuItem_OnClick); } } // Show/Hide bottom buttonBar if (this.order == null) { this.layoutButton.Hide(); this.tabControl.Height += this.layoutButton.Height; } }