Exemplo n.º 1
0
            public static void Discipline(string str, TeacherInfo teacher)
            {
                var disp = Db.Disciplines.AddDisciplinesRow(str);

                Db.AcceptChanges();
                var temp = Db.DiscipTeachers.NewDiscipTeachersRow();

                temp.ID_Teacher    = teacher.ID_Teacher;
                temp.ID_Discipline = disp.ID_Discipline;
                Db.DiscipTeachers.AddDiscipTeachersRow(temp);
                Db.AcceptChanges();
            }
Exemplo n.º 2
0
        public static DisciplineInfo[] GetDisciplinesFromTwoTeacher(TeacherInfo teacher1, TeacherInfo teacher2)
        {
            if (teacher1 == null)
            {
                return(null);
            }
            var disp1 = (Db.DiscipTeachers.Where(d => d.ID_Teacher == teacher1.ID_Teacher)
                         .Select(d => new DisciplineInfo(d.DisciplinesRow))).ToArray();

            if (teacher2 == null)
            {
                return(null);
            }
            var disp2 = (Db.DiscipTeachers.Where(d => d.ID_Teacher == teacher2.ID_Teacher)
                         .Select(d => new DisciplineInfo(d.DisciplinesRow))).ToArray();

            return(disp1.Intersect(disp2, new MyDisciplineComparer()).ToArray());
        }
        public AddParaTeacher(
			TeacherInfo teacherInfo, IEnumerable<ScheduleInfo> scheduleInfos, int para, int dayWeek, int idPeriod, string text, bool edit)
        {
            InitializeComponent();
            Text = text;
            IDTeacher = teacherInfo.ID_Teacher;
            Para = para;
            DayWeek = dayWeek;
            IDPeriod = idPeriod;
            if (IDPeriod != 1 && IDPeriod != 2)
            {
                checkBox2.Visible = false;
                Size = new Size(431, 238);
            }
            Sched = edit ? new List<ScheduleInfo>(scheduleInfos) : new List<ScheduleInfo>();
            if (edit)
            {
                var locAll = Model.GetAll.Location();
                var dispAll = Model.GetDisciplinesFromTeacher(teacherInfo);
                var facAll = Model.GetAll.Fuculty();
                var loc = (from a in locAll
                                     where a.ID_Location == Sched.First().ID_Location
                                     select a).Single();
                var disp = (from a in dispAll
                                        where a.ID_Discipline == Sched.First().ID_Discipline
                                        select a).Single();
                var fac = (from a in facAll
                                     where a.ID_Faculty == Sched.First().ID_Faculty
                                     select a).Single();
                Location.Items.AddRange(locAll);
                Location.SelectedItem = loc;
                Disp.Items.AddRange(dispAll);
                Disp.SelectedItem = disp;
                Faculty.Items.AddRange(facAll);
                Faculty.SelectedItem = fac;
                var auAll = Model.GetAuditoriumsFromLocation(loc);
                var au = (from a in auAll
                                    where a.ID_Auditorium == Sched.First().ID_Auditorium
                                    select a).Single();
                Aud.Items.Clear();
                Aud.Items.AddRange(auAll);
                Aud.Enabled = true;
                Aud.SelectedItem = au;
                try
                {
                    var temp = Sched.First().GroupName.Substring(Sched.First().GroupName.Length - 2, 1);
                    Curs.SelectedIndex = Convert.ToInt32(temp) - 1;
                }
                catch (Exception)
                {
                }

                for (int i = 0; i < List.Items.Count; i++)
                    foreach (var list in Sched)
                        if (((GroupInfo)List.Items[i]).ID_Group == list.ID_Group)
                            List.SetItemChecked(i, true);
            }
            else
            {
                var loc = Model.GetAll.Location();
                Location.Items.AddRange(loc);
                if (loc.Count() == 1)
                    Location.SelectedIndex = 0;
                var disp = Model.GetDisciplinesFromTeacher(teacherInfo);
                Disp.Items.AddRange(disp);
                if (disp.Count() == 1)
                    Disp.SelectedIndex = 0;
                var fac = Model.GetAll.Fuculty();
                Faculty.Items.AddRange(fac);
                if (fac.Count() == 1)
                    Faculty.SelectedIndex = 0;
            }
        }
        public AddParaTeacher(
            TeacherInfo teacherInfo, IEnumerable <ScheduleInfo> scheduleInfos, int para, int dayWeek, int idPeriod, string text, bool edit)
        {
            InitializeComponent();
            Text      = text;
            IDTeacher = teacherInfo.ID_Teacher;
            Para      = para;
            DayWeek   = dayWeek;
            IDPeriod  = idPeriod;
            if (IDPeriod != 1 && IDPeriod != 2)
            {
                checkBox2.Visible = false;
                Size = new Size(431, 238);
            }
            Sched = edit ? new List <ScheduleInfo>(scheduleInfos) : new List <ScheduleInfo>();
            if (edit)
            {
                var locAll  = Model.GetAll.Location();
                var dispAll = Model.GetDisciplinesFromTeacher(teacherInfo);
                var facAll  = Model.GetAll.Fuculty();
                var loc     = (from a in locAll
                               where a.ID_Location == Sched.First().ID_Location
                               select a).Single();
                var disp = (from a in dispAll
                            where a.ID_Discipline == Sched.First().ID_Discipline
                            select a).Single();
                var fac = (from a in facAll
                           where a.ID_Faculty == Sched.First().ID_Faculty
                           select a).Single();
                Location.Items.AddRange(locAll);
                Location.SelectedItem = loc;
                Disp.Items.AddRange(dispAll);
                Disp.SelectedItem = disp;
                Faculty.Items.AddRange(facAll);
                Faculty.SelectedItem = fac;
                var auAll = Model.GetAuditoriumsFromLocation(loc);
                var au    = (from a in auAll
                             where a.ID_Auditorium == Sched.First().ID_Auditorium
                             select a).Single();
                Aud.Items.Clear();
                Aud.Items.AddRange(auAll);
                Aud.Enabled      = true;
                Aud.SelectedItem = au;
                try
                {
                    var temp = Sched.First().GroupName.Substring(Sched.First().GroupName.Length - 2, 1);
                    Curs.SelectedIndex = Convert.ToInt32(temp) - 1;
                }
                catch (Exception)
                {
                }

                for (int i = 0; i < List.Items.Count; i++)
                {
                    foreach (var list in Sched)
                    {
                        if (((GroupInfo)List.Items[i]).ID_Group == list.ID_Group)
                        {
                            List.SetItemChecked(i, true);
                        }
                    }
                }
            }
            else
            {
                var loc = Model.GetAll.Location();
                Location.Items.AddRange(loc);
                if (loc.Count() == 1)
                {
                    Location.SelectedIndex = 0;
                }
                var disp = Model.GetDisciplinesFromTeacher(teacherInfo);
                Disp.Items.AddRange(disp);
                if (disp.Count() == 1)
                {
                    Disp.SelectedIndex = 0;
                }
                var fac = Model.GetAll.Fuculty();
                Faculty.Items.AddRange(fac);
                if (fac.Count() == 1)
                {
                    Faculty.SelectedIndex = 0;
                }
            }
        }