Beispiel #1
0
 private void doctorsearchbutton_Click(object sender, EventArgs e)
 {
     if (doctorsearchbycomboBox.SelectedItem == null)
     {
         MessageBox.Show("Please select your search type");
     }
     else
     {
         if (doctorsearchtextBox.Text == "")
         {
             MessageBox.Show("Please type your search");
         }
         else
         {
             if (doctorsearchbycomboBox.SelectedItem.ToString() == "Name")
             {
                 doctordataGridView.DataSource = null;
                 doctordataGridView.Rows.Clear();
                 List <Doctor> dlist = da.getDoctorByName(doctorsearchtextBox.Text);
                 if (dlist.Count != 0)
                 {
                     foreach (var item in dlist)
                     {
                         doctordataGridView.Rows.Add(item.Name, item.Contactno, item.Designation);
                     }
                 }
                 else
                 {
                     MessageBox.Show("No results found");
                 }
             }
             else if (doctorsearchbycomboBox.SelectedItem.ToString() == "Designation")
             {
                 doctordataGridView.DataSource = null;
                 doctordataGridView.Rows.Clear();
                 List <Doctor> dlist = da.getDoctorByDes(doctorsearchtextBox.Text);
                 if (dlist.Count != 0)
                 {
                     foreach (var item in dlist)
                     {
                         doctordataGridView.Rows.Add(item.Name, item.Contactno, item.Designation);
                     }
                 }
                 else
                 {
                     MessageBox.Show("No results found");
                 }
             }
         }
     }
 }