Пример #1
0
        public ActionResult Assign()
        {
            COURSE        course  = new COURSE();
            List <COURSE> courses = course.Select();

            ViewBag.COURSE = courses;
            return(RedirectToAction("Index", "Manage"));
        }
Пример #2
0
        //
        // GET: /Manage/

        public ActionResult Index()
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            EMPLOYEE EM   = new EMPLOYEE();
            var      dept = EM.GetDepartment();

            ViewBag.DEPT = dept;
            COURSE        course  = new COURSE();
            List <COURSE> courses = course.Select();

            ViewBag.COURSE = courses;
            return(View());
        }
Пример #3
0
        //
        // GET: /Home/

        public ActionResult Index(int COURSE_ID = -1, string MENTOR = "", string EMP_ID = "", int PAGE = 1)
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            var      dept   = "";
            HISTORY  his    = new HISTORY();
            COURSE   course = new COURSE();
            EMPLOYEE em     = new EMPLOYEE();

            List <COURSE> courses = course.Select();

            if (COURSE_ID == -1)
            {
                if (course != null && courses.Count > 0)
                {
                    COURSE_ID = courses[0].ID;
                }
                else
                {
                    COURSE_ID = 0;
                }
            }
            if (Convert.ToInt32(Session["Role"].ToString()) == 0)
            {
                var isMentee = em.IsMentee(COURSE_ID, Session["Username"].ToString());
                var isMentor = em.IsMentor(COURSE_ID, Session["Username"].ToString());
                if (isMentee == 1 && string.IsNullOrWhiteSpace(EMP_ID))
                {
                    EMP_ID = Session["Username"].ToString();
                    MENTOR = em.GetListMentor(COURSE_ID).FirstOrDefault().ID;
                }
                else if (isMentor == 1 && string.IsNullOrWhiteSpace(MENTOR))
                {
                    MENTOR = Session["Username"].ToString();
                }
                else
                {
                    EMP_ID = "0";
                    MENTOR = "0";
                }
            }
            if (Convert.ToInt32(Session["Role"].ToString()) == 2)
            {
                dept = Session["Dept"].ToString();
            }

            var lstHis        = his.GetHistory(MENTOR, EMP_ID, COURSE_ID, dept, PAGE);
            var lstCntEm      = new DataTable();
            var listCntCourse = new DataTable();

            lstCntEm.Columns.Add("EMP_ID");
            lstCntEm.Columns.Add("CNT_EMP");
            listCntCourse.Columns.Add("EMP_ID");
            listCntCourse.Columns.Add("COURSE_ID");
            listCntCourse.Columns.Add("CNT_COURSE");
            foreach (var item in lstHis)
            {
                var count1 = 0;
                var count2 = 0;
                foreach (var item1 in lstHis)
                {
                    if (item.EMP_ID.Equals(item1.EMP_ID))
                    {
                        count1++;
                        if (item.COURSE_ID.Equals(item1.COURSE_ID))
                        {
                            count2++;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                bool exists1 = lstCntEm.Select().ToList().Exists(row => row["EMP_ID"].ToString().ToUpper() == item.EMP_ID);
                bool exists2 = listCntCourse.Select().ToList().Exists(row => row["EMP_ID"].ToString().ToUpper() == item.EMP_ID &&
                                                                      Convert.ToInt32(row["COURSE_ID"].ToString()) == item.COURSE_ID);
                if (exists1)
                {
                    var rowsToUpdate = lstCntEm.AsEnumerable().Where(r => r.Field <string>("EMP_ID") == item.EMP_ID);

                    foreach (var row in rowsToUpdate)
                    {
                        row.SetField("CNT_EMP", count1);
                    }
                }
                else
                {
                    DataRow r = lstCntEm.NewRow();
                    r[0] = item.EMP_ID;
                    r[1] = count1;
                    lstCntEm.Rows.Add(r);
                }
                if (exists2)
                {
                    var rowsToUpdate = listCntCourse.AsEnumerable().Where(r => r.Field <string>("EMP_ID") == item.EMP_ID &&
                                                                          r.Field <string>("COURSE_ID") == item.COURSE_ID.ToString());

                    foreach (var row in rowsToUpdate)
                    {
                        row.SetField("CNT_COURSE", count2);
                    }
                }
                else
                {
                    DataRow r = listCntCourse.NewRow();
                    r[0] = item.EMP_ID;
                    r[1] = item.COURSE_ID;
                    r[2] = count2;
                    listCntCourse.Rows.Add(r);
                }
            }
            // var countEmp = his.GetCountByEmp(MENTOR, EMP_ID, COURSE_ID, dept);
            //var countCourse = his.GetCountByCourse(MENTOR, EMP_ID, COURSE_ID, dept);

            ViewBag.COURSE        = courses;
            ViewBag.HIS           = lstHis;
            ViewBag.CNT_EMP       = lstCntEm;
            ViewBag.CNT_COURSE    = listCntCourse;
            ViewBag.TOTAL         = his.CountHistory(MENTOR, EMP_ID, COURSE_ID, dept);
            ViewBag.MENTORS       = em.GetListMentor(COURSE_ID);
            ViewBag.MENTEES       = em.GetListMentee(COURSE_ID, MENTOR);
            ViewBag.SELECT_COURSE = COURSE_ID;
            return(View());
        }
Пример #4
0
        public ActionResult Manage(int COURSE_ID = 0, string MENTOR = "", string EMP_ID = "", int PAGE = 1)
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }
            HISTORY       his     = new HISTORY();
            EMPLOYEE      em      = new EMPLOYEE();
            COURSE        course  = new COURSE();
            List <COURSE> courses = course.Select();

            ViewBag.COURSE = courses;
            var DEPARTMENT = "";

            if (Convert.ToInt32(Session["Role"].ToString()) == 0)
            {
                var isMentee = em.IsMentee(COURSE_ID, Session["Username"].ToString());
                var isMentor = em.IsMentor(COURSE_ID, Session["Username"].ToString());
                if (isMentee == 1 && string.IsNullOrWhiteSpace(EMP_ID))
                {
                    return(RedirectToAction("Index", "Home"));
                }
                else if (isMentor == 1 && string.IsNullOrWhiteSpace(MENTOR))
                {
                    MENTOR = Session["Username"].ToString();
                }
                else
                {
                    EMP_ID = "0";
                    MENTOR = "0";
                }
            }
            if (Convert.ToInt32(Session["Role"].ToString()) == 2)
            {
                DEPARTMENT = Session["Dept"].ToString();
            }
            var lstHis        = his.GetHistorySimple(MENTOR, EMP_ID, COURSE_ID, DEPARTMENT, PAGE);
            var cnt           = his.CountHistorySimpleTotal(MENTOR, EMP_ID, DEPARTMENT, COURSE_ID);
            var listCntCourse = new DataTable();

            listCntCourse.Columns.Add("COURSE_ID");
            listCntCourse.Columns.Add("CNT_COURSE");
            foreach (var item in lstHis)
            {
                var count1 = 0;
                foreach (var item1 in lstHis)
                {
                    if (item.COURSE_ID.Equals(item1.COURSE_ID))
                    {
                        count1++;
                    }
                    else
                    {
                        continue;
                    }
                }
                bool exists2 = listCntCourse.Select().ToList().Exists(row => Convert.ToInt32(row["COURSE_ID"].ToString()) == item.COURSE_ID);

                if (exists2)
                {
                    var rowsToUpdate = listCntCourse.AsEnumerable().Where(r => r.Field <string>("COURSE_ID") == item.COURSE_ID.ToString());

                    foreach (var row in rowsToUpdate)
                    {
                        row.SetField("CNT_COURSE", count1);
                    }
                }
                else
                {
                    DataRow r = listCntCourse.NewRow();
                    r[0] = item.COURSE_ID;
                    r[1] = count1;
                    listCntCourse.Rows.Add(r);
                }
            }
            ViewBag.HIS     = lstHis;
            ViewBag.Total   = cnt;
            ViewBag.CNT     = listCntCourse;
            ViewBag.MENTORS = em.GetListMentor(COURSE_ID);
            ViewBag.MENTEES = em.GetListMentee(COURSE_ID, MENTOR);
            return(View());
        }