protected void btnGoCarrollId_Click(object sender, EventArgs e)
        {
            int stuID;

            int.TryParse(txtCarrollIdSelect.Text, out stuID);
            if (stuID != 0)
            {
                lblLastNameError.Visible = false;
                App_Data.Student student = StudentDAO.getStudentByID(stuID);
                if (student != null)
                {
                    AssignInformationCarrollId(student);
                }
                else
                {
                    lblLastNameError.Visible = true;
                    lblLastNameError.Text    = "No Students With This Carroll ID";
                }
            }
            else
            {
                lblLastNameError.Visible = true;
                lblLastNameError.Text    = "Please Enter a Valid Carroll ID";
            }
        }
        protected void grdLastNameStudents_SelectedIndexChanged(object sender, EventArgs e)
        {
            int stuID;

            int.TryParse(grdLastNameStudents.Rows[grdLastNameStudents.SelectedIndex].Cells[2].Text, out stuID);
            App_Data.Student student = StudentDAO.getStudentByID(stuID);
            if (student != null)
            {
                AssignInformationCarrollId(student);
            }
        }
        /// It only returns first name, last name and carroll id
        public List <StudentOrganisationApp.App_Data.Student> getStudentByLastName(string lastname)
        {
            List <StudentOrganisationApp.App_Data.Student> students = new List <App_Data.Student>();
            var stud = dataContext.sp_GetStudentByLastName(lastname);

            foreach (var s in stud)
            {
                StudentOrganisationApp.App_Data.Student student = new App_Data.Student();
                student.FirstName  = s.FirstName;
                student.LastName   = s.LastName;
                student.Carroll_ID = s.Carroll_ID;
                students.Add(student);
            }
            return(students);
        }
        public StudentOrganisationApp.App_Data.Student getStudentByID(int stuID)
        {
            StudentOrganisationApp.App_Data.Student student = null;

            try
            {
                var stud = dataContext.sp_GetStudentByCarrollID(stuID).First();

                student                 = new App_Data.Student();
                student.FirstName       = stud.FirstName;
                student.LastName        = stud.LastName;
                student.ClassOf         = stud.ClassOf;
                student.Email           = stud.Email;
                student.PreferredPhone  = stud.PreferredPhone;
                student.Active          = stud.Active;
                student.Gender          = stud.Gender;
                student.Carroll_ID      = stud.Carroll_ID;
                student.GPABoard        = stud.GPABoard;
                student.GPAOrg          = stud.GPAOrg;
                student.Major           = stud.Major;
                student.Major2          = stud.Major2;
                student.CertifiedDriver = stud.CertifiedDriver;
                student.ApprovedDriver  = stud.ApprovedDriver;
                student.GreekGPA        = stud.GreekGPA;
                student.Ferpa           = stud.Ferpa;
                student.Student_ID      = stud.Student_ID;
                student.OnCampus        = stud.OnCampus;
                student.Race            = stud.Race;
                student.International   = stud.International;
            }
            catch (Exception e)
            {
            }

            return(student);
        }
        public void AssignInformationCarrollId(App_Data.Student studentForEdit)
        {
            try
            {
                pnlEditing.Visible   = true;
                pnlOrgMember.Visible = true;

                pnlSearchStudent.Visible = false;
                txtLastNameSelect.Text   = string.Empty;
                txtCarrollIdSelect.Text  = string.Empty;

                lblNameStudent.Text = studentForEdit.FirstName + " " + studentForEdit.LastName;

                gridview_OrgMember.DataSource = StudentDAO.getHistoricalOrgsByID(Convert.ToInt32(studentForEdit.Carroll_ID));
                gridview_OrgMember.DataBind();

                txtStudentEmail.Text     = studentForEdit.Email;
                txtPrefPhoneNo.Text      = studentForEdit.PreferredPhone;
                txtStudentFirstName.Text = studentForEdit.FirstName;
                txtStudentLastName.Text  = studentForEdit.LastName;
                txtCarrollID.Text        = studentForEdit.Carroll_ID.ToString();
                txtGradClass.Text        = studentForEdit.ClassOf.ToString();
                txtMajor.Text            = studentForEdit.Major;
                txtMajor2.Text           = studentForEdit.Major2;

                txtRace.Text = studentForEdit.Race;

                if (studentForEdit.OnCampus.ToString().Equals("Y"))
                {
                    cbOnCampus.Checked = true;
                }
                else
                {
                    cbOnCampus.Checked = false;
                }

                if (studentForEdit.International.ToString().Equals("Y"))
                {
                    cbIntl.Checked = true;
                }
                else
                {
                    cbIntl.Checked = false;
                }

                lblStuID.Text = studentForEdit.Student_ID.ToString();
                if (studentForEdit.GreekGPA == true)
                {
                    chkGreekGPA.Checked = true;
                }
                else
                {
                    chkGreekGPA.Checked = false;
                }
                if (studentForEdit.Gender == true)
                {
                    rblGender.SelectedIndex = 0;
                }
                else
                {
                    rblGender.SelectedIndex = 1;
                }
                if (studentForEdit.GPABoard == true)
                {
                    chklGrades.Items[0].Selected = true;
                }
                if (studentForEdit.GPAOrg == true)
                {
                    chklGrades.Items[1].Selected = true;
                }
                if (studentForEdit.Active == true)
                {
                    rblStatus.SelectedIndex = 0;
                }
                else
                {
                    rblStatus.SelectedIndex = 1;
                }
                if (studentForEdit.CertifiedDriver == true)
                {
                    chklDrvingPermission.Items[0].Selected = true;
                }
                if (studentForEdit.ApprovedDriver == true)
                {
                    chklDrvingPermission.Items[1].Selected = true;
                }
            }
            catch (Exception)
            {
                lblMessage.Text          = "Unable to retrieve the Student data!!";
                pnlEditing.Visible       = false;
                pnlSearchStudent.Visible = false;
                txtLastNameSelect.Text   = string.Empty;
                txtCarrollIdSelect.Text  = string.Empty;
            }
        }