Ejemplo n.º 1
0
        public static void UpdateCart(MODEL.ShoppingCart cart)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update shoppingCart set ");
            strSql.Append("userId=@userId,");
            strSql.Append("prdNo=@prdNo,");
            strSql.Append("prdName=@prdName,");
            //strSql.Append("prdPrice=@prdPrice,");
            strSql.Append("prdQty=@prdQty, ");
            strSql.Append("settleStt=@settleStt ");

            strSql.Append(" where Id=@Id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@Id",        SqlDbType.Int),
                new SqlParameter("@userId",    SqlDbType.VarChar),
                new SqlParameter("@prdNo",     SqlDbType.VarChar),
                new SqlParameter("@prdName",   SqlDbType.VarChar),
                //new SqlParameter("@prdPrice", SqlDbType.VarChar),
                new SqlParameter("@prdQty",    SqlDbType.VarChar),
                new SqlParameter("@settleStt", SqlDbType.Int)
            };

            parameters[0].Value = cart.Id;
            parameters[1].Value = cart.UserId;
            parameters[2].Value = cart.PrdNo;
            parameters[3].Value = cart.PrdName;
            //parameters[4].Value = cart.PrdPrice;
            parameters[4].Value = cart.PrdQty;
            parameters[5].Value = cart.SettleStt;

            DBHelper.ExecuteNonQuery(strSql.ToString(), CommandType.Text, parameters);
        }
Ejemplo n.º 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string PrdNo = context.Request["PrdNo"];
            if (context.Session["userInfo"] == null)
            {
                context.Response.Write("NoLogin");
            }
            else
            {
                if (!string.IsNullOrEmpty(PrdNo))
                {
                    MODEL.Product product = BLL.ProductManager.GetPrd(PrdNo);
                    if (product != null)
                    {
                        MODEL.User user = context.Session["userInfo"] as MODEL.User;
                        MODEL.ShoppingCart cart = BLL.ShoppingCartManager.GetCart(user.LoginId, PrdNo);
                        if (cart != null)
                        {
                            cart.PrdQty = cart.PrdQty + 1;
                            BLL.ShoppingCartManager.UpdateCart(cart);
                        }
                        else
                        {
                            cart = new MODEL.ShoppingCart();
                            cart.UserId = user.LoginId;
                            cart.PrdName = product.PrdName;
                            cart.PrdNo = product.PrdNo;
                            cart.PrdQty = 1;
                            cart.SettleStt = 0;
                            BLL.ShoppingCartManager.AddCart(cart);
                        }
                        string strCart = Common.LoadShoppingCart.GetCartByUser();
                        context.Response.Write(strCart);
                    }

                }
            }
        }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string PrdNo = context.Request["PrdNo"];

            if (context.Session["userInfo"] == null)
            {
                context.Response.Write("NoLogin");
            }
            else
            {
                if (!string.IsNullOrEmpty(PrdNo))
                {
                    MODEL.Product product = BLL.ProductManager.GetPrd(PrdNo);
                    if (product != null)
                    {
                        MODEL.User         user = context.Session["userInfo"] as MODEL.User;
                        MODEL.ShoppingCart cart = BLL.ShoppingCartManager.GetCart(user.LoginId, PrdNo);
                        if (cart != null)
                        {
                            cart.PrdQty = cart.PrdQty + 1;
                            BLL.ShoppingCartManager.UpdateCart(cart);
                        }
                        else
                        {
                            cart           = new MODEL.ShoppingCart();
                            cart.UserId    = user.LoginId;
                            cart.PrdName   = product.PrdName;
                            cart.PrdNo     = product.PrdNo;
                            cart.PrdQty    = 1;
                            cart.SettleStt = 0;
                            BLL.ShoppingCartManager.AddCart(cart);
                        }
                        string strCart = Common.LoadShoppingCart.GetCartByUser();
                        context.Response.Write(strCart);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public static void AddCart(MODEL.ShoppingCart cart)
        {
            string sql = @"INSERT INTO dbo.shoppingCart
                        ( userId ,
                          prdNo ,
                          prdName ,
                          prdQty ,
                          settleStt
                        )
                VALUES  ( @userId , -- userId - varchar(50)
                          @prdNo , -- prdNo - varchar(50)
                          @prdName , -- prdName - varchar(200)
                          @prdQty , -- prdQty - int
                          0  -- settleStt - int
                        )";

            SqlParameter[] parameter = new SqlParameter[4];
            parameter[0] = new SqlParameter("@userId", cart.UserId);
            parameter[1] = new SqlParameter("@prdNo", cart.PrdNo);
            parameter[2] = new SqlParameter("@prdName", cart.PrdName);
            parameter[3] = new SqlParameter("@prdQty", cart.PrdQty);
            DBHelper.ExecuteNonQuery(sql, CommandType.Text, parameter);
        }
Ejemplo n.º 5
0
 public static void AddCart(MODEL.ShoppingCart cart)
 {
     DAL.ShoppingCartService.AddCart(cart);
 }
Ejemplo n.º 6
0
 public static void UpdateCart(MODEL.ShoppingCart cart)
 {
     DAL.ShoppingCartService.UpdateCart(cart);
 }