コード例 #1
0
        public string getUserCollection(int currentpage,int num)
        {
            string result = "";

            string sctemp = "<li class=\"clf\"><a href=\"shop_list_detail.aspx?pro_id={0}\"><span class=\"smallImgbox fl\"><img width=\"70px\" src=\"images/smallDefaultPic.png\" alt=\"{1}\" class=\"lazy boxshowdow\"></span><span class=\"Pdesc fl\"><b>{2}</b> <span class=\"Titledesc\">{3}</span> <span class=\"red\">¥{4}</span><span class=\"yj\">¥{5}</span> </span><span class=\"zk\" onclick=\"deleteIt(this,{6})\">取消</span> </a></li>";//0 产品链接地址 1产品图片 2产品名称 3产品描述 4商城价 5市场价 6删除收藏id
            UserCollectionBll ucbll = new UserCollectionBll();
            ProductBll pbll = new ProductBll();
            int userid = 1;
            var uclist = ucbll.GetAll("*", 1, num, " userid=" + userid, null, "id").Entity;
            if (uclist.Items.Count > 0)
            {
                for (int i = 0; i < uclist.Items.Count; i++)
                {
                    var p = pbll.GetByPrimaryKey(uclist.Items[i].Productid.ToString().ToInt()).Entity;
                    if (p != null)
                    {
                        result += string.Format(sctemp, uclist.Items[i].Productid, ApplicationSettings.Get("imgurl") + p.BigThumPic, p.ProductName, p.Keyword, ((decimal)p.OemPrice).ToString("f0"), ((decimal)p.MarketPrice).ToString("f0"), uclist.Items[i].Id);
                    }
                }
                result += "<span id=\"pager\" style=\"display:none\" pagesize=\"" + num + "\" pagecount=\"" + uclist.PageCount + "\" page=\""+currentpage+"\"></span>";
            }
            else
            {
                result += "<span id=\"pager\" style=\"display:none\" pagesize=\"" + num + "\" pagecount=\"1\" page=\"1\"></span>";
            }
            return result;
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string result = "1";
            try
            {
                string type = context.Request.QueryString["type"].ToString();
                int id = context.Request.QueryString["id"].ToString().ToInt();

                UserCollectionBll ucbll = new UserCollectionBll();
                //用户末登录 返回 0 result=0;

                if (type == "add")
                {
                    //用户登录 id
                    if (Cookie.Get("AdminInfo") != null)
                    {
                        HttpCookie cookie = Cookie.Get("AdminInfo");
                        int userid = HttpUtility.UrlDecode(cookie.Values["AdminId"]).ToInt();
                        UserCollection model = new UserCollection();
                        model.UserId = userid;
                        model.AddTime = DateTime.Now;
                        model.Productid = id;
                        if (!ucbll.Add(model).ResultStatus.Success)
                            result = "-1";
                    }
                    else
                    {
                        //末登录
                        result = "-2";
                    }
                }
                else
                {
                    //用户登录 id
                    if (Cookie.Get("AdminInfo") != null)
                    {
                        HttpCookie cookie = Cookie.Get("AdminInfo");
                        int userid = HttpUtility.UrlDecode(cookie.Values["AdminId"]).ToInt();
                        if (!ucbll.DeleteList(" userid=" + userid + " and productid=" + id).ResultStatus.Success)
                            result = "-1";
                    }
                    else
                    {
                        //末登录
                        result = "-2";
                    }
                }

            }
            catch
            {

                result = "-1";
            }

            context.Response.Write(result);
        }
コード例 #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            pro_id=Request["pro_id"].ToInt();
               userId = Request["userId"].ToInt();
            if (pro_id > 0)
            {
                huodaofukuanlink = huodaofukuanlink + pro_id;
                if (pno.NoEmpty())
                {
                    huodaofukuanlink += "&pno=" + pno;
                }
                //检查是否登录 登录 检查是否收藏些产品
                int userid = 1;
                var col = new UserCollectionBll().GetAll("id", " userid=" + userid + " and productid=" + pro_id, null, "id").Entity;
                if (col.Count > 0)
                    islike = "liked";
                getProductDetail();
                getDetailPic();
                getProductDetailTuiJian();
                pro1();

            }

            if (HttpContext.Current.Request.Cookies["AdminInfo"] == null)
            {
                if (userId > 0)
                {

                        HttpCookie cookie = new HttpCookie("AdminInfo");
                        cookie.Values.Add("AdminId", userId.ToString());
                        cookie.Expires = DateTime.Now.AddDays(7);
                        Response.AppendCookie(cookie);
                }
                else
                {
                    Response.Redirect("http://www.ibananas.cn/", false);
                }

            }
            else
            {
                if (userId != 0)
                {
                    HttpCookie cookie = Cookie.Get("AdminInfo");
                    //cookie不同 修改cookie
                    if (HttpUtility.UrlDecode(cookie.Values["AdminId"]).ToInt() != userId)
                    {
                        cookie.Values.Set("AdminId", userId.ToString());
                        Response.AppendCookie(cookie);
                    }
                }
            }

            var p = pbll.GetByPrimaryKey(pro_id).Entity;
            if (p != null)
                title = p.ProductName;
        }