예제 #1
0
        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);
        }
예제 #2
0
        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);
        }