Example #1
0
        public void AddToCart(ArrayList p_name, ArrayList p_price)
        {
            for (int i = 0; i < p_name.Count; i++)
            {
                objDT = (DataTable)Session["cart"];

                Common cls = new Common();
                int indexOfItem = cls.IsExistItemInShoppingCart(p_name[i].ToString(), objDT);

                if (indexOfItem != -1)
                {
                    objDT.Rows[indexOfItem]["Quantity"] = Convert.ToInt32(objDT.Rows[indexOfItem]["Quantity"]) + 1;
                }
                else
                {
                    objDR = objDT.NewRow();
                    objDR["ProductName"] = p_name[i].ToString();
                    objDR["Price"] = p_price[i];
                    objDR["Quantity"] = 1;
                    objDR["Product_ID"] = GetProductID(p_name[i].ToString());
                    objDR["Total"] = Convert.ToDecimal(p_price[i]);
                    objDT.Rows.Add(objDR);
                }
            }
            Session["cart"] = objDT;
            Session["sum"] = GetItemTotal();
        }
Example #2
0
        public void AddToCart(string namevar, string costvar)
        {
            objDT = (DataTable)Session["cart"];
            string product_name = namevar;

            Bussiness.Common cls = new Bussiness.Common();
            int indexOfItem = cls.IsExistItemInShoppingCart(namevar, objDT);

            if (indexOfItem != -1)
            {
                objDT.Rows[indexOfItem]["Quantity"] = Convert.ToInt32(objDT.Rows[indexOfItem]["Quantity"]) + Convert.ToInt32(txtQuantity.Text);
            }
            else
            {
                objDR = objDT.NewRow();
                objDR["ProvName"] = ddlProvName.SelectedItem.ToString();
                objDR["ProvID"] = ddlProvName.SelectedValue.ToString();
                objDR["Employee"] = txtEmployee.Text;
                objDR["ProductName"] = product_name;
                objDR["ProductID"] = ddlProduct.SelectedValue.ToString();
                objDR["PriceInput"] = _costvar;
                objDR["Quantity"] = txtQuantity.Text;
                objDR["BuyDate"] = lblBuyDate.Text;
                objDR["Total"] = (Convert.ToDecimal(objDR["PriceInput"]) * Convert.ToDecimal(objDR["Quantity"]));
                objDT.Rows.Add(objDR);
            }
            Session["cart"] = objDT;
            Session["sum"] = GetItemTotal();
        }