Beispiel #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());
            }
        }
Beispiel #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;
         }
     }
 }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string rawId = Request.QueryString["ProdukID"];
            int    produkId;

            if (!String.IsNullOrEmpty(rawId) && int.TryParse(rawId, out produkId))
            {
                using (ModifShoppingCart usersShoppingCart = new ModifShoppingCart())
                {
                    usersShoppingCart.TambahItem(Convert.ToInt16(rawId));
                }
            }
            else
            {
                Debug.Fail("ERROR : Penambahan produk yang akan dibeli pada halaman TambahItem.aspx tidak dapat dilakukan tanpa ProdukId.");

                throw new Exception("ERROR: Tidak diizinkan memanggil halaman TambahItem.aspx tanpa menentukan PRodukId telebih dahulu.");
            }
            Response.Redirect("ShoppingCart.aspx");
        }
Beispiel #4
0
        public List <CartItem> GetShoppingCartItem()
        {
            ModifShoppingCart modifikasi = new ModifShoppingCart();

            return(modifikasi.GetCartItem());
        }