protected void btAdd_Click(object sender, EventArgs e)
        {
            string        id  = Request.QueryString["pid"];
            SqlDataSource sds = new SqlDataSource();

            sds.ConnectionString = @"Data Source=.;Initial Catalog=dbASPDemo;Integrated Security=True";
            sds.SelectCommand    = "select * from tProduct where fId = @ID;";
            sds.SelectParameters.Add("ID", id);
            DataView dv = sds.Select(DataSourceSelectArguments.Empty) as DataView;

            if (dv.Table.Rows.Count <= 0)
            {
                Response.Redirect("WfProduct.aspx");
            }

            List <CShoppingCartItem> list =
                Session[CDictionary.SHOPPINGCART_ITEMS_LIST] as List <CShoppingCartItem>;

            if (list == null)
            {
                list = new List <CShoppingCartItem>();
                Session[CDictionary.SHOPPINGCART_ITEMS_LIST] = list;
            }

            CShoppingCartItem item = new CShoppingCartItem();

            item.Name    = dv[0]["fName"].ToString();
            item.Quality = Convert.ToInt32(txtMessage.Text);
            item.Price   = Convert.ToDouble(dv[0]["fPrice"].ToString());

            list.Add(item);
            Response.Redirect("WfProduct.aspx");
        }
Ejemplo n.º 2
0
        public ActionResult addsession(tShoppingCar item)
        {
            int      prodID = Convert.ToInt32(item.fProduct);
            tProject t      = db.tProject.FirstOrDefault(p => p.fid == prodID);

            if (t != null)
            {
                List <CShoppingCartItem> list = (List <CShoppingCartItem>)Session[CDictionary.SK_PURCHASED_IN_SHOPPINGCART];
                if (list == null)
                {
                    list = new List <CShoppingCartItem>();
                    Session[CDictionary.SK_PURCHASED_IN_SHOPPINGCART] = list;
                }
                CShoppingCartItem x = new CShoppingCartItem();
                x.price       = Convert.ToDouble(t.fprice);
                x.productID   = t.fid;
                x.productname = t.fname;
                x.count       = (int)item.fCount;
                list.Add(x);
            }

            return(RedirectToAction("List"));
        }