예제 #1
0
 private void nursesearchbutton_Click(object sender, EventArgs e)
 {
     if (nursesearchcomboBox.SelectedItem == null)
     {
         MessageBox.Show("Please select your search type");
     }
     else
     {
         if (nursesearchtextBox.Text == "")
         {
             MessageBox.Show("Please type your search");
         }
         else
         {
             if (nursesearchcomboBox.SelectedItem.ToString() == "Name")
             {
                 nursedataGridView.DataSource = null;
                 nursedataGridView.Rows.Clear();
                 List <Nurse> nlist = da.getNurseByName(nursesearchtextBox.Text);
                 if (nlist.Count != 0)
                 {
                     foreach (var item in nlist)
                     {
                         nursedataGridView.Rows.Add(item.Name, item.Contactno, item.Designation);
                     }
                 }
                 else
                 {
                     MessageBox.Show("No results found");
                 }
             }
             else if (nursesearchcomboBox.SelectedItem.ToString() == "Designation")
             {
                 nursedataGridView.DataSource = null;
                 nursedataGridView.Rows.Clear();
                 List <Nurse> nlist = da.getNurseByDes(nursesearchtextBox.Text);
                 if (nlist.Count != 0)
                 {
                     foreach (var item in nlist)
                     {
                         nursedataGridView.Rows.Add(item.Name, item.Contactno, item.Designation);
                     }
                 }
                 else
                 {
                     MessageBox.Show("No results found");
                 }
             }
         }
     }
 }