public async Task <IActionResult> Edit(int id, [Bind("SemestrId,KursId,SemestrNameId")] Semestr semestr, int KursId)
        {
            if (id != semestr.SemestrId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(semestr);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SemestrExists(semestr.SemestrId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index), new { KursId }));
            }

            ViewData["SemestrNameId"] = new SelectList(_context.Set <SemestrName>(), "SemestrNameId", "SemestrNameId", semestr.SemestrNameId);
            return(View(semestr));
        }
        private void AddSemesterNameCommand(object parameter)
        {
            AddSemesterName frm          = new AddSemesterName();
            Nullable <bool> dialogResult = frm.ShowDialog();

            SemesterName = Semestr.GetSemestersNames();
        }
Example #3
0
        private void RegisterSemester(object parameter)
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            Guid idSemestr   = Semestr.FindSemestrIdByName(_selectedSemester);
            Guid idPrzedmiot = Przedmiot.FindPrzedmiotIdByFullName(_selectedPrzedmiot);

            if (!Semestr.CheckSemestrExistInGroup(CurrentGroupId, idSemestr))
            {
                var grupaSemestrPrzedmiot = new GrupaSemestrPrzedmiot
                {
                    Id_Grupa     = CurrentGroupId,
                    Id_Przedmiot = idPrzedmiot,
                    Id_Semestr   = idSemestr
                };

                context.GrupaSemestrPrzedmiots.InsertOnSubmit(grupaSemestrPrzedmiot);
                context.SubmitChanges();
            }
            else
            {
                MessageBox.Show("Semestr jest już wpisany", "Uwaga", MessageBoxButton.OK, MessageBoxImage.Error);
            }

            Window frm = (Window)parameter;

            frm.Close();
        }
Example #4
0
        public IActionResult GetWpisNaSem(string indexNumber)
        {
            using (SqlConnection con = new SqlConnection(ConString))
                using (SqlCommand com = new SqlCommand())
                {
                    com.Connection  = con;
                    com.CommandText = $"select Name,Semestr,StartDate from Student inner join Enrollment on Student.IdEnrollment=Enrollment.IdEnrollment inner join Studies on Enrollment.IdStudy=Studies.IdStudy where indexnumber = @index ";

                    com.Parameters.AddWithValue("index", indexNumber);
                    con.Open();
                    var dr = com.ExecuteReader();
                    if (dr.Read())
                    {
                        var sem = new Semestr();

                        sem.Name      = dr["IndexNumber"].ToString();
                        sem.Semester  = Int32.Parse("Semester");
                        sem.StartDate = DateTime.Parse("StartDate");
                        return(Ok(sem));
                    }
                }


            return(NotFound());
        }
Example #5
0
        public RegistrationSemesterVM(Guid idGrupa)
        {
            _groupId = idGrupa;
            ExecuteAddSemesterCommand     = new Commanding(RegisterSemester, CanRegisterSemester);
            ExecuteAddSemesterNameCommand = new Commanding(AddSemesterName, CanAddSemesterName);
            ExecuteAddPrzedmiotName       = new Commanding(AddPrzedmiot, CanAddPrzedmiotName);

            SemesterName  = Semestr.GetSemestersNames();
            PrzedmiotName = Przedmiot.GetPrzedmiots();
        }
Example #6
0
        public ActionResult Create(Semestr semestr)
        {
            if (ModelState.IsValid)
            {
                semestr.ID = Guid.NewGuid();
                db.Semestrs.Add(semestr);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(semestr);
        }
Example #7
0
 public FormSelectCourseInWork(Database AmyDatabase, Employee filterEmployee, Group filterGroup,
                               Semestr filterSemestr, SchoolYear filterSchoolYear, WorkloadType filterWorkloadType,
                               CourseInWork exceptCourseInWork)
 {
     InitializeComponent();
     myDatabase          = AmyDatabase;
     _filterEmployee     = filterEmployee;
     _filterGroup        = filterGroup;
     _filterSemestr      = filterSemestr;
     _filterSchoolYear   = filterSchoolYear;
     _filterWorkloadType = filterWorkloadType;
     _exceptCourseInWork = exceptCourseInWork;
 }
        public RegistrationGroupVM(Guid studentId)
        {
            _studentId = studentId;
            ExecuteAddKierunekCommand = new Commanding(AddKierunekCiagGroupCommand, CanAddKierunekCiagGroupCommand);
            ExecuteAddKierunek        = new Commanding(AddKierunekCommand, CanAddKierunekCommand);
            ExecuteAddCiag            = new Commanding(AddCiagCommand, CanAddCiagCommand);
            ExecuteAddGroup           = new Commanding(AddGroupCommand, CanAddGroupCommand);

            SemesterName = Semestr.GetSemestersNames();
            KierunekName = Kierunek.GetKieruneks();
            CiagName     = Ciag.GetCiags();
            GroupName    = Grupa.GetGrupas();
        }
        public async Task <IActionResult> Create([Bind("SemestrId,KursId,SemestrNameId")] Semestr semestr, int?KursId)
        {
            if (ModelState.IsValid)
            {
                _context.Add(semestr);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index), new { KursId }));
            }

            ViewBag.KursId            = KursId;
            ViewData["SemestrNameId"] = new SelectList(_context.SemestrNames, "SemestrNameId", "SemestrNameNumber", semestr.SemestrNameId);
            return(View(semestr));
        }
Example #10
0
        private void AddSemestrNameCommand(object parameter)
        {
            DataClasses1DataContext context = new DataClasses1DataContext();
            var semestr = new Semestr
            {
                Semestr_Nazwa = _semestrName
            };

            context.Semestrs.InsertOnSubmit(semestr);
            context.SubmitChanges();

            Window frm = (Window)parameter;

            frm.Close();
        }
Example #11
0
        private void dodaj_przedmiot()
        {
            DataClasses1DataContext context = new DataClasses1DataContext();

            Guid      idWykladowcy     = Wykladowca.FindWykladowcaIdByName(_selectedWykladowca);
            Guid      idTyp            = Typ_Zajec.FindZajeciasIdByName(_selectedTyp);
            Guid      PrzedmiotNazwaId = Przedmiot.FindPrzedmiotNazwaIdByNazwa(_selectedPrzedmiot);
            Przedmiot przedmiotExist   = Przedmiot.CheckPrzedmiotExist(idTyp, idWykladowcy, PrzedmiotNazwaId);

            if (przedmiotExist == null)
            {
                var newPrzedmiot = new Przedmiot
                {
                    Id_PrzedmiotNazwa = PrzedmiotNazwaId,
                    Id_Typ_Zajec      = idTyp,
                    PunktyETCS        = Convert.ToInt32(_punktyETCS),
                    Godziny           = Convert.ToInt32(_liczbaGodzin),
                    Id_Wykladowcy     = idWykladowcy
                };
                przedmiotExist = newPrzedmiot;
                context.Przedmiots.InsertOnSubmit(przedmiotExist);
                context.SubmitChanges();
            }

            if (!Semestr.CheckPrzedmiotExistInSemester(_idSemestr, _idGrupa, przedmiotExist.Id_Przedmiot))
            {
                var grupaPrzedmiotSemestr = new GrupaSemestrPrzedmiot
                {
                    Id_Grupa     = _idGrupa,
                    Id_Semestr   = _idSemestr,
                    Id_Przedmiot = przedmiotExist.Id_Przedmiot
                };
                context.GrupaSemestrPrzedmiots.InsertOnSubmit(grupaPrzedmiotSemestr);
                context.SubmitChanges();
            }
            else
            {
                MessageBox.Show("Przedmiot jest już na liście", "Uwaga", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Example #12
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            SchoolYear sy      = (SchoolYear)schoolYearBindingSource.Current;
            Semestr    semestr = (Semestr)semestrBindingSource.Current;

            List <string> ls = new List <string>();

            var q = myDatabase.CourseInWork
                    .Where(cif =>
                           cif.SchoolYear.ID == sy.ID &&
                           cif.Semestr == semestr.ID &&
                           // &&
                           cif.DocumentId == (int)comboBox1.SelectedValue)
                    .OrderBy(cif => cif.Course.ID)
                    .ThenBy(cif => cif.ID)
                    .AsQueryable();

            if (!radioButtonEvening.Checked)
            {
                q = q.Where(cif => cif.FormStudy == radioButtonOchniki.Checked && !cif.GroupInCourse.Any(gic => gic.GroupInSemestr.Group.Group1.Contains("В") || gic.GroupInSemestr.Group.Group1.Contains("B")));
            }
            else
            {
                q = q.Where(cif => cif.GroupInCourse.Any(gic => gic.GroupInSemestr.Group.Group1.Contains("В") || gic.GroupInSemestr.Group.Group1.Contains("B")));
            }

            var form = radioButtonEvening.Checked ? "вечерников" : radioButtonOchniki.Checked ? "очников" : "заочников";
            var step = comboBox1.Text.Contains("магистр") ? "магистрантов" : "бакалавров";


            ls.Add("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
            ls.Add("<html>");
            ls.Add(" <head>");
            ls.Add("  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">");
            ls.Add("  <title>Распределение учебной нагрузки</title>");
            ls.Add(" </head>");
            ls.Add(" <body>");
            ls.Add("<p align=\"center\">Для составления расписания занятий со студентами представить в учебный отдел к _______________ 20 __ г.</p>");
            ls.Add("<p align=\"right\"><b>Кафедра АСУ</b></p>");
            ls.Add("<h1 align=\"center\">РАСПРЕДЕЛЕНИЕ</h1>");
            string s = String.Format("учебной нагрузки для {0} {1} на {2} семестр {3} учебного года",
                                     step,
                                     form, semestr.Name.ToLower(), sy.Years);

            ls.Add("<p align=\"center\">" + s + "</p>");
            ls.Add("<table border=\"1\">");
            ls.Add("<thead>");
            ls.Add("<tr>");
            ls.Add("<td><b>Дисциплина</b></td>");
            ls.Add("<td><b>Вид занятий</b></td>");
            ls.Add("<td><b>Номера учебных групп</b></td>");
            ls.Add("<td><b>Ученое звание, должность, фамилия и инициалы преподавателя</b></td>");
            ls.Add("<td><b>Номера лабораторий</b></td>");
            ls.Add("<td><b>Примечание</b></td>");
            ls.Add("</tr>");
            ls.Add("<tr>");
            ls.Add("<td align=\"center\">1</td>");
            ls.Add("<td align=\"center\">2</td>");
            ls.Add("<td align=\"center\">3</td>");
            ls.Add("<td align=\"center\">4</td>");
            ls.Add("<td align=\"center\">5</td>");
            ls.Add("<td align=\"center\">6</td>");
            ls.Add("</tr>");
            ls.Add("</thead>");
            ls.Add("<tbody>");
            int counter = 1;

            foreach (CourseInWork cif in q)
            {
                int rowspan = cif.LoadInCoursePlan.Count(p => p.SortLoad.IsClass);
                if (rowspan > 0)
                {
                    string rs = "";

                    rs += "<tr id=\"datarow\">";

                    rs += String.Format("<td rowspan=\"{0}\">{1}</td>", rowspan, counter++ + ". " + cif.Course.Name);

                    bool isfirstline = true;
                    foreach (var licp in cif.LoadInCoursePlan.Where(p => p.SortLoad.IsClass))
                    {
                        if (!isfirstline)
                        {
                            rs += "</tr>";
                        }
                        else
                        {
                            isfirstline = false;
                        }

                        rs += "<td>" + licp.SortLoad.ShortName + "</td>";
                        rs += "<td>" + cif.Groups + "</td>";

                        string emps = "";
                        foreach (LoadInCourseFact licf in licp.LoadInCourseFact)
                        {
                            if (!String.IsNullOrEmpty(emps))
                            {
                                emps += ", ";
                            }
                            emps += licf.Employee.ShortName;
                        }
                        rs += "<td>" + emps + "</td>";
                        rs += "<td>" + licp.LoadInCourseFact.FirstOrDefault()?.ClassRoom?.Number ?? "" + "</td>";
                        rs += "<td></td>";
                        rs += "</tr>";
                    }
                    ls.Add(rs);
                }
            }

            ls.Add("</tbody>");
            ls.Add("</table>");
            ls.Add(" </body>");
            ls.Add("</html>");

            var fileName = $"Shedule_{sy.Years.Replace('/', '_')}_{step}_{form}.html";

            File.WriteAllLines(fileName, ls.ToArray(), Encoding.GetEncoding(1251));
            Process.Start(fileName);
        }
Example #13
0
        public ActionResult Import(HttpPostedFileBase fileExcel, int semCount, List <EmpAndHours> Itemlist)
        {
            using (XLWorkbook workbook = new XLWorkbook(fileExcel.InputStream, XLEventTracking.Disabled))
            {
                List <String>      Errors      = new List <string>();
                List <EmpAndHours> empAndHours = new List <EmpAndHours>();
                IXLWorksheet       worksheet   = workbook.Worksheet("План");
                int count = 0;

                int semestrCount  = worksheet.Row(2).CellsUsed().Count();
                int VidyControlya = 6;
                Dictionary <String, List <Semestr> > Subject = new Dictionary <string, List <Semestr> >();
                int startPosition = 15;
                foreach (IXLRow row in worksheet.RowsUsed())
                {
                    if (row.Cell("BL").Value.ToString().Contains("0605"))
                    {
                        count++;
                        List <Semestr> Clocks  = new List <Semestr>();
                        String         SubName = row.Cell(3).Value.ToString();
                        Semestr        semestr = new Semestr();
                        semestr.Clock = new float[6];
                        for (int i = 0; i < semestrCount * VidyControlya; i++)
                        {
                            if (!row.Cell(i + startPosition).IsEmpty())
                            {
                                semestr.number = i / 6 + 1;
                                while (semestr.number == i / 6 + 1)
                                {
                                    String temp = row.Cell(i + startPosition).Value.ToString();
                                    if (temp == "")
                                    {
                                        semestr.Clock[i % 6] = 0;
                                    }
                                    else
                                    {
                                        semestr.Clock[i % 6] = float.Parse(temp, CultureInfo.InvariantCulture);
                                    }
                                    i++;
                                }
                                i--;
                                Clocks.Add(semestr);
                                semestr       = new Semestr();
                                semestr.Clock = new float[6];
                            }
                        }
                        Subject.Add(SubName, Clocks);
                    }

                    /*foreach(var item in Subject)
                     * {
                     *  item.
                     * }*/
                }

                /*foreach(var item in Subject)
                 * {
                 *  var temp = db.Subjects.Where(x => x.Name == item.Key).SingleOrDefault();
                 *  if (temp == null)
                 *  {
                 *      Subjects subjects = new Subjects();
                 *      subjects.Name = item.Key;
                 *      subjects.ID_employee = new Random().Next(1, 6);
                 *      subjects.Coef = Convert.ToSingle(Math.Round( new Random().NextDouble() * (1-0.1)+0.1, 1));
                 *      //int Last_ID - db.Subjects.Select(e=>e.ID).OrderByDescending(i)
                 *      try
                 *      {
                 *          db.Subjects.Add(subjects);
                 *          db.SaveChanges();
                 *          ViewBag.Subjects += subjects;
                 *      }
                 *      catch(Exception)
                 *      {
                 *
                 *      }
                 *
                 *  }
                 *
                 * }*/
                foreach (var item in Subject)
                {
                    List <Subjects> employes4thissub = new List <Subjects>();

                    employes4thissub = db.Subjects.Where(n => n.Name == item.Key).OrderByDescending(z => z.Coef).ToList();

                    if (employes4thissub.Count != 0)
                    {
                        float timeForLect  = 0;
                        int   countWorkers = 0;
                        int   timeForLab   = 0;
                        int   timeForPract = 0;
                        foreach (var sem in item.Value)
                        {
                            timeForLect += sem.Clock[1];
                        }
                        foreach (var sem in item.Value)
                        {
                            timeForPract += (int)sem.Clock[3];
                        }
                        foreach (var sem in item.Value)
                        {
                            timeForLab += (int)sem.Clock[2];
                        }
                        timeForLab *= semCount;
                        foreach (var employee in employes4thissub)
                        {
                            countWorkers++;
                            Employee    employee1      = employee.Employee;
                            EmpAndHours empAndHoursRes = new EmpAndHours();
                            Employee    Employee123    = db.Employees.Where(e => e.ID == employee.ID_employee).Where(m => (m.Position == "Профессор" || m.Position == "Доцент") && m.WorkingTime > 0).SingleOrDefault();
                            //Single.TryParse(Employee.ToString(), out time);



                            if (employee1 != null && (employee1.Position == "Профессор" || employee1.Position == "Доцент") && employee1.WorkingTime > 0)
                            {
                                if (timeForLab == 0 && timeForLect == 0 && timeForPract == 0)
                                {
                                    break;
                                }
                                empAndHoursRes.subject = item.Key;
                                empAndHoursRes.EmpName = employee1.Name;

                                if (timeForLect > employee1.WorkingTime)
                                {
                                    timeForLect -= (int)employee1.WorkingTime;
                                    empAndHoursRes.hoursForLect = (int)employee1.WorkingTime;
                                    employee1.WorkingTime       = 0;
                                }
                                else
                                {
                                    empAndHoursRes.hoursForLect = (int)timeForLect;
                                    employee1.WorkingTime      -= (int)timeForLect;
                                    timeForLect = 0;

                                    if (timeForPract > employee1.WorkingTime)
                                    {
                                        timeForPract -= (int)employee1.WorkingTime;
                                        empAndHoursRes.hoursForPractice = (int)employee1.WorkingTime;
                                        employee1.WorkingTime           = 0;
                                    }
                                    else
                                    {
                                        employee1.WorkingTime          -= timeForPract;
                                        empAndHoursRes.hoursForPractice = timeForPract;
                                        timeForPract = 0;

                                        if (timeForLab > employee1.WorkingTime)
                                        {
                                            timeForLab -= (int)employee1.WorkingTime;
                                            empAndHoursRes.hoursForLab = (int)employee1.WorkingTime;
                                            employee1.WorkingTime      = 0;
                                        }
                                        else
                                        {
                                            employee1.WorkingTime     -= timeForLab;
                                            empAndHoursRes.hoursForLab = timeForLab;
                                            timeForLab = 0;
                                        }
                                    }

                                    /*db.Entry(Employee123).State = EntityState.Added;
                                     * db.SaveChanges();*/
                                }

                                db.Entry(employee1).State = EntityState.Modified;
                                db.SaveChanges();
                                empAndHours.Add(empAndHoursRes);
                            }
                            else if (employee1.WorkingTime > 0)
                            {
                                if (timeForLab == 0 && timeForPract == 0)
                                {
                                    break;
                                }
                                Employee Employee12 = db.Employees.Where(e => e.ID == employee.ID_employee).Where(m => m.WorkingTime > 0).SingleOrDefault();

                                /*if (Employee12 == null)
                                 * {
                                 * var temp = employee.Name;
                                 * String error1 = (temp.ToString() + " - не нашлось свободного ? преподавателя");
                                 * Errors.Add(error1);
                                 * //ViewBag.Bad += employes4thissub.Select(m => m.Name).SingleOrDefault().ToString() + " - не нашлось преподавателя"  + "\n";
                                 * break;
                                 * }*/

                                empAndHoursRes.subject = item.Key;
                                empAndHoursRes.EmpName = employee1.Name;


                                if (timeForPract > employee1.WorkingTime)
                                {
                                    timeForPract -= (int)employee1.WorkingTime;
                                    empAndHoursRes.hoursForPractice = (int)employee1.WorkingTime;
                                    employee1.WorkingTime           = 0;
                                }
                                else
                                {
                                    employee1.WorkingTime          -= timeForPract;
                                    empAndHoursRes.hoursForPractice = timeForPract;
                                    timeForPract = 0;

                                    if (timeForLab > employee1.WorkingTime)
                                    {
                                        timeForLab -= (int)employee1.WorkingTime;
                                        empAndHoursRes.hoursForLab = (int)employee1.WorkingTime;
                                        employee1.WorkingTime      = 0;
                                    }
                                    else
                                    {
                                        employee1.WorkingTime     -= timeForLab;
                                        empAndHoursRes.hoursForLab = timeForLab;
                                        timeForLab = 0;
                                    }
                                }

                                empAndHours.Add(empAndHoursRes);
                                db.Entry(employee1).State = EntityState.Modified;
                                db.SaveChanges();
                            }
                        }
                        if (countWorkers == employes4thissub.Count && (timeForLect != 0 || timeForLab != 0 || timeForPract != 0))
                        {
                            String error = ("Не распределен педмет: " + item.Key + " " + "лаб.: " + timeForLab.ToString() + " лекц.: " + timeForLect.ToString() + " практич.: " + timeForPract.ToString());
                            Errors.Add(error);
                            //ViewBag.Bad += ("Не распределен " + employes4thissub.Select(m => m.Name).SingleOrDefault().ToString() + " " + timeForLab.ToString() + " " + timeForLect.ToString() + " " + timeForPract.ToString()+ "\n" );
                        }
                    }
                    else
                    {
                        String error1 = (item.Key + " - не нашлось свободного  преподавателя");
                        Errors.Add(error1);
                        //ViewBag.Bad += employes4thissub.Select(m => m.Name).SingleOrDefault().ToString() + " - не нашлось преподавателя"  + "\n";
                    }
                }



                ViewBag.Bad = Errors;

                return(View(empAndHours));
            }
        }
Example #14
0
        private void buttonCreate_Click(object sender, EventArgs e)
        {
            SchoolYear sy      = (SchoolYear)schoolYearBindingSource.Current;
            Semestr    semestr = (Semestr)Enum.Parse(typeof(Semestr), comboBoxSemestr.Text);

            List <string> ls = new List <string>();

            var q = from ciw in myDatabase.CourseInWork
                    where ciw.SchoolYear.ID == sy.ID && (ciw.Fact == (short?)WorkloadType.Формальная || ciw.Fact == (short?)WorkloadType.Фактическая_и_формальная) && ciw.Semestr == (short?)semestr &&
                    ciw.Group.IsOchniki == radioButtonOchniki.Checked
                    orderby ciw.Course.ID, ciw.Group.Group1, ciw.LectHours descending, ciw.LabHours descending, ciw.UprHours descending
            select ciw;

            ls.Add("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
            ls.Add("<html>");
            ls.Add(" <head>");
            ls.Add("  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1251\">");
            ls.Add("  <title>Распределение учебной нагрузки</title>");
            ls.Add(" </head>");
            ls.Add(" <body>");
            ls.Add("<p align=\"center\">Для составления расписания занятий со студентами представить в учебный отдел к _______________ 20 __ г.</p>");
            ls.Add("<p align=\"right\"><b>Кафедра АСУ</b></p>");
            ls.Add("<h1 align=\"center\">РАСПРЕДЕЛЕНИЕ</h1>");
            string s = String.Format("учебной нагрузки для заочников на {0} семестр {1} учебного года", semestr.ToString().ToLower(), sy.Years);

            ls.Add("<p align=\"center\">" + s + "</p>");
            ls.Add("<table border=\"1\">");
            ls.Add("<thead>");
            ls.Add("<tr>");
            ls.Add("<td><b>Дисциплина</b></td>");
            ls.Add("<td><b>Вид занятий</b></td>");
            ls.Add("<td><b>Номера учебных групп</b></td>");
            ls.Add("<td><b>Ученое звание, должность, фамилия и инициалы преподавателя</b></td>");
            ls.Add("<td><b>Номера лабораторий</b></td>");
            ls.Add("<td><b>Примечание</b></td>");
            ls.Add("</tr>");
            ls.Add("<tr>");
            ls.Add("<td align=\"center\">1</td>");
            ls.Add("<td align=\"center\">2</td>");
            ls.Add("<td align=\"center\">3</td>");
            ls.Add("<td align=\"center\">4</td>");
            ls.Add("<td align=\"center\">5</td>");
            ls.Add("<td align=\"center\">6</td>");
            ls.Add("</tr>");
            ls.Add("</thead>");
            ls.Add("<tbody>");
            int                 counter = 1;
            HtmlTableRow        oldhtr  = new HtmlTableRow();
            List <HtmlTableRow> lhtr    = new List <HtmlTableRow>();

            foreach (CourseInWork ciw in q)
            {
                HtmlTableRow htr = new HtmlTableRow(ciw.Course.Name,
                                                    ciw.LectHours, ciw.LabHours, ciw.UprHours,
                                                    ciw.Groups,
                                                    ciw.Employee.ShortName,
                                                    ciw.Room);

                if (lhtr.Count > 0 && oldhtr.Course != "" && (oldhtr.Course != htr.Course || oldhtr.Groups != htr.Groups))
                {
                    lhtr[0].Course = counter + ". " + lhtr[0].Course;
                    counter++;
                    for (int i = 0; i < lhtr.Count; i++)
                    {
                        HtmlTableRow r = lhtr[i];
                        if (i == 0)
                        {
                            ls.Add(r.TableRow(lhtr.Count));
                        }
                        else
                        {
                            ls.Add(r.TableRow(0));
                        }
                    }
                    lhtr.Clear();
                }
                if ((ciw.LabHours > 0) || (ciw.LectHours > 0) || (ciw.UprHours > 0))
                {
                    if (oldhtr.Course == htr.Course &&
                        oldhtr.Groups == htr.Groups &&
                        (oldhtr.LectHours == 0 || oldhtr.LectHours == null) &&
                        (htr.LectHours == 0 || htr.LectHours == null) &&
                        oldhtr.LabHours > 0 &&
                        htr.LabHours > 0)
                    {
                        oldhtr.Employee += ", " + htr.Employee;
                    }
                    else
                    {
                        lhtr.Add(htr);
                    }
                    oldhtr = htr;
                }
            }
            if (oldhtr.Course != "")
            {
                if (lhtr.Count > 0)
                {
                    lhtr[0].Course = counter + ". " + lhtr[0].Course;
                    for (int i = 0; i < lhtr.Count; i++)
                    {
                        HtmlTableRow r = lhtr[i];
                        if (i == 0)
                        {
                            ls.Add(r.TableRow(lhtr.Count));
                        }
                        else
                        {
                            ls.Add(r.TableRow(0));
                        }
                    }
                }
            }

            ls.Add("</tbody>");
            ls.Add("</table>");
            ls.Add(" </body>");
            ls.Add("</html>");

            File.WriteAllLines("Shedule.html", ls.ToArray(), Encoding.GetEncoding(1251));
            Process.Start("Shedule.html");

            Close();

            // MessageBox.Show("Формирование завершено!");
        }
Example #15
0
 private void buttonOk_Click(object sender, EventArgs e)
 {
     this.DialogResult = System.Windows.Forms.DialogResult.OK;
     SelectedSemestr   = (Semestr)comboBoxSemestr.SelectedItem;
     Close();
 }
Example #16
0
 public ActionResult Edit(Semestr semestr)
 {
     if (ModelState.IsValid)
     {
         db.Entry(semestr).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(semestr);
 }