Example #1
0
        //Получение инфармации о кафедре
        public Kafedra getKafedraInfo(int id)
        {
            Kafedra kaf = new Kafedra();

            Connect();
            loger.Info("Вызван метод " + new StackTrace(false).GetFrame(0).GetMethod().Name);
            try
            {
                SqlCommand cmd = new SqlCommand("SELECT * FROM Kafedra WHERE id=@id", Connection);
                cmd.Parameters.Add(new SqlParameter("@id", id));
                SqlDataReader reader = cmd.ExecuteReader();
                while (reader.Read())
                {
                    kaf.id    = Convert.ToInt32(reader["Id"]);
                    kaf.name  = Convert.ToString(reader["Name"]);
                    kaf.email = Convert.ToString(reader["Email"]);
                }
            }
            catch (Exception e)
            {
                loger.Error("Произошла ошибка при запросе инфаормации о группе");
                loger.Trace(e.StackTrace);
            }
            finally
            {
                Disconnect();
            }
            return(kaf);
        }
Example #2
0
        public bool add(Kafedra kafedra)
        {
            bool result = true;

            loger.Info("Вызван метод " + new StackTrace(false).GetFrame(0).GetMethod().Name);
            Connect();
            try
            {
                SqlCommand cmd = new SqlCommand("INSERT INTO Kafedra(Name, email) VALUES (@Name, @email)", Connection);
                cmd.Parameters.Add(new SqlParameter("@Name", kafedra.name));
                cmd.Parameters.Add(new SqlParameter("@email", kafedra.email));;
                cmd.ExecuteNonQuery();
                loger.Info("Успешное добавление кафедры" + kafedra.name);
            }
            catch (Exception e)
            {
                result = false;
                loger.Error("Произошла ошибка при запросе инфаормации о группе");
                loger.Trace(e.StackTrace);
            }
            finally
            {
                Disconnect();
            }
            return(result);
        }
Example #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Kafedra kafedra = db.Kafedras.Find(id);

            db.Kafedras.Remove(kafedra);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Example #4
0
        //Все преподаватели кафедры
        public ActionResult getTeachersInKafedra(int id)
        {
            Kafedra               kafedra  = kDAO.getKafedraInfo(id);
            List <Teacher>        teachers = tDAO.getAllTeachersByKafedra(id);
            TeachersInKafedraView tIKV     = new TeachersInKafedraView(kafedra, teachers);

            return(View(tIKV));
        }
Example #5
0
        //Вовыд информации о кафедре и группах
        public ActionResult getKafedraInfo(int id)
        {
            Kafedra         kafedra = kDAO.getKafedraInfo(id);
            List <Gruppa>   groups  = gDAO.getAllGroupsByKafedra(id);
            GroupsInKafedra gIK     = new GroupsInKafedra(groups, kafedra);

            return(View(gIK));
        }
Example #6
0
 public ActionResult Edit([Bind(Include = "KafedraID,Name,FacultID")] Kafedra kafedra)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kafedra).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kafedra));
 }
Example #7
0
 private void buttonYeni_Click(object sender, EventArgs e)
 {
     comboBoxKafedralar.SelectedIndex = -1;
     seciliKafedra                    = new Kafedra();
     seciliKafedra.Fakulte            = this.Fakulte;
     buttonKafedraDersleri.Enabled    = true;
     buttonKafedraIxtisaslari.Enabled = true;
     buttonSil.Enabled                = true;
     buttonSaxla.Enabled              = true;
 }
Example #8
0
 public ActionResult Edit([Bind(Include = "Kafedra_id,Kafedra_name,Kafedra_zav,Count_Doctor_Science,Instytyts_id")] Kafedra kafedra)
 {
     if (ModelState.IsValid)
     {
         db.Entry(kafedra).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(kafedra));
 }
Example #9
0
 public ActionResult Create([Bind(Include = "KafedraID,Name,FacultID")] Kafedra kafedra)
 {
     if (ModelState.IsValid)
     {
         db.Kafedras.Add(kafedra);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.FacultID = new SelectList(db.Facults, "FacultID", "Name", kafedra.FacultID);
     return(View(kafedra));
 }
Example #10
0
        public ActionResult Create([Bind(Include = "Kafedra_id,Kafedra_name,Kafedra_zav,Count_Doctor_Science,Instytyts_id")] Kafedra kafedra)
        {
            if (ModelState.IsValid)
            {
                db.Kafedras.Add(kafedra);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(kafedra));
        }
Example #11
0
 public ActionResult AddKafedra([Bind(Exclude = "ID")] Kafedra kafedra)
 {
     if (kDAO.add(kafedra))
     {
         return(View("Index"));
     }
     else
     {
         return(View("AddKafedra"));
     };
 }
Example #12
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Univer != null ? Univer.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Institut != null ? Institut.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Facultet != null ? Facultet.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Kafedra != null ? Kafedra.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Course;
         hashCode = (hashCode * 397) ^ (Group != null ? Group.GetHashCode() : 0);
         return(hashCode);
     }
 }
Example #13
0
        // GET: Kafedras/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Kafedra kafedra = db.Kafedras.Find(id);

            if (kafedra == null)
            {
                return(HttpNotFound());
            }
            return(View(kafedra));
        }
Example #14
0
        private void FormKafedralar_Load(object sender, EventArgs e)
        {
            if (this.Fakulte == null)
            {
                this.Close();
                return;
            }
            this.Text     = this.Fakulte.Ad + " Fakultəsi Kafedraları";
            seciliKafedra = null;
            buttonKafedraDersleri.Enabled    = false;
            buttonKafedraIxtisaslari.Enabled = false;
            buttonSil.Enabled   = false;
            buttonSaxla.Enabled = false;

            kafedralariGetir();
        }
Example #15
0
        private void comboBoxKafedralar_SelectedIndexChanged(object sender, EventArgs e)
        {
            seciliKafedra = comboBoxKafedralar.SelectedItem as Kafedra;
            if (seciliKafedra != null)
            {
                var muellimler = (from Muellim m in Program.VBE
                                  orderby m.TamAdi ascending
                                  where m.VezifeliOlduguYer == seciliKafedra
                                  select m).ToList();
                comboBoxMudir.DataSource    = muellimler;
                comboBoxMudir.DisplayMember = "TamAdi";
                comboBoxMudir.SelectedIndex = -1;

                comboBoxMudirMuavini.DataSource    = muellimler;
                comboBoxMudirMuavini.DisplayMember = "TamAdi";
                comboBoxMudirMuavini.SelectedIndex = -1;

                textBoxAd.Text                    = seciliKafedra.Ad;
                comboBoxMudir.SelectedItem        = seciliKafedra.Mudir;
                comboBoxMudirMuavini.SelectedItem = seciliKafedra.MudirMuavini;
                buttonKafedraDersleri.Enabled     = true;
                buttonKafedraIxtisaslari.Enabled  = true;
                buttonSil.Enabled                 = true;
                buttonSaxla.Enabled               = true;
            }
            else
            {
                textBoxAd.Text                   = "";
                comboBoxMudir.DataSource         = null;
                comboBoxMudirMuavini.DataSource  = null;
                buttonKafedraDersleri.Enabled    = false;
                buttonKafedraIxtisaslari.Enabled = false;
                buttonSil.Enabled                = false;
                buttonSaxla.Enabled              = false;
            }
        }
        // GET: KafedraPanel
        public ActionResult Index()
        {
            int            idCurrentTeacher = (int)Session["Teacher_Id"];
            Kafedra        kaf                  = db.Kafedras.Single(k => k.Id_TeacherZav == idCurrentTeacher);
            List <Teacher> kafTeachers          = db.Teachers.Where(t => t.Id_Kafedra == kaf.Id).ToList();
            List <TeacherStatusViewModel> tsvmL = new List <TeacherStatusViewModel>();

            foreach (var t in kafTeachers)
            {
                int b1 = 0, b2 = 0, b3 = 0, b4 = 0, b5 = 0, bTotal = 0;
                if (db.Mark_Teachers.Any(m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 1))
                {
                    b1 = db.Mark_Teachers.Where(
                        m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 1)
                         .Sum(m => m.Kolvo_Mark);
                }
                if (db.Mark_Teachers.Any(m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 2))
                {
                    b2 = db.Mark_Teachers.Where(
                        m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 2)
                         .Sum(m => m.Kolvo_Mark);
                }
                if (db.Mark_Teachers.Any(m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 3))
                {
                    b3 = db.Mark_Teachers.Where(
                        m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 3)
                         .Sum(m => m.Kolvo_Mark);
                }
                if (db.Mark_Teachers.Any(m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 4))
                {
                    b4 = db.Mark_Teachers.Where(
                        m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 4)
                         .Sum(m => m.Kolvo_Mark);
                }
                if (db.Mark_Teachers.Any(m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 5))
                {
                    b5 = db.Mark_Teachers.Where(
                        m => m.Id_teachers == t.Id && m.Сriteria_Teachers.Category_Teachers.Block_Teachers.Id == 5)
                         .Sum(m => m.Kolvo_Mark);
                }
                if (db.Mark_Teachers.Any(m => m.Id_teachers == t.Id))
                {
                    bTotal = db.Mark_Teachers.Where(
                        m => m.Id_teachers == t.Id).Sum(m => m.Kolvo_Mark);
                }
                tsvmL.Add(new TeacherStatusViewModel()
                {
                    IdTeacher  = t.Id,
                    FIO        = t.Name,
                    block1     = b1,
                    block2     = b2,
                    block3     = b3,
                    block4     = b4,
                    block5     = b5,
                    blockTotal = bTotal
                });
            }

            KafedraPanelViewModel kpvm = new KafedraPanelViewModel()
            {
                kafedra  = kaf,
                tsvmList = tsvmL
            };

            return(View(kpvm));
        }
        public ActionResult ShowMarks(int id, int?idKafedra)
        {
            ViewBag.IdBlock = id;

            ViewBag.Blocks = db.Block_Kafedra.ToList();


            #region setting ViewBag.Points
            Teacher CurrentTeacher = new Teacher();
            Kafedra CurrentKafedra = new Kafedra();
            if (idKafedra == null)
            {
                int idUser = (int)Session["User_ID"];
                CurrentTeacher = db.Teachers.Single(t => t.Id_User == idUser);
                CurrentKafedra = db.Kafedras.Single(t => t.Id_TeacherZav == CurrentTeacher.Id);
            }
            else
            {
                ViewBag.IdTeacher = idKafedra;
                CurrentKafedra    = db.Kafedras.Single(t => t.Id == idKafedra);
            }
            ViewBag.TeacherName = CurrentTeacher.Name;
            ViewBag.KafedraName = CurrentKafedra.Name;

            if (db.Mark_Kafedra.Count(a => a.Id_Kafedra == CurrentKafedra.Id) != 0)
            {
                ViewBag.WaitedTotalPoints = db.Mark_Kafedra.Where(a => a.Id_Kafedra == CurrentKafedra.Id).Sum(a => a.Kolvo_Mark);
            }
            else
            {
                ViewBag.WaitedTotalPoints = 0;
            }

            if (db.Mark_Kafedra.Count(a => a.Id_Kafedra == CurrentKafedra.Id && a.Status == 1) != 0)
            {
                ViewBag.CheckedTotalPoints =
                    db.Mark_Kafedra.Where(a => a.Id_Kafedra == CurrentKafedra.Id && a.Status == 1)
                    .Sum(a => a.Kolvo_Mark);
            }
            else
            {
                ViewBag.CheckedTotalPoints = 0;
            }

            if (
                db.Mark_Kafedra.Count(
                    a => a.Id_Kafedra == CurrentKafedra.Id && a.Criteria_Kafedra.Category_Kafedra.Id_Block == id) != 0)
            {
                ViewBag.WaitedBlockTotalPoints = db.Mark_Kafedra.Where(
                    a => a.Id_Kafedra == CurrentKafedra.Id && a.Criteria_Kafedra.Category_Kafedra.Id_Block == id)
                                                 .Sum(a => a.Kolvo_Mark);
            }
            else
            {
                ViewBag.WaitedBlockTotalPoints = 0;
            }

            if (
                db.Mark_Kafedra.Count(
                    a => a.Id_Kafedra == CurrentKafedra.Id && a.Criteria_Kafedra.Category_Kafedra.Id_Block == id &&
                    a.Status == 1) != 0)
            {
                ViewBag.CheckedBlockTotalPoints = db.Mark_Kafedra.Where(a =>
                                                                        a.Id_Kafedra == CurrentKafedra.Id && a.Criteria_Kafedra.Category_Kafedra.Id_Block == id &&
                                                                        a.Status == 1).Sum(a => a.Kolvo_Mark);
            }
            else
            {
                ViewBag.CheckedBlockTotalPoints = 0;
            }
            #endregion

            var allCategories = db.Category_Kafedra.Where(a => a.Id_Block == id).ToList();
            var allMarks      = db.Mark_Kafedra.Where(a => a.Criteria_Kafedra.Category_Kafedra.Id_Block == id && a.Id_Kafedra == CurrentKafedra.Id).ToList();

            List <ManualMarks> manualMarks = new List <ManualMarks>();
            foreach (var c in allCategories)
            {
                if (allMarks.Any(a => a.Criteria_Kafedra.Id_Category == c.Id))
                {
                    List <Mark_Kafedra> newMarks = allMarks.Where(a => a.Criteria_Kafedra.Id_Category == c.Id).ToList();
                    manualMarks.Add(new ManualMarks()
                    {
                        CategoryMarks = newMarks,
                        CategoryName  = c.Name
                    });
                }
            }

            List <CalculatedMarks> calculatedMarks = new List <CalculatedMarks>();

            foreach (var cr in db.Calculation_Rules_Kafedra)
            {
                switch (cr.TypeOfOperating)
                {
                case 0:
                    if (
                        db.Mark_Teachers.Count(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id) != 0)
                    {
                        ViewBag.WaitedTotalPoints += db.Mark_Teachers.Where(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id)
                                                     .Sum(m => m.Kolvo_Mark);
                    }

                    break;

                case 1:
                    if (
                        db.Mark_Teachers.Count(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id) != 0)
                    {
                        ViewBag.WaitedTotalPoints = db.Mark_Teachers.Where(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id)
                                                    .Sum(m => m.Kolvo_Mark) / (decimal)db.Mark_Teachers.Where(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id)
                                                    .Sum(m => m.Kolvo_ed);
                    }


                    break;
                }
            }

            foreach (var cr in db.Calculation_Rules_Kafedra.Where(c => c.Category_Kafedra.Id_Block == id))
            {
                string  cmName   = "";
                decimal cmPoints = 0;
                int     cmCount  = 0;
                switch (cr.TypeOfOperating)
                {
                case 0: cmName = cr.Сriteria_Teachers.Name + " (Сумма)";
                    if (
                        db.Mark_Teachers.Count(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id) != 0)
                    {
                        cmPoints = db.Mark_Teachers.Where(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id)
                                   .Sum(m => m.Kolvo_Mark);
                        cmCount = (int)db.Mark_Teachers.Where(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id)
                                  .Sum(m => m.Kolvo_ed);
                    }

                    break;

                case 1: cmName = cr.Сriteria_Teachers.Name + " (Среднее значение суммы)";
                    if (
                        db.Mark_Teachers.Count(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id) != 0)
                    {
                        cmPoints = db.Mark_Teachers.Where(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id)
                                   .Sum(m => m.Kolvo_Mark) / (decimal)db.Mark_Teachers.Where(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id)
                                   .Sum(m => m.Kolvo_ed);
                        cmCount = (int)db.Mark_Teachers.Where(
                            m => m.Id_Criteria == cr.Id_Criteria && m.Teacher.Id_Kafedra == CurrentKafedra.Id)
                                  .Sum(m => m.Kolvo_ed);
                    }


                    break;
                }

                ViewBag.WaitedBlockTotalPoints += cmPoints;

                calculatedMarks.Add(new CalculatedMarks()
                {
                    CategoryName = cr.Category_Kafedra.Name,
                    Name         = cmName,
                    Count        = cmCount,
                    Points       = cmPoints
                }
                                    );
            }


            ShowMarksObjectKafedra marks = new ShowMarksObjectKafedra()
            {
                ManualMarks     = manualMarks,
                CalculatedMarks = calculatedMarks
            };

            return(View(marks));
        }