/// <summary> /// 根据关键字搜索客户信息 /// </summary> /// <param name="KeyWord"></param> /// <param name="TopSize"></param> /// <returns></returns> public List <CusAddressEntity> SearchCustomer(string KeyWord, int TopSize) { CusAddressEntity entity = new CusAddressEntity(); entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.CompanyID == this.CompanyID); CustomerEntity customer = new CustomerEntity(); customer.Include(a => new { CusNum = a.CusNum, CusName = a.CusName, CusType = a.CusType, Fax = a.Fax, Email = a.Email }); entity.Left <CustomerEntity>(customer, new Params <string, string>() { Item1 = "CustomerSN", Item2 = "SnNum" }); customer.And(a => a.IsDelete == (int)EIsDelete.NotDelete); PageInfo pageInfo = new PageInfo() { PageIndex = 1, PageSize = 10 }; customer.AndBegin <CustomerEntity>() .Or <CustomerEntity>("CusNum", ECondition.Like, "%" + KeyWord + "%") .Or <CustomerEntity>("CusName", ECondition.Like, "%" + KeyWord + "%") .Or <CustomerEntity>("Phone", ECondition.Like, "%" + KeyWord + "%") .End(); int rowCount = 0; List <CusAddressEntity> listResult = this.CusAddress.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; return(listResult); }
/// <summary> /// 查询客户地址分页列表 /// </summary> /// <param name="entity"></param> /// <param name="pageInfo"></param> /// <returns></returns> public List <CusAddressEntity> GetList(CusAddressEntity entity, ref PageInfo pageInfo) { entity.IncludeAll(); entity.OrderBy(a => a.ID, EOrderBy.DESC); entity.Where(a => a.CompanyID == this.CompanyID) .And(a => a.IsDelete == (int)EIsDelete.NotDelete); CustomerEntity customer = new CustomerEntity(); customer.Include(a => new { CusNum = a.CusNum, CusName = a.CusName, CusType = a.CusType, Fax = a.Fax, Email = a.Email }); entity.Left <CustomerEntity>(customer, new Params <string, string>() { Item1 = "CustomerSN", Item2 = "SnNum" }); customer.And(a => a.IsDelete == (int)EIsDelete.NotDelete); if (entity.CusType > 0) { customer.And(item => item.CusType == entity.CusType); } if (!entity.Address.IsEmpty()) { entity.And("Address", ECondition.Like, "%" + entity.Address + "%"); } if (!entity.Phone.IsEmpty()) { entity.And("Phone", ECondition.Like, "%" + entity.Phone + "%"); } if (!entity.CusNum.IsEmpty()) { customer.And("CusNum", ECondition.Like, "%" + entity.CusNum + "%"); } if (!entity.CusName.IsEmpty()) { customer.And("CusName", ECondition.Like, "%" + entity.CusName + "%"); } int rowCount = 0; List <CusAddressEntity> listResult = this.CusAddress.GetList(entity, pageInfo.PageSize, pageInfo.PageIndex, out rowCount); pageInfo.RowCount = rowCount; return(listResult); }