private void PanelAddTeacher_Load(object sender, EventArgs e)
 {
     using (schoolEntities db = new schoolEntities())
     {
         checkedlistbox_subjects.Items.AddRange(db.subjects.ToArray <subject>());
     }
 }
Exemplo n.º 2
0
 private void PanelAddMark_Load(object sender, EventArgs e)
 {
     using (schoolEntities db = new schoolEntities())
     {
         listbox_student.Items.AddRange(db.lesson_mark.ToArray());
     }
 }
        private void button_confirm_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                learning_program program = new learning_program
                {
                    name             = textbox_lesson_name.Text,
                    year_of_creation = int.Parse(textbox_year_of_creation.Text)
                };

                using (schoolEntities db = new schoolEntities())
                {
                    db.learning_program.Add(program);


                    int[] keys = checkedlistbox_subjects.CheckedItems.Cast <subject>().Select(s => s.id).ToArray();
                    foreach (var key in keys)
                    {
                        subject s = db.subjects.Find(key);
                        if (s != null)
                        {
                            s.learning_program1.Add(program);
                            program.subjects1.Add(s);
                        }
                    }

                    db.SaveChanges();
                    MessageBox.Show(string.Format("Learning program is added!"), "Success!");
                    textbox_lesson_name.Clear();
                    textbox_year_of_creation.Clear();
                    checkedlistbox_subjects.ClearSelected();
                }
            }
        }
 private void button1_Click(object sender, EventArgs e)
 {
     using (schoolEntities contextDB = new schoolEntities())
     {
         MessageBox.Show("Connection established!", "Success!");
     }
 }
 private void PanelDiary_Load(object sender, EventArgs e)
 {
     using (schoolEntities db = new schoolEntities())
     {
         listBox1.Items.AddRange(db.students.Where(c => c.id != -1).ToArray <student>());
     }
 }
 private void PanelAddStudentGroup_Load(object sender, EventArgs e)
 {
     using (schoolEntities db = new schoolEntities())
     {
         listbox_classroom.Items.AddRange(db.classrooms.Where(c => c.id != -1).ToArray <classroom>());
         listbox_classroom_teacher.Items.AddRange(db.teachers.Where(c => c.id != -1).ToArray <teacher>());
         listbox_learning_program.Items.AddRange(db.learning_program.Where(c => c.id != -1).ToArray <learning_program>());
         checkedLilistbox_students.Items.AddRange(db.students.Where(c => c.id != -1).ToArray <student>());
     }
 }
        private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            int keyStudent = ((student)listBox1.SelectedItem).id;

            using (schoolEntities db = new schoolEntities())
            {
                listBox2.Items.Clear();

                listBox2.Items.AddRange(
                    db.lesson_mark
                    .Where(c => c.student_id == keyStudent)
                    .Select(mark => mark.subject.name + " #" + mark.lesson_number + " - " + mark.lesson_mark1)
                    .ToArray()
                    );
            }
        }
        private void button_confirm_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                student_group t = new student_group
                {
                    name       = textbox_group_name.Text,
                    entry_year = int.Parse(textbox_year_of_creation.Text),
                };

                int   keyClassroom = ((classroom)listbox_classroom.SelectedItem).id;
                int   keyTeacher   = ((teacher)listbox_classroom_teacher.SelectedItem).id;
                int   keyLearning  = ((learning_program)listbox_learning_program.SelectedItem).id;
                int[] keys         = checkedLilistbox_students.CheckedItems.Cast <student>().Select(s => s.id).ToArray();


                using (schoolEntities db = new schoolEntities())
                {
                    t.classroom        = db.classrooms.Find(keyClassroom);
                    t.teacher          = db.teachers.Find(keyTeacher);
                    t.learning_program = db.learning_program.Find(keyLearning);
                    db.student_group.Add(t);
                    foreach (var key in keys)
                    {
                        student s = db.students.Find(key);
                        if (s != null)
                        {
                            s.student_group = t;
                        }
                    }
                    db.SaveChanges();
                    MessageBox.Show(string.Format("Student group {0} (Year: {1}) is added!", t.name, t.entry_year), "Success!");

                    this.textbox_group_name.Clear();
                    this.textbox_year_of_creation.Clear();

                    this.listbox_classroom.ClearSelected();
                    this.listbox_classroom_teacher.ClearSelected();
                    this.listbox_learning_program.ClearSelected();

                    this.checkedLilistbox_students.ClearSelected();
                }
            }
        }
Exemplo n.º 9
0
        private void button_confirm_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                subject c = new subject
                {
                    name             = textbox_lesson_name.Text,
                    quantity         = int.Parse(textbox_lesson_quantity.Text),
                    year_of_creation = int.Parse(textbox_year_of_creation.Text)
                };

                using (schoolEntities db = new schoolEntities())
                {
                    db.subjects.Add(c);
                    db.SaveChanges();
                    MessageBox.Show(string.Format("Subject {0} (Y:{2}, Q:{1}) is added!", c.name, c.quantity, c.year_of_creation), "Success!");
                }
                this.textbox_lesson_name.Clear();
                this.textbox_year_of_creation.Clear();
                this.textbox_lesson_quantity.Clear();
            }
        }
Exemplo n.º 10
0
        private void button_confirm_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                object[] keys = new object[4];
                keys[0] = ((object)((lesson_mark)listbox_student.SelectedItem).lesson_timestamp);
                keys[1] = ((object)((lesson_mark)listbox_student.SelectedItem).student_id);
                keys[2] = ((object)((lesson_mark)listbox_student.SelectedItem).subject_id);
                keys[3] = ((object)((lesson_mark)listbox_student.SelectedItem).lesson_number);

                using (schoolEntities db = new schoolEntities())
                {
                    db.lesson_mark.Remove(db.lesson_mark.Find(keys));
                    db.SaveChanges();

                    listbox_student.Items.Clear();
                    listbox_student.Items.AddRange(db.lesson_mark.ToArray());

                    MessageBox.Show(string.Format("Mark is deleted!"), "Success!");
                }
            }
        }
        private void button_confirm_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                classroom c = new classroom
                {
                    primary_num   = int.Parse(textBox1.Text),
                    secondary_num = textBox2.Text,
                    floor         = int.Parse(textBox3.Text)
                };

                using (schoolEntities db = new schoolEntities())
                {
                    db.classrooms.Add(c);
                    db.SaveChanges();
                    MessageBox.Show(string.Format("Classroom {0}-{1} on {2} floor is added!", c.primary_num, c.secondary_num, c.floor), "Success!");
                    textBox1.Clear();
                    textBox2.Clear();
                    textBox3.Clear();
                }
            }
        }
        private void button_confirm_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                student t = new student
                {
                    first_name       = text_box_student_first_name.Text,
                    last_name        = text_box_student_last_name.Text,
                    third_name       = text_box_student_third_name.Text,
                    student_group_id = -1
                };

                using (schoolEntities db = new schoolEntities())
                {
                    db.students.Add(t);
                    db.SaveChanges();
                    MessageBox.Show(string.Format("Student {0} {1} {2} is added!", t.first_name, t.last_name, t.third_name), "Success!");
                    text_box_student_first_name.Clear();
                    text_box_student_last_name.Clear();
                    text_box_student_third_name.Clear();
                }
            }
        }
        private void button_confirm_Click(object sender, EventArgs e)
        {
            if (ValidateChildren(ValidationConstraints.Enabled))
            {
                teacher t = new teacher
                {
                    first_name = text_box_teacher_first_name.Text,
                    last_name  = text_box_teacher_last_name.Text,
                    third_name = text_box_teacher_third_name.Text,
                };



                using (schoolEntities db = new schoolEntities())
                {
                    int[] keys = checkedlistbox_subjects.CheckedItems.Cast <subject>().Select(s => s.id).ToArray();
                    foreach (var key in keys)
                    {
                        subject s = db.subjects.Find(key);
                        if (s != null)
                        {
                            s.teachers.Add(t);
                            t.subjects.Add(s);
                        }
                    }

                    db.teachers.Add(t);
                    db.SaveChanges();
                    MessageBox.Show(string.Format("Teacher {0} {1} {2} is added!", t.first_name, t.last_name, t.third_name), "Success!");
                }
                text_box_teacher_first_name.Clear();
                text_box_teacher_last_name.Clear();
                text_box_teacher_third_name.Clear();
                checkedlistbox_subjects.ClearSelected();
            }
        }