示例#1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                NewRegisterCustomerModel newRegisterCustomer = new NewRegisterCustomerModel()
                {
                    CustomerID     = Request["name"].ToString().Trim(),
                    CustomerEmail  = Request["email"].ToString().Trim(),
                    PassWordInput1 = Request["pass1"].ToString().Trim(),
                    PassWordInput2 = Request["pass2"].ToString().Trim(),
                };



                string msg = String.Empty;

                var result = CustomerHelper.RegisterNewCustomer(Context, newRegisterCustomer, out msg);

                if (result)
                {
                    System.Web.HttpCookie myCookie = new HttpCookie("LoginInfo");
                    myCookie.Domain  = YoeJoyConfig.SiteBaseURL;
                    myCookie.Expires = DateTime.Now.AddYears(1); //Cookie过期时间
                    myCookie.Value   = newRegisterCustomer.CustomerID + "," + DateTime.Now.ToString(AppConst.DateFormatLong);
                    Response.Cookies.Add(myCookie);              //添加到页面cookie中
                }

                Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
            }
        }
示例#2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string name     = Request["name"].ToString().Trim();
                string password = Request["pass"].ToString().Trim();
                string external = Request["extern"].ToString().Trim();

                bool autoLogin = false;
                if (String.Equals(external, "autoLogin"))
                {
                    autoLogin = true;
                }

                string msg = String.Empty;

                bool result = CustomerHelper.CustomerLogin(Context, name, password, out msg);

                if (result)
                {
                    System.Web.HttpCookie mycookie = new System.Web.HttpCookie("LoginInfo");    //申明新的COOKIE变量
                    mycookie.Domain  = YoeJoyConfig.SiteBaseURL;
                    mycookie.Expires = DateTime.Now.AddYears(1);
                    mycookie.Value   = name + "," + DateTime.Now.ToString(AppConst.DateFormatLong);
                    Response.Cookies.Add(mycookie);
                    //添加自动登录的cookie
                    if (autoLogin)
                    {
                        string cookieValue  = String.Concat(name, ",", password);
                        string encriptValue = DESProvider.EncryptString(cookieValue);
                        var    cookie       = new System.Web.HttpCookie("LocalSession", encriptValue);
                        cookie.Expires = DateTime.Now.AddDays(7);
                        Response.Cookies.Add(cookie);
                    }
                }
                Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IcsonSessionInfo oSessionInfo = CommonUtility.GetUserSession(Context);

            CustomerInfo cInfo  = oSessionInfo.sCustomer;
            int          cSysNo = cInfo.SysNo;

            bool   result = false;
            string msg    = String.Empty;

            try
            {
                switch (Cmd)
                {
                //添加商品到收藏
                case "add":
                {
                    WishListInfo wInfo = new WishListInfo();
                    wInfo.CustomerSysNo = cSysNo;
                    wInfo.ProductSysNo  = productSysNo;
                    WishListManager.GetInstance().Insert(wInfo);
                    result = true;
                    msg    = "成功添加";
                    Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
                    break;
                }

                //删除单个收藏商品
                case "delete":
                {
                    foreach (string pid in productSysNos)
                    {
                        WishListManager.GetInstance().Delete(cSysNo, int.Parse(pid));
                    }
                    msg = "删除成功";
                    Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
                    break;
                }

                //清空收藏商品
                case "empty":
                {
                    WishListManager.GetInstance().Clear(cSysNo);
                    msg = "清空收藏夹成功";
                    Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
                    break;
                }

                //获得分页的收藏列表
                default:
                {
                    Response.Write(CustomerHelper.GetCustomerWishListProducts(cSysNo, StartIndex));
                    break;
                }
                }
            }
            catch
            {
                msg = "用户请求的操作失败";
                Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (CommonUtility.GetUserSession(Context).sCustomer != null)
            {
                if (!IsPostBack)
                {
                    string msg    = String.Empty;
                    bool   result = false;
                    try
                    {
                        switch (Cmd)
                        {
                        //添加商品到购物车
                        case "add":
                        {
                            CartInfo oInfo = new CartInfo()
                            {
                                ProductSysNo = ProductSysNo,
                                Quantity     = ProductQty,
                                ExpectQty    = ProductQty,
                            };
                            newHt = CartManager.GetInstance().GetCartHash();
                            newHt.Add(ProductSysNo, oInfo);
                            Hashtable ht = new Hashtable();
                            ht.Add(ProductSysNo, oInfo);
                            CartManager.GetInstance().AddToCart(ht);
                            result = true;
                            msg    = "成功添加";
                            Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
                            break;
                        }

                        //删除单个购物车中的商品
                        case "delete":
                        {
                            CartManager.GetInstance().DeleteFromCart(ProductSysNo);
                            msg    = "删除成功";
                            result = true;
                            Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
                            break;
                        }

                        //更新购物车商品数量
                        case "update":
                        {
                            CartInfo cart = new CartInfo();
                            newHt         = CartManager.GetInstance().GetCartHash();
                            cart          = (CartInfo)newHt[ProductSysNo];
                            cart.Quantity = ProductQty;
                            CartManager.GetInstance().UpdateCart(cart);
                            msg    = "修改成功";
                            result = true;
                            Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
                            break;
                        }

                        case "clear":
                        {
                            CartManager.GetInstance().ClearCart();
                            msg    = "成功清空购物车";
                            result = true;
                            Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
                            break;
                        }

                        case "viewshortcuts":
                        {
                            //浏览购物车
                            Hashtable ht = new Hashtable();
                            if (newHt.Count == 0)
                            {
                                ht = CartManager.GetInstance().GetCartHash();
                            }
                            else
                            {
                                ht = newHt;
                            }
                            if (ht == null || ht.Count == 0)
                            {
                                Response.Write(emptyShoppingCartHTML);
                            }
                            else
                            {
                                Response.Write(CustomerHelper.GetCustomerShoppingCartShortCuts(ht));
                            }
                            break;
                        }

                        //默认什么都不做
                        case "viewcart":
                        {
                            break;
                        }

                        case "goshopping":
                        {
                            goShopping();
                            break;
                        }

                        default:
                        {
                            break;
                        }
                        }
                    }
                    catch
                    {
                        msg = "用户请求的操作失败";
                        Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = result, Msg = msg }));
                    }
                }
            }
            else
            {
                Response.Write(JsonContentTransfomer <object> .GetJsonContent(new { IsSuccess = false, Msg = "请先登录" }));
            }
        }