public async Task <ActionResult> Index(CompanyLimitSM sm) { var Dtos = companyLimitRepo.GetList(sm, ViewHelp.GetCompanyIds(), ViewHelp.GetCateIds()); var models = Mapper.Map <List <CompanyLimitVM> >(Dtos); if (Request.IsAjaxRequest()) { return(PartialView("_List", models)); } InitSelect(); return(View(models)); }
public List <CompanyLimitDTO> GetList(CompanyLimitSM sm, string companyIds, string cateIds) { var sql = @"select a.Id,b.CompanyName,c.CateName,a.LimitSum,a.ModifyDate,a.Modifier,a.SeasonType from EM_Company_Limit a join EM_Company b on a.CompanyId=b.Id join EM_Charge_Cate c on a.CateId=c.Id where 1=1 "; if (sm.CompanyId != 0) { sql += " and a.CompanyId=@CompanyId"; } if (sm.CateId != 0) { sql += " and a.CateId=@CateId"; } if (sm.SeasonType != 0) { sql += " and a.SeasonType=@SeasonType"; } if (sm.SDate.HasValue) { sql += " and a.ModifyDate>=@SDate"; } if (sm.EDate.HasValue) { sql += " and a.ModifyDate<=@EDate"; } if (!string.IsNullOrEmpty(companyIds)) { sql += " and a.CompanyId in (" + companyIds + ")"; } if (!string.IsNullOrEmpty(cateIds)) { sql += " and a.CateId in (" + cateIds + ")"; } var result = DapperHelper.SqlQuery <CompanyLimitDTO>(sql, sm).ToList(); return(result); }