Пример #1
0
        private void button7_Click(object sender, EventArgs e)
        {
            string phrase = txtMenuPrice.Text;

            int  number;
            bool isNumeric = int.TryParse(phrase, out number);

            if (isNumeric == true)
            {
                Menu_Item      item = new Menu_Item();
                Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Description == cmbMenuItemType.Text);

                Menu_Item_Price price = new Menu_Item_Price();
                price.Menu_Price = Convert.ToDouble(txtMenuPrice.Text);
                db.Menu_Item_Price.Add(price);

                item.Menu_Item_Name        = txtMenuItemName.Text;
                item.Menu_Item_Description = richDescription.Text;
                item.Menu_Item_Type_ID     = type.Menu_Item_Type_ID;
                item.Menu_Item_Price       = price.Menu_Price;
                item.Menu_Price_ID         = price.Menu_Price_ID;
                db.Menu_Item.Add(item);
                db.SaveChanges();

                MessageBox.Show("Menu item added successfully");
                this.Close();
            }
            else
            {
                MessageBox.Show("Error: Values entered is not in correct format(not numeric)");
            }
        }
        private void button7_Click(object sender, EventArgs e)
        {
            if (numericUpDown1.Text != "0")
            {
                int id = Globals.OrderMenuItem;

                Menu_Item       item  = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);
                Menu_Item_Price price = db.Menu_Item_Price.FirstOrDefault(c => c.Menu_Price_ID == id);

                if ((item != null) && (price != null))
                {
                    string itemDesc = "ID:  " + Convert.ToString(item.Menu_Item_ID) + " Name:  " + item.Menu_Item_Name
                                      + " Description:  " + item.Menu_Item_Description + " Quantity:  " + numericUpDown1.Text;
                    listBox1.Items.Add(itemDesc);
                    Globals menu = new Globals();

                    menu.OrderItemId          = id;
                    menu.OrderItemName        = item.Menu_Item_Name;
                    menu.OrderItemDescription = item.Menu_Item_Description;

                    menu.OrderItemPrice = price.Menu_Price;

                    menu.OrderQuantity = Convert.ToInt32(numericUpDown1.Text);
                    itemsA.Add(menu);
                }
            }
            else
            {
                MessageBox.Show("Error:Quantity can't be zero");
            }
        }
        private void button7_Click(object sender, EventArgs e)
        {
            string phrase = txtMenuPrice.Text;

            int  number;
            bool isNumeric = int.TryParse(phrase, out number);

            if (isNumeric == true)
            {
                int            id   = Globals.MenuCombopassing;
                Menu_Item      item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);
                Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Description == cmbMenuItemType.Text);


                Menu_Item_Price price = db.Menu_Item_Price.FirstOrDefault(c => c.Menu_Price_ID == id);
                price.Menu_Price = Convert.ToDouble(txtMenuPrice.Text);
                // db.Menu_Item_Price.Add(price);

                item.Menu_Item_Name        = txtMenuItemName.Text;
                item.Menu_Item_Description = richDescription.Text;
                item.Menu_Item_Type_ID     = type.Menu_Item_Type_ID;
                item.Menu_Item_Price       = price.Menu_Price;
                item.Menu_Price_ID         = price.Menu_Price_ID;

                //item.fileName =fileName = ConvertImageToBinary(pictureBox1.Image);

                // db.Menu_Item.Add(item);

                //item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_Name == txtMenuItemName.Text);
                ItemsPicture itempic = db.ItemsPictures.FirstOrDefault(c => c.Menu_Item_ID == id);
                {
                    if ((Globals.browse == true) && (itempic != null))
                    {
                        itempic.ItemName = Globals.fileName;
                        itempic.imageVar = Globals.ConvertImageToBinary(pictureBox1.Image);
                        // itempic.ImageID = item.Combo_ID;
                        // Globals.browse = false;
                    }
                }
                //itempic.ImageID = item.Menu_Item_ID;
                // itempic.Menu_Item_ID = item.Menu_Item_ID;
                //db.ItemsPictures.Add(itempic);



                db.SaveChanges();
                Globals.refresher = true;
                MessageBox.Show("Menu item updated successfully");
                this.Close();
            }
            else
            {
                MessageBox.Show("Error: Values entered is not in correct format(not numeric)");
            }
        }
Пример #4
0
        private void frmMaintainMenuItem_Load(object sender, EventArgs e)
        {
            int            id   = Globals.MenuCombopassing;
            Menu_Item      item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);
            Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Type_ID == item.Menu_Price_ID);

            txtMenuItemName.Text = item.Menu_Item_Name;
            txtMenuPrice.Text    = Convert.ToString(item.Menu_Item_Price);
            richDescription.Text = item.Menu_Item_Description;
            // cmbMenuItemType.Text = type.Menu_Item_Description;
        }
        private /*async*/ void button7_Click(object sender, EventArgs e)
        {
            string phrase = txtMenuPrice.Text;

            int  number;
            bool isNumeric = int.TryParse(phrase, out number);

            if (isNumeric == true)
            {
                Menu_Item      item = new Menu_Item();
                Menu_Item_Type type = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Description == cmbMenuItemType.Text);


                Menu_Item_Price price = new Menu_Item_Price();
                price.Menu_Price = Convert.ToDouble(txtMenuPrice.Text);
                db.Menu_Item_Price.Add(price);

                item.Menu_Item_Name        = txtMenuItemName.Text;
                item.Menu_Item_Description = richDescription.Text;
                item.Menu_Item_Type_ID     = type.Menu_Item_Type_ID;
                item.Menu_Item_Price       = price.Menu_Price;
                item.Menu_Price_ID         = price.Menu_Price_ID;

                //item.fileName =fileName = ConvertImageToBinary(pictureBox1.Image);

                db.Menu_Item.Add(item);

                //item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_Name == txtMenuItemName.Text);
                ItemsPicture itempic = new ItemsPicture();
                {
                    itempic.ItemName     = item.Menu_Item_Name;
                    itempic.imageVar     = Globals.ConvertImageToBinary(pictureBox1.Image);
                    itempic.ImageID      = item.Menu_Item_ID;
                    itempic.Menu_Item_ID = item.Menu_Item_ID;
                    db.ItemsPictures.Add(itempic);
                    //db.SaveChanges();
                }



                db.SaveChanges();
                Globals.refresher = true;
                MessageBox.Show("Menu item added successfully");
                txtMenuItemName.Text = "";
                txtMenuPrice.Text    = "";
                richDescription.Text = "";
                pictureBox1.Image    = null;
            }
            else
            {
                MessageBox.Show("Error: Values entered is not in correct format(not numeric)");
            }
        }
        private void frmMaintain_Menu_Item_Load(object sender, EventArgs e)
        {
            cmbMenuItemType.ValueMember   = "Menu_Item_Type_ID";
            cmbMenuItemType.DisplayMember = "Menu_Item_Description";

            cmbMenuItemType.DataSource = db.Menu_Item_Type.ToList();
            int          id  = Globals.MenuCombopassing;
            ItemsPicture pic = db.ItemsPictures.FirstOrDefault(c => c.Menu_Item_ID == id);
            // Image n = (Bitmap)((new ImageConverter()).ConvertFrom(pic.imageVar));
            Menu_Item       item  = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);
            Menu_Item_Price price = db.Menu_Item_Price.FirstOrDefault(c => c.Menu_Price_ID == id);
            Menu_Item_Type  type  = db.Menu_Item_Type.FirstOrDefault(c => c.Menu_Item_Type_ID == item.Menu_Item_Type_ID);

            pictureBox1.Image    = Globals.converBinToImage(pic.imageVar);
            txtMenuItemName.Text = item.Menu_Item_Name;
            txtMenuPrice.Text    = Convert.ToString(price.Menu_Price);
            cmbMenuItemType.Text = type.Menu_Item_Description;
            richDescription.Text = item.Menu_Item_Description;
            Globals.browse       = false;
        }
Пример #7
0
        private void dgvAuditList_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            dgvAuditDetails.DataSource = null;
            dgvAuditDetails.Rows.Clear();
            int     rowindex = dgvAuditList.CurrentCell.RowIndex;
            dynamic value    = dgvAuditList.Rows[rowindex].Cells[0].Value;

            if (value != null)
            {
                int   v = value;
                Audit t = db.Audits.FirstOrDefault(c => c.Audit_ID == v);
                if (t.Audit_Description == "Order Processing")
                {
                    var Menus = from obj in db.Customer_Order_Line
                                join obj2 in db.Customer_Order
                                on obj.Customer_Order_ID equals obj2.Order_ID
                                where (obj.Menu_Item_ID != null && obj2.Order_ID == t.transactionNumber)
                                select new
                    {
                        Id        = obj.Menu_Item_ID,
                        Quantity1 = obj.Menu_Item_Quantity
                    };

                    var Combos = from obj in db.Customer_Order_Line
                                 join obj2 in db.Customer_Order
                                 on obj.Customer_Order_ID equals obj2.Order_ID
                                 where (obj.Combo_ID != null && obj2.Order_ID == t.transactionNumber)
                                 select new
                    {
                        Id        = obj.Combo_ID,
                        Quantity1 = obj.Combo_Quantity
                    };

                    var Stocks = from obj in db.Customer_Order_Line
                                 join obj2 in db.Customer_Order
                                 on obj.Customer_Order_ID equals obj2.Order_ID
                                 where (obj.Stock_ID != null && obj2.Order_ID == t.transactionNumber)
                                 select new
                    {
                        Id        = obj.Stock_ID,
                        Quantity1 = obj.Stock_Item_Quantity
                    };



                    foreach (var i in Menus)
                    {
                        Menu_Item m = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == i.Id);
                        this.dgvAuditDetails.Rows.Add(m.Menu_Item_Name, i.Quantity1);
                    }

                    foreach (var i in Combos)
                    {
                        Combo m = db.Comboes.FirstOrDefault(c => c.Combo_ID == i.Id);
                        this.dgvAuditDetails.Rows.Add(m.Combo_Name, i.Quantity1);
                    }

                    foreach (var i in Stocks)
                    {
                        Stock_Item m = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == i.Id);
                        this.dgvAuditDetails.Rows.Add(m.Stock_Item_Name, i.Quantity1);
                    }
                }

                else if (t.Audit_Description == "Order Saving")
                {
                    var Menus = from obj in db.DeliveryLines
                                join obj2 in db.DeliveryTables
                                on obj.orderId equals obj2.OrderId
                                where (obj.menuItemId != null && obj2.OrderId == t.transactionNumber)
                                select new
                    {
                        Id        = obj.menuItemId,
                        Quantity1 = obj.menuItemQuantity
                    };

                    var Combos = from obj in db.DeliveryLines
                                 join obj2 in db.DeliveryTables
                                 on obj.orderId equals obj2.OrderId
                                 where (obj.comboItemId != null && obj2.OrderId == t.transactionNumber)
                                 select new
                    {
                        Id        = obj.comboItemId,
                        Quantity1 = obj.comboItemQuantity
                    };

                    var Stocks = from obj in db.DeliveryLines
                                 join obj2 in db.DeliveryTables
                                 on obj.orderId equals obj2.OrderId
                                 where (obj.stockItemId != null && obj2.OrderId == t.transactionNumber)
                                 select new
                    {
                        Id        = obj.stockItemId,
                        Quantity1 = obj.stockItemQuantity
                    };



                    foreach (var i in Menus)
                    {
                        Menu_Item m = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == i.Id);
                        this.dgvAuditDetails.Rows.Add(m.Menu_Item_Name, i.Quantity1);
                    }

                    foreach (var i in Combos)
                    {
                        Combo m = db.Comboes.FirstOrDefault(c => c.Combo_ID == i.Id);
                        this.dgvAuditDetails.Rows.Add(m.Combo_Name, i.Quantity1);
                    }

                    foreach (var i in Stocks)
                    {
                        Stock_Item m = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == i.Id);
                        this.dgvAuditDetails.Rows.Add(m.Stock_Item_Name, i.Quantity1);
                    }
                }

                else if (t.Audit_Description == "Stock_Item_Write_Off")
                {
                    Stock_WriteOff_Line w = db.Stock_WriteOff_Line.FirstOrDefault(c => c.Stock_WriteOff_LineID == t.transactionNumber);
                    Stock_Item          s = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == w.Stock_ID);
                    this.dgvAuditDetails.Rows.Add(s.Stock_Item_Name, w.Quantity);
                }
                else if (t.Audit_Description == "Item_CheckIn")
                {
                    Check_In_Line w = db.Check_In_Line.FirstOrDefault(c => c.Check_In_Line_ID == t.transactionNumber);
                    Stock_Item    s = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == w.Stock_ID);
                    this.dgvAuditDetails.Rows.Add(s.Stock_Item_Name, w.Quantity);
                }

                else if (t.Audit_Description == "Item_CheckOut")
                {
                    Check_Out_Line w = db.Check_Out_Line.FirstOrDefault(c => c.Check_Out_ID == t.transactionNumber);
                    Stock_Item     s = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == w.Stock_ID);
                    this.dgvAuditDetails.Rows.Add(s.Stock_Item_Name, w.Quaantity);
                }
            }
        }
Пример #8
0
        private void dgvOrders_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            int rowindex = dgvOrders.CurrentCell.RowIndex;

            Globals.Salespassing = dgvOrders.Rows[rowindex].Cells[0].Value;

            int            orderNo = Globals.Salespassing;
            Customer_Order ordeR   = db.Customer_Order.FirstOrDefault(c => c.Order_ID == orderNo);

            txtDate.Enabled       = false;
            txtOrderTotal.Enabled = false;
            txtOrdNum.Enabled     = false;
            txtStatus.Enabled     = false;
            txtVat.Enabled        = false;
            rbxNotes.Enabled      = false;

            txtDate.Text       = ordeR.Order_Date.ToString();
            txtOrderTotal.Text = ordeR.OrderTotal.ToString();
            txtOrdNum.Text     = ordeR.Order_ID.ToString();
            txtStatus.Text     = ordeR.Order_Status.ToString();
            txtVat.Text        = ordeR.Sale_Vat_Amount.ToString();
            rbxNotes.Text      = ordeR.OrderNotes.ToString();

            var combos = from obj in db.Customer_Order_Line
                         where (obj.Customer_Order_ID == orderNo) && (obj.Combo_ID != null)
                         select new
            {
                itemId       = obj.Combo_ID,
                itemQuantity = obj.Combo_Quantity
            };

            foreach (var item in combos)
            {
                Globals it    = new Globals();
                dynamic num   = item.itemId;
                int     id    = num;
                dynamic num2  = item.itemQuantity;
                int     quant = num2;
                Combo   comb  = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);
                it.OrderItemName  = comb.Combo_Name;
                it.OrderQuantity  = num2;
                it.OrderItemPrice = comb.Combo_Price;

                list.Add(it);
            }



            var menus = from obj in db.Customer_Order_Line
                        where (obj.Customer_Order_ID == orderNo) && (obj.Menu_Item_ID != null)
                        select new
            {
                itemId       = obj.Menu_Item_ID,
                itemQuantity = obj.Menu_Item_Quantity
            };

            foreach (var item in menus)
            {
                Globals   it    = new Globals();
                dynamic   num   = item.itemId;
                int       id    = num;
                dynamic   num2  = item.itemQuantity;
                int       quant = num2;
                Menu_Item comb  = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);
                it.OrderItemName  = comb.Menu_Item_Name;
                it.OrderQuantity  = num2;
                it.OrderItemPrice = comb.Menu_Item_Price;

                list.Add(it);
            }

            var stocks = from obj in db.Customer_Order_Line
                         where (obj.Customer_Order_ID == orderNo) && (obj.Stock_ID != null)
                         select new
            {
                itemId       = obj.Stock_ID,
                itemQuantity = obj.Stock_Item_Quantity
            };

            foreach (var item in stocks)
            {
                Globals    it    = new Globals();
                dynamic    num   = item.itemId;
                int        id    = num;
                dynamic    num2  = item.itemQuantity;
                int        quant = num2;
                Stock_Item comb  = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                it.OrderItemName = comb.Stock_Item_Name;
                it.OrderQuantity = num2;
                dynamic     num3 = comb.Stock_ID;
                int         id5  = num3;
                Stock_Price pric = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == id5);
                it.OrderItemPrice = pric.Stock_Price1;

                list.Add(it);
            }



            var products = from obj in list
                           select new
            {
                ItemName     = obj.OrderItemName,
                ItemQuantity = obj.OrderQuantity,
                ItemPrice    = obj.OrderItemPrice
            };


            dataGridView1.DataSource = products.ToList();
            list.Clear();
        }
Пример #9
0
        private void frmViewOrder_Load(object sender, EventArgs e)
        {
            int            orderNo = Globals.Salespassing;
            Customer_Order ordeR   = db.Customer_Order.FirstOrDefault(c => c.Order_ID == orderNo);

            if (ordeR != null)
            {
                txtDate.Enabled       = false;
                txtOrderTotal.Enabled = false;
                txtOrdNum.Enabled     = false;
                txtStatus.Enabled     = false;
                txtVat.Enabled        = false;
                rbxNotes.Enabled      = false;

                txtDate.Text       = ordeR.Order_Date.ToString();
                txtOrderTotal.Text = ordeR.OrderTotal.ToString();
                txtOrdNum.Text     = ordeR.Order_ID.ToString();
                txtStatus.Text     = ordeR.Order_Status.ToString();
                txtVat.Text        = ordeR.Sale_Vat_Amount.ToString();
                rbxNotes.Text      = ordeR.OrderNotes.ToString();

                var combos = from obj in db.Customer_Order_Line
                             where (obj.Customer_Order_ID == orderNo) && (obj.Combo_ID != null)
                             select new
                {
                    itemId       = obj.Combo_ID,
                    itemQuantity = obj.Combo_Quantity
                };

                foreach (var item in combos)
                {
                    Globals it    = new Globals();
                    dynamic num   = item.itemId;
                    int     id    = num;
                    dynamic num2  = item.itemQuantity;
                    int     quant = num2;
                    Combo   comb  = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);
                    it.OrderItemName  = comb.Combo_Name;
                    it.OrderQuantity  = num2;
                    it.OrderItemPrice = comb.Combo_Price;

                    list.Add(it);
                }



                var menus = from obj in db.Customer_Order_Line
                            where (obj.Customer_Order_ID == orderNo) && (obj.Menu_Item_ID != null)
                            select new
                {
                    itemId       = obj.Menu_Item_ID,
                    itemQuantity = obj.Menu_Item_Quantity
                };

                foreach (var item in menus)
                {
                    Globals   it    = new Globals();
                    dynamic   num   = item.itemId;
                    int       id    = num;
                    dynamic   num2  = item.itemQuantity;
                    int       quant = num2;
                    Menu_Item comb  = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);
                    it.OrderItemName  = comb.Menu_Item_Name;
                    it.OrderQuantity  = num2;
                    it.OrderItemPrice = comb.Menu_Item_Price;

                    list.Add(it);
                }

                var stocks = from obj in db.Customer_Order_Line
                             where (obj.Customer_Order_ID == orderNo) && (obj.Stock_ID != null)
                             select new
                {
                    itemId       = obj.Stock_ID,
                    itemQuantity = obj.Stock_Item_Quantity
                };

                foreach (var item in stocks)
                {
                    Globals    it    = new Globals();
                    dynamic    num   = item.itemId;
                    int        id    = num;
                    dynamic    num2  = item.itemQuantity;
                    int        quant = num2;
                    Stock_Item comb  = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                    it.OrderItemName = comb.Stock_Item_Name;
                    it.OrderQuantity = num2;
                    dynamic     num3 = comb.Stock_ID;
                    int         id5  = num3;
                    Stock_Price pric = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == id5);
                    it.OrderItemPrice = pric.Stock_Price1;

                    list.Add(it);
                }



                var products = from obj in list
                               select new
                {
                    ItemName     = obj.OrderItemName,
                    ItemQuantity = obj.OrderQuantity,
                    ItemPrice    = obj.OrderItemPrice
                };


                dgvOrders.DataSource = products.ToList();
            }
            else
            {
                this.Close();
                MessageBox.Show("No Order selected,Select order to view");
            }
        }
Пример #10
0
        void myMenu_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {
            if (navButton == btnMenu)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.MenuCombopassing;

                        Menu_Item deieteItem = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);

                        if (deieteItem != null)
                        {
                            db.Menu_Item.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Menu_Item_Name + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int       id   = Globals.MenuCombopassing;
                    Menu_Item item = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == id);
                    if (item != null)
                    {
                        frmMaintainMenuItem form = new frmMaintainMenuItem();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }



            //Suppliers Right Cick Event handlers

            if (navButton == btnEmployees)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.Employeepassing;

                        Employee deieteItem = db.Employees.FirstOrDefault(c => c.Employee_ID == id);

                        if (deieteItem != null)
                        {
                            db.Employees.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Employee_Name + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int      id   = Globals.Employeepassing;
                    Employee item = db.Employees.FirstOrDefault(c => c.Employee_ID == id);
                    if (item != null)
                    {
                        Maintain_Employee form = new Maintain_Employee();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }


            //Suppliers Right click Handlers

            if (navButton == btnSuppliers11)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.Supplierpassing;

                        Supplier deieteItem = db.Suppliers.FirstOrDefault(c => c.Supllier_ID == id);

                        if (deieteItem != null)
                        {
                            db.Suppliers.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Supplier_Name + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int      id   = Globals.Supplierpassing;
                    Supplier item = db.Suppliers.FirstOrDefault(c => c.Supllier_ID == id);
                    if (item != null)
                    {
                        SupplierForm form = new SupplierForm();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }

            if (navButton == btnCombo)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.Combopassing;

                        Combo deieteItem = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);

                        if (deieteItem != null)
                        {
                            db.Comboes.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Combo_Description + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int   id   = Globals.Combopassing;
                    Combo item = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);
                    if (item != null)
                    {
                        frmMaintainCombo form = new frmMaintainCombo();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }

            if (navButton == btnCombo)
            {
                if (e.ClickedItem.Name.ToString() == "Deleted")
                {
                    Globals.menu.Hide();
                    if (dgvSupplier.Rows.Count != 0)
                    {
                        int id = Globals.Combopassing;

                        Combo deieteItem = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);

                        if (deieteItem != null)
                        {
                            db.Comboes.Remove(deieteItem);
                            db.SaveChanges();
                            MessageBox.Show("Stock item(" + deieteItem.Combo_Description + ") deleted successfully");
                        }
                        else
                        {
                            MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                        }
                    }
                }
                else if (e.ClickedItem.Name.ToString() == "View")
                {
                    Globals.menu.Hide();
                    int   id   = Globals.Combopassing;
                    Combo item = db.Comboes.FirstOrDefault(c => c.Combo_ID == id);
                    if (item != null)
                    {
                        frmMaintainCombo form = new frmMaintainCombo();
                        form.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
            }

            //Stock Management Click Event Handlers
            //
            //-----------------------------------------------------------------------------------------------------//
            if (e.ClickedItem.Name.ToString() == "View")
            {
                Globals.menu.Hide();

                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited != null)
                {
                    Maintain_Stock_Item myform = new Maintain_Stock_Item();
                    myform.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                }
            }

            else if (e.ClickedItem.Name.ToString() == "Check In")
            {
                Globals.menu.Hide();
                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited.Stock_Type_ID == 1)
                {
                    if (itemEdited != null)
                    {
                        Check_In_Stock_Item myform = new Check_In_Stock_Item();
                        myform.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
                else
                {
                    MessageBox.Show("Action not allowed in such stock item");
                }
            }

            else if (e.ClickedItem.Name.ToString() == "Check Out")
            {
                Globals.menu.Hide();
                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited.Stock_Type_ID == 1)
                {
                    if (itemEdited != null)
                    {
                        Check_Out_Stock_Item myform = new Check_Out_Stock_Item();
                        myform.ShowDialog();
                    }
                    else
                    {
                        MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                    }
                }
                else
                {
                    MessageBox.Show("Action not allowed in such stock item");
                }
            }

            else if (e.ClickedItem.Name.ToString() == "Take")
            {
                Globals.menu.Hide();
                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited != null)
                {
                    Take_Stock_Item myform = new Take_Stock_Item();
                    myform.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                }
            }
            else if (e.ClickedItem.Name.ToString() == "Write Off")
            {
                Globals.menu.Hide();
                int        id         = Globals.MStockpassing;
                Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                if (itemEdited != null)
                {
                    Write_Off_stock_Item myform = new Write_Off_stock_Item();
                    myform.ShowDialog();
                }
                else
                {
                    MessageBox.Show("Error:Stock item does not exist/No stock item selected,select a stock item");
                }
            }
        }
        private void btnRetrieve_Click(object sender, EventArgs e)
        {
            string phrase = txtOrderNo.Text;

            double number;
            bool   isNumeric = double.TryParse(phrase, out number);

            if ((phrase.Length < 9) && (isNumeric == true))
            {
                if (Convert.ToInt32(txtOrderNo.Text) > -1)
                {
                    listBox1.Items.Clear();
                    int orderNo             = Convert.ToInt32(txtOrderNo.Text);
                    Company_Information inf = db.Company_Information.FirstOrDefault(c => c.Company_Info_ID == 1);

                    var combos = from obj in db.DeliveryLines
                                 where (obj.orderId == orderNo) && (obj.comboItemId != null)
                                 select new
                    {
                        itemId       = obj.comboItemId,
                        itemQuantity = obj.comboItemQuantity
                    };

                    foreach (var item in combos)
                    {
                        var    comboId = item.itemId;
                        Combo  comb    = db.Comboes.FirstOrDefault(c => c.Combo_ID == comboId);
                        string itemAdd = "ItemName:: " + comb.Combo_Name + " Price: " + comb.Combo_Price + " Quantity: " + Convert.ToString(item.itemQuantity);
                        Globals.vatAmountDelivery = Globals.vatAmountDelivery + comb.Combo_Price * inf.VAT_Percentage;
                        listBox1.Items.Add(itemAdd);
                    }


                    var menus = from obj in db.DeliveryLines
                                where (obj.orderId == orderNo) && (obj.menuItemId != null)
                                select new
                    {
                        itemId       = obj.menuItemId,
                        itemQuantity = obj.menuItemQuantity
                    };

                    foreach (var item in menus)
                    {
                        var       Menu_Item_ID = item.itemId;
                        Menu_Item comb         = db.Menu_Item.FirstOrDefault(c => c.Menu_Item_ID == Menu_Item_ID);
                        string    itemAdd      = "ItemName:: " + comb.Menu_Item_Name + " Price:: " + comb.Menu_Item_Price + " Quantity: " + Convert.ToString(item.itemQuantity);
                        Globals.vatAmountDelivery = Globals.vatAmountDelivery + comb.Menu_Item_Price * inf.VAT_Percentage;
                        listBox1.Items.Add(itemAdd);
                    }

                    var stocks = from obj in db.DeliveryLines
                                 where (obj.orderId == orderNo) && (obj.stockItemId != null)
                                 select new
                    {
                        itemId       = obj.stockItemId,
                        itemQuantity = obj.stockItemQuantity
                    };

                    foreach (var item in stocks)
                    {
                        var         Stock_ID = item.itemId;
                        Stock_Item  comb     = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == Stock_ID);
                        string      itemAdd  = "ItemName:: " + comb.Stock_Item_Name + " Price: " + comb.Stock_Price + " Quantity: " + Convert.ToString(item.itemQuantity);
                        Stock_Price pric     = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == Stock_ID);
                        Globals.vatAmountDelivery = Globals.vatAmountDelivery + pric.Stock_Price1 * inf.VAT_Percentage;
                        listBox1.Items.Add(itemAdd);
                    }

                    if (listBox1.Items.Count != 0)
                    {
                        btnPay.Visible = true;
                    }
                }
                else
                {
                    MessageBox.Show("Error: Item 'ID' can't be less than one");
                }
            }
            else
            {
                MessageBox.Show("Error: Item 'ID' not numeric,please anter a numeric value(integer)");
            }
        }