/// <summary>
 /// Trang chi tiết cấp 2 theo id
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult CalendarWorkingDetails_Level2(int id)
 {
     var cw = new CalendarWorkingDao().ViewDetails(id);
     ViewBag.Calendarworking = cw;
     ViewBag.teacher = new TeacherDao().ViewDetails(cw.CalendarWorkingTeacher.ToList());
     return View();
 }
Example #2
0
        public async Task <ActionResult> Index()
        {
            var listCW           = new List <CalendarWorkingViewModel>();
            var calendarWorkings = await _calendarWorkingService.GetCalendarWorkingListAsyc();

            calendarWorkings.ForEach(S =>
            {
                listCW.Add(new CalendarWorkingViewModel(
                               S.ID,
                               S.Name_CalendarWorking,
                               S.Description,
                               S.DateStart,
                               S.DateEnd,
                               S.Address,
                               S.TeacherID,
                               S.WorkID,
                               S.TypeCalendarID,
                               S.WorkState,
                               S.Status
                               ));
            });

            ViewBag.listCW = listCW;
            var dao   = new CalendarWorkingDao();
            var model = dao.ListAll();

            return(View(model));
        }
Example #3
0
        /// <summary>
        /// Trang chi tiết cấp 2 theo id
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult CalendarWorkingDetails_Level2(int id)
        {
            var cw = new CalendarWorkingDao().ViewDetails(id);

            ViewBag.Calendarworking = cw;
            ViewBag.teacher         = new TeacherDao().ViewDetails(cw.TeacherID);
            ViewBag.work            = new WorkDao().ViewDetailsWork(cw.WorkID);
            ViewBag.typecalendar    = new TypeCalendarDao().ViewDetailTypeCalendar(cw.TypeCalendarID);
            return(View());
        }
        public ActionResult ListCalendarWorking(int idteacher)
        {
            var teacherDao = new TeacherDao();
            var calendarWorking = new CalendarWorkingDao();
            var teacher = teacherDao.ViewDetails(idteacher);
            ViewBag.teacher = teacher;
            var calendarWorkings = calendarWorking.GetListByTeacher(idteacher);
            ViewBag.calendarWorkings = calendarWorkings;


            return View();
        }
Example #5
0
        // GET: Home
        public ActionResult Index()
        {
            var listCW = new List <CalendarWorkingViewModel>();

            db.CalendarWorkings.ToList().ForEach(S =>
            {
                listCW.Add(new CalendarWorkingViewModel(S.ID, S.Name_CalendarWorking, S.Description, S.DateStart, S.DateEnd, S.Address, S.TeacherID, S.WorkID, S.TypeCalendarID, S.WorkState, S.Status));
            });
            ViewBag.listCW = listCW;
            var dao   = new CalendarWorkingDao();
            var model = dao.ListAll();


            return(View(model));
        }
        public FileResult ExportListCalendarWorking(int idteacher)
        {
            var teacherDao = new TeacherDao();
            var calendarWorking = new CalendarWorkingDao();
            var teacher = teacherDao.ViewDetails(idteacher);
            ViewBag.teacher = teacher;
            var calendarWorkings = calendarWorking.GetListByTeacher(idteacher);
            ViewBag.calendarWorkings = calendarWorkings;

            //Create new Excel Workbook
            var workbook = new HSSFWorkbook();

            //Create new Excel Sheet
            var sheet = workbook.CreateSheet();

            HSSFCellStyle borderedCellStyle = (HSSFCellStyle)workbook.CreateCellStyle();
            borderedCellStyle.BorderLeft = NPOI.SS.UserModel.BorderStyle.Medium;
            borderedCellStyle.BorderTop = NPOI.SS.UserModel.BorderStyle.Medium;
            borderedCellStyle.BorderRight = NPOI.SS.UserModel.BorderStyle.Medium;
            borderedCellStyle.BorderBottom = NPOI.SS.UserModel.BorderStyle.Medium;


            //Create a title row
            var font = workbook.CreateFont();
            font.FontHeightInPoints = 11;
            font.FontName = "Calibri";
            font.Boldweight = (short)NPOI.SS.UserModel.FontBoldWeight.Bold;

            ICellStyle styleMiddle = workbook.CreateCellStyle();
            styleMiddle.Alignment = HorizontalAlignment.Center;
            styleMiddle.VerticalAlignment = VerticalAlignment.Center;
            styleMiddle.WrapText = true; //wrap the text in the cell

            var titleRow = sheet.CreateRow(0);
            CellRangeAddress region = new CellRangeAddress(0, 0, 0, 5);
            sheet.AddMergedRegion(region);
            titleRow.CreateCell(0).SetCellValue("Danh sách công tác của giảng viên " + teacher.Name_Teacher);
            titleRow.Cells[0].CellStyle = styleMiddle;
            titleRow.Cells[0].CellStyle = borderedCellStyle;
            titleRow.RowStyle = (HSSFCellStyle)workbook.CreateCellStyle();
            titleRow.RowStyle.SetFont(font);

            //Create a header row
            var headerRow = sheet.CreateRow(1);
            headerRow.CreateCell(0).SetCellValue("Công tác");
            headerRow.CreateCell(1).SetCellValue("Ngày bắt đầu");
            headerRow.CreateCell(2).SetCellValue("Ngày kết thúc");
            headerRow.CreateCell(3).SetCellValue("Địa chỉ");
            headerRow.CreateCell(4).SetCellValue("Trạng thái");
            headerRow.CreateCell(5).SetCellValue("Tình trạng công việc");
            headerRow.Cells[0].CellStyle = borderedCellStyle;
            headerRow.Cells[1].CellStyle = borderedCellStyle;
            headerRow.Cells[2].CellStyle = borderedCellStyle;
            headerRow.Cells[3].CellStyle = borderedCellStyle;
            headerRow.Cells[4].CellStyle = borderedCellStyle;
            headerRow.Cells[5].CellStyle = borderedCellStyle;
            headerRow.RowStyle = (HSSFCellStyle)workbook.CreateCellStyle();
            headerRow.RowStyle.SetFont(font);

            //(Optional) freeze the header row so it is not scrolled
            sheet.CreateFreezePane(0, 1, 0, 1);

            int rowNumber = 2;

            //Populate the sheet with values from the grid data

            foreach (var item in calendarWorkings)
            {
                //Create a new Row
                var row = sheet.CreateRow(rowNumber++);

                //Set the Values for Cells
                row.CreateCell(0).SetCellValue(item.Name_CalendarWorking);
                row.CreateCell(1).SetCellValue(item.DateStart.ToString("dd/MM/yyyy"));
                row.CreateCell(2).SetCellValue(item.DateEnd.ToString("dd/MM/yyyy"));
                row.CreateCell(3).SetCellValue(item.Address);
                row.CreateCell(4).SetCellValue(item.Status == "HoatDong" ? "Hoạt động" : "Không hoạt động");
                if(item.WorkState == "DangThucHien")
                {
                    row.CreateCell(5).SetCellValue("Đang thực hiện");
                }
                else if(item.WorkState == "DaHoanThanh")
                {
                    row.CreateCell(5).SetCellValue("Đã hoàn thành");
                }
                else if (item.WorkState == "KhongHoanThanh")
                {                       
                    row.CreateCell(5).SetCellValue("Không hoàn thành");
                }
                else if (item.WorkState == "ChuaHoanThanh")
                {                  
                    row.CreateCell(5).SetCellValue("Chưa hoàn thành");
                }
                else if (item.WorkState == "DaDiemDanh")
                {      
                    row.CreateCell(5).SetCellValue("Đã điểm danh");
                }
                else if (item.WorkState == "DangDiemDanh")
                {              
                    row.CreateCell(5).SetCellValue("Đang điểm danh");
                }
                row.Cells[0].CellStyle = borderedCellStyle;
                row.Cells[1].CellStyle = borderedCellStyle;
                row.Cells[2].CellStyle = borderedCellStyle;
                row.Cells[3].CellStyle = borderedCellStyle;
                row.Cells[4].CellStyle = borderedCellStyle;
                row.Cells[5].CellStyle = borderedCellStyle;

            }
            //(Optional) set the width of the columns
            sheet.AutoSizeColumn(0);
            sheet.AutoSizeColumn(1);
            sheet.AutoSizeColumn(2);
            sheet.AutoSizeColumn(3);
            sheet.AutoSizeColumn(4);
            sheet.AutoSizeColumn(5);

            //Write the Workbook to a memory stream
            MemoryStream output = new MemoryStream();
            workbook.Write(output);

            //Return the result to the end user
            return File(output.ToArray(),   //The binary data of the XLS file
             "application/vnd.ms-excel",//MIME type of Excel files
             string.Format("Danh sách công tác của giảng viên {0}.xls",teacher.Name_Teacher));
        }