private void frmControlSubjects_Load(object sender, EventArgs e)
        {
            RegistrationServiceClient registrationService = new RegistrationServiceClient();
            string message = String.Empty;

            ControlStudent = registrationService.GetStudent(controlStudentId,ref message);
            StudentEnrollment enrStudent = new StudentEnrollment();

            SY = GlobalClass.currentsy;
            enrStudent = registrationService.GetStudentEnrolled(controlStudentId,SY);

            EnrolMe.StudentSY = controlStudentId + SY;
            int prev =Int32.Parse(SY.Substring(0,4));
            prev--;
            int sy = Int32.Parse(SY.Substring(5, 4));
            sy--;
            string prevSY = prev.ToString() + "-" + sy.ToString();

            string prevRecord = controlStudentId + prevSY;
            FailedSubjects = new List<StudentSubject>(registrationService.GetFailedSubjects(prevRecord));
            StudentSubs = new List<StudentSubject>(registrationService.GetStudentSubjects(EnrolMe.StudentSY));
            Schedules = new List<StudentSchedule>(registrationService.GetSubjectSchedules(SY));

            if (StudentSubs.Count > 0)
            {
                ExistingSchedule = new List<StudentSchedule>(registrationService.GetStudentExistingSchedule(StudentSubs.ToArray(), SY));

            }

            if (ExistingSchedule.Count > 0) {
                foreach (StudentSchedule ss in ExistingSchedule) {
                    int index = Schedules.FindIndex(item => item.SubjectAssignments == ss.SubjectAssignments);
                    Schedules.RemoveAt(index);
                    //StudentSubject s = new StudentSubject()
                    //{
                    //    StudentSY = controlStudentId + SY,
                    //    SubjectCode = ss.SubjectCode,
                    //    SubjectAssignments = ss.SubjectAssignments,
                    //    StudentEnrSubCode = controlStudentId + SY + ss.SubjectCode,
                    //    LockFirst = false,
                    //    LockSecond = false,
                    //    LockThird = false,
                    //    LockFourth = false,
                    //    FirstPeriodicRating = 0.00,
                    //    SecondPeriodicRating = 0.00,
                    //    ThirdPeriodicRating = 0.00,
                    //    FourthPeriodicRating = 0.00
                    //};
                    //subjects.Add(s);
                }
            }

            gvAllSchedules.DataSource = Schedules;
            gvFail.DataSource = FailedSubjects;

            if (ControlStudent.UnitsFailedLastYear == 0 && StudentSubs.Count == 0)
            {
                int sectionCode = (int)enrStudent.GradeSectionCode;
                Schedule = new List<StudentSchedule>(registrationService.GetSubjectsOfSection(sectionCode, SY));
                foreach (StudentSchedule sch in Schedule) {
                    StudentSubject ss = new StudentSubject()
                    {
                        StudentSY = controlStudentId + SY,
                        SubjectCode = sch.SubjectCode,
                        SubjectAssignments = sch.SubjectAssignments,
                        StudentEnrSubCode = controlStudentId + SY + sch.SubjectCode,
                        LockFirst = false,
                        LockSecond = false,
                        LockThird = false,
                        LockFourth = false,
                        FirstPeriodicRating = 0.00,
                        SecondPeriodicRating = 0.00,
                        ThirdPeriodicRating = 0.00,
                        FourthPeriodicRating = 0.00
                    };
                    subjects.Add(ss);
                }

                ControlSchedule = Schedule;
                GlobalClass.gvDatasource = 1;
                gvSchedule.DataSource = ControlSchedule;
                gvSchedule.ReadOnly = false;
            }
            else if (StudentSubs.Count > 0)
            {
                GlobalClass.gvDatasource = 2;
                ControlSchedule = ExistingSchedule;
                gvAllSchedules.ReadOnly = false;
                gvSchedule.ReadOnly = false;
                //   btnSelect.Enabled = true;
                gvSchedule.DataSource = ControlSchedule;
            }
             else if (ControlStudent.UnitsFailedLastYear > 0)
             {
                GlobalClass.gvDatasource = 3;
                gvAllSchedules.ReadOnly = false;
                gvSchedule.ReadOnly = false;
            }
            txtSection.Text = ControlStudent.Section;
            txtSY.Text = SY;
            txtGradeLevel.Text = ControlStudent.GradeLevel;
            txtStudentId.Text = ControlStudent.StudentId;
            txtStudentName.Text = ControlStudent.LastName + "," + ControlStudent.FirstName + " " + ControlStudent.MiddleName;
            txtPrevGPA.Text = ControlStudent.Average.ToString();
            txtUnitsFailed.Text = ControlStudent.UnitsFailedLastYear.ToString();
        }