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 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;
        }
        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");
            }
        }