Ejemplo n.º 1
0
        public JavaScriptResult DeleteDay(string Facultet_ID, string Gruppa_ID, string Disciplina_ID, string PrepodID, string IDZanyatiya)
        {
            try
            {
                int idZanyatiya = int.Parse(IDZanyatiya);

                var otmetki =
                    from o in contextDB.tablePoseshenie
                    where o.ID_Zanyatiya == idZanyatiya
                    select o;

                foreach (var o in otmetki)
                {
                    contextDB.tablePoseshenie.Remove(o);
                }

                var zanyatie =
                    (from z in contextDB.tableZanyatiy
                     where z.ID == idZanyatiya
                     select z).First();

                contextDB.tableZanyatiy.Remove(zanyatie);
                contextDB.SaveChanges();
                int GruppaID     = int.Parse(Gruppa_ID);
                int DisciplinaID = int.Parse(Disciplina_ID);
                int Prepod_ID    = int.Parse(PrepodID);

                var students =
                    from s in contextDB.tableStudents
                    where GruppaID == s.ID_Gruppi
                    orderby s.Name
                    select s;
                balliZaPoseshenie(GruppaID, DisciplinaID, Prepod_ID, students);
                var script = "$('input').removeAttr('disabled'); $('#center_loader').hide();" + "window.location ='" + Url.Action("JournalForSubjectofGrupp", "Journal", new { Facultet = Facultet_ID, Gruppa = Gruppa_ID, Predmet = Disciplina_ID, Prepodvatel = PrepodID }) + "' ;";
                return(JavaScript(script));
            }
            catch
            {
                return(JavaScript("createInfoBlock(4, false, 'Возникла ошибка! Дата не может быть удалена, обратитесь к администратору.');$('input').removeAttr('disabled'); $('#center_loader').hide();"));
            }
        }
Ejemplo n.º 2
0
        public ActionResult AddTeacher(string teacherFio)
        {
            try
            {
                tablePrepods prepodObj = new tablePrepods();
                prepodObj.Name = teacherFio;
                contextDB.tablePrepods.Add(prepodObj);
                contextDB.SaveChanges();
                BRSGSTOU.Translit trans = new Translit();

                int    prepodID = prepodObj.ID;
                string Login    = trans.TranslitFileName(teacherFio);
                string Parol    = trans.GenPassword(teacherFio).Substring(trans.GenPassword(teacherFio).Length / 2);
                if (Login.Length > 16)
                {
                    Login = Login.Substring(0, 16);
                }
                if (Parol.Length > 8)
                {
                    Parol = Parol.Substring(0, 8);
                }
                int Rol = 2;
                contextDB.teachersAccounts.Add(new teachersAccounts {
                    Role_ID = Rol, ID_Prepoda = prepodID, Login = Login, Password = Parol
                });
                contextDB.SaveChanges();


                ViewBag.Message = "ok";
                return(isAdminMetod());
            }
            catch
            {
                return(View("Error"));
            }
        }
Ejemplo n.º 3
0
        public JavaScriptResult UpdateStudValue()
        {
            int rol = 0;

            try
            {
                rol =
                    (from r in contextDB.teachersAccounts
                     where r.Login == User.Identity.Name
                     select r.Role_ID).First();
            }
            catch
            {
                return(JavaScript("createInfoBlock(1, false, 'Возникла ошибка! Баллы не могут быть сохранены, обратитесь к администратору.');"));
            }
            if (rol == 2)
            {
                try
                {
                    int    Facultet_ID   = int.Parse(Request.Params.Get("Facultet_ID"));
                    int    Gruppa_ID     = int.Parse(Request.Params.Get("Gruppa_ID"));
                    int    Disciplina_ID = int.Parse(Request.Params.Get("Disciplina_ID"));
                    string vidBallov     = Request.Params.Get("vidBallov");
                    int    Student_ID    = int.Parse(Request.Params.Get("student"));
                    int    value         = int.Parse(Request.Params.Get("value"));

                    string Disciplina =
                        (from t in contextDB.tableDisciplin
                         where t.ID == Disciplina_ID
                         select t.Name).First().ToString();

                    int Prepod_ID =
                        //2 раза
                        (from t in contextDB.teachersAccounts
                         where t.Login == User.Identity.Name
                         from p in contextDB.tablePrepods
                         where t.ID_Prepoda == p.ID
                         select p.ID).First();

                    var StudentsPoint =
                        (from sp in contextDB.tableBalli
                         where sp.ID_Gruppi == Gruppa_ID && sp.ID_Disciplini == Disciplina_ID && sp.ID_prepoda == Prepod_ID && sp.ID_Studenta == Student_ID
                         select sp).First();

                    int tek = 15, rub = 20;
                    if (DiscipliniVM.Contains(Disciplina))
                    {
                        tek = 10; rub = 25;
                    }
                    if (System.IO.File.Exists(Server.MapPath(Url.Content("/Models/AT.cs"))))
                    {
                        switch (vidBallov)
                        {
                        case "Tek1":
                            value = value > tek ? tek : value;
                            StudentsPoint.Tek1 = value;
                            break;

                        case "Rub1":
                            value = value > rub ? rub : value;
                            StudentsPoint.Rub1 = value;
                            break;
                        }
                        StudentsPoint.Itog = StudentsPoint.Pos1 + StudentsPoint.Tek1 + StudentsPoint.Rub1 + StudentsPoint.Pos2 + StudentsPoint.Tek2 + StudentsPoint.Rub2 + StudentsPoint.Samost + StudentsPoint.Dosdacha + StudentsPoint.Premial;
                        contextDB.SaveChanges();
                        return(JavaScript("createInfoBlock(1, false, 'Данные сохранены');$('input').removeAttr('disabled'); $('#center_loader').hide();"));
                    }
                    else if (System.IO.File.Exists(Server.MapPath(Url.Content("/Models/ATT.cs"))))
                    {
                        switch (vidBallov)
                        {
                        case "Tek2":
                            value = value > tek ? tek : value;
                            StudentsPoint.Tek2 = value;
                            break;

                        case "Rub2":
                            value = value > rub ? rub : value;
                            StudentsPoint.Rub2 = value;
                            break;

                        case "Samost":
                            value = value > 15 ? 15 : value;
                            StudentsPoint.Samost = value;
                            break;

                        case "Dosdacha":
                            value = value > 20 ? 20 : value;
                            StudentsPoint.Dosdacha = value;
                            break;

                        case "Premial":
                            value = value > 20 ? 20 : value;
                            StudentsPoint.Premial = value;
                            break;
                        }
                        StudentsPoint.Itog = StudentsPoint.Pos1 + StudentsPoint.Tek1 + StudentsPoint.Rub1 + StudentsPoint.Pos2 + StudentsPoint.Tek2 + StudentsPoint.Rub2 + StudentsPoint.Samost + StudentsPoint.Dosdacha + StudentsPoint.Premial;
                        contextDB.SaveChanges();
                        return(JavaScript("createInfoBlock(1, false, 'Данные сохранены');$('input').removeAttr('disabled'); $('#center_loader').hide();"));
                    }
                    else
                    {
                        return(JavaScript(""));
                    }
                }
                catch
                {
                    return(JavaScript("createInfoBlock(1, false, 'Возникла ошибка! Баллы не могут быть сохранены, обратитесь к администратору.');"));
                }
            }
            else
            {
                return(JavaScript("createInfoBlock(1, false, 'Возникла ошибка! Баллы не могут быть сохранены, обратитесь к администратору.');"));
            }
        }
Ejemplo n.º 4
0
        public ActionResult SpisokStudentov(string Facultet_ID, string Grupp_ID)
        {
            try
            {
                int GruppID = int.Parse(Grupp_ID);
                ViewBag.GruppID     = GruppID;
                ViewBag.Facultet_ID = Facultet_ID;

                string GruppName =
                    (from gn in contextDB.tableGrupp
                     where gn.ID == GruppID
                     select gn.Name).First();

                ViewBag.GruppName = GruppName;
                int k = 1;
                foreach (var s in Request.Form.AllKeys)
                {
                    if (k <= Request.Form.AllKeys.Length - 2)
                    {
                        int  idStud  = 0;
                        byte otmetka = 0;
                        if (int.TryParse(s, out idStud))
                        {
                            idStud = int.Parse(s);
                            if (Request.Form.Get(s) == "false")
                            {
                                otmetka = 0;
                            }
                            else
                            {
                                otmetka = 1;
                            }
                            var stud =
                                (from st in contextDB.tableStudents
                                 where st.ID == idStud
                                 select st).First();
                            stud.DopuskKSessii = otmetka;
                        }
                    }
                    else
                    {
                        break;
                    }
                    k++;
                }
                contextDB.SaveChanges();

                var Students =
                    from s in contextDB.tableStudents
                    where s.ID_Gruppi == GruppID
                    select s;

                ViewBag.Students = Students;
                ViewBag.Message  = "ok";
                return(isAdminMetod());
            }
            catch
            {
                return(View("Error"));
            }
        }