Skip to content

Commit

Permalink
added search function
Browse files Browse the repository at this point in the history
  • Loading branch information
KusalPriyanka committed Oct 16, 2020
1 parent 9284e62 commit c2b0837
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions TimeTable_App/Forms/SubForms/SessionsSubForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -346,5 +346,33 @@ private void btnCansel_Click(object sender, EventArgs e)
initForm();
}

private void btnSearch_Click(object sender, EventArgs e)
{
if (comboSearchType.SelectedIndex == 0)
{
MessageBox.Show("Please Select Search Type!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
comboSearchType.Focus();
}
else if (string.IsNullOrEmpty(txtSearch.Text))
{
MessageBox.Show("Please Enter Search Value!", "Validation Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
txtSearch.Focus();
}
else
{
if (comboSearchType.SelectedIndex == 1)
{
gridSessionDetails.DataSource = sessionList.Where(session => session.LecturersList.Contains(txtSearch.Text.Trim())).ToList();
}
else if (comboSearchType.SelectedIndex == 2)
{
gridSessionDetails.DataSource = sessionList.Where(session => session.SubjectName == txtSearch.Text.Trim()).ToList();
}
else if (comboSearchType.SelectedIndex == 3)
{
gridSessionDetails.DataSource = sessionList.Where(session => session.GroupId == txtSearch.Text.Trim()).ToList();
}
}
}
}
}

0 comments on commit c2b0837

Please sign in to comment.