Ejemplo n.º 1
0
        protected void cmdnext_Click(object sender, EventArgs e)
        {
            int orderid      = Convert.ToInt32(Session["OrderId"]);
            int userid       = Convert.ToInt32(Session["UserId"]);
            var delivaryDate = DateTime.Today.AddDays(7);

            order.Insert(new Order
            {
                OrderDate        = DateTime.Today,
                UserId           = userid,
                TotalPrice       = Convert.ToSingle(lbltotal.Text),
                IsProcessedOrNot = 0,
                DeliveryDate     = delivaryDate,
            });
            Session["CartId"] = order.GetMaxId();
            var Maxorderid     = order.GetMaxId();
            var ProductDetails = _checkout.GetAllData(userid);
            int i = 0;

            foreach (var item in ProductDetails)
            {
                _productOrder.insert(new ProductOrder
                {
                    _Size12   = item.Size,
                    OrderId   = Maxorderid,
                    ProductId = item.ColorId,
                    Quantity  = item.Quantity,
                    Status    = "false"
                });
                var ss       = _size.SearchData(item.ColorId, item.Size);
                int quantity = ss.Quantity - Convert.ToInt32(item.Size);
                _size.updateQuantity(ss.SizeId, quantity);
            }



            Session["TotalAmount"] = lbltotal.Text;

            lbl_total.Text = lbltotal.Text;
            int total = Convert.ToInt32(lbltotal.Text);

            if (total > 500)
            {
                lbl_deliveryCharge.Text = "0";
            }
            else
            {
                lbl_deliveryCharge.Text = "100";
            }
            var discountItems = from c in _discount.GetallData() select c;

            foreach (var item in discountItems)
            {
                if (item.Price <= total)
                {
                    var date1 = DateTime.Compare(DateTime.Today, DateTime.Parse(item.ValidityFrom));
                    var date2 = DateTime.Compare(DateTime.Today, DateTime.Parse(item.ValidityTo));

                    if (date1 > 0 && date2 < 0)
                    {
                        lbl_Discount.Text = item.DiscountPercentage;
                    }
                    else
                    {
                        lbl_Discount.Text = "0";
                    }
                }
                else
                {
                    lbl_Discount.Text = "0";
                }
            }
            int   GTotal     = total + Convert.ToInt32(lbl_deliveryCharge.Text);
            float discount   = (total * Convert.ToInt32(lbl_Discount.Text)) / 100;
            float GrandTotal = GTotal - discount;

            lbl_GrandTotal.Text = GrandTotal.ToString();

            MultiView1.ActiveViewIndex = 2;
        }