Esempio n. 1
0
        public ActionResult ReportExportToPaper(Round1ReportModelCriteria _model)
        {
            if (Session["USER"] == null)
            {
                return(RedirectToAction("../Account/ManagementLogin"));
            }

            List <Round1Report01Model> reportLists = GetListForExport(_model);

            if (reportLists != null)
            {
                var pageIndex = _model.Page ?? 1;
                _model.reports = reportLists.ToPagedList(pageIndex, 25);
            }

            return(View("ReportExportToPaper", _model));
        }
Esempio n. 2
0
        public ActionResult ReportExportToExcel(Round1ReportModelCriteria model)
        {
            if (Session["USER"] == null)
            {
                return(RedirectToAction("../Account/ManagementLogin"));
            }

            ReportClass rptH = new ReportClass();

            List <Round1Report01Model> reportLists = GetListForExport(model);

            /*Init value*/
            rptH.FileName = Server.MapPath("~/Reports/RptForExamPaper.rpt");
            rptH.SetDataSource(reportLists);


            System.IO.Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.Excel);
            return(File(stream, "application/xls", "ReportData.xls"));
        }
Esempio n. 3
0
        public List <Round1Report01Model> GetListForExport(Round1ReportModelCriteria model)
        {
            List <Round1Report01Model> reportLists = new List <Round1Report01Model>();

            int index = 1;
            var items = from ss in db.TB_STUDENT_SEAT
                        join s in db.TB_APPLICATION_STUDENT on ss.STUDENT_ID equals s.STD_ID
                        where s.STD_LEVEL_ID == model.studentLevel
                        orderby s.STD_LEVEL_ID ascending, s.TB_STUDENT_SEAT.STUDENT_CODE ascending
                select new
            {
                studentCode     = ss.STUDENT_CODE,
                studentFullName = ss.TB_APPLICATION_STUDENT.TB_M_TITLE.TITLE_NAME_TH + "" + ss.TB_APPLICATION_STUDENT.STD_NAME + "  " + ss.TB_APPLICATION_STUDENT.STD_SURNAME,
                schoolName      = ss.TB_APPLICATION_STUDENT.TB_APPLICATION_SCHOOL.SCHOOL_NAME,
                studentLevel    = s.TB_M_LEVEL.LEVEL_NAME_TH,
                roomNo          = ss.TB_ROOM.ROOM_NUMBER,
                sitPerfix       = ss.SIT_NUMBER_PREFIX,
                sitNumber       = ss.SIT_NUMBER
            };

            foreach (var item in items)
            {
                Round1Report01Model rr = new Round1Report01Model();
                rr.seq             = index;
                rr.studentCode     = item.studentCode + "";
                rr.studentFullName = item.studentFullName;
                rr.schoolName      = item.schoolName;
                rr.studentLevel    = item.studentLevel;
                rr.roomNo          = item.roomNo + "";
                rr.remark          = item.sitPerfix + "" + Convert.ToInt16(item.sitNumber).ToString("00");
                rr.phone           = "สอบแข่งขันภาษาจีน";
                reportLists.Add(rr);
                index++;
            }
            return(reportLists);
        }
        public ActionResult Index1(Round1ReportModelCriteria _model)
        {
            if (Session["USER"] == null)
            {
                return(RedirectToAction("../Account/ManagementLogin"));
            }

            List <TB_APPLICATION_STUDENT> studentLists = db.TB_APPLICATION_STUDENT.Where(s => s.STD_LEVEL_ID == _model.studentLevel).OrderBy(s => s.STD_ID).ToList();
            List <TB_M_LEVEL>             tbMLevel     = db.TB_M_LEVEL.Where(l => l.LEVEL_ID > 0).ToList();

            if (studentLists != null)
            {
                if (studentLists.Count > 0)
                {
                    if (_model.action.Equals("บันทึก"))
                    {
                        //ล้างข้อมูลเก่าออก
                        foreach (TB_APPLICATION_STUDENT std in studentLists)
                        {
                            TB_EXAM_ABSENT studentSeat = db.TB_EXAM_ABSENT.Where(s => s.STD_CODE == std.TB_STUDENT_SEAT.STUDENT_CODE).FirstOrDefault();
                            if (studentSeat != null)
                            {
                                db.TB_EXAM_ABSENT.Remove(studentSeat);
                            }
                        }
                        //บันทึกเด็กที่ขาดใหม่
                        foreach (String id in _model.SelectedStudentIDs)
                        {
                            int            absentId       = Convert.ToInt32(id);
                            TB_EXAM_ABSENT tb_exam_absent = new TB_EXAM_ABSENT();
                            tb_exam_absent.STD_CODE = absentId;
                            db.TB_EXAM_ABSENT.Add(tb_exam_absent);
                        }
                        db.SaveChanges();
                    }

                    List <Round1Report01Model> lists = new List <Round1Report01Model>();
                    int seq = 1;
                    foreach (TB_APPLICATION_STUDENT std in studentLists)
                    {
                        if (std.TB_STUDENT_SEAT == null)
                        {
                            ViewBag.ResultMsg = "ยังไม่ได้จัดผังสอบ ไม่สามารถทำรายการได้!";

                            ViewBag.StudentLevel = new SelectList(tbMLevel, "LEVEL_ID", "LEVEL_NAME_TH", _model.studentLevel);
                            return(View(_model));
                        }


                        Round1Report01Model rpt = new Round1Report01Model();
                        rpt.seq             = seq;
                        rpt.studentCode     = std.TB_STUDENT_SEAT.STUDENT_CODE + "";
                        rpt.studentFullName = std.TB_M_TITLE.TITLE_NAME_TH + std.STD_NAME + "  " + std.STD_SURNAME;
                        rpt.schoolName      = std.TB_APPLICATION_SCHOOL.SCHOOL_NAME;
                        rpt.remark          = "";
                        seq++;
                        lists.Add(rpt);
                    }

                    List <String> absentStudents = new List <string>();
                    foreach (TB_EXAM_ABSENT exam in db.TB_EXAM_ABSENT.ToList())
                    {
                        absentStudents.Add(exam.STD_CODE + "");
                    }
                    if (lists != null)
                    {
                        var pageIndex = _model.Page ?? 1;
                        _model.reports            = lists.ToPagedList(pageIndex, 50);
                        _model.SelectedStudentIDs = absentStudents;
                    }
                }
            }
            ViewBag.StudentLevel = new SelectList(tbMLevel, "LEVEL_ID", "LEVEL_NAME_TH", _model.studentLevel);
            return(View(_model));
        }