예제 #1
0
        private void GenerateInitialStateProfessorsTimetable()
        {
            TimetableDataContext context = new TimetableDataContext();

            IEnumerable <Professor> profs = from p in context.Professors
                                            select p;

            foreach (var prof in profs)
            {
                ProfessorTimetable pt = new ProfessorTimetable();
                pt.NumeProfesor = prof.Name;
                pt.Clasa        = new List <string>();
                pt.Zi           = new List <string>();
                pt.Modul        = new List <int>();
                pt.OraCurs      = new List <string>();
                pt.Grupa        = new List <string>();

                orarFinalProfessori.Add(pt);
            }
        }
예제 #2
0
        //Creem orarul
        private bool CheckProfessorsSync(string clasa, string zi, int modul, string oraCurs, string grupa, string profName)
        {
            ProfessorTimetable pt = null;

            foreach (var item in orarFinalProfessori)
            {
                if (item.NumeProfesor == profName)
                {
                    pt = item;
                    break;
                }
            }

            bool checkOcupat = false;

            for (int i = 0; i < pt.Zi.Count(); i++)
            {
                if (zi == pt.Zi[i] && modul == pt.Modul[i])
                {
                    checkOcupat = true;
                    break;
                }
            }
            if (checkOcupat == true)
            {
                return(true);
            }

            pt.Clasa.Add(clasa);
            pt.Zi.Add(zi);
            pt.Modul.Add(modul);
            pt.OraCurs.Add(oraCurs);
            pt.Grupa.Add(grupa);

            return(true);
        }
        private void cbox_Professors_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cbox_Professors.SelectedIndex == -1)
            {
                return;
            }

            lview_Orar.Items.Clear();


            ProfessorTimetable pt = new ProfessorTimetable();

            foreach (var item in orarFinalProfessori)
            {
                if (item.NumeProfesor == cbox_Professors.Text)
                {
                    pt = item;
                    break;
                }
            }

            string[] rowLuni     = { "Luni", "", "", "", "", "" };
            string[] rowMarti    = { "Marti", "", "", "", "", "" };
            string[] rowMiercuri = { "Miercuri", "", "", "", "", "" };
            string[] rowJoi      = { "Joi", "", "", "", "", "" };
            string[] rowVineri   = { "Vineri", "", "", "", "", "" };

            List <ListViewItem> items = new List <ListViewItem>();

            for (int i = 0; i < pt.Zi.Count(); i++)
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(pt.OraCurs[i][0]);
                sb.Append(pt.OraCurs[i][1]);

                if (pt.Zi[i] == "luni")
                {
                    rowLuni[pt.Modul[i] + 1] = sb.ToString() + ". : " + pt.Clasa[i] + " : " + pt.Grupa[i];
                }
                else if (pt.Zi[i] == "marti")
                {
                    rowMarti[pt.Modul[i] + 1] = sb.ToString() + ". : " + pt.Clasa[i] + " : " + pt.Grupa[i];
                }
                else if (pt.Zi[i] == "miercuri")
                {
                    rowMiercuri[pt.Modul[i] + 1] = sb.ToString() + ". : " + pt.Clasa[i] + " : " + pt.Grupa[i];
                }
                else if (pt.Zi[i] == "joi")
                {
                    rowJoi[pt.Modul[i] + 1] = sb.ToString() + ". : " + pt.Clasa[i] + " : " + pt.Grupa[i];
                }
                else if (pt.Zi[i] == "vineri")
                {
                    rowVineri[pt.Modul[i] + 1] = sb.ToString() + ". : " + pt.Clasa[i] + " : " + pt.Grupa[i];
                }
            }

            items.Add(new ListViewItem(rowLuni));
            items.Add(new ListViewItem(rowMarti));
            items.Add(new ListViewItem(rowMiercuri));
            items.Add(new ListViewItem(rowJoi));
            items.Add(new ListViewItem(rowVineri));

            foreach (var item in items)
            {
                lview_Orar.Items.Add(item);
            }
        }