private string GetList(HttpContext context) { ProductCategoryEntity entity = new ProductCategoryEntity(); entity.deleted = false; entity.Category = context.Request["category"]; entity.ParentId = context.Request["parentid"].ToNullable <int>(); Pagination pagination = new Pagination(); pagination.PageIndex = Convert.ToInt32(HttpContext.Current.Request["pageIndex"].ToInt(1)); pagination.PageSize = Convert.ToInt32(HttpContext.Current.Request["pageSize"].ToInt(3)); pagination.IsPaging = (bool)context.Request["isPaging"].To <bool>(false); ProductCategoryService service = new ProductCategoryService(); List <ProductCategoryEntity> list = service.GetList(entity, pagination); var resultObj = new { page = pagination, data = list, code = 10000 }; //将对象序列化成为JSON格式 return(Newtonsoft.Json.JsonConvert.SerializeObject(resultObj)); }
protected void Page_Load(object sender, EventArgs e) { int?id = Request["id"].ToNullable <int>(); if (!IsPostBack) { ProductCategoryService service = new ProductCategoryService(); list = service.GetList(new ProductCategoryEntity { ParentId = 0, }, new Entity.BussinessModel.Pagination { IsPaging = false }); ProductService productService = new ProductService(); entity = productService.Get((int)id); } else { ProductService service = new ProductService(); ProductEntity entity = new ProductEntity(); entity.Name = Request["name"]; entity.CategoryId = Convert.ToInt32(Request["parentid"]); entity.SubCategoryId = Convert.ToInt32(Request["categoryId"]); entity.Summary = Request["summary"]; entity.Price = Convert.ToInt32(Request["price"]); entity.Picture = Request["file"]; entity.OnSale = Convert.ToBoolean(Request["onsale"]); entity.Description = Request["description"]; entity.ActualStock = Convert.ToInt32(Request["actualstock"]); entity.AvailableStock = Convert.ToInt32(Request["availablestock"]); entity.HoldingStock = Convert.ToInt32(Request["holdingstock"]); entity.CreatedTime = DateTime.Now; entity.ModifiedTime = DateTime.Now; entity.Deleted = false; entity = new ProductEntity(); entity.Id = id; if (service.Update(entity)) { Response.Redirect("/Pages/Product/List.aspx"); } else { Response.Write("<script>alert('失败')</script>"); } } }
protected void Page_Load(object sender, EventArgs e) { //是回发触发条件 if (IsPostBack) { string category = Request["category"]; string summary = Request["summary"]; string remark = Request["remark"]; bool recommend = Convert.ToBoolean(Request["recommend"]); BLL.ProductCategoryService service = new ProductCategoryService(); ProductCategoryEntity entity = new ProductCategoryEntity(); entity.Category = category; entity.Remark = remark; entity.Summary = summary; entity.CreatedTime = DateTime.Now; entity.ModifiedTime = DateTime.Now; entity.ParentId = Convert.ToInt32(Request["parentid"]); entity.deleted = false; entity.isRecommend = recommend; bool success = service.Create(entity); if (success) { Response.Redirect("/Pages/ProductCategory/List.aspx"); } else { Response.Write("<script>添加失败!</script>"); } } else { ProductCategoryService service = new ProductCategoryService(); parent_list = service.GetList(new ProductCategoryEntity { ParentId = 0, }, new Entity.BussinessModel.Pagination { IsPaging = false }); } }
protected void Page_Load(object sender, EventArgs e) { int?id = Request["id"].ToNullable <int>(); if (!IsPostBack) { if (id == null) { Response.Redirect("/Pages/ProductCategory/ProductCategoryList.aspx"); } ProductCategoryService service = new ProductCategoryService(); entity = service.Get(Convert.ToInt32(id)); parent_list = service.GetList(new ProductCategoryEntity { ParentId = 0, }, new Entity.BussinessModel.Pagination { IsPaging = false }); } else { entity = new ProductCategoryEntity(); entity.Id = id; entity.Category = Request["category"].ToString(); entity.Summary = Request["summary"].ToString(); entity.Remark = Request["remark"].ToString(); entity.ModifiedTime = DateTime.Now; entity.ParentId = Convert.ToInt32(Request["ParentId"].ToString()); entity.isRecommend = Convert.ToBoolean(Request["recommend"]); ProductCategoryService service = new ProductCategoryService(); if (service.Update(entity)) { Response.Redirect("/Pages/ProductCategory/List.aspx"); } else { Response.Write("<script>alert('失败')</script>"); } } }