private void btnQuery_Click(object sender, EventArgs e) { switch (cmbQuery.SelectedIndex) { case 0: // 全部 List <HealthInformation> informations = HealthInformationService.QueryByUser(CurrentUser.UserId); HealthBindingSource.DataSource = informations; break; case 1: // 按居民ID查询 informations = HealthInformationService.QueryByUser(CurrentUser.UserId); List <HealthInformation> temp = new List <HealthInformation>(); var list = from HealthInformation h in informations where h.Resident.ResidentId == txtQuery.Text select h; temp = list.ToList(); HealthBindingSource.DataSource = HealthInformationService.QueryByResident(txtQuery.Text); break; case 2: // 按日期查询 DateTime dt = Convert.ToDateTime(txtQuery.Text); informations = HealthInformationService.QueryByUser(CurrentUser.UserId); var date = from HealthInformation h in informations where h.Date == dt select h; temp = date.ToList(); HealthBindingSource.DataSource = temp; break; } HealthBindingSource.ResetBindings(true); }
public HealthInfoResident(User user) : this() { CurrentUser = user; List <Resident> residents = ResidentService.QueryByUser(CurrentUser.UserId); List <HealthInformation> healthInformation = null; for (int i = 0; i < residents.Count(); i++) { healthInformation.Add(new HealthInformation(residents[i])); } TodayBindingSource.DataSource = healthInformation; HealthBindingSource.DataSource = HealthInformationService.QueryByUser(CurrentUser.UserId); }
private void button2_Click(object sender, EventArgs e) { switch (cmbQuery.SelectedIndex) { case 0: // 全部 HealthBindingSource.DataSource = HealthInformationService.GetAll(); break; case 1: // 按居民ID查询 HealthBindingSource.DataSource = HealthInformationService.QueryByResident(txtQuery.Text); break; case 2: // 按用户ID查询 HealthBindingSource.DataSource = HealthInformationService.QueryByUser(txtQuery.Text); break; case 3: // 按日期查询 DateTime dt = Convert.ToDateTime(txtQuery.Text); HealthBindingSource.DataSource = HealthInformationService.QueryByDate(dt); break; } HealthBindingSource.ResetBindings(true); }