Esempio n. 1
0
        public async Task <IActionResult> Index(string mess)
        {
            IEnumerable <MoDot> listDotDangKy = await _service.GetAll(x => x.Loai == (int)MoDotLoai.DangKy);

            if (!listDotDangKy.Any())
            {
                return(View());
            }
            MoDot DotDangKyMoiNhat = listDotDangKy.ToList().Last();

            MoDot moDot = await _service.GetEntity(x => x.Status == (int)MoDotStatus.Mo);

            DeTaiNghienCuu detai = await _serviceDeTai.GetEntity(x => x.NgayThucHien != null && x.NgayDangKy > DotDangKyMoiNhat.ThoiGianBd && x.NgayDangKy < DotDangKyMoiNhat.ThoiGianKt);

            if (mess != "")
            {
                ViewBag.mess = mess;
            }
            if (detai != null)
            {
                ViewBag.NgayBdDeTai = detai.NgayThucHien.Value.ToString("yyyy-MM-dd'T'HH:mm:ss");
                ViewBag.NgayKtDeTai = detai.NgayKetThuc.Value.ToString("yyyy-MM-dd'T'HH:mm:ss");
            }

            if (moDot != null)
            {
                if (DateTime.Now > moDot.ThoiGianKt.Value)
                {
                    moDot.Status = (int)MoDotStatus.Dong;
                    await _service.Update(moDot);
                }
            }

            return(View(moDot));
        }
Esempio n. 2
0
        public async Task <bool> BaoCaoTreHan(DeTaiNghienCuu deTai)
        {
            var baoCao = deTai.BaoCaoTienDo;
            int week   = ((DateTime.Now - deTai.NgayThucHien.Value).Days) / 7 + 1;

            if (!baoCao.Any())
            {
                if (week == 1)
                {
                    BaoCaoTienDo entity = new BaoCaoTienDo
                    {
                        TuanDaNop = 1,
                        NgayNop   = DateTime.Now,
                        Status    = (int)StatusBaoCao.TreHan
                    };
                    deTai.BaoCaoTienDo.Add(entity);
                }
                else
                {
                    for (int i = 1; i < week; i++)
                    {
                        BaoCaoTienDo entity = new BaoCaoTienDo
                        {
                            TuanDaNop = i,
                            NgayNop   = DateTime.Now,
                            Status    = (int)StatusBaoCao.TreHan
                        };
                        deTai.BaoCaoTienDo.Add(entity);
                    }
                }
                await _service.Update(deTai);

                return(true);
            }
            else
            {
                int tuanDaNop = baoCao.LastOrDefault().TuanDaNop;
                if (tuanDaNop == week || week == tuanDaNop + 1)
                {
                    return(true);
                }
                for (int i = tuanDaNop + 1; i < week; i++)
                {
                    BaoCaoTienDo entity = new BaoCaoTienDo
                    {
                        TuanDaNop = i,
                        NgayNop   = DateTime.Now,
                        Status    = (int)StatusBaoCao.TreHan
                    };
                    deTai.BaoCaoTienDo.Add(entity);
                }
                await _service.Update(deTai);

                return(true);
            }
        }
Esempio n. 3
0
        public async Task <ActionResult> Create(DeTaiNghienCuuViewModel vmodel)
        {
            IEnumerable <DeTaiNghienCuu> list = await _service.GetAll();

            if (list.Count() != 0)
            {
                DeTaiNghienCuu LastE = list.OrderBy(x => x.Id).LastOrDefault();
                vmodel.Id = _service.KhoiTaoMa(LastE);
            }
            else
            {
                vmodel.Id = long.Parse(DateTime.Now.Year.ToString() + "001");
            }
            var model = new DeTaiNghienCuu()
            {
                Id              = vmodel.Id,
                TenDeTai        = vmodel.TenDeTai,
                MoTa            = vmodel.MoTa,
                IdgiangVien     = long.Parse(User.Identity.Name),
                NgayLap         = DateTime.Now,
                TinhTrangDangKy = (int)StatusDangKyDeTai.Con,
                TinhTrangDeTai  = (int)StatusDeTai.MoiTao,
                Loai            = LoaiDeTai.CoSan
            };

            if (await UpLoadFile(vmodel.Files, model) == false)
            {
                return(Json(new { status = false, mess = MessageResult.UpLoadFileFail }));
            }
            try
            {
                var isAuthorize = await _authorizationService.AuthorizeAsync(User, model, DeTaiNghienCuuOperation.Create);

                if (!isAuthorize.Succeeded)
                {
                    return(Ok(new
                    {
                        status = false,
                        toastr = MessageResult.AccessDenied
                    }));
                }
                await _service.Add(model);

                return(Json(new { status = true, create = true, data = new { NgayLap = DateTime.Now.ToString("dd/MM/yyyy"), Id = vmodel.Id, TenTep = model.TenTep }, mess = MessageResult.CreateSuccess }));
            }
            catch (Exception e)
            {
                return(Json(new { status = false, mess = e.ToString() }));
            }
        }
Esempio n. 4
0
        public async Task <IActionResult> PhanCongGiangVien(long IdGiangVien, long IdDeTai)
        {
            DeTaiNghienCuu deTaiNghienCuu = await _service.GetById(IdDeTai);

            if (deTaiNghienCuu != null)
            {
                deTaiNghienCuu.IdgiangVien = IdGiangVien;
                await _service.Update(deTaiNghienCuu);

                return(RedirectToAction("Index", new { mess = "Phân công thành công" }));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
Esempio n. 5
0
        public async Task <bool> UpLoadFile(IFormFile file, DeTaiNghienCuu model)
        {
            if (file == null)
            {
                return(true);
            }
            string[] permittedExtensions = { ".txt", ".pdf", ".doc", ".docx", ".xlsx", ".xls" };

            var ext = Path.GetExtension(file.FileName).ToLowerInvariant();

            if (string.IsNullOrEmpty(ext) || !permittedExtensions.Contains(ext))
            {
                return(false);
            }
            string UploadsFolder  = Path.Combine(_hostingEnvironment.WebRootPath, "FileUpload/DeTaiNghienCuu");
            string uniqueFileName = Guid.NewGuid().ToString() + "_" + file.FileName;
            string filePath       = Path.Combine(UploadsFolder, uniqueFileName);
            await file.CopyToAsync(new FileStream(filePath, FileMode.Create));

            model.TenTep     = file.FileName;
            model.TepDinhKem = uniqueFileName;
            return(true);
        }
Esempio n. 6
0
        public async Task <ActionResult> DeXuatDeTai(DeTaiNghienCuuViewModel vmodel)
        {
            var SV = await _serviceSV.GetById(long.Parse(User.Identity.Name));

            if (SV == null)
            {
                return(Ok(new
                {
                    status = false,
                    mess = MessageResult.NotFoundSV
                }));
            }
            if (vmodel.IdgiangVien == 0)
            {
                vmodel.IdgiangVien = null;
            }
            //Update DeTai
            if (vmodel.Id > 0)
            {
                var DeTai = await _service.GetById(vmodel.Id);

                DeTai.IdgiangVien = vmodel.IdgiangVien;
                DeTai.MoTa        = vmodel.MoTa;
                DeTai.TenDeTai    = vmodel.TenDeTai;
                if (await UpLoadFile(vmodel.Files, DeTai) == false)
                {
                    return(Json(new { status = false, mess = MessageResult.UpLoadFileFail }));
                }
                await _service.Update(DeTai);

                return(Ok(new { status = true, mess = MessageResult.UpdateSuccess }));
            }
            //Kiểm tra SV đã có đề tài?
            var nhomSV = SV.NhomSinhVien.SingleOrDefault(x => x.IdnhomNavigation.Status == (int)BaseStatus.Active);

            if (nhomSV != null)
            {
                return(Ok(new
                {
                    status = false,
                    mess = MessageResult.ExistDeTai
                }));
            }
            IEnumerable <DeTaiNghienCuu> list = await _service.GetAll();

            if (list.Count() != 0)
            {
                DeTaiNghienCuu LastE = list.OrderBy(x => x.Id).LastOrDefault();
                vmodel.Id = _service.KhoiTaoMa(LastE);
            }
            else
            {
                vmodel.Id = long.Parse(DateTime.Now.Year.ToString() + "001");
            }

            var model = new DeTaiNghienCuu()
            {
                Id              = vmodel.Id,
                TenDeTai        = vmodel.TenDeTai,
                MoTa            = vmodel.MoTa,
                NgayDangKy      = DateTime.Now,
                IdNguoiDangKy   = long.Parse(User.Identity.Name),
                IdgiangVien     = vmodel.IdgiangVien,
                NgayLap         = DateTime.Now,
                TinhTrangDangKy = (int)StatusDangKyDeTai.Het,
                TinhTrangDeTai  = (int)StatusDeTai.DaDangKy,
                Loai            = LoaiDeTai.DeXuat
            };

            if (await UpLoadFile(vmodel.Files, model) == false)
            {
                return(Json(new { status = false, mess = MessageResult.UpLoadFileFail }));
            }
            try
            {
                Nhom nhom = new Nhom();
                await _serviceNhom.Add(nhom);

                NhomSinhVien nhomSinhVien = new NhomSinhVien {
                    Idnhom = nhom.Id, IdsinhVien = SV.Mssv
                };
                model.NhomSinhVien.Add(nhomSinhVien);
                await _service.Add(model);

                return(Json(new { status = true, create = true, data = model, mess = MessageResult.CreateSuccess }));
            }
            catch
            {
                return(Json(new { status = false, mess = MessageResult.Fail }));
            }
        }
Esempio n. 7
0
        public async Task <IActionResult> XuatBaoCaoChiTietDeTai(long id)
        {
            #region -- Lấy dữ liệu --
            DeTaiNghienCuu deTaiNghienCuu = await _service.GetById(id);

            //Dữ liệu nhóm
            var NhomSV = await _serviceNhomSV.GetAll(x => x.IddeTai == id);

            IEnumerable <Data.Models.SinhVien> sinhViens = NhomSV.Select(x => x.IdsinhVienNavigation);

            //Dữ liệu hội đồng xét duyệt
            IEnumerable <XetDuyetVaDanhGia> hoidongXetDuyet = await _serviceXetDuyet.GetAll(x => x.IddeTai == id && x.IdmoDotNavigation.Loai == (int)MoDotLoai.XetDuyetDeTai);


            //Dữ liệu hội đồng đánh giá nghiệm thu
            IEnumerable <XetDuyetVaDanhGia> hoidongNghiemThu = await _serviceXetDuyet.GetAll(x => x.IddeTai == id && x.IdmoDotNavigation.Loai == (int)MoDotLoai.NghiemThuDeTai);

            #endregion

            var stream = new MemoryStream();

            using (var package = new ExcelPackage(stream))
            {
                var Sheet1 = package.Workbook.Worksheets.Add("Báo cáo chi tiết đề tài");



                Sheet1.Cells["A1"].Style.Font.Bold           = true;
                Sheet1.Cells["A1"].Value                     = "TRƯỜNG ĐẠI HỌC SÀI GÒN";
                Sheet1.Cells["F1"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Right;
                Sheet1.Cells["F1"].Value                     = DateTime.Now.ToString("HH:mm, dd/MM/yyyy");
                Sheet1.Cells["A3:F3"].Merge                  = true;
                Sheet1.Cells["A3"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                Sheet1.Cells["A3"].Style.Font.Bold           = true;
                Sheet1.Cells["A3"].Value                     = "BÁO CÁO CHI TIẾT ĐỀ TÀI " + deTaiNghienCuu.TenDeTai.ToUpper();

                if (sinhViens.Any())
                {
                    #region -- Header Thông tin sinh viên --
                    Sheet1.Cells["A5"].Style.Font.Bold = true;
                    Sheet1.Cells["A5"].Value           = "Thông tin sinh viên";

                    Sheet1.Cells["A7:E7"].Style.Font.Bold           = true;
                    Sheet1.Cells["A7:E7"].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                    Sheet1.Cells["A7"].Value = "MSSV";
                    Sheet1.Cells["B7"].Value = "Họ tên";
                    Sheet1.Cells["C7"].Value = "SĐT";
                    Sheet1.Cells["D7"].Value = "Email";

                    #endregion

                    #region -- Details Thông tin sinh viên --
                    int rowSheet1 = 8;
                    foreach (var item in sinhViens)
                    {
                        Sheet1.Cells[string.Format("A{0}", rowSheet1)].Value = item.Mssv;
                        Sheet1.Cells[string.Format("B{0}", rowSheet1)].Value = item.Ho + " " + item.Ten;
                        Sheet1.Cells[string.Format("C{0}", rowSheet1)].Value = item.Sdt;
                        Sheet1.Cells[string.Format("D{0}", rowSheet1)].Value = item.Email;
                        rowSheet1++;
                    }

                    Sheet1.Cells["A7" + ":" + string.Format("D{0}", rowSheet1 - 1)].Style.Border.Top.Style    = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                    Sheet1.Cells["A7" + ":" + string.Format("D{0}", rowSheet1 - 1)].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                    Sheet1.Cells["A7" + ":" + string.Format("D{0}", rowSheet1 - 1)].Style.Border.Left.Style   = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                    Sheet1.Cells["A7" + ":" + string.Format("D{0}", rowSheet1 - 1)].Style.Border.Right.Style  = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                    #endregion


                    //Phần xét duyệt đề tài

                    int rowSheet2 = rowSheet1 + 1;
                    Sheet1.Cells["A" + (rowSheet2)].Style.Font.Bold = true;
                    Sheet1.Cells["A" + (rowSheet2)].Value           = "XÉT DUYỆT ĐỀ TÀI";

                    if (hoidongXetDuyet.Any())
                    {
                        foreach (var dot in hoidongXetDuyet)
                        {
                            #region -- Header Hội đồng xét duyệt --
                            rowSheet2 += 2;
                            Sheet1.Cells["A" + (rowSheet2)].Value = "Hội đồng: ";
                            Sheet1.Cells["B" + (rowSheet2)].Value = dot.IdhoiDongNavigation.TenHoiDong;

                            rowSheet2 += 1;
                            int rowStart = rowSheet2;
                            int rowEnd   = rowSheet2;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowSheet2, rowSheet2)].Style.Font.Bold           = true;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowSheet2, rowSheet2)].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                            Sheet1.Cells["A" + (rowSheet2)].Value = "Thành viên";
                            Sheet1.Cells["B" + (rowSheet2)].Value = "Vai trò";
                            Sheet1.Cells["C" + (rowSheet2)].Value = "Câu hỏi";
                            Sheet1.Cells["D" + (rowSheet2)].Value = "Câu trả lời";
                            Sheet1.Cells["E" + (rowSheet2)].Value = "Nhận xét";
                            Sheet1.Cells["F" + (rowSheet2)].Value = "Điểm";
                            #endregion

                            #region -- Details Hội đồng xét duyệt --
                            rowSheet2 += 1;
                            IEnumerable <CtxetDuyetVaDanhGia> ctXetDuyet = await _serviceCTXetDuyetVaDanhGia.GetAll(x => x.IdxetDuyetNavigation.IddeTai == id &&
                                                                                                                    x.IdxetDuyetNavigation.IdmoDotNavigation.Loai == (int)MoDotLoai.XetDuyetDeTai &&
                                                                                                                    x.IdxetDuyet == dot.Id);

                            foreach (var item in ctXetDuyet)
                            {
                                Sheet1.Cells[string.Format("A{0}", rowSheet2)].Value = item.IdgiangVienNavigation.Ho + " " + item.IdgiangVienNavigation.Ten;
                                if (item.VaiTro == 1)
                                {
                                    Sheet1.Cells[string.Format("B{0}", rowSheet2)].Value = "Chủ tịch";
                                }
                                else if (item.VaiTro == 2)
                                {
                                    Sheet1.Cells[string.Format("B{0}", rowSheet2)].Value = "Ủy viên";
                                }
                                else if (item.VaiTro == 3)
                                {
                                    Sheet1.Cells[string.Format("B{0}", rowSheet2)].Value = "Thư ký";
                                }
                                else
                                {
                                    Sheet1.Cells[string.Format("B{0}", rowSheet2)].Value = "Phản biện";
                                }
                                Sheet1.Cells[string.Format("C{0}", rowSheet2)].Value = item.CauHoi;
                                Sheet1.Cells[string.Format("D{0}", rowSheet2)].Value = item.CauTraLoi;
                                Sheet1.Cells[string.Format("E{0}", rowSheet2)].Value = item.NhanXet;
                                Sheet1.Cells[string.Format("F{0}", rowSheet2)].Value = item.Diem;
                                rowSheet2++;
                            }
                            Sheet1.Cells[string.Format("A{0}:E{1}", rowSheet2, rowSheet2)].Merge = true;
                            Sheet1.Cells["A" + rowSheet2].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                            Sheet1.Cells["A" + rowSheet2].Style.Font.Bold           = true;
                            Sheet1.Cells["A" + rowSheet2].Value = "Điểm trung bình";
                            Sheet1.Cells["F" + rowSheet2].Value = TinhDiemTrungBinh(dot.Id).Result;

                            rowEnd = rowSheet2;

                            rowSheet2 += 1;
                            Sheet1.Cells["A" + rowSheet2].Value = "KẾT QUẢ:";
                            if (TinhDiemTrungBinh(dot.Id).Result > dot.IdmoDotNavigation.DiemToiDa)
                            {
                                Sheet1.Cells["B" + rowSheet2].Value = "ĐẠT";
                            }
                            else if (TinhDiemTrungBinh(dot.Id).Result < dot.IdmoDotNavigation.DiemToiThieu)
                            {
                                Sheet1.Cells["B" + rowSheet2].Value = "KHÔNG ĐẠT";
                            }
                            else
                            {
                                Sheet1.Cells["B" + rowSheet2].Value = "DUYỆT LẠI";
                            }

                            Sheet1.Cells[string.Format("A{0}:F{1}", rowStart, rowEnd)].Style.Border.Top.Style    = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowStart, rowEnd)].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowStart, rowEnd)].Style.Border.Left.Style   = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowStart, rowEnd)].Style.Border.Right.Style  = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                            #endregion
                        }
                    }
                    else
                    {
                        Sheet1.Cells["A" + (rowSheet2)].Style.Font.Bold = true;
                        Sheet1.Cells["A" + (rowSheet2)].Value           = "ĐỀ TÀI CHƯA ĐƯỢC XÉT DUYỆT";
                    }


                    //Phần đánh giá nghiệm thu đề tài
                    int rowSheet3 = rowSheet2 + 2;
                    Sheet1.Cells["A" + (rowSheet3)].Style.Font.Bold = true;
                    Sheet1.Cells["A" + (rowSheet3)].Value           = "ĐÁNH GIÁ NGHIỆM THU ĐỀ TÀI";

                    if (hoidongNghiemThu.Any())
                    {
                        foreach (var dot in hoidongNghiemThu)
                        {
                            #region -- Header Hội đồng nghiệm thu --
                            rowSheet3 += 2;
                            Sheet1.Cells["A" + (rowSheet3)].Value = "Hội đồng: ";
                            Sheet1.Cells["B" + (rowSheet3)].Value = dot.IdhoiDongNavigation.TenHoiDong;

                            rowSheet3 += 1;
                            int rowStart = rowSheet3;
                            int rowEnd   = rowSheet3;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowSheet3, rowSheet3)].Style.Font.Bold           = true;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowSheet3, rowSheet3)].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                            Sheet1.Cells["A" + (rowSheet3)].Value = "Thành viên";
                            Sheet1.Cells["B" + (rowSheet3)].Value = "Vai trò";
                            Sheet1.Cells["C" + (rowSheet3)].Value = "Câu hỏi";
                            Sheet1.Cells["D" + (rowSheet3)].Value = "Câu trả lời";
                            Sheet1.Cells["E" + (rowSheet3)].Value = "Nhận xét";
                            Sheet1.Cells["F" + (rowSheet3)].Value = "Điểm";
                            #endregion

                            #region -- Details Hội đồng nghiệm thu --
                            rowSheet3 += 1;
                            IEnumerable <CtxetDuyetVaDanhGia> ctXetDuyet = await _serviceCTXetDuyetVaDanhGia.GetAll(x => x.IdxetDuyetNavigation.IddeTai == id &&
                                                                                                                    x.IdxetDuyetNavigation.IdmoDotNavigation.Loai == (int)MoDotLoai.NghiemThuDeTai &&
                                                                                                                    x.IdxetDuyet == dot.Id);

                            foreach (var item in ctXetDuyet)
                            {
                                Sheet1.Cells[string.Format("A{0}", rowSheet3)].Value = item.IdgiangVienNavigation.Ho + " " + item.IdgiangVienNavigation.Ten;
                                if (item.VaiTro == 1)
                                {
                                    Sheet1.Cells[string.Format("B{0}", rowSheet3)].Value = "Chủ tịch";
                                }
                                else if (item.VaiTro == 2)
                                {
                                    Sheet1.Cells[string.Format("B{0}", rowSheet3)].Value = "Ủy viên";
                                }
                                else if (item.VaiTro == 3)
                                {
                                    Sheet1.Cells[string.Format("B{0}", rowSheet3)].Value = "Thư ký";
                                }
                                else
                                {
                                    Sheet1.Cells[string.Format("B{0}", rowSheet3)].Value = "Phản biện";
                                }
                                Sheet1.Cells[string.Format("C{0}", rowSheet3)].Value = item.CauHoi;
                                Sheet1.Cells[string.Format("D{0}", rowSheet3)].Value = item.CauTraLoi;
                                Sheet1.Cells[string.Format("E{0}", rowSheet3)].Value = item.NhanXet;
                                Sheet1.Cells[string.Format("F{0}", rowSheet3)].Value = item.Diem;
                                rowSheet3++;
                            }
                            Sheet1.Cells[string.Format("A{0}:E{1}", rowSheet3, rowSheet3)].Merge = true;
                            Sheet1.Cells["A" + rowSheet3].Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                            Sheet1.Cells["A" + rowSheet3].Style.Font.Bold           = true;
                            Sheet1.Cells["A" + rowSheet3].Value = "Điểm trung bình";
                            Sheet1.Cells["F" + rowSheet3].Value = TinhDiemTrungBinh(dot.Id).Result;

                            rowEnd = rowSheet3;

                            rowSheet3 += 1;
                            Sheet1.Cells["A" + rowSheet3].Value = "KẾT QUẢ:";
                            if (TinhDiemTrungBinh(dot.Id).Result > dot.IdmoDotNavigation.DiemToiDa)
                            {
                                Sheet1.Cells["B" + rowSheet3].Value = "ĐẠT";
                            }
                            else if (TinhDiemTrungBinh(dot.Id).Result < dot.IdmoDotNavigation.DiemToiThieu)
                            {
                                Sheet1.Cells["B" + rowSheet3].Value = "KHÔNG ĐẠT";
                            }
                            else
                            {
                                Sheet1.Cells["B" + rowSheet3].Value = "DUYỆT LẠI";
                            }

                            Sheet1.Cells[string.Format("A{0}:F{1}", rowStart, rowEnd)].Style.Border.Top.Style    = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowStart, rowEnd)].Style.Border.Bottom.Style = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowStart, rowEnd)].Style.Border.Left.Style   = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                            Sheet1.Cells[string.Format("A{0}:F{1}", rowStart, rowEnd)].Style.Border.Right.Style  = OfficeOpenXml.Style.ExcelBorderStyle.Thin;
                            #endregion
                        }
                    }
                    else
                    {
                        Sheet1.Cells["A" + (rowSheet3)].Style.Font.Bold = true;
                        Sheet1.Cells["A" + (rowSheet3)].Value           = "ĐỀ TÀI CHƯA ĐƯỢC ĐÁNH GIÁ NGHIỆM THU";
                    }
                }
                else
                {
                    Sheet1.Cells["A5"].Style.Font.Bold = true;
                    Sheet1.Cells["A5"].Value           = "ĐỀ TÀI CHƯA ĐƯỢC THỰC HIỆN";
                }

                #region -- Footer --
                Sheet1.Cells["A:AZ"].AutoFitColumns();
                #endregion

                package.Save();
            }

            stream.Position = 0;
            var filename = $"BaoCaoChiTietDeTai.xlsx";
            return(File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", filename));
        }
Esempio n. 8
0
        public async Task <IActionResult> Index()
        {
            DeTaiNghienCuu DetaiXetDuyet = (from t0 in _context.DeTaiNghienCuu
                                            join t1 in _context.XetDuyetVaDanhGia on t0.Id equals t1.IddeTai
                                            join t2 in _context.NhomSinhVien on t0.Id equals t2.IddeTai
                                            where t2.IdsinhVien == long.Parse(User.Identity.Name) &&
                                            t2.IdnhomNavigation.Status == 1 && t1.Status == 1
                                            select t0).SingleOrDefault();
            List <CtxetDuyetVaDanhGia> ct = new List <CtxetDuyetVaDanhGia>();

            if (DetaiXetDuyet != null)
            {
                ViewBag.TenDeTai = DetaiXetDuyet.TenDeTai;
                var xetDuyetVaDanhGia = DetaiXetDuyet.XetDuyetVaDanhGia.SingleOrDefault(x => x.Status == 1);
                if (xetDuyetVaDanhGia != null)
                {
                    ViewBag.XDDG = xetDuyetVaDanhGia;
                    ct           = xetDuyetVaDanhGia.CtxetDuyetVaDanhGia.ToList();
                    double diemtb = 0;
                    int    chia   = 0;
                    foreach (var item in ct)
                    {
                        if (item.Diem.HasValue)
                        {
                            if (item.VaiTro == (int)LoaiVaiTro.PhanBien)
                            {
                                diemtb = diemtb + (2 * item.Diem.Value);
                                chia   = chia + 2;
                            }
                            else
                            {
                                diemtb = diemtb + item.Diem.Value;
                                chia++;
                            }
                        }
                    }
                    if (chia == 0)
                    {
                        ViewBag.DiemTB = 0;
                    }
                    else
                    {
                        ViewBag.DiemTB = diemtb / chia * 1.0;
                    }
                }
            }

            MoDot moDot = await _serviceMoDot.GetEntity(x => x.Status == (int)MoDotStatus.Mo && x.Loai == (int)MoDotLoai.NghiemThuDeTai);

            if (moDot != null)
            {
                ViewBag.Dot = moDot;
                if (DateTime.Now >= moDot.ThoiGianBd && DateTime.Now <= moDot.ThoiGianKt)
                {
                    double thoigian = (moDot.ThoiGianKt - DateTime.Now).Value.TotalSeconds;
                    HttpContext.Response.Headers.Add("refresh", "" + thoigian + "; url=" + Url.Action("Index"));
                    ViewBag.DangMoDot = true;
                }
                else
                {
                    ViewBag.DangMoDot = false;
                }
            }
            else
            {
                ViewBag.DangMoDot = false;
            }
            return(View(ct));
        }
Esempio n. 9
0
        public async Task <IActionResult> ChangeStatus(long[] data, int type)
        {
            if (data.Count() == 0)
            {
                return(Ok(new
                {
                    status = false,
                    mess = MessageResult.NotSelectDeTai
                }));
            }
            DeTaiNghienCuu entity = new DeTaiNghienCuu();

            foreach (long item in data)
            {
                entity = await _service.GetById(item);

                var isAuthorize = await _authorizationService.AuthorizeAsync(User, entity, DeTaiNghienCuuOperation.Update);

                if (!isAuthorize.Succeeded)
                {
                    return(Ok(new
                    {
                        status = false,
                        toastr = MessageResult.AccessDenied
                    }));
                }
                if (type == 2) // xoa detai
                {
                    await _service.Delete(entity);

                    return(Ok(new
                    {
                        status = true,
                        mess = MessageResult.UpdateSuccess
                    }));
                }
                else if (type == 0) // gui duyet dang ky
                {
                    if (entity.TinhTrangPheDuyet == (int)StatusPheDuyet.GuiDangKy)
                    {
                        return(Ok(new
                        {
                            status = false,
                            toastr = "Đã gửi yêu cầu đăng ký cho đề tài " + entity.Id
                        }));
                    }
                    entity.TinhTrangPheDuyet = (int)StatusPheDuyet.GuiDangKy;
                    YeuCauPheDuyet yeuCau = new YeuCauPheDuyet
                    {
                        LoaiYeuCau = (int)LoaiYeuCauPheDuyet.DuyetDangKy,
                        NgayTao    = DateTime.Now,
                    };
                    entity.YeuCauPheDuyet.Add(yeuCau);
                }
                else // huy gui
                {
                    if (entity.TinhTrangPheDuyet != (int)StatusPheDuyet.ChuaCoYeuCau)
                    {
                        entity.TinhTrangPheDuyet = (int)StatusPheDuyet.ChuaCoYeuCau;
                        var yeuCau = entity.YeuCauPheDuyet.FirstOrDefault(x => x.Status == (int)StatusYeuCauPheDuyet.ChuaXuLy);
                        entity.YeuCauPheDuyet.Remove(yeuCau);
                    }
                    else
                    {
                        return(Ok(new
                        {
                            status = false,
                            toastr = "Đề tài " + entity.Id + " chưa gửi đăng ký"
                        }));
                    }
                }
            }
            await _service.Update(entity);

            return(Ok(new
            {
                status = true,
                mess = MessageResult.UpdateSuccess
            }));
        }