private void btnRemove_Click(object sender, EventArgs e) { List <StudentSchedule> ss = new List <StudentSchedule>(); gvAllSchedules.DataSource = ss; gvSchedule.DataSource = ss; Schedules.AddRange(AddFromAll); List <StudentSchedule> selControlledTrue = AddFromAll.FindAll(item => item.Selected == true); IGradingService gradingService = new GradingService(); listStSub = gradingService.GetStudentGrades(controlStudentId, SY); foreach (StudentSchedule sche in selControlledTrue) { if (listStSub != null) { stSubj = listStSub.Find(item => item.StudentSY == controlStudentId + SY && item.SubjectCode == sche.SubjectCode); } if (stSubj != null) { if (stSubj.FirstPeriodicRating > 0 || stSubj.SecondPeriodicRating > 0 || stSubj.ThirdPeriodicRating > 0 || stSubj.FourthPeriodicRating > 0 || stSubj.FinalRating > 0) { MessageBox.Show("Cannot remove " + stSubj.Description + ", already has grade/s inputted", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Information); int i = ControlSchedule.FindIndex(item => item.SubjectAssignments == sche.SubjectAssignments); ControlSchedule[i].Selected = false; int i3 = ExistingSchedRemove.FindIndex(item => item.SubjectAssignments == sche.SubjectAssignments); ExistingSchedRemove.RemoveAt(i3); } else { int i = ControlSchedule.FindIndex(item => item.SubjectAssignments == sche.SubjectAssignments); ControlSchedule.RemoveAt(i); int i2 = Schedules.FindIndex(item => item.SubjectAssignments == sche.SubjectAssignments); Schedules[i2].Selected = false; } } } gvAllSchedules.DataSource = Schedules; gvSchedule.DataSource = ControlSchedule; AddFromAll.Clear(); }
private void btnAdd_Click(object sender, EventArgs e) { List <StudentSchedule> ss = new List <StudentSchedule>(); gvAllSchedules.DataSource = ss; gvSchedule.DataSource = ss; ControlSchedule.AddRange(AddFromControl); List <StudentSchedule> seltrue = ControlSchedule.FindAll(item => item.Selected == true); foreach (StudentSchedule s in seltrue) { int i = ControlSchedule.FindIndex(item => item.SubjectAssignments == s.SubjectAssignments); ControlSchedule[i].Selected = false; } gvAllSchedules.DataSource = Schedules; gvSchedule.DataSource = ControlSchedule; AddFromControl.Clear(); }
private void cbEditor_ValueChanged(object sender, EventArgs e) { StudentSchedule sa = new StudentSchedule(); int i = gvSchedule.CurrentRow.Index; string subass = gvSchedule.Rows[i].Cells["SubjectAssignments"].Value.ToString(); int index = ControlSchedule.FindIndex(item => item.SubjectAssignments == subass); ControlSchedule[index].Selected = false; sa = ControlSchedule[index]; RadCheckBoxEditor cbEditor = sender as RadCheckBoxEditor; StudentSubject ss = new StudentSubject() { StudentSY = controlStudentId + SY, SubjectCode = sa.SubjectCode, SubjectAssignments = sa.SubjectAssignments, StudentEnrSubCode = controlStudentId + SY + sa.SubjectCode, LockFirst = false, LockSecond = false, LockThird = false, LockFourth = false, FirstPeriodicRating = 0.00, SecondPeriodicRating = 0.00, ThirdPeriodicRating = 0.00, FourthPeriodicRating = 0.00 }; if ((Telerik.WinControls.Enumerations.ToggleState)cbEditor.Value == Telerik.WinControls.Enumerations.ToggleState.Off) { sa.Selected = false; AddFromControl.Add(sa); subjects.Add(ss); Schedules.Remove(sa); } else if ((Telerik.WinControls.Enumerations.ToggleState)cbEditor.Value == Telerik.WinControls.Enumerations.ToggleState.On) { sa.Selected = false; RemoveFromControl.Add(sa); bool cont = ExistingSchedule.Contains(sa); if (cont) { int ind = ExistingSchedule.FindIndex(item => item.SubjectAssignments == sa.SubjectAssignments); StudentSubject sti = new StudentSubject() { StudentSY = controlStudentId + SY, SubjectCode = ExistingSchedule[ind].SubjectCode, SubjectAssignments = ExistingSchedule[ind].SubjectAssignments, StudentEnrSubCode = controlStudentId + SY + ExistingSchedule[ind].SubjectCode, LockFirst = false, LockSecond = false, LockThird = false, LockFourth = false, FirstPeriodicRating = 0.00, SecondPeriodicRating = 0.00, ThirdPeriodicRating = 0.00, FourthPeriodicRating = 0.00 }; ExistingSchedRemove.Add(sti); } else { subjects.Remove(ss); } AddFromAll.Add(sa); } }