public JsonResult ListDS(string pstatus, int page, int rows) { ProductsDSQuery query = new ProductsDSQuery(); query.PageNo = page; query.PageSize = rows; int i; if (int.TryParse(pstatus, out i)) { query.dsstatus = int.Parse(pstatus); } PageModel <ProductsDS> p = ServiceHelper.Create <IProductsDSService>().GetProductsDSList(query); IEnumerable <ProductsDS> models = from item in p.Models.ToArray() select new ProductsDS() { Id = item.Id, UserId = item.UserId, ProductId = item.ProductId, productCode = ServiceHelper.Create <IProductService>().GetProduct(item.ProductId) == null ? "" : ServiceHelper.Create <IProductService>().GetProduct(item.ProductId).ProductCode, sellerusername = ServiceHelper.Create <IMemberService>().GetMember(item.UserId) == null ? "" : ServiceHelper.Create <IMemberService>().GetMember(item.UserId).UserName, productName = ServiceHelper.Create <IProductService>().GetProduct(item.ProductId) == null ? "" : ServiceHelper.Create <IProductService>().GetProduct(item.ProductId).ProductName, cas = ServiceHelper.Create <IProductService>().GetProduct(item.ProductId) == null ? "" : ServiceHelper.Create <IProductService>().GetProduct(item.ProductId).CASNo, DSStatus = item.DSStatus, DSTime = item.DSTime }; DataGridModel <ProductsDS> dataGridModel = new DataGridModel <ProductsDS>() { rows = models, total = p.Total }; return(Json(dataGridModel)); }
/// <summary> /// update /// </summary> /// <param name="query"></param> /// <returns></returns> public bool UpdateProductsDS(ProductsDSQuery query) { ProductsDS p = context.ProductsDS.FirstOrDefault((ProductsDS m) => m.Id == query.id); if (p == null) { return(false); } p.ProductId = query.productid; p.ShopId = query.shopid; p.UserId = query.userid; p.UserType = query.usertype; p.DSStatus = query.dsstatus; p.DSTime = query.dstime; int i = context.SaveChanges(); if (i > 0) { return(true); } else { return(false); } }
/// <summary> /// add /// </summary> /// <param name="query"></param> /// <returns></returns> public bool AddProductsDS(ProductsDSQuery query) { int i = 0; ProductsDS p = new ProductsDS(); p.ProductId = query.productid; p.ShopId = query.shopid; p.UserId = query.userid; p.UserType = query.usertype; p.DSStatus = query.dsstatus; p.DSTime = query.dstime; try { // 写数据库 context.ProductsDS.Add(p); i = context.SaveChanges(); } catch (DbEntityValidationException dbEx) { } if (i > 0) { return(true); } else { return(false); } }
/// <summary> /// del /// </summary> /// <param name="query"></param> /// <returns></returns> public bool DelProductsDS(ProductsDSQuery query) { ProductsDS p = context.ProductsDS.FirstOrDefault((ProductsDS m) => m.Id == query.id); if (p == null) { return(false); } context.ProductsDS.Remove(p); int i = context.SaveChanges(); if (i > 0) { return(true); } else { return(false); } }
public JsonResult DS(string id, int Status) { if (string.IsNullOrEmpty(id)) { return(Json("")); } else { int i; if (!int.TryParse(id, out i)) { return(Json("")); } else { ProductsDSQuery query = new ProductsDSQuery(); query.id = int.Parse(id); ProductsDS p = ServiceHelper.Create <IProductsDSService>().GetProductsDSbyId(int.Parse(id)); query.dsstatus = Status; query.shopid = p.ShopId; query.productid = p.ProductId; query.productcode = p.productCode; query.userid = p.UserId; query.usertype = p.UserType; query.dstime = p.DSTime; if (ServiceHelper.Create <IProductsDSService>().UpdateProductsDS(query)) { return(Json("ok")); } else { return(Json("")); } } } }
public PageModel <ProductsDS> GetProductsDSList(ProductsDSQuery query) { int num = 0; IQueryable <ProductsDS> p = context.ProductsDS.AsQueryable <ProductsDS>(); //产品货号 if (!string.IsNullOrWhiteSpace(query.productcode)) { p = from d in p where d.productCode.Equals(query.productcode) select d; } //产品名称 if (!string.IsNullOrWhiteSpace(query.productname)) { p = from d in p where d.productName.Equals(query.productname) select d; } //cas if (!string.IsNullOrWhiteSpace(query.CAS)) { p = from d in p where d.cas.Equals(query.CAS) select d; } //供应商名称 if (!string.IsNullOrWhiteSpace(query.sellerusername)) { p = from d in p where d.sellerusername.Equals(query.sellerusername) select d; } //供应商编号 if (query.userid != 0) { p = from d in p where d.UserId.Equals(query.userid) select d; } //状态 if (query.dsstatus >= 0) { p = from d in p where d.DSStatus.Equals(query.dsstatus) select d; } p = p.GetPage(out num, query.PageNo, query.PageSize, (IQueryable <ProductsDS> d) => from o in d orderby o.DSTime descending select o); return(new PageModel <ProductsDS>() { Models = p, Total = num }); }