private void btnQuery_Click(object sender, EventArgs e) { UserType identity = CurrentUser.UserType; switch (cmbQuery.SelectedIndex) { case 0: // 全部 if (identity == UserType.Resident) { TravelBindingSource.DataSource = TravelRecordService.QueryByUserID(CurrentUser.UserId); } else if (identity == UserType.Administrator) { TravelBindingSource.DataSource = TravelRecordService.GetAll(); } break; case 1: // 根据ID查询 TravelBindingSource.DataSource = TravelRecordService.QueryByResidentID(txtQuery.Text); break; case 2: // 根据日期查询 DateTime dt = Convert.ToDateTime(txtQuery.Text); TravelBindingSource.DataSource = TravelRecordService.QuerydByDateLeave(dt); break; } TravelBindingSource.ResetBindings(true); }
public TravelExperience(User user) : this() { CurrentUser = user; // 判断权限 UserType identity = CurrentUser.UserType; if (identity == UserType.Resident) { groupBox3.Visible = false; TravelBindingSource.DataSource = TravelRecordService.QueryByUserID(CurrentUser.UserId); } else if (identity == UserType.Administrator) { btnAdd.Visible = false; btnEdit.Visible = false; btnDelete.Visible = false; TravelBindingSource.DataSource = TravelRecordService.GetAll(); } }