示例#1
0
        public static EFStudent GetStudentByID(int studentID)
        {
            EFStudent student = (from students in schoolData.EFStudents
                                 where students.StudentID == studentID
                                 select students).Single();

            return(student);
        }
示例#2
0
 public static string GetStudentNameByID(int studentID)
 {
     if (IsValidStudentID(studentID))
     {
         EFStudent student = schoolData.EFStudents.Where(c => c.StudentID == studentID).Single();
         string    name    = student.First_Name.Trim() + " " + student.Last_Name.Trim();
         return(name);
     }
     else
     {
         return(" ");
     }
 }
 private void btnFindStudent_Click(object sender, RoutedEventArgs e)
 {
     int studentID = 0;
     if (SchoolValidation.StringToInt(txtStudentFind.Text, out studentID))
     {
         if (StudentDB.IsValidStudentID(studentID))
         {
             EFStudent student = schoolData.EFStudents.Where(s => s.StudentID == studentID).Single();
             oldStudent = student;
             txtFirstName.Text = student.First_Name.Trim();
             txtLastName.Text = student.Last_Name.Trim();
             txtAddress.Text = student.Address.Trim();
             txtZip.Text = student.ZipCode.ToString();
             cboStates.SelectedValue = student.StateCode;
             lblStudentFullName.Content = student.First_Name.Trim() + " " + student.Last_Name.Trim();
             lblStudentID.Content = studentID.ToString();
             if (student.Photo != null)
             {
                 StringtoImage(student.Photo.Trim());
             }
             else
             {
                 StringtoImage("http://i882.photobucket.com/albums/ac22/CoreySanders/noImage_zpsctmad3nk.png");
             }
             ToggleEditMode();
         }
         else
         {
             MessageBox.Show("Is not a valid student");
         }
     }
     else
     {
         MessageBox.Show("Please insert a valid student id (number between 0 - 1000000)");
     }
 }