protected override void PageLoad() { base.PageLoad(); string action = RequestHelper.GetQueryString <string>("Action"); if (action == "Delete") { string deleteId = RequestHelper.GetForm <string>("id"); ProductCollectBLL.Delete(Array.ConvertAll <string, int>(deleteId.Split(','), k => Convert.ToInt32(k)), base.UserId); ResponseHelper.Write("ok"); ResponseHelper.End(); } ProductCollectList = ProductCollectBLL.ReadListByUserId(base.UserId); int count = ProductCollectList.Count; int currentPage = RequestHelper.GetQueryString <int>("Page"); if (currentPage < 1) { currentPage = 1; } int pageSize = 20; ProductCollectList = ProductCollectList.Skip((currentPage - 1) * pageSize).Take(pageSize).ToList(); pager.Init(currentPage, pageSize, count, !string.IsNullOrEmpty(isMobile)); }
/// <summary> /// 页面加载 /// </summary> protected override void PageLoad() { base.PageLoad(); user = UserBLL.ReadUserMore(base.UserId); userGradeId = UserGradeBLL.Read(base.GradeID).Id; string action = RequestHelper.GetQueryString <string>("Action"); if (action == "Delete") { string deleteID = RequestHelper.GetQueryString <string>("ID"); ProductCollectBLL.Delete(Array.ConvertAll(deleteID.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries), k => Convert.ToInt32(k)), base.UserId); ResponseHelper.Write("ok"); ResponseHelper.End(); } int currentPage = RequestHelper.GetQueryString <int>("Page"); if (currentPage < 1) { currentPage = 1; } int pageSize = 20; int count = 0; productCollectList = ProductCollectBLL.ReadList(currentPage, pageSize, ref count, base.UserId); //commonPagerClass.CurrentPage = currentPage; //commonPagerClass.PageSize = pageSize; //commonPagerClass.Count = count; //commonPagerClass.FirstPage = "<<首页"; //commonPagerClass.PreviewPage = "<<上一页"; //commonPagerClass.NextPage = "下一页>>"; //commonPagerClass.LastPage = "末页>>"; //commonPagerClass.ListType = false; //commonPagerClass.DisCount = false; //commonPagerClass.PrenextType = true; commonPagerClass.Init(currentPage, pageSize, count, !string.IsNullOrEmpty(isMobile)); string strProductID = string.Empty; foreach (ProductCollectInfo productCollect in productCollectList) { if (strProductID == string.Empty) { strProductID = productCollect.ProductId.ToString(); } else { strProductID += "," + productCollect.ProductId.ToString(); } } if (strProductID != string.Empty) { ProductSearchInfo productSearch = new ProductSearchInfo(); productSearch.InProductId = strProductID; productList = ProductBLL.SearchList(productSearch); } }
private void Collect() { string result = string.Empty; int productId = RequestHelper.GetQueryString <int>("id"); if (productId > 0) { if (base.UserId == 0) { result = "还未登录"; } else { var productCollect = ProductCollectBLL.Read(productId, base.UserId) ?? new ProductCollectInfo(); if (productCollect.Id > 0) { ProductCollectBLL.Delete(new int[] { productCollect.Id }, base.UserId); result = "已取消收藏"; } else { productCollect.ProductId = productId; productCollect.Tm = RequestHelper.DateNow; productCollect.UserId = base.UserId; ProductCollectBLL.Add(productCollect); result = "成功收藏"; } } } else { result = "请选择产品"; } ResponseHelper.Write(result); ResponseHelper.End(); }