Exemplo n.º 1
0
        public List <CartItem> UbahCartItem()
        {
            using (ModifShoppingCart usersShoppingCart = new ModifShoppingCart())
            {
                String cartId = usersShoppingCart.GetCartId();

                ModifShoppingCart.UbahShoppingCart[] ubahCart = new ModifShoppingCart.UbahShoppingCart[GridView1.Rows.Count];
                for (int i = 0; i < GridView1.Rows.Count; i++)
                {
                    IOrderedDictionary rowValues = new OrderedDictionary();
                    rowValues            = GetValue(GridView1.Rows[i]);
                    ubahCart[i].ProdukId = Convert.ToInt32(rowValues["ProdukID"]);

                    CheckBox cbHapus = new CheckBox();
                    cbHapus = (CheckBox)GridView1.Rows[i].FindControl("HapusCheckBox");
                    ubahCart[i].HapusItem = cbHapus.Checked;

                    TextBox UbahJumlahTextBox = new TextBox();
                    UbahJumlahTextBox         = (TextBox)GridView1.Rows[i].FindControl("JumlahTextBox");
                    ubahCart[i].JumlahTextBox = Convert.ToInt16(UbahJumlahTextBox.Text.ToString());
                }
                usersShoppingCart.UbahShoppingCartDatabase(cartId, ubahCart);
                GridView1.DataBind();
                lblTotal.Text = String.Format("{0:c}", usersShoppingCart.GetTotal());
                return(usersShoppingCart.GetCartItem());
            }
        }
Exemplo n.º 2
0
 protected void Page_Load(object sender, EventArgs e)
 {
     using (ModifShoppingCart usersShoppingCart = new ModifShoppingCart())
     {
         decimal cartTotal = 0;
         cartTotal = usersShoppingCart.GetTotal();
         if (cartTotal > 0)
         {
             lblTotal.Text = String.Format("{0:c}", cartTotal);
         }
         else
         {
             LabelTotalText.Text         = "";
             lblTotal.Text               = "";
             ShoppingCartTitle.InnerText = "Tidak ada produk yang dipesan pada troli";
             BtnUbah.Visible             = false;
         }
     }
 }