//产品新增 public ActionResult InsertProduct(string productName, string Probarcode, int productCount, float price, string Specifications, string contents, string productLeixNum, string CompanyNum, string LocationNum, string customerNum) { ChanPinBLL bll = new ChanPinBLL(); int shu = bll.Product().Count(); string zhang = shu.ToString(); string productNum = null; if (zhang.Length == 1) { productNum = "00000" + (shu + 1); } else if (zhang.Length == 2) { productNum = "0000" + (shu + 1); } else if (zhang.Length == 3) { productNum = "000" + (shu + 1); } product pro = new product(); pro.productNum = productNum; pro.productName = productName; pro.Probarcode = Probarcode; pro.price = price; pro.productCount = productCount; pro.isDel = 1; pro.Specifications = Specifications; pro.contents = contents; pro.productLeixNum = productLeixNum; pro.CompanyNum = CompanyNum; pro.LocationNum = LocationNum; pro.customerNum = customerNum; bll.Add(pro); return(Json("新增成功!", JsonRequestBehavior.AllowGet)); }
//产品总条数 public ActionResult SelectProducts(string productName, string productLeixNum) { ChanPinBLL bll = new ChanPinBLL(); List <product> list = bll.Product(); var obj = from p in list where p.isDel == 1 select p; if (!string.IsNullOrEmpty(productName)) { obj = obj.Where(p => p.productName.Contains(productName)); } if (!string.IsNullOrEmpty(productLeixNum)) { obj = obj.Where(p => p.productLeixNum.Contains(productLeixNum)); } return(Json(obj.Count(), JsonRequestBehavior.AllowGet)); }
//产品管理分页 public ActionResult SelectProduct(int pageIndex, int pageSize, string productName, string productLeixNum) { ChanPinBLL bll = new ChanPinBLL(); List <product> list = bll.Product(); var obj = from j in list where j.isDel == 1 && j.productName.Contains(productName) && j.productLeixNum.Contains(productLeixNum) select new { productNum = j.productNum, productName = j.productName, productCount = j.productCount, price = j.price, Specifications = j.Specifications, productLeixNum = j.productLeix.productLeixName, CompanyNum = j.Company.CompanyName, contents = j.contents }; obj = obj.OrderBy(p => p.productNum).Skip((pageIndex - 1) * pageSize).Take(pageSize); return(Json(obj, JsonRequestBehavior.AllowGet)); }
//产品的查询 public ActionResult SelectOneProdut(string id) { ChanPinBLL bll = new ChanPinBLL(); List <product> list = bll.Product(); var obj = from j in list where j.productNum == id select new { productNum = j.productNum, productName = j.productName, productCount = j.productCount, price = j.price, Specifications = j.Specifications, productLeixNum = j.productLeixNum, CompanyNum = j.CompanyNum, LocationNum = j.LocationNum, customerNum = j.customerNum, contents = j.contents }; List <productLeix> lists = new List <productLeix>(); return(Json(obj, JsonRequestBehavior.AllowGet)); }