Exemple #1
0
        public async Task <IActionResult> Create(MoDot moDot)
        {
            var allXDDG = await _serviceXDDG.GetAll();

            if (allXDDG.Any())
            {
                foreach (var item in allXDDG)
                {
                    item.Status = 0;
                    await _serviceXDDG.Update(item);
                }
            }
            var HoiDong = await _serviceHoiDong.GetAll();

            if (HoiDong.Any())
            {
                foreach (var item in HoiDong)
                {
                    item.StatusPhanCong = (int)StatusPhanCong.ChuaPhanCong;
                    await _serviceHoiDong.Update(item);
                }
            }
            var DeTai = await _serviceDeTai.GetAll();

            if (DeTai.Any())
            {
                foreach (var item in DeTai)
                {
                    item.TinhTrangPhanCong = (int)StatusPhanCong.ChuaPhanCong;
                    await _serviceDeTai.Update(item);
                }
            }
            if (moDot.Loai == (int)MoDotLoai.DangKy)
            {
                var Nhom = await _serviceNhom.GetAll();

                if (Nhom.Any())
                {
                    foreach (var item in Nhom)
                    {
                        item.Status = (int)BaseStatus.Disable;
                        await _serviceNhom.Update(item);
                    }
                }
            }
            moDot.Status   = 1;
            moDot.IdquanLy = long.Parse(User.Identity.Name);
            await _service.Add(moDot);

            return(RedirectToAction("Index", new { mess = "Mở đợt thành công" }));
        }
Exemple #2
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));
        }