//新增产品类别 public ActionResult AddLieBie(string ProductLeixName, string contents) { LeiBieBLL bll = new LeiBieBLL(); productLeix pro = new productLeix(); int shu = bll.productLeixes().Count(); string zhang = shu.ToString(); string productLeixNum = null; if (zhang.Length == 1) { productLeixNum = "00000" + (shu + 1); } else if (zhang.Length == 2) { productLeixNum = "0000" + (shu + 1); } else if (zhang.Length == 3) { productLeixNum = "000" + (shu + 1); } pro.productLeixNum = productLeixNum; pro.productLeixName = ProductLeixName; pro.contents = contents; pro.Founder = "宋志浩"; pro.isDel = 1; pro.createTime = DateTime.Now; bll.Add(pro); return(Json("新增成功!", JsonRequestBehavior.AllowGet)); }
//查询产品类别总条数 public ActionResult SelectLeiBies(string id, string name) { LeiBieBLL bll = new LeiBieBLL(); List <productLeix> list = bll.productLeixes(); var obj = from p in list where p.isDel == 1 && p.productLeixNum.Contains(id) && p.productLeixName.Contains(name) select p; return(Json(obj.Count(), JsonRequestBehavior.AllowGet)); }
//查询产品类别 public ActionResult SelectLeiBie(int pageIndex, int pageSize, string id, string name) { LeiBieBLL bll = new LeiBieBLL(); List <productLeix> list = bll.productLeixes(); var obj = from p in list where p.isDel == 1 && p.productLeixNum.Contains(id) && p.productLeixName.Contains(name) select new { productLeixNum = p.productLeixNum, productLeixName = p.productLeixName, Founder = p.Founder, contents = p.contents, createTime = p.createTime.ToString("yyyy年MM月dd日") }; obj = obj.OrderBy(p => p.productLeixNum).Skip((pageIndex - 1) * pageSize).Take(pageSize); return(Json(obj, JsonRequestBehavior.AllowGet)); }
//查询一条产品类别 public ActionResult SelectOneLieBie(string productLeixNum) { LeiBieBLL bll = new LeiBieBLL(); List <productLeix> list = bll.productLeixes(); var obj = from p in list where p.productLeixNum == productLeixNum select new { productLeixNum = p.productLeixNum, productLeixName = p.productLeixName, contents = p.contents }; return(Json(obj, JsonRequestBehavior.AllowGet)); }