Exemplo n.º 1
0
 void SetShoppingCartInfo(bool isAuthenticated, string userName, int uniqueId, ShoppingCart sc)
 {
     if (isAuthenticated)
     {
         sc.Shoppings = Shoppings.ShoppingLoad(GetUniqueId(userName).ToString());
     }
     else
     {
         sc.Shoppings = Shoppings.ShoppingLoad(userName);
     }
 }
Exemplo n.º 2
0
        ShoppingCart GetShoppings(bool isAuthenticated, string userName)
        {
            ShoppingCart sc = new ShoppingCart();

            if (isAuthenticated)
            {
                sc.Shoppings = Shoppings.ShoppingLoad(GetUniqueId(userName).ToString());
            }
            else
            {
                sc.Shoppings = Shoppings.ShoppingLoad(userName);
            }
            return(sc);
        }
Exemplo n.º 3
0
    void BindAmount()
    {
        string userID = string.Empty;

        if (Profile.IsAnonymous)
        {
            userID = Profile.UserName;
        }
        else
        {
            userID = Profile.AccountInfo.UserID.ToString();
        }
        List <Shopping> shops = Shoppings.ShoppingLoad(userID);

        btnSeeShopCart.Text = "查看购物车(" + shops.Count + "件)";
        btnSeeShopCart.Attributes.Add("onclick", "parent.window.location.href='" + GlobalSettings.RelativeWebRoot + "pages/view.aspx?shopcart-cartitems'");
    }
    protected void egvShoppings_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        GridViewRow gvr = egvShoppings.Rows[e.RowIndex];
        int         k   = int.Parse(egvShoppings.DataKeys[e.RowIndex].Value.ToString());

        try
        {
            int      amount = int.Parse((gvr.FindControl("txtAmount") as TextBox).Text.Trim());
            Shopping shop   = new Shopping();
            shop.UpdateTime = DateTime.Now;
            shop.ShoppingID = k;
            shop.Quantity   = amount;
            Shoppings.ShoppingUpdate(shop);
        }
        catch (Exception ex) { throw new HHException(ExceptionType.Failed, ex.Message); }
        egvShoppings.EditIndex = -1;
        BindCartItems();
    }
    void BindCartItems()
    {
        string userID = Profile.UserName;

        if (!Profile.IsAnonymous)
        {
            userID = Profile.AccountInfo.UserID.ToString();
        }
        List <Shopping> shops = Shoppings.ShoppingLoad(userID);

        egvShoppings.DataSource = shops;
        egvShoppings.DataBind();

        int quantities = 0;

        foreach (Shopping s in shops)
        {
            quantities += s.Quantity;
        }
        ltItemsAmount.Text = "共【" + shops.Count + "】件产品,合计【" + quantities + "】小件。";
    }
        public void ProcessRequest(HttpContext context)
        {
            string msg = string.Empty;
            bool   suc = false;

            try
            {
                string curUser = string.Empty;
                if (context.Profile.IsAnonymous)
                {
                    curUser = context.Profile.UserName;
                }
                else
                {
                    curUser = Users.GetUniqueId(context.Profile.UserName).ToString();
                }
                NameValueCollection req = context.Request.QueryString;
                string action           = req["action"];
                switch (action)
                {
                case "getFriendLinks":
                    try
                    {
                        suc = true;
                        msg = Newtonsoft.Json.JavaScriptConvert.SerializeObject(FriendLinks.FriendLinkGet());
                    }
                    catch (Exception ex)
                    {
                        suc = false;
                        msg = ex.Message;
                    }
                    break;

                case "addShopcart":
                    int      pid    = int.Parse(req["d"]);
                    int      amount = int.Parse(req["c"]);
                    int      mid    = int.Parse(req["m"]);
                    Shopping shop   = new Shopping()
                    {
                        CreateTime   = DateTime.Now,
                        UpdateTime   = DateTime.Now,
                        ModelID      = mid,
                        ProductID    = pid,
                        Quantity     = amount,
                        ShoppingMemo = string.Empty,
                        UserID       = curUser
                    };
                    suc = Shoppings.ShoppingAdd(shop);
                    break;

                case "getPSuggestion":
                    string        v  = req["value"];
                    List <string> sw = WordSearchManager.GetWordSuggest(v, 10);
                    suc = true;
                    msg = Newtonsoft.Json.JavaScriptConvert.SerializeObject(sw);
                    break;

                case "getStatistic":
                    List <WordStatistic> wss = WordSearchManager.GetStatistic(GlobalSettings.MinValue, GlobalSettings.MaxValue);
                    wss = wss.GetRange(0, Math.Min(10, wss.Count));
                    suc = true;
                    msg = Newtonsoft.Json.JavaScriptConvert.SerializeObject(wss);
                    break;

                case "batchDelete":
                    int i1 = Products.BatchOperation(req["ids"], 2, int.Parse(curUser));
                    if (i1 < 0)
                    {
                        msg = "操作失败,系统数据错误,请联系管理员!";
                    }
                    else
                    {
                        msg = "操作成功!";
                    }
                    suc = true;
                    break;

                case "batchPublish":
                    int i2 = Products.BatchOperation(req["ids"], 1, int.Parse(curUser));
                    if (i2 < 0)
                    {
                        msg = "操作失败,系统数据错误,请联系管理员!";
                    }
                    else
                    {
                        msg = "操作成功!";
                    }
                    suc = true;
                    break;

                case "batchCopy":
                    int i3 = Products.BatchOperation(req["ids"], 3, int.Parse(curUser));
                    if (i3 < 0)
                    {
                        msg = "操作失败,系统数据错误,请联系管理员!";
                    }
                    else
                    {
                        msg = "操作成功!";
                    }
                    suc = true;
                    break;

                case "batchTruncate":
                    int i4 = Products.BatchOperation(req["ids"], 4, int.Parse(curUser));
                    if (i4 < 0)
                    {
                        msg = "操作失败,系统数据错误,请联系管理员!";
                    }
                    else
                    {
                        msg = "操作成功!";
                    }
                    suc = true;
                    break;
                }

                context.Response.Write("{msg:'" + msg + "',suc:" + suc.ToString().ToLower() + "}");
            }
            catch (Exception ex)
            {
                context.Response.Write("{msg:'" + ex.Message + "',suc:false}");
            }
        }
 protected void egvShoppings_RowDeleting(object sender, GridViewDeleteEventArgs e)
 {
     Shoppings.ShoppingDelete(int.Parse(egvShoppings.DataKeys[e.RowIndex].Value.ToString()));
     BindCartItems();
 }