private void Check_Out_Stock_Item_Load(object sender, EventArgs e)
        {
            int         id         = Globals.MStockpassing;
            Stock_Item  itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
            Stock_Price priceEdit  = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == id);
            Stock_Type  stockType  = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_ID == itemEdited.Stock_Type_ID);

            txtStockItemID.Text    = Convert.ToString(itemEdited.Stock_ID);
            txtStockItemNamee.Text = itemEdited.Stock_Item_Name;

            var customers = from p in db.Check_Out_Line
                            select new
            {
                CheckInLineID = p.Check_Out_Line_ID,
                StockItemName = p.Stock_Item_Name,
                Quantity      = p.Quaantity,
                CheckOutID    = p.Check_Out_ID,
                StockItemID   = p.Stock_ID,
            };

            dgvCheckOut.DataSource = customers.ToList();
            dgvCheckOut.ClearSelection();

            txtStockItemID.Enabled    = false;
            txtStockItemNamee.Enabled = false;
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string phrase = txtStockQuantity.Text;

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

            if (isNumeric == true)
            {
                if ((phrase.Length < 9) && Convert.ToInt32(txtStockQuantity.Text) > 0)
                {
                    int        id         = Globals.MStockpassing;
                    Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);

                    itemEdited.Stock_Item_Quantity = itemEdited.Stock_Item_Quantity + Convert.ToInt32(txtStockQuantity.Text);
                    db.SaveChanges();

                    MessageBox.Show("Stock item checked out successfully,quantity: +" + txtStockQuantity.Text);
                    Globals.refresher = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error:Quantity less than 1 or too large");
                }
            }
            else
            {
                MessageBox.Show("Error: Value entered is not in correct format(not numeric)");
            }
        }
Exemple #3
0
        public void stock(int index)
        {
            stockID = index;
            Stock_Item i = db.Stock_Item.Where(x => x.Stock_ID == stockID).FirstOrDefault();

            txtSelectStock.Text = i.Stock_Item_Name;
        }
Exemple #4
0
        private void btnCheckIn_Click(object sender, EventArgs e)
        {
            string phrase = txtStockQuantity.Text;

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

            if (isNumeric == true)
            {
                int id = Globals.MStockpassing;

                Stock_Item    itemEdited    = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                Check_In      checkitem     = new Check_In();
                Check_In_Line checkitemline = new Check_In_Line();

                if ((phrase.Length < 9) && (Convert.ToInt32(txtStockQuantity.Text) <= itemEdited.Stock_Item_Quantity) && (Convert.ToInt32(txtStockQuantity.Text) > 0))
                {
                    itemEdited.Stock_Item_Quantity = itemEdited.Stock_Item_Quantity - Convert.ToInt32(txtStockQuantity.Text);
                    checkitem.Stock_Item_Name      = itemEdited.Stock_Item_Name;
                    checkitem.Check_In_Date        = DateTime.Today;

                    checkitemline.Check_In_ID     = checkitem.Check_In_ID;
                    checkitemline.Stock_ID        = itemEdited.Stock_ID;
                    checkitemline.Quantity        = Convert.ToInt32(txtStockQuantity.Text);
                    checkitemline.Stock_Item_Name = itemEdited.Stock_Item_Name;
                    db.Check_In_Line.Add(checkitemline);
                    db.Check_In.Add(checkitem);
                    db.SaveChanges();

                    int      id2 = Globals.LogedUser;
                    Employee emp = db.Employees.FirstOrDefault(c => c.Employee_ID == id2);
                    Audit    ad  = new Audit();
                    ad.Audit_Name        = emp.Employee_Name;
                    ad.Audit_Table       = "Stock_Item";
                    ad.Audit_Description = "Item_CheckIn";
                    ad.User_ID           = Globals.LogedUser;
                    ad.transactionNumber = checkitem.Check_In_ID;
                    ad.auditDate         = DateTime.Now;
                    db.Audits.Add(ad);
                    db.SaveChanges();

                    MessageBox.Show("Stock item checked in successfully,quantity: -" + txtStockQuantity.Text);
                    Globals.refresher = true;

                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error:Quantity exceeds stock items available/Quantity less than 1 or too large");
                }
            }
            else
            {
                MessageBox.Show("Error: Value entered is not in correct format(not numeric)");
            }
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            string phrase = txtStockQuantity.Text;

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

            if (isNumeric == true)
            {
                if ((phrase.Length < 9) && Convert.ToInt32(txtStockQuantity.Text) > 0)
                {
                    int            id         = Globals.MStockpassing;
                    Stock_Item     itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                    Check_Out      itemout    = new Check_Out();
                    Check_Out_Line outline    = new Check_Out_Line();

                    itemout.Stock_Item_Name = itemEdited.Stock_Item_Name;
                    itemout.Check_Out_Date  = DateTime.Today;

                    outline.Stock_ID        = itemEdited.Stock_ID;
                    outline.Check_Out_ID    = itemout.Check_Out_ID;
                    outline.Quaantity       = Convert.ToInt32(txtStockQuantity.Text);
                    outline.Stock_Item_Name = itemEdited.Stock_Item_Name;

                    itemEdited.Stock_Item_Quantity = itemEdited.Stock_Item_Quantity + Convert.ToInt32(txtStockQuantity.Text);
                    db.Check_Out.Add(itemout);
                    db.Check_Out_Line.Add(outline);
                    db.SaveChanges();

                    int      id2 = Globals.LogedUser;
                    Employee emp = db.Employees.FirstOrDefault(c => c.Employee_ID == id2);
                    Audit    ad  = new Audit();
                    ad.Audit_Name        = emp.Employee_Name;
                    ad.Audit_Table       = "Check_Out";
                    ad.Audit_Description = "Item_CheckOut";
                    ad.User_ID           = Globals.LogedUser;
                    ad.transactionNumber = itemout.Check_Out_ID;
                    ad.auditDate         = DateTime.Now;
                    db.Audits.Add(ad);
                    db.SaveChanges();

                    MessageBox.Show("Stock item checked out successfully,quantity: +" + txtStockQuantity.Text);
                    Globals.refresher = true;
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Error:Quantity less than 1 or too large");
                }
            }
            else
            {
                MessageBox.Show("Error: Value entered is not in correct format(not numeric)");
            }
        }
        private void button4_Click(object sender, EventArgs e)
        {
            int        id         = Globals.MStockpassing;
            Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);

            db.Stock_Item.Remove(itemEdited);
            db.SaveChanges();
            MessageBox.Show("Stock item deleted successfully");
            Globals.refresher = true;
            this.Close();
        }
        private void Maintain_Stock_Item_Load(object sender, EventArgs e)
        {
            int        id         = Globals.MStockpassing;
            Stock_Item itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);

            Stock_Price priceEdit = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == id);
            Stock_Type  stockType = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_ID == itemEdited.Stock_Type_ID);

            txtStockItemNameMaint.Text        = itemEdited.Stock_Item_Name;
            txtStockItemDescriptionMaint.Text = itemEdited.Stock_Item_Description;
            txtCostPrice.Text  = Convert.ToString(priceEdit.Stock_Price1);
            cmbSTypeMaint.Text = stockType.Stock_Type_Description;
        }
        private void Take_Stock_Item_Load(object sender, EventArgs e)
        {
            int         id         = Globals.MStockpassing;
            Stock_Item  itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
            Stock_Price priceEdit  = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == id);
            Stock_Type  stockType  = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_ID == itemEdited.Stock_Type_ID);

            txtStockItemID.Text    = Convert.ToString(itemEdited.Stock_ID);
            txtStockItemNamee.Text = itemEdited.Stock_Item_Name;

            txtStockItemID.Enabled    = false;
            txtStockItemNamee.Enabled = false;
        }
Exemple #9
0
        public void SendEmail()
        {
            Supplier s = db.Suppliers.Where(x => x.Supplier_ID == supplierID).FirstOrDefault();
            Supplier_Contact_Details sc = db.Supplier_Contact_Details.Where(x => x.Supplier_Contact_ID == s.Supplier_ID).FirstOrDefault();
            Stock_Item       st         = db.Stock_Item.Where(x => x.Stock_ID == stockID).FirstOrDefault();
            Stock_Order_Line so         = db.Stock_Order_Line.Where(x => x.Stock_Order_Line_ID == stockID).FirstOrDefault();


            try
            {
                SmtpClient  client  = new SmtpClient("smtp.gmail.com", 587);
                MailMessage message = new MailMessage();

                string myEmail = "*****@*****.**";
                string pswd    = "@mulaudzi";
                message.From    = new MailAddress(myEmail);
                message.Subject = "Placing an order";

                foreach (var order in Globals.StockOrders)
                {
                    message.Body = "Dear " + s.Supplier_Name + "\nWe are very interested in making an order for the following item:\n\n" +
                                   order.StockItemName + "     Quantity: " + order.sOrderQuantity +
                                   "\n\nWe look forward to your reply \n\nKind Regards Mr Mafokwane (Manager)";
                }

                //message.Body = "Dear \n"+s.Supplier_Name+"\nWe are very interested in making an order for the following item: \n"+
                //                st.Stock_Item_Name +" Quantity"+ so.Stock_Order_Quantity +
                //                "\n\nWe look forward to your reply \n\nKind Regards Mr Mafokwane (Manager)";
                //message.To.Add(sc.Supplier_Email_Adress);
                message.To.Add(sc.Supplier_Email_Adress);
                client.UseDefaultCredentials = false;
                client.EnableSsl             = true;

                client.Credentials = new System.Net.NetworkCredential(myEmail, pswd);
                client.Send(message);
                message = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error " + ex);
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            string phrase = txtCostPrice.Text;

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

            if ((phrase.Length < 9) && isNumeric == true)
            {
                int         id         = Globals.MStockpassing;
                Stock_Item  itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                Stock_Price priceEdit  = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == id);


                itemEdited.Stock_Item_Name        = txtStockItemNameMaint.Text;
                itemEdited.Stock_Item_Description = txtStockItemDescriptionMaint.Text;
                priceEdit.Stock_Price1            = Convert.ToDouble(txtCostPrice.Text);
                if (cmbSTypeMaint.Text == "Ingredient")
                {
                    Stock_Type idTracker = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_Description == "Ingredient");
                    itemEdited.Stock_Type_ID = idTracker.Stock_Type_ID;
                }
                else if (cmbSTypeMaint.Text == "Product")
                {
                    Stock_Type idTracker = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_Description == "Product");
                    itemEdited.Stock_Type_ID = idTracker.Stock_Type_ID;
                }
                db.SaveChanges();

                MessageBox.Show("Stock item updated successfully");
                Globals.refresher = true;

                this.Close();
            }

            else
            {
                MessageBox.Show("Error: Price value entered is not in correct format or value too large");
            }
        }
        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)");
            }
        }
        private void button6_Click(object sender, EventArgs e)
        {
            string phrase = txtShelfId.Text;

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

            if ((phrase.Length < 9) && (isNumeric == true))
            {
                if (Convert.ToInt32(txtShelfId.Text) > -1)
                {
                    if (numericUpDown1.Text != "0")
                    {
                        Globals shelf = new Globals();

                        int id = Convert.ToInt32(txtShelfId.Text);

                        Stock_Item  item  = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                        Stock_Price price = db.Stock_Price.FirstOrDefault(c => c.Stock_Price_ID == id);

                        if ((item != null) && (price != null) && (item.Stock_Type_ID != 2))
                        {
                            shelf.OrderItemId          = id;
                            shelf.OrderItemName        = item.Stock_Item_Name;
                            shelf.OrderItemDescription = item.Stock_Item_Description;
                            shelf.ItemType             = item.Stock_Type_ID.ToString();
                            shelf.OrderItemPrice       = price.Stock_Price1;
                            shelf.OrderQuantity        = Convert.ToInt32(numericUpDown1.Text);
                            Globals.StockItems.Add(shelf);
                            Globals.AmountDue = Globals.AmountDue + shelf.OrderItemPrice * shelf.OrderQuantity;
                            lblAmountDue.Text = Convert.ToString(Globals.AmountDue);
                        }
                        else
                        {
                            MessageBox.Show("Item not found");
                            return;
                        }



                        List <Globals> something = new List <Globals>();
                        something = Globals.StockItems;
                        var items = from obj in something
                                    // where obj.ItemType == "2"
                                    select new

                        {
                            Id           = obj.OrderItemId,
                            Name         = obj.OrderItemName,
                            Description  = obj.OrderItemDescription,
                            ItemQuantity = obj.OrderQuantity,
                            ItemPrice    = obj.OrderItemPrice
                        };

                        dgvShelfItemz.DataSource = items.ToList();
                        dgvShelfItemz.ClearSelection();
                    }

                    else
                    {
                        MessageBox.Show("Error:Quantity cant be zero");
                    }
                }

                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)");
            }
        }
        private void button7_Click(object sender, EventArgs e)
        {
            //string phrase = txtCash.Text;

            //double number;
            //bool isNumeric = double.TryParse(phrase, out number);
            //if ((phrase.Length < 9) && (isNumeric == true))
            //{
            //    if (Convert.ToInt32(txtCash.Text) > -1)
            //    {


            //int contact = Convert.ToInt32(txtContact.Text);

            Customer_Order order = new Customer_Order();


            //Object Declaration---------------------------------//

            try
            {
                Company_Information inf = db.Company_Information.FirstOrDefault(c => c.Company_Info_ID == 1);


                double VatAmount = 0;
                if (Globals.ComboItems.Count != 0)
                {
                    foreach (var item in Globals.ComboItems)
                    {
                        VatAmount = VatAmount + item.OrderItemPrice * inf.VAT_Percentage;
                    }
                }

                if (Globals.ComboItems.Count != 0)
                {
                    foreach (var item in Globals.MenuItems)
                    {
                        VatAmount = VatAmount + item.OrderItemPrice * inf.VAT_Percentage;
                    }
                }

                if (Globals.StockItems.Count != 0)
                {
                    foreach (var item in Globals.StockItems)
                    {
                        VatAmount = VatAmount + item.OrderItemPrice * inf.VAT_Percentage;
                    }
                }

                //-----------------------------------------------------//
                VatAmount = Math.Round(VatAmount, 2);
                //Order Details insert------------------------------------//
                order.Order_Status       = "N";
                order.Order_Date         = DateTime.Now;
                order.Sale_Vat_Amount    = VatAmount;
                order.Payment_ID         = Globals.SalesPaymentID;
                order.Delivery_Status_ID = 2;
                order.OrderNotes         = richTextBox1.Text;
                order.OrderTotal         = Globals.AmountDue;
                order.TotalItems         = Globals.ComboItems.Count + Globals.MenuItems.Count + Globals.StockItems.Count;
                order.Cash   = Convert.ToDouble(txtCash.Text);
                order.Change = Convert.ToDouble(txtCash.Text) - Globals.AmountDue;
                //order.Customer_ID = cust.Customer_ID;
                //---------------------------------------------------------//

                db.Customer_Order.Add(order);
                db.SaveChanges();
            }
            catch (Exception i)
            {
                MessageBox.Show(Convert.ToString(i));
            }
            for (int i = 0; i < Globals.ComboItems.Count; i++)
            {
                Customer_Order_Line orderLine = new Customer_Order_Line();
                orderLine.Customer_Order_ID = order.Order_ID;
                orderLine.Combo_Quantity    = Globals.ComboItems[i].OrderQuantity;
                orderLine.Combo_ID          = Globals.ComboItems[i].OrderItemId;

                db.Customer_Order_Line.Add(orderLine);
                db.SaveChanges();
            }

            for (int i = 0; i < Globals.StockItems.Count; i++)
            {
                Customer_Order_Line orderLine = new Customer_Order_Line();

                orderLine.Customer_Order_ID   = order.Order_ID;
                orderLine.Stock_Item_Quantity = Globals.StockItems[i].OrderQuantity;
                orderLine.Stock_ID            = Globals.StockItems[i].OrderItemId;

                int        id  = Globals.StockItems[i].OrderItemId;
                Stock_Item stc = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                stc.Stock_Item_Quantity = stc.Stock_Item_Quantity - Globals.StockItems[i].OrderQuantity;

                db.Customer_Order_Line.Add(orderLine);
                db.SaveChanges();
            }

            for (int i = 0; i < Globals.MenuItems.Count; i++)
            {
                Customer_Order_Line orderLine = new Customer_Order_Line();
                orderLine.Customer_Order_ID  = order.Order_ID;
                orderLine.Menu_Item_Quantity = Globals.MenuItems[i].OrderQuantity;
                orderLine.Menu_Item_ID       = Globals.MenuItems[i].OrderItemId;

                db.Customer_Order_Line.Add(orderLine);
                db.SaveChanges();
            }

            Globals.ComboItems.Clear();
            Globals.MenuItems.Clear();
            Globals.StockItems.Clear();

            Globals.refresher = true;

            Globals.AmountDue = 0;

            this.Close();

            int      id2 = Globals.LogedUser;
            Employee emp = db.Employees.FirstOrDefault(c => c.Employee_ID == id2);
            Audit    ad  = new Audit();

            ad.Audit_Name        = emp.Employee_Name;
            ad.Audit_Table       = "Customer_Order";
            ad.Audit_Description = "Order Processing";
            ad.User_ID           = Globals.LogedUser;
            ad.transactionNumber = order.Order_ID;
            ad.auditDate         = DateTime.Now;
            db.Audits.Add(ad);
            db.SaveChanges();

            MessageBox.Show("Order created successfully with order number: " + order.Order_ID.ToString());
            btnEatIn.Visible = false;
        }
Exemple #14
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);
                }
            }
        }
Exemple #15
0
        private void button1_Click(object sender, EventArgs e)
        {
            string phrase = txtStockItemPrice.Text;

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

            if ((phrase.Length < 9) && isNumeric == true)
            {
                if (cmbStockItemType.Text == "Ingredient")
                {
                    Stock_Price newPrice = new Stock_Price();
                    newPrice.Stock_Price1 = Convert.ToDouble(txtStockItemPrice.Text);
                    db.Stock_Price.Add(newPrice);
                    newPrice.Stock_Price1 = Convert.ToDouble(txtStockItemPrice.Text);


                    db.Stock_Price.Add(newPrice);
                    Stock_Item newItem   = new Stock_Item();
                    Stock_Type idTracker = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_Description == "Ingredient");
                    newItem.Stock_Item_Name        = txtStockItemnName.Text;
                    newItem.Stock_Item_Description = txtStockItemDescription.Text;
                    newItem.Stock_Item_Quantity    = 0;
                    newItem.Stock_Type_ID          = idTracker.Stock_Type_ID;
                    newItem.Stock_Price_ID         = newPrice.Stock_Price_ID;
                    db.Stock_Item.Add(newItem);
                    db.SaveChanges();
                    MessageBox.Show("Stock item added successfully");
                    Globals.refresher            = true;
                    txtStockItemnName.Text       = "";
                    txtStockItemDescription.Text = "";
                    txtStockItemPrice.Text       = "";
                    cmbStockItemType.Text        = "";
                }


                if ((phrase.Length < 9) && cmbStockItemType.Text == "Product")
                {
                    Stock_Price newPrice = new Stock_Price();
                    newPrice.Stock_Price1 = Convert.ToDouble(txtStockItemPrice.Text);
                    db.Stock_Price.Add(newPrice);
                    newPrice.Stock_Price1 = Convert.ToDouble(txtStockItemPrice.Text);


                    db.Stock_Price.Add(newPrice);
                    Stock_Item newItem   = new Stock_Item();
                    Stock_Type idTracker = db.Stock_Type.FirstOrDefault(c => c.Stock_Type_Description == "Product");
                    newItem.Stock_Item_Name        = txtStockItemnName.Text;
                    newItem.Stock_Item_Description = txtStockItemDescription.Text;
                    newItem.Stock_Item_Quantity    = 0;
                    newItem.Stock_Type_ID          = idTracker.Stock_Type_ID;
                    newItem.Stock_Price_ID         = newPrice.Stock_Price_ID;

                    db.Stock_Item.Add(newItem);

                    db.SaveChanges();
                    MessageBox.Show("Stock item added successfully");
                    Globals.refresher            = true;
                    txtStockItemnName.Text       = "";
                    txtStockItemDescription.Text = "";
                    txtStockItemPrice.Text       = "";
                    cmbStockItemType.Text        = "";
                }
            }

            else
            {
                MessageBox.Show("Error: Price value entered is not in correct format or too large");
            }
        }
        private void button1_Click_1(object sender, EventArgs e)
        {
            string phrase = txtStockQuantity.Text;

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

            if (isNumeric == true)
            {
                int                 id         = Globals.MStockpassing;
                Stock_Item          itemEdited = db.Stock_Item.FirstOrDefault(c => c.Stock_ID == id);
                Stock_Write_Off     writeoff   = new Stock_Write_Off();
                Stock_WriteOff_Line writeline  = new Stock_WriteOff_Line();

                if ((phrase.Length < 9) && (Convert.ToInt32(txtStockQuantity.Text) <= itemEdited.Stock_Item_Quantity) && Convert.ToInt32(txtStockQuantity.Text) > 0)
                {
                    itemEdited.Stock_Item_Quantity = itemEdited.Stock_Item_Quantity - Convert.ToInt32(txtStockQuantity.Text);

                    writeoff.WriteOff_Stock_Name     = itemEdited.Stock_Item_Name;
                    writeoff.WriteOff_Reason         = txtReason.Text;
                    writeoff.Stock_WriteOff_Quantity = Convert.ToInt32(txtStockQuantity.Text);
                    writeoff.WriteOffDate            = DateTime.Now;

                    writeline.Stock_ID        = itemEdited.Stock_ID;
                    writeline.Write_Off_ID    = writeoff.Write_Off_ID;
                    writeline.Quantity        = Convert.ToInt32(txtStockQuantity.Text);
                    writeline.Stock_Item_Name = itemEdited.Stock_Item_Name;

                    db.Stock_Write_Off.Add(writeoff);
                    db.Stock_WriteOff_Line.Add(writeline);

                    db.SaveChanges();

                    int      id2 = Globals.LogedUser;
                    Employee emp = db.Employees.FirstOrDefault(c => c.Employee_ID == id2);
                    Audit    ad  = new Audit();
                    ad.Audit_Name        = emp.Employee_Name;
                    ad.Audit_Table       = "Stock_Write_Off";
                    ad.Audit_Description = "Stock_Item_Write_Off";
                    ad.User_ID           = Globals.LogedUser;
                    ad.transactionNumber = writeoff.Write_Off_ID;
                    ad.auditDate         = DateTime.Now;
                    db.Audits.Add(ad);
                    db.SaveChanges();

                    MessageBox.Show("Stock item writen off successfully,quantity: -" + txtStockQuantity.Text);
                    Globals.refresher = true;
                    this.Close();
                }


                else
                {
                    MessageBox.Show("Error:Quantity exceeds available stock items/Quantity less than 1 or too large");
                }
            }
            else
            {
                MessageBox.Show("Error: Value entered is not in correct format(not numeric)");
            }
        }
Exemple #17
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");
                }
            }
        }
Exemple #18
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();
        }
Exemple #19
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");
            }
        }