Пример #1
0
 private void ButtonDeleteClassSubject_Click(object sender, EventArgs e)
 {
     if (TableClasses.SelectedRows.Count != 0)
     {
         if (TableSubjects.SelectedRows.Count != 0)
         {
             if (MessageBox.Show("Вы уверены, что хотите удалить выбранный предмет из этого класса?", "Удаление выбраного предмета из класса", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No)
             {
             }
             else
             {
                 DBControl.Delete(Class_Subject.GetObj(Class.Classes[(Guid)TableClasses.SelectedCells[0].Value], Subject.Subjects[(Guid)TableSubjects.SelectedCells[0].Value]));
                 TableSubjects.Rows.Remove(TableSubjects.SelectedRows[0]);
                 TableSubjects.ClearSelection();
             }
         }
         else
         {
             MessageBox.Show("Для удаления предмета, выбирете его из таблицы", "Не выбран предмет для удаления", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Для удаления предмета, выбирете класс из таблицы", "Не выбран класс для удаления предмета", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #2
0
 private void ButtonAddSubjectTeacher_Click(object sender, EventArgs e)
 {
     if (TableClasses.SelectedRows.Count != 0)
     {
         if (TableSubjects.SelectedRows.Count != 0)
         {
             FormList formlist = new FormList(Class_Subject.GetObj(Class.Classes[(Guid)TableClasses.SelectedCells[0].Value], Subject.Subjects[(Guid)TableSubjects.SelectedCells[0].Value]));
             if (formlist.ShowDialog() == DialogResult.OK)
             {
                 if (formlist.Table.SelectedRows.Count == 0)
                 {
                     MessageBox.Show("Для добавления предмета, выбирете его", "Вы не выбрали предмет", MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
                 else
                 {
                     foreach (DataGridViewRow row in formlist.Table.SelectedRows)
                     {
                         DBControl.Add(Class_Subject.GetObj(Class.Classes[(Guid)TableClasses.SelectedCells[0].Value], Subject.Subjects[(Guid)TableSubjects.SelectedCells[0].Value]), Teacher.Teachers[(Guid)row.Cells[0].Value]);
                         TableTeachers.Rows.Add(row.Cells[0].Value, row.Cells[1].Value, Teacher.Teachers[(Guid)row.Cells[0].Value].Login, Teacher.Teachers[(Guid)row.Cells[0].Value].GetPassword(row.Cells[0].Value.ToString()));
                     }
                     TableTeachers.ClearSelection();
                 }
             }
             formlist.Close();
         }
         else
         {
             MessageBox.Show("Для добавления учителя предмету, выбирете предмет из таблицы", "Не выбран предмет для добавления учителя предмету", MessageBoxButtons.OK, MessageBoxIcon.Error);
         }
     }
     else
     {
         MessageBox.Show("Для добавления учителя предмету, выбирете класс из таблицы", "Не выбран класс для добавления учителя предмету", MessageBoxButtons.OK, MessageBoxIcon.Error);
     }
 }
Пример #3
0
        public FormList(Class_Subject class_subject)
        {
            InitializeComponent();
            rect          = new Rectangle(0, 0, Size.Width - 1, Size.Height - 1);
            gr            = CreateGraphics();
            Class_subject = class_subject;
            foreach (var tchr in Teacher.Teachers.Values)
            {
                Table.Rows.Add(tchr.Id, tchr.Name);
            }
            List <DataGridViewRow> extraRows = new List <DataGridViewRow>();

            foreach (DataGridViewRow row in Table.Rows)
            {
                foreach (var tchr in Class_subject.Teachers)
                {
                    if ((Guid)row.Cells[0].Value == tchr.Id)
                    {
                        extraRows.Add(row);
                    }
                }
            }
            foreach (var rw in extraRows)
            {
                Table.Rows.Remove(rw);
            }
            ColumnName.HeaderText = "Ф.И.О.";
            LabelChoose.Text     += string.Format("учителя предмета \"{0}\" в классе {1}", Class_subject.Subject.Name, Class_subject.Class.Name);
        }
Пример #4
0
        public static void Add(Class_Subject class_subject, Teacher teacher)      //Add Class_Subject_Teacher
        {
            Class_Subject_Teacher NewClass_Subject_Teacher = new Class_Subject_Teacher()
            {
                Class_Subject = class_subject, Teacher = teacher
            };

            Class_Subject_Teacher.Classes_Subjects_Teachers.Add(NewClass_Subject_Teacher.Id, NewClass_Subject_Teacher);
            command.CommandText = string.Format("INSERT INTO Classes_Subjects_Teachers VALUES ('{0}', '{1}', '{2}')", NewClass_Subject_Teacher.Id, NewClass_Subject_Teacher.Class_Subject.Id, NewClass_Subject_Teacher.Teacher.Id);
            command.ExecuteNonQuery();
        }
Пример #5
0
        public static void Add(Class _class, Subject subject)      //Add Class_Subject
        {
            Class_Subject NewClass_Subject = new Class_Subject()
            {
                Class = _class, Subject = subject
            };

            Class_Subject.Classes_Subjects.Add(NewClass_Subject.Id, NewClass_Subject);
            command.CommandText = string.Format("INSERT INTO Classes_Subjects VALUES ('{0}', '{1}', '{2}')", NewClass_Subject.Id, NewClass_Subject.Class.Id, NewClass_Subject.Subject.Id);
            command.ExecuteNonQuery();
        }
Пример #6
0
 private void TableSubjects_SelectionChanged(object sender, EventArgs e)
 {
     TableTeachers.Rows.Clear();
     if (TableSubjects.SelectedRows.Count != 0 && TableClasses.SelectedRows.Count != 0)
     {
         foreach (var tchr in Class_Subject.GetObj(Class.Classes[(Guid)TableClasses.SelectedCells[0].Value], Subject.Subjects[(Guid)TableSubjects.SelectedCells[0].Value]).Teachers)
         {
             TableTeachers.Rows.Add(tchr.Id, tchr.Name, tchr.Login, tchr.GetPassword(tchr.Id.ToString()));
         }
         TableTeachers.ClearSelection();
     }
 }
Пример #7
0
        public static Class_Subject GetObj(Class clss, Subject sbjct)
        {
            Class_Subject obj = null;

            foreach (var clss_sbjct in Classes_Subjects.Values)
            {
                if (clss_sbjct.Class.Id == clss.Id && clss_sbjct.Subject.Id == sbjct.Id)
                {
                    obj = clss_sbjct;
                }
            }
            return(obj);
        }
Пример #8
0
 public static void Delete(Class_Subject DeletedClass_Subject)        //Delete Class_Subject
 {
     command.CommandText = string.Format("DELETE FROM Classes_Subjects WHERE Id = '{0}'", DeletedClass_Subject.Id);
     command.ExecuteNonQuery();
     foreach (var clss_sbjct_tchr in Class_Subject_Teacher.Classes_Subjects_Teachers.Values)
     {
         if (clss_sbjct_tchr.Class_Subject.Id == DeletedClass_Subject.Id)
         {
             Delete(clss_sbjct_tchr);
         }
     }
     Class_Subject.Classes_Subjects.Remove(DeletedClass_Subject.Id);
 }
Пример #9
0
        public static Class_Subject_Teacher GetObj(Class_Subject clss_sbjct, Teacher tchr)
        {
            Class_Subject_Teacher obj = null;

            foreach (var clss_sbjct_tchr in Classes_Subjects_Teachers.Values)
            {
                if (clss_sbjct_tchr.Class_Subject.Id == clss_sbjct.Id && clss_sbjct_tchr.Teacher.Id == tchr.Id)
                {
                    obj = clss_sbjct_tchr;
                }
            }
            return(obj);
        }
Пример #10
0
        public static void Load()
        {
            //Load Cities

            command.CommandText = "SELECT * FROM Cities";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    City obj = new City(reader["Name"].ToString(), (Guid)reader["Id"]);
                    City.Cities.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Schools

            command.CommandText = "SELECT * FROM Schools";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    School obj = new School(reader["Name"].ToString(), (Guid)reader["Id"])
                    {
                        City = City.Cities[(Guid)reader["City_id"]]
                    };
                    School.Schools.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Managers

            command.CommandText = "SELECT * FROM Managers";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Manager obj = new Manager(reader["FullName"].ToString(), reader["Login"].ToString(), reader["Password"].ToString(), (Guid)reader["Id"])
                    {
                        School = School.Schools[(Guid)reader["School_id"]]
                    };
                    Manager.Managers.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Classes

            command.CommandText = "SELECT * FROM Classes";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Class obj = new Class(reader["Name"].ToString(), (Guid)reader["Id"])
                    {
                        School = School.Schools[(Guid)reader["School_id"]]
                    };
                    Class.Classes.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Students

            command.CommandText = "SELECT * FROM Students";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Student obj = new Student(reader["FullName"].ToString(), reader["Login"].ToString(), reader["Password"].ToString(), (Guid)reader["Id"])
                    {
                        Class = Class.Classes[(Guid)reader["Class_id"]]
                    };
                    Student.Students.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Subjects

            command.CommandText = "SELECT * FROM Subjects";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Subject obj = new Subject(reader["Name"].ToString(), (Guid)reader["Id"]);
                    Subject.Subjects.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Marks

            command.CommandText = "SELECT * FROM Marks";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Mark obj = new Mark(Convert.ToInt32(reader["Value"]), reader["Name"].ToString(), (Guid)reader["Id"])
                    {
                        Student = Student.Students[(Guid)reader["Student_id"]], Subject = Subject.Subjects[(Guid)reader["Subject_id"]]
                    };
                    Mark.Marks.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Classes_Subjects

            command.CommandText = "SELECT * FROM Classes_Subjects";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Class_Subject obj = new Class_Subject((Guid)reader["Id"])
                    {
                        Class = Class.Classes[(Guid)reader["Class_id"]], Subject = Subject.Subjects[(Guid)reader["Subject_id"]]
                    };
                    Class_Subject.Classes_Subjects.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Teachers

            command.CommandText = "SELECT * FROM Teachers";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Teacher obj = new Teacher(reader["FullName"].ToString(), reader["Login"].ToString(), reader["Password"].ToString(), (Guid)reader["Id"])
                    {
                        School = School.Schools[(Guid)reader["School_id"]]
                    };
                    Teacher.Teachers.Add(obj.Id, obj);
                }
            }
            reader.Close();


            //Load Classes_Subjects_Teachers

            command.CommandText = "SELECT * FROM Classes_Subjects_Teachers";
            reader = command.ExecuteReader();
            if (reader.HasRows)
            {
                while (reader.Read())
                {
                    Class_Subject_Teacher obj = new Class_Subject_Teacher((Guid)reader["Id"])
                    {
                        Class_Subject = Class_Subject.Classes_Subjects[(Guid)reader["Class_Subject_id"]], Teacher = Teacher.Teachers[(Guid)reader["Teacher_id"]]
                    };
                    Class_Subject_Teacher.Classes_Subjects_Teachers.Add(obj.Id, obj);
                }
            }
            reader.Close();
        }