Example #1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                examListView examo    = avaialableExams.SelectedItem as examListView;
                int          ExamCode = (from exam in context2.exams
                                         where exam.Name == examo.ExamName
                                         select exam.ExamCode).FirstOrDefault();

                foreach (var item in selecteStudentstoExam)
                {
                    var r = (from d in context2.rel_exam_student
                             where d.ExamCode == ExamCode && d.StuId == item && d.Taken == false select d).FirstOrDefault();
                    if (r == null)

                    {
                        context2.rel_exam_student.Add(new rel_exam_student {
                            StuId = item, ExamCode = ExamCode
                        });

                        MessageBox.Show("done");
                    }
                    else
                    {
                        MessageBox.Show("some students already have been assigned to hte exam");
                    }
                }
                context2.SaveChanges();
            }
            catch (Exception d)
            {
                MessageBox.Show("Erorr Please Enter a Valid Data");
            }
        }
Example #2
0
        private void Coure_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var CourseName = sender as ComboBox;
            //fill the exam list
            var                 CourseNName    = Coure.SelectedItem.ToString();
            List <exam>         exams          = getAllExamsofCourse(CourseNName);
            List <examListView> examstoBeViewd = new List <examListView>();

            foreach (var item in exams)
            {
                examListView ex = new examListView {
                    ExamCode = item.ExamCode, ExamName = item.Name, Type = item.Type, Date = item.Date
                };
                examstoBeViewd.Add(ex);
            }
            avaialableExams.ItemsSource = examstoBeViewd;

            //fill the students list
            CourseNName = Coure.SelectedItem.ToString();
            List <student>         students          = getAllStudentsofCourse(CourseNName);
            List <studentListView> studentstoBeViewd = new List <studentListView>();

            AvaialableStudents.Items.Clear();
            foreach (var item in students)
            {
                ListViewItem d = new ListViewItem();

                studentListView st = new studentListView {
                    ID = item.StuId, Name = item.FirstName + " " + item.LastName, Track = getStudentTrack(item)
                };
                AvaialableStudents.Items.Add(st);
            }
            //AvaialableStudents.Items[0].SubItems[5].BackColor = System.Drawing.Color.Red;
            //AvaialableStudents.ItemsSource = studentstoBeViewd;
        }
Example #3
0
        private void Button_Click_6(object sender, RoutedEventArgs e)
        {
            try
            {
                examListView     exa = avaialableExams.SelectedItem as examListView;
                rel_exam_student t   = (from y in context2.rel_exam_student
                                        where y.ExamCode == exa.ExamCode
                                        select y).FirstOrDefault();

                context2.rel_exam_student.Remove(t);
                context2.SaveChanges();
                MessageBox.Show("done");
            }
            catch (Exception dds)
            {
            }
        }
Example #4
0
        private void avaialableExams_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            examListView po = avaialableExams.SelectedItem as examListView;
            List <int>   qu = (from y in context2.rel_exam_student
                               where y.ExamCode == po.ExamCode
                               select y.StuId).ToList();

            foreach (var stu in AvaialableStudents.Items)
            {
                var d = stu as studentListView;
                foreach (var exa in qu)
                {
                    if (d.ID == exa)
                    {
                        checkedd f = new checkedd();
                        f.check = true;
                    }
                }
            }
        }
Example #5
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         examListView examo    = avaialableExams.SelectedItem as examListView;
         int          ExamCode = (from exam in context2.exams
                                  where exam.Name == examo.ExamName
                                  select exam.ExamCode).FirstOrDefault();
         foreach (var item in selecteStudentstoExam)
         {
             context2.rel_exam_student.Add(new rel_exam_student {
                 StuId = item, ExamCode = ExamCode
             });
         }
         context2.SaveChanges();
     }
     catch (Exception d)
     {
         MessageBox.Show("already assigned");
     }
 }