예제 #1
0
 public void AddOrder(OrdersWM webModel)
 {
     try
     {
         _ordersOperations.AddOrder(OrdersMapping.MapToEntity(webModel));
     }
     catch (Exception ex)
     {
         throw new Exception(ex.ToString());
     }
 }
        private void btnAdd_Click(object sender, EventArgs e)
        {
            //add order
            Order order = new Order();


            OrdersOperations bl = new OrdersOperations();

            order.ID               = Convert.ToInt32(textBox1.Text);
            order.IdCustomer       = Convert.ToInt32(textBox2.Text);
            order.IdEmployee       = Convert.ToInt32(textBox3.Text);
            order.ShippindAddress  = textBox4.Text;
            order.IdentificationNr = Convert.ToInt32(textBox5.Text);
            order.DeliveryDate     = date.Value;
            order.Status           = textBox7.Text;

            bl.AddOrder(order);

            //add ativity employee
            Activity           activity = new Activity();
            ActivityOperations blll     = new ActivityOperations();

            activity.IdEmployee   = Convert.ToInt32(textBox3.Text);
            activity.AddOp        = 1;
            activity.UpdateOp     = 0;
            activity.Viewproduct  = 0;
            activity.DeliveryDate = date.Value.ToString("yyyy-MM-dd");
            //   string d1 = date1.Value.ToString("yyyy-MM-dd");
            blll.AddActivity(activity);



            //total order
            double       sum = 0;
            OrderProduct po  = new OrderProduct();

            //  Product prod = new Product();
            po.IdOrder = Convert.ToInt32(textBox1.Text);

            OrderProductOperations y            = new OrderProductOperations();
            IList <OrderProduct>   listIdProdus = y.RetrieveOrderProductList(po.IdOrder);


            ProductOperations op1 = new ProductOperations();


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

                foreach (Product j in listP)
                {
                    sum += j.Price;
                }
            }
            Console.WriteLine(sum);

            //suma = Convert.ToString(sum);


            textBox8.Text = sum.ToString();
            MessageBox.Show("Operation succesful");
        }