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 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;
        }
        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 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");
            }
        }
示例#5
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");
            }
        }
示例#6
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();
        }
示例#7
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");
            }
        }
        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 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)");
            }
        }