public ActionResult GetCustomerList() { int pageIndex = WebUtil.GetFormValue <int>("pageIndex", 1); int pageSize = WebUtil.GetFormValue <int>("pageSize", 15); string CusNum = WebUtil.GetFormValue <string>("CusNum", string.Empty); int CusType = WebUtil.GetFormValue <int>("CusType", 0); CustomerProvider provider = new CustomerProvider(); CustomerEntity entity = new CustomerEntity(); PageInfo pageInfo = new PageInfo() { PageIndex = pageIndex, PageSize = pageSize }; if (!CusNum.IsEmpty()) { entity.Begin <CustomerEntity>() .Where <CustomerEntity>("CusNum", ECondition.Like, "%" + CusNum + "%") .Or <CustomerEntity>("CusName", ECondition.Like, "%" + CusNum + "%") .End <CustomerEntity>(); } if (CusType != 0) { entity.Where <CustomerEntity>(a => a.CusType == CusType); } List <CustomerEntity> listResult = provider.GetCustomerList(entity, ref pageInfo); string json = ConvertJson.ListToJson <CustomerEntity>(listResult, "List"); this.ReturnJson.AddProperty("Data", new JsonObject(json)); this.ReturnJson.AddProperty("RowCount", pageInfo.RowCount); return(Content(this.ReturnJson.ToString())); }
/// <summary> /// 分页查询客户信息 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <CustomerEntity> GetCustomerList(CustomerEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete) .And(a => a.CompanyID == this.CompanyID); if (!entity.CusNum.IsEmpty()) { entity.And("CusNum", ECondition.Like, "%" + entity.CusNum + "%"); } if (!entity.CusName.IsEmpty()) { entity.And("CusName", ECondition.Like, "%" + entity.CusName + "%"); } if (!entity.Phone.IsEmpty()) { entity.And("Phone", ECondition.Like, "%" + entity.Phone + "%"); } if (entity.CusType > 0) { entity.And(a => a.CusType == entity.CusType); } int rowCount = 0; List <CustomerEntity> listResult = this.Customer.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; return(listResult); }
/// <summary> /// 根据客户编号获得客户信息 /// </summary> /// <param name="cusNum"></param> /// <returns></returns> public CustomerEntity GetSingleCustomer(string cusNum) { CustomerEntity entity = new CustomerEntity(); entity.IncludeAll(); entity.Where(a => a.CusNum == cusNum); entity = this.Customer.GetSingle(entity); return(entity); }
/// <summary> /// 查询所有的客户数据信息 /// </summary> /// <returns></returns> public List <CustomerEntity> GetList() { CustomerEntity entity = new CustomerEntity(); entity.IncludeAll(); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); List <CustomerEntity> listResult = this.Customer.GetList(); return(listResult); }
/// <summary> /// 分页查询客户信息 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <CustomerEntity> GetCustomerList(CustomerEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.IsDelete == (int)EIsDelete.NotDelete); int rowCount = 0; List <CustomerEntity> listResult = this.Customer.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; return(listResult); }
/// <summary> /// 删除 /// </summary> /// <param name="cusNum"></param> /// <returns></returns> public int Delete(string cusNum) { CustomerEntity entity = new CustomerEntity(); entity.IsDelete = (int)EIsDelete.Deleted; entity.IncludeIsDelete(true); entity.Where(a => a.CusNum == cusNum); int line = this.Customer.Update(entity); if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_CUSADDRESS_CACHE); } return(line); }
/// <summary> /// 删除 /// </summary> /// <param name="cusNum"></param> /// <returns></returns> public int Delete(IEnumerable <string> list) { string Key = string.Format(CacheKey.JOOSHOW_CUSADDRESS_CACHE, this.CompanyID); CustomerEntity entity = new CustomerEntity(); entity.IsDelete = (int)EIsDelete.Deleted; entity.IncludeIsDelete(true); entity.Where("SnNum", ECondition.In, list.ToArray()); int line = this.Customer.Update(entity); if (line > 0) { CacheHelper.Remove(Key); } return(line); }
/// <summary> /// 修改 /// </summary> /// <param name="entity"></param> /// <param name="list"></param> /// <returns></returns> public int Update(CustomerEntity entity, List <CusAddressEntity> list) { entity.IncludeCusName(true) .IncludeEmail(true) .IncludeFax(true) .IncludePhone(true) .IncludeRemark(true) .IncludeCusType(true) ; entity.Where(a => a.CusNum == entity.CusNum); int line = this.Customer.Update(entity); if (!list.IsNullOrEmpty()) { foreach (CusAddressEntity item in list) { item.CusNum = entity.CusNum; CusAddressEntity tempEntity = new CusAddressEntity(); tempEntity.IncludeAll(); tempEntity.Where(a => a.CusNum == item.CusNum).And(a => a.SnNum == item.SnNum); tempEntity = this.CusAddress.GetSingle(tempEntity); if (tempEntity.IsNotNull()) { item.IncludeAddress(true) .IncludeContact(true) .IncludePhone(true) ; item.Where(a => a.SnNum == item.SnNum).And(a => a.CusNum == item.CusNum); line += this.CusAddress.Update(item); } else { item.IncludeAll(); line = this.CusAddress.Add(item); } } if (line > 0) { CacheHelper.Remove(CacheKey.JOOSHOW_CUSADDRESS_CACHE); } } return(line); }
/// <summary> /// 修改 /// </summary> /// <param name="entity"></param> /// <param name="list"></param> /// <returns></returns> public int Update(CustomerEntity entity, List <CusAddressEntity> list) { string Key = string.Format(CacheKey.JOOSHOW_CUSADDRESS_CACHE, this.CompanyID); entity.IncludeCusName(true) .IncludeEmail(true) .IncludeFax(true) .IncludePhone(true) .IncludeRemark(true) .IncludeCusType(true) .IncludeCusNum(true) ; entity.Where(a => a.SnNum == entity.SnNum); int line = this.Customer.Update(entity); if (!list.IsNullOrEmpty()) { CusAddressEntity addSource = new CusAddressEntity(); addSource.IncludeAll(); addSource.Where(a => a.CustomerSN == entity.SnNum) .And(a => a.IsDelete == (int)EIsDelete.NotDelete) ; List <CusAddressEntity> listSource = this.CusAddress.GetList(addSource); listSource = listSource.IsNull() ? new List <CusAddressEntity>() : listSource; //处理未删除的 foreach (CusAddressEntity item in list.Where(a => a.IsDelete == (int)EIsDelete.NotDelete)) { if (listSource.Exists(a => a.SnNum == item.SnNum)) { item.Include(a => new { a.Contact, a.Phone, a.Address, a.Remark }); item.Where(a => a.SnNum == item.SnNum); line += this.CusAddress.Update(item); } else { item.IncludeAll(); item.CustomerSN = entity.SnNum; item.CreateTime = DateTime.Now; item.IsDelete = (int)EIsDelete.NotDelete; item.CompanyID = this.CompanyID; line += this.CusAddress.Add(item); } } //处理删除的 foreach (CusAddressEntity item in listSource) { if (!list.Exists(a => a.SnNum == item.SnNum)) { item.IsDelete = (int)EIsDelete.Deleted; item.IncludeIsDelete(true); item.Where(a => a.SnNum == item.SnNum); line += this.CusAddress.Update(item); } } } if (line > 0) { CacheHelper.Remove(Key); } return(line); }