Example #1
0
        public JsonResult GetByKHvaLoaiTT2(long IDHK, long IDTT, string masv, string studentname, int pageNumber = 0, int pageSize = 10)
        {
            long       id_gv   = long.Parse(Session["UserId"].ToString());
            var        thuctap = practiceService.GetByLoaiTTvaHocKy(IDTT, IDHK);
            IQueryable listtc  = null;
            var        total   = 0;

            if (teacherService.GetRole(Session["Username"].ToString(), "Trưởng bộ môn"))
            {
                var bomon = teacherService.GetByMagv(Session["Username"].ToString()).SubjectID;
                listtc = topicStudentService.GetListByTTvaBoMon(thuctap.ID, bomon, masv, studentname, pageNumber, pageSize);
                total  = topicStudentService.GetListByTTvaBoMonCount(thuctap.ID, bomon, masv, studentname, pageNumber, pageSize);
            }
            else
            {
                listtc = topicStudentService.GetListByTT(thuctap.ID, masv, studentname, pageNumber, pageSize);
                total  = topicStudentService.GetListByTTCount(thuctap.ID, masv, studentname, pageNumber, pageSize);
            }
            var resultsList = new List <TopicStudentModel>();

            foreach (var item in listtc)
            {
                var  ID = (long)item.GetType().GetProperty("ID").GetValue(item, null);
                bool?result;
                if (item.GetType().GetProperty("Result").GetValue(item, null) != null)
                {
                    result = (bool)item.GetType().GetProperty("Result").GetValue(item, null);
                }
                else
                {
                    result = null;
                }
                var topic = new TopicStudentModel
                {
                    ID          = ID,
                    TopicName   = (string)item.GetType().GetProperty("TopicName").GetValue(item, null),
                    FirstName   = (string)item.GetType().GetProperty("FirstName").GetValue(item, null),
                    LastName    = (string)item.GetType().GetProperty("LastName").GetValue(item, null),
                    MaSV        = (string)item.GetType().GetProperty("MaSV").GetValue(item, null),
                    TeacherName = (string)item.GetType().GetProperty("TeacherName").GetValue(item, null),
                    Progress    = (int)item.GetType().GetProperty("Progress").GetValue(item, null),
                    Result      = result
                };
                var check = scoreService.GetByTopicStudent2(ID);
                if (check != null)
                {
                    topic.TeacherScore = check.TeacherScore;
                }
                resultsList.Add(topic);
            }


            // 5. Trả về các Link được phân trang theo kích thước và số trang.
            return(Json(resultsList, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        public JsonResult GetByKHvaLoaiTT(long IDHK, long IDTT, string search, int pageNumber = 0, int pageSize = 100)
        {
            long id_gv       = long.Parse(Session["UserId"].ToString());
            var  thuctap     = practiceService.GetByLoaiTTvaHocKy(IDTT, IDHK);
            var  total       = topicStudentService.GetCount(thuctap.ID, id_gv, search);
            var  list        = topicStudentService.GetListByTTvaMaGV(thuctap.ID, id_gv, search);
            var  resultsList = new List <TopicStudentModel>();

            foreach (var item in list)
            {
                var  ID = (long)item.GetType().GetProperty("ID").GetValue(item, null);
                bool?result;
                if (item.GetType().GetProperty("Result").GetValue(item, null) != null)
                {
                    result = (bool)item.GetType().GetProperty("Result").GetValue(item, null);
                }
                else
                {
                    result = null;
                }

                var topic = new TopicStudentModel
                {
                    ID        = ID,
                    TopicName = (string)item.GetType().GetProperty("TopicName").GetValue(item, null),
                    FirstName = (string)item.GetType().GetProperty("FirstName").GetValue(item, null),
                    LastName  = (string)item.GetType().GetProperty("LastName").GetValue(item, null),
                    MaSV      = (string)item.GetType().GetProperty("MaSV").GetValue(item, null),

                    Progress = (int)item.GetType().GetProperty("Progress").GetValue(item, null),
                    Result   = result
                };
                var check = scoreService.GetByTopicStudent2(ID);
                if (check != null)
                {
                    topic.TeacherScore = check.TeacherScore;
                }
                resultsList.Add(topic);
            }


            // 5. Trả về các Link được phân trang theo kích thước và số trang.
            return(Json(resultsList, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        private Stream CreateExcelFile(long PracticeID, long SemesterID, Stream stream = null)
        {
            long       id_gv   = long.Parse(Session["UserId"].ToString());
            IQueryable List    = null;
            var        thuctap = practiceService.GetByLoaiTTvaHocKy(PracticeID, SemesterID);

            if (Session["Quyen"].ToString().Contains("Phân hội đồng chấm thi"))
            {
                var bomon = teacherService.GetByMagv(Session["Username"].ToString()).SubjectID;
                List = topicStudentService.GetListByTTvaBoMon(thuctap.ID, bomon, "", "", 0, 50);
            }
            else if (Session["Quyen"].ToString().Contains("Xem list thực tập"))
            {
                List = topicStudentService.GetListByTT(thuctap.ID, "", "", 0, 50);
            }
            else
            {
                List = topicStudentService.getExport(thuctap.ID, id_gv, "");
            }
            var resultsList = new List <TopicStudentModel>();

            foreach (var item in List)
            {
                var  ID = (long)item.GetType().GetProperty("ID").GetValue(item, null);
                bool?result;
                if (item.GetType().GetProperty("Result").GetValue(item, null) != null)
                {
                    result = (bool)item.GetType().GetProperty("Result").GetValue(item, null);
                }
                else
                {
                    result = null;
                }
                var topic = new TopicStudentModel
                {
                    ID        = ID,
                    TopicName = (string)item.GetType().GetProperty("TopicName").GetValue(item, null),
                    FirstName = (string)item.GetType().GetProperty("FirstName").GetValue(item, null),
                    LastName  = (string)item.GetType().GetProperty("LastName").GetValue(item, null),
                    MaSV      = (string)item.GetType().GetProperty("MaSV").GetValue(item, null),
                    Birthday  = (DateTime)item.GetType().GetProperty("Birthday").GetValue(item, null),
                    Progress  = (int)item.GetType().GetProperty("Progress").GetValue(item, null),
                    Result    = result
                };
                var check = scoreService.GetByTopicStudent2(ID);
                if (check != null)
                {
                    topic.TeacherScore = check.TeacherScore;
                }
                resultsList.Add(topic);
            }

            string practice = practiceService.GetByIdPractice(PracticeID).PracticeName;

            using (var excelPackage = new ExcelPackage(stream ?? new MemoryStream()))
            {
                // Tạo author cho file Excel
                excelPackage.Workbook.Properties.Author = "Hanker";
                // Tạo title cho file Excel
                excelPackage.Workbook.Properties.Title = "EPP test background";
                // Add Sheet vào file Excel
                excelPackage.Workbook.Worksheets.Add("First Sheet");
                // Lấy Sheet bạn vừa mới tạo ra để thao tác
                var workSheet = excelPackage.Workbook.Worksheets[1];
                // Đổ data vào Excel file
                workSheet.Cells[1, 1].LoadFromCollection(resultsList, false);
                BindingFormatForExcel(workSheet, resultsList, practice);
                excelPackage.Save();
                return(excelPackage.Stream);
            }
        }