Esempio n. 1
0
        public void GetAllCartItems()
        {
            if (Convert.ToInt32(Session["UserId"]) == 0)
            {
                EmptyCart.Visible = true;
                CartItems.Visible = false;
            }
            else
            {
                List <ShoppingCart_Result> objList = new List <ShoppingCart_Result>();
                using (var entities = new ShoppingCartEntities())


                    objList = entities.ShoppingCart(Convert.ToInt32(Session["UserId"])).ToList <ShoppingCart_Result>();
                if (objList.Count != 0)    //cart table is not empty
                {
                    EmptyCart.Visible = false;
                    CartItems.Visible = true;

                    CartList.DataSource = objList; //allocate  data - objlist contain all the products
                    CartList.DataBind();           //bind
                }

                else
                {
                    EmptyCart.Visible = true;
                    CartItems.Visible = false;
                }
            }
        }
Esempio n. 2
0
        public List <CartItem> UpdateCartItems()
        {
            using (CartController cartController = new CartController())
            {
                String cartId = cartController.GetCurrentCartId();

                CartController.ShoppingCartUpdates[] cartUpdates = new CartController.ShoppingCartUpdates[CartList.Rows.Count];
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].ProductId = Guid.Parse(Convert.ToString(rowValues["Product.Id"]));

                    CheckBox cbRemove = new CheckBox();
                    cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                    cartUpdates[i].RemoveItem = cbRemove.Checked;

                    TextBox quantityTextBox = new TextBox();
                    quantityTextBox         = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                    cartUpdates[i].Quantity = Convert.ToInt16(quantityTextBox.Text.ToString());
                }
                cartController.UpdateShoppingCart(cartId, cartUpdates);
                CartList.DataBind();
                lblTotal.Text = String.Format("{0:c}", cartController.GetTotalPrice());
                return(cartController.GetAllCartItems());
            }
        }
Esempio n. 3
0
        public List <CartItem> UpdateCartItems()
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                String cartId = usersShoppingCart.GetCartId();

                ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count];
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);

                    CheckBox cbRemove = new CheckBox();
                    cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                    cartUpdates[i].RemoveItem = cbRemove.Checked;

                    TextBox quantityTextBox = new TextBox();
                    quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                    cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
                }
                usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItems());
            }
        }
Esempio n. 4
0
        //UpdatecartItems Method
        public List <CartItem> UpdateCartItems()
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                String cartId = usersShoppingCart.GetCartId();

                ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count];
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    //The amount of products in the cart.
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);


                    //This the checkbox to tick to remove a product.
                    CheckBox cbRemove = new CheckBox();
                    cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                    cartUpdates[i].RemoveItem = cbRemove.Checked;

                    //This is the textbox to change the quantity.
                    TextBox quantityTextBox = new TextBox();
                    quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                    cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
                }

                //This updates the total for all prdoucts in the cart using the GetTotal method.
                usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItems());
            }
        }
Esempio n. 5
0
        public List <CartItem> UpdateRepeats()
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                String cartId = usersShoppingCart.GetCartId();

                ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new
                                                                        ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count];
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);

                    //CheckBox cbRemove = new CheckBox();
                    //cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                    //cartUpdates[i].RemoveItem = cbRemove.Checked;

                    // DropDownList selectedRepeat = new DropDownList();
                    // selectedRepeat =
                    //(DropDownList)CartList.Rows[i].FindControl("Repeat");
                    // cartUpdates[i].RepeatOrder = selectedRepeat.SelectedValue; /* HERE */

                    //DropDownList selectedRepeat = new DropDownList();
                    DropDownList selectedRepeat = (DropDownList)CartList.Rows[i].FindControl("RepeatOrder");
                    cartUpdates[i].RepeatOrder = selectedRepeat.SelectedValue; /* HERE */
                }
                usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                //lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItems());
            }
        }
        public List <CartItem> UpdateCartItems()
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                String cartId = usersShoppingCart.GetCartId();

                List <ShoppingCartActions.ShoppingCartUpdates> cartUpdates = new List <ShoppingCartActions.ShoppingCartUpdates>();
                foreach (GridViewRow row in CartList.Rows)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(row);
                    var ControlCheckbox = (CheckBox)row.FindControl("Remove");
                    var TextBox         = (TextBox)row.FindControl("PurchaseQuantity");
                    ShoppingCartActions.ShoppingCartUpdates cartUpdate = new ShoppingCartActions.ShoppingCartUpdates
                    {
                        ProductId        = Convert.ToInt32(rowValues["ProductID"]),
                        RemoveItem       = ControlCheckbox.Checked,
                        PurchaseQuantity = Convert.ToInt16(TextBox.Text.ToString())
                    };
                    cartUpdates.Add(cartUpdate);
                }
                usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItems());
            }
        }
Esempio n. 7
0
        //update cart item with db
        private List <CartItem> UpdateCartItems()
        {
            using (ShoppingCartActions shopaction = new ShoppingCartActions())
            {
                string cartId = shopaction.GetCartId().ToString();
                ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count];

                //collect item in cart to update list
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);

                    CheckBox cbRm = CartList.Rows[i].FindControl("Remove") as CheckBox;
                    cartUpdates[i].RemoveItem = cbRm.Checked;

                    TextBox qnt = CartList.Rows[i].FindControl("PurchaseQuantity") as TextBox;
                    cartUpdates[i].PurchaseQuantity = Convert.ToInt16(qnt.Text);
                }

                shopaction.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                lblTotal.Text = string.Format("{0:c}", shopaction.GetTotal());
                return(shopaction.GetCartItems());
            }
        }
        private List <CartItem> UpdateCartItems()
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                ShoppinCartUpdates[] cartUpdates = new ShoppinCartUpdates[CartList.Rows.Count];

                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].produtoId = Convert.ToInt32(rowValues["ProductId"]);

                    CheckBox cbRemove = new CheckBox();
                    cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                    cartUpdates[i].isRemovedItem = cbRemove.Checked;


                    TextBox TbQuantity = new TextBox();
                    TbQuantity = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                    cartUpdates[i].purchaseQuantity = Convert.ToInt32(TbQuantity.Text);
                }

                usersShoppingCart.UpdateShoppingCartDatabase(cartUpdates);
                CartList.DataBind();
                lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItems().ToList());
            }
        }
Esempio n. 9
0
        public List <CartItem> UpdateCartItems()
        {
            var cartManager = new Logic.CartManager();
            var cartId      = ShoppingCartActions.GetCartId();

            Domain.Models.ShoppingCartUpdates[] cartUpdates = new Domain.Models.ShoppingCartUpdates[CartList.Rows.Count];
            for (int i = 0; i < CartList.Rows.Count; i++)
            {
                IOrderedDictionary rowValues = new OrderedDictionary();
                rowValues = GetValues(CartList.Rows[i]);
                cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);

                CheckBox cbRemove = new CheckBox();
                cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                cartUpdates[i].RemoveItem = cbRemove.Checked;

                TextBox quantityTextBox = new TextBox();
                quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
            }
            cartManager.UpdateShoppingCartDatabase(cartId, cartUpdates);
            CartList.DataBind();
            lblTotal.Text = $"{cartManager.GetCartTotal(cartId):c}";
            return(cartManager.GetCartItems(cartId));
        }
Esempio n. 10
0
        public List <CARTITEM> UpdateCartItems()
        {
            using (ShoppingCart shoppingCart = new ShoppingCart())
            {
                int cartId = shoppingCart.getCartId();

                ShoppingCart.ShoppingCartUpdates[] cartUpdates = new ShoppingCart.ShoppingCartUpdates[CartList.Rows.Count];
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    //This is to store the new values from the entered value in the grid view
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);

                    CheckBox cbRemove = new CheckBox();
                    cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                    cartUpdates[i].RemoveItem = cbRemove.Checked;

                    TextBox quantityTextBox = new TextBox();
                    quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                    cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
                }
                shoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                lblTotal.Text = String.Format("{0:c}", shoppingCart.GetTotal());
                return(shoppingCart.GetCartItems());
            }
        }
Esempio n. 11
0
        public async Task GetShoppingCartItems()
        {
            ShoppingCartActions actions = new ShoppingCartActions();
            var cartItems = await actions.GetCartItems();

            CartList.DataSource = cartItems;
            CartList.DataBind();
        }
Esempio n. 12
0
 protected void UpdateBtn_Click(object sender, EventArgs e)
 {
     //https://docs.microsoft.com/en-us/aspnet/aspnet/overview/web-development-best-practices/what-not-to-do-in-aspnet-and-what-to-do-instead#reliability-and-performance
     Page.RegisterAsyncTask(new PageAsyncTask(async() =>
     {
         var cartItems       = await UpdateCartItems();
         CartList.DataSource = cartItems;
         CartList.DataBind();
     }));
 }
 private void UpdateCart()
 {
     CartList.DataSource = CartActions.GetCart();
     CartList.DataBind();
     if (CartList.Rows.Count > 0)
     {
         Label lbltotal = CartList.FooterRow.Cells[4].FindControl("lblTotal") as Label;
         lbltotal.Text = CartActions.GetCart().Sum(a => a.LineTotal).ToString("c");
     }
 }
Esempio n. 14
0
        protected void Page_Load(object sender, EventArgs e)
        {
            double bookcost;
            string searchString = (string)Session["SearchString"];

            if (!IsPostBack)
            {
                if (Request.UrlReferrer.AbsolutePath == "/ConfirmationPage")
                {
                    Response.Write("<script language=javascript>alert('ORDER CANCELED: emptying shopping cart.');</script>");
                    var datareset = Session["EmptySetForCart"];
                    CartList.DataBind();
                }
                else
                {
                    if (searchString == "Linda Prince")
                    {
                        var dataset = Session["dataSource"];
                        CartList.DataSource = dataset;
                        CartList.DataBind();
                        totalBooksInCart.Text = totalBooksInCart.Text + " " + CartList.Rows.Count.ToString();
                        bookcost            = 22;
                        Session["bookcost"] = bookcost;
                        subTotal.Text       = subTotal.Text + " " + $"{bookcost}";
                    }
                    else
                    {
                        var dataset = Session["dataSource"];
                        CartList.DataSource = dataset;
                        CartList.DataBind();
                        totalBooksInCart.Text = totalBooksInCart.Text + " " + CartList.Rows.Count.ToString();
                        bookcost            = 78.73;
                        Session["bookcost"] = bookcost;
                        subTotal.Text       = subTotal.Text + " " + $"{bookcost}";
                    }
                }
            }
            else
            {
                if (Request.UrlReferrer.AbsolutePath == "/ConfirmationPage")
                {
                    var datareset = Session["EmptySetForCart"];
                    CartList.DataBind();
                }
                else
                {
                    var dataset = Session["dataSource"];
                    CartList.DataSource = dataset;
                    CartList.DataBind();
                    totalBooksInCart.Text = totalBooksInCart.Text + " " + CartList.Rows.Count.ToString();
                    subTotal.Text         = subTotal.Text + " " + "500";
                }
            }
        }
Esempio n. 15
0
 protected void OnItemCommand(object sender, ListViewCommandEventArgs e)
 {
     if (String.Equals(e.CommandName, "Remove"))
     {
         computerList = GetComputers();
         computerList.RemoveAt(0);
         CartList.DataSource = computerList;
         CartList.DataBind();
         Cart cart = new Cart(computerList);
         Response.Cookies["computer"].Value = Cart.Serialize(cart);
         Quantity_Change(null, null);
     }
 }
Esempio n. 16
0
        public List <CartItem> UpdateCartItems()
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                String cartId = usersShoppingCart.GetCartId();

                ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count];
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].LivroId = Convert.ToInt32(rowValues["livro_id"]);

                    CheckBox cbRemove = new CheckBox();
                    cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remover");
                    cartUpdates[i].RemoverItem = cbRemove.Checked;

                    int quantidadeAnterior = GetShoppingCartItems().Cast <CartItem>().ElementAt(i).quantidade;

                    Estoque estoque = commands["CONSULTAR"].execute(new Estoque()
                    {
                        Livro = new Dominio.Livro.Livro()
                        {
                            ID = cartUpdates[i].LivroId
                        }
                    }).Entidades.Cast <Estoque>().ElementAt(0);

                    TextBox quantityTextBox = new TextBox();
                    quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");

                    if (estoque.Qtde < Convert.ToInt32(quantityTextBox.Text))
                    {
                        cartUpdates[i].PurchaseQuantity = quantidadeAnterior;
                        lblResultadoCarrinho.Text       = "Quantidade em estoque do livro " + estoque.Livro.Titulo + " é de " + estoque.Qtde + " unidade(s)";
                        lblResultadoCarrinho.Visible    = true;
                    }
                    else
                    {
                        cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
                        lblResultadoCarrinho.Text       = "";
                        lblResultadoCarrinho.Visible    = false;
                    }
                }
                usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                lblSubtotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItems());
            }
        }
Esempio n. 17
0
        protected void Page_Init(object sender, EventArgs e)
        {
            computerList = GetComputers();
            Cart cart = new Cart(computerList);

            PriceLabel.Text     = cart.GetTotalStr();
            CartList.DataSource = computerList;
            CartList.DataBind();
            for (int i = 0; i < CartList.Items.Count; i++)
            {
                Computer     computer = computerList[i];
                ListViewItem item     = CartList.Items[i];
                DropDownList ddList   = (DropDownList)item.FindControl("QuantityDropDown");
                ddList.Items[computer.Quantity - 1].Selected = true;
            }
        }
Esempio n. 18
0
        private void UpdateSummaryPanel()
        {
            if (isEmployeeSet)
            {
                Summary_Header.InnerText = "Summary for " + session.GetEmployeeFirstName() + " " + session.GetEmployeeLastName();

                GrossSalary_Label.Text      = session.GetAnnualGross().ToString("C");
                AnnualDeductions_Label.Text = session.GetAnnualDeductions().ToString("C");
                AnnualTakehome_Label.Text   = session.GetAnnualNet().ToString("C");

                GrossPayPeriod_Label.Text      = session.GetPaycheckGross().ToString("C");
                PayPeriodDeductions_Label.Text = session.GetPaycheckDeductions().ToString("C");
                PayPeriodTakehome_Label.Text   = session.GetPaycheckNet().ToString("C");
            }

            CartList.DataSource = LoadGridView();
            CartList.DataBind();
        }
Esempio n. 19
0
        public List <CartItem> UpdateCartItems()
        {
            using (ShoppingCartActions usersShoppingCart = new ShoppingCartActions())
            {
                String cartId = usersShoppingCart.GetCartId();

                ShoppingCartActions.ShoppingCartUpdates[] cartUpdates = new ShoppingCartActions.ShoppingCartUpdates[CartList.Rows.Count];
                for (int i = 0; i < CartList.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues = GetValues(CartList.Rows[i]);
                    cartUpdates[i].ProductId = Convert.ToInt32(rowValues["ProductID"]);

                    CheckBox cbRemove = new CheckBox();
                    cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                    cartUpdates[i].RemoveItem = cbRemove.Checked;

                    TextBox priceTextBox = new TextBox();
                    priceTextBox           = (TextBox)CartList.Rows[i].FindControl("PriceBx");
                    cartUpdates[i].PriceBx = Convert.ToDecimal(priceTextBox.Text.ToString());

                    //cartUpdates[i].ItemPrice = Convert.ToInt32(rowValues["OriginalPrice"]);

                    TextBox quantityTextBox = new TextBox();
                    quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                    cartUpdates[i].PurchaseQuantity = Convert.ToInt16(quantityTextBox.Text.ToString());
                }
                usersShoppingCart.UpdateShoppingCartDatabase(cartId, cartUpdates);
                CartList.DataBind();
                //GetTotal() suppose to execute after UpdateShoppingCartDatabase
                string x = String.Format("{0:c}", usersShoppingCart.GetTotal());
                if (x != "$0.00")
                {
                    lblTotal.Text = x;
                }
                else
                {
                    lblTotal.Text = "";
                }
                return(usersShoppingCart.GetCartItems());
            }
        }
Esempio n. 20
0
        private List <ShoppingItem> UpdateCartItems()
        {
            var cart = new ProductCart();

            string cartGuid = cart.GetCartGuid();

            ProductCart.ShoppingCartUpdates[] cartUpdates = new ProductCart.ShoppingCartUpdates[CartList.Rows.Count];
            for (int i = 0; i < CartList.Rows.Count; i++)
            {
                var rowValue = GetValues(CartList.Rows[i]);
                cartUpdates[i].ProductId = int.Parse(rowValue["ProductId"].ToString());

                var cbRemove = (CheckBox)CartList.Rows[i].FindControl("Remove");
                cartUpdates[i].RemoveItem = cbRemove.Checked;

                var quantityTextBox = (TextBox)CartList.Rows[i].FindControl("PurchaseQuantity");
                cartUpdates[i].PurchaseQuantity = int.Parse(quantityTextBox.Text);
            }

            cart.UpdateShoppingCart(cartGuid, cartUpdates);
            CartList.DataBind();
            lblTotal.Text = $"{cart.GetTotal():c}";
            return(cart.GetCartItems());
        }
 private void BindView(int userid, int cartid)
 {
     if (c.GetCarts(userid, cartid).Count == 0)
     {
         LabelTotalText.Text         = "";
         lblTotal.Text               = "";
         ShoppingCartTitle.InnerHtml = "<h1>Shopping Cart is Empty</h1>";
         BtnUpdate.Visible           = false;
         BtnCheckOut.Visible         = false;
         CartList.Visible            = false;
     }
     else
     {
         double total = 0;
         foreach (Model.Cart c in c.GetCarts(userid, cartid))
         {
             total += c.Amount * c.Quantity;
         }
         lblTotal.Text          = string.Format("{0:00}", total);
         Session["TotalAmount"] = total;
         CartList.DataSource    = c.GetCarts(userid, cartid);
         CartList.DataBind();
     }
 }
    private void BindListView()
    {
        string connectionString = "Data Source=omisbi3.niunt.niu.edu;Initial Catalog = z1776252; Persist Security Info = True; User ID = z1776252; Password = Bw1243$h11";

        using (SqlConnection con = new SqlConnection(connectionString))
        {
            try
            {
                Debug.WriteLine("shopping cart before try");
                con.Open();
                Debug.WriteLine("shopping cart inside try");
                if (Session["sessionid"] == null)
                {
                    Label8.Visible = true;
                }
                else
                {
                    Label4.Visible = true;
                    Label5.Visible = true;
                    using (SqlCommand cmd = new SqlCommand("SELECT o.ord_id,s.service,o.address,o.order_amount from orders_table o,services_table s where s.serviceid=o.s_id and o.session_id=@sessid", con))
                    {
                        Debug.WriteLine("shopping cart inside using try");

                        cmd.Parameters.AddWithValue("@sessid", Session["sessionid"].ToString());
                        Debug.WriteLine("cart id in sc is:" + Session["sessionid"].ToString());
                        Debug.WriteLine("shopping cart before using");
                        using (SqlDataAdapter sda = new SqlDataAdapter(cmd))
                        {
                            Debug.WriteLine("shopping cart inside 2nd using");
                            DataTable dt = new DataTable();
                            Debug.WriteLine("data table is:" + dt.Rows.Count);


                            sda.Fill(dt);
                            CartList.DataSource = dt;
                            CartList.DataBind();

                            Debug.WriteLine("shopping cart data table2 is:" + dt.Rows.Count);
                            decimal total = dt.AsEnumerable().Sum(row => row.Field <decimal>("Order_Amount"));
                            Session["totalPrice"] = null;
                            Session["totalPrice"] = total.ToString();

                            /*CartList.FooterRow.Cells[1].Text = "Your Grand Total";
                             * CartList.FooterRow.Cells[1].HorizontalAlign = HorizontalAlign.Right;
                             * CartList.FooterRow.Cells[2].Text = total.ToString("N2");*/
                            Label5.Text = total.ToString("N2");

                            /*  if (Button2.Visible == false)
                             * {
                             *    Button2.Visible = true;
                             * }*/
                        }
                    }
                }
            }
            catch (Exception ex)

            {
                // Display error message

                String errorMessage = ex.Message;
            }

            finally

            {
                // Close the connection

                con.Close();
            }
        }
    }
 private void BindView(int userid, int cartid)
 {
     CartList.DataSource = c.GetCartsPaid(userid, cartid);
     CartList.DataBind();
 }
Esempio n. 24
0
 private void BindView(int userid, int cartid)
 {
     amount.InnerHtml    = string.Format("₹{0:F2}", Session["TotalAmount"].ToString());
     CartList.DataSource = c.GetCarts(userid, cartid);
     CartList.DataBind();
 }