Example #1
0
        public void AddProdus()
        {
            var op = view.ProductOrder();
            DataAccessOrderProduct bl = new DataAccessOrderProduct();

            bl.AddProductOrder(op);

            int prodID = view.Product();

            DataAccessProduct x   = new DataAccessProduct();
            IList <Product>   pro = x.RetrieveProductOrder(prodID);

            foreach (Product pp in pro)
            {
                pp.Stock = pp.Stock - 1;
                if (pp.Stock < 0)
                {
                    MessageBox.Show("Stock epuizat!");
                    break;
                }
                else
                {
                    x.UpdateProduct(prodID, pp.Stock);
                }

                ///test
                ///
                //total order
                double sum = 0;

                int orderID = view.OrderProduct();
                //  OrderProduct po = new OrderProduct();
                //  Product prod = new Product();
                //   po.IdOrder = Convert.ToInt32(textBox1.Text);

                DataAccessOrderProduct y            = new DataAccessOrderProduct();
                IList <OrderProduct>   listIdProdus = y.RetrieveOrderProduct(orderID);


                DataAccessProduct op1 = new DataAccessProduct();


                foreach (OrderProduct i in listIdProdus)
                {
                    IList <Product> listP = op1.RetrieveProductOrder(i.IdProduct);

                    foreach (Product j in listP)
                    {
                        sum += j.Price;
                    }
                }
                MessageBox.Show("Total comanda: " + sum);
                // view.textBox8.Text = sum.ToString();

                //  return sum;
            }
        }
        public void AddProductOrder(OrderProduct product)
        {
            DataAccessOrderProduct dal = new DataAccessOrderProduct();

            dal.AddProductOrder(product);
        }