Ejemplo n.º 1
0
        public JsonResult DeleteLichCongTac(long id)
        {
            AssignUserInfo();
            JsonResultBO result = new JsonResultBO(true);

            lichCongTacBusiness = Get <LICHCONGTACBusiness>();
            qlDangKyXeBusiness  = Get <QL_DANGKY_XEBusiness>();

            LICHCONGTAC calendar = lichCongTacBusiness.Find(id);

            if (calendar != null && calendar.IS_DELETE != true && calendar.NGUOITAO == currentUser.ID)
            {
                calendar.IS_DELETE = true;
                lichCongTacBusiness.Save(calendar);

                //kiểm tra lịch công tác có đăng ký xe hay không?
                //nếu có thì hủy lịch đăng ký xe
                QL_DANGKY_XE registration = qlDangKyXeBusiness.GetAvailableRegistrationByCalendarId(id);
                if (registration != null)
                {
                    registration.IS_DELETE = true;
                    qlDangKyXeBusiness.Save(registration);
                }
            }
            else
            {
                result.Status  = false;
                result.Message = "Không tìm thấy lịch công tác";
            }
            return(Json(result));
        }
Ejemplo n.º 2
0
        public ActionResult Details(long id)
        {
            AssignUserInfo();
            qlDangKyXeBusiness  = Get <QL_DANGKY_XEBusiness>();
            lichCongTacBusiness = Get <LICHCONGTACBusiness>();
            DangKyXeBO entity = qlDangKyXeBusiness.GetDetail(id);

            if (entity != null && entity.CCTC_THANHPHAN_ID == currentUser.DeptParentID.GetValueOrDefault())
            {
                DangKyXeDetailViewModel viewModel = new DangKyXeDetailViewModel();

                viewModel.canSendRegistration = entity.TRANGTHAI == TRANGTHAI_DANGKY_XE_CONSTANT.MOITAO_ID &&
                                                entity.NGUOITAO == currentUser.ID;
                viewModel.canRecieveRegistratiion = currentUser.ListThaoTac
                                                    .Where(x => x.MA_THAOTAC == CONFIRM_CAR_REGISTRATION).FirstOrDefault() != null &&
                                                    entity.TRANGTHAI == TRANGTHAI_DANGKY_XE_CONSTANT.DAGUI_ID;
                viewModel.currentUserId  = currentUser.ID;
                viewModel.entity         = entity;
                viewModel.entityCalendar = lichCongTacBusiness.repository.All()
                                           .Where(x => x.IS_DELETE != true && x.IS_LATTEST == true && x.ID == entity.LICHCONGTAC_ID)
                                           .FirstOrDefault();
                return(View(viewModel));
            }
            return(Redirect("/Home/UnAuthor"));
        }
Ejemplo n.º 3
0
        public PartialViewResult EditFastLichCongTac(int year, int month, int day, int hour = 0, int minute = 0, long id = 0)
        {
            AssignUserInfo();
            lichCongTacBusiness   = Get <LICHCONGTACBusiness>();
            dmNguoiDungBusiness   = Get <DM_NGUOIDUNGBusiness>();
            dmDanhMucDataBusiness = Get <DM_DANHMUC_DATABusiness>();

            EditLichCongTacViewModel model = new EditLichCongTacViewModel();
            List <long> groupLanhDaoIds    = new List <long>();
            long        userId             = 0;

            if (id > 0)
            {
                LICHCONGTAC entity = lichCongTacBusiness.Find(id);
                if (entity != null && entity.IS_DELETE != true && entity.NGAY_CONGTAC.IsOldWeek() == false)
                {
                    model  = new EditLichCongTacViewModel(entity);
                    userId = entity.LANHDAO_ID.GetValueOrDefault();
                }
            }
            else
            {
                LICHCONGTAC entity = new LICHCONGTAC();
                entity.NGAY_CONGTAC = new DateTime(year, month, day);
                entity.GIO_CONGTAC  = hour;
                entity.PHUT_CONGTAC = minute;
                model = new EditLichCongTacViewModel(entity);
            }
            model.groupOfLanhDaos     = dmNguoiDungBusiness.GetDropDownByDeptParentId(currentUser.DeptParentID.GetValueOrDefault(), userId);
            model.groupOfDestinations = dmDanhMucDataBusiness.GetGroupTextByCode(DMLOAI_CONSTANT.DIEM_DEN);
            model.isPopUp             = true;
            return(PartialView("_EditFastLichCongTac", model));
        }
Ejemplo n.º 4
0
        public JsonResult GetInfoLichCongTac(long id)
        {
            lichCongTacBusiness = Get <LICHCONGTACBusiness>();
            LICHCONGTAC calendar = lichCongTacBusiness.Find(id);

            if (calendar != null && calendar.IS_DELETE != true)
            {
                return(Json(calendar));
            }
            return(Json(new LICHCONGTAC()));
        }
Ejemplo n.º 5
0
        public PartialViewResult DetailLichCongTac(long id, bool isShowCarRegistration = false)
        {
            qlDangKyXeBusiness  = Get <QL_DANGKY_XEBusiness>();
            lichCongTacBusiness = Get <LICHCONGTACBusiness>();
            LichCongTacDetailViewModel viewModel = new LichCongTacDetailViewModel();

            viewModel.calendarEntity        = lichCongTacBusiness.GetDetailLichCongTac(id);
            viewModel.isShowCarRegistration = isShowCarRegistration;
            if (isShowCarRegistration)
            {
                viewModel.carRegistrationEntity = qlDangKyXeBusiness.GetAvailableRegistrationByCalendarId(id);
            }
            return(PartialView("_DetailLichCongTac", viewModel));
        }
Ejemplo n.º 6
0
        public JsonResult SendEmail(FormCollection fc)
        {
            JsonResultBO result = new JsonResultBO(false);

            lichCongTacBusiness = Get <LICHCONGTACBusiness>();
            dmNguoiDungBusiness = Get <DM_NGUOIDUNGBusiness>();

            DateTime           currentDate = DateTime.Now;
            var                startOfWeek = currentDate.GetStartDayOfWeek();
            var                endOfWeek   = currentDate.GetEndDayOfWeek();
            LICHCONGTAC_SEARCH searchModel = new LICHCONGTAC_SEARCH();

            searchModel.startDate = startOfWeek;
            searchModel.endDate   = endOfWeek;
            List <long> userIds = fc["LANHDAO_ID"].ToListLong(',');
            string      subject = fc["TIEUDE"].Trim();

            string emailTemplatePath = Path.Combine(ConfigurationManager.AppSettings["FileUpload"], ConfigurationManager.AppSettings["LichCongTacEmailTemplate"]);
            string emailContent      = System.IO.File.ReadAllText(emailTemplatePath);

            foreach (var item in userIds)
            {
                DM_NGUOIDUNG user = dmNguoiDungBusiness.Find(item);
                if (user != null && string.IsNullOrEmpty(user.EMAIL) == false)
                {
                    searchModel.leaderId = user.ID;
                    List <LICHCONGTAC_BO> calendars        = lichCongTacBusiness.GetListLichCongTacs(searchModel);
                    List <LICHCONGTAC_BO> deletedCalendars = lichCongTacBusiness.GetListDeletedLichCongTacs(searchModel);
                    emailContent = emailContent.Replace("[[recipient]]", user.HOTEN);
                    emailContent = emailContent.Replace("[[week_header_title]]", currentDate.GetWeekNumber() + " (từ ngày " + startOfWeek.ToVietnameseDateFormat() + " đến ngày " + endOfWeek.ToVietnameseDateFormat() + ")");
                    emailContent = emailContent.Replace("[[week_title]]", currentDate.GetNameOfWeek() + " năm " + currentDate.Year);
                    emailContent = emailContent.Replace("[[week_start_end_date_title]]", currentDate.GetNameOfWeek() +
                                                        " (" + startOfWeek.GetNameOfDay() + ", "
                                                        + startOfWeek.ToVietnameseDateFormat() + " - "
                                                        + endOfWeek.GetNameOfDay() + ", "
                                                        + endOfWeek.ToVietnameseDateFormat() + ")");
                    emailContent = emailContent.Replace("[[email_main_content]]", this.GenerateLichCongTacEmailContent(calendars));
                    emailContent = emailContent.Replace("[[email_error_content]]", this.GenerateLichCongTacDeleteEmailContent(deletedCalendars));
                    List <string> address = new List <string>()
                    {
                        user.EMAIL
                    };
                    EmailProvider.sendEmail(emailContent, subject, address);
                }
            }
            result.Status = true;
            return(Json(result));
        }
Ejemplo n.º 7
0
        public PartialViewResult GetCalendarToRegisterCar(FormCollection collection)
        {
            lichCongTacBusiness = Get <LICHCONGTACBusiness>();
            LICHCONGTAC_SEARCH searchModel = new LICHCONGTAC_SEARCH();

            searchModel.leaderId  = collection["CAL_LANHDAO_ID"].ToIntOrNULL();
            searchModel.startDate = collection["CAL_NGAYBATDAU"].ToDateTime();
            searchModel.endDate   = collection["CAL_NGAYKETTHUC"].ToDateTime();
            LichCongTacByDayViewModel viewModel = new LichCongTacByDayViewModel();

            viewModel.groupDateEntities = lichCongTacBusiness.GetListLichCongTacs(searchModel)
                                          .GroupBy(x => x.NGAY_CONGTAC).OrderBy(x => x.Key)
                                          .Select(x => new LichCongTacDateEntity()
            {
                title            = x.Key.GetNameOfDay() + " (" + x.Key.ToVietnameseDateFormat() + ")",
                groupOfCalendars = x.OrderBy(y => y.GIO_CONGTAC).ThenBy(y => y.PHUT_CONGTAC).ToList()
            }).ToList();
            return(PartialView("_ListLichCongTacRegisterCar", viewModel));
        }
Ejemplo n.º 8
0
        public PartialViewResult LichCongTacCanBoTrongNgay(long userId, DateTime date)
        {
            AssignUserInfo();
            lichCongTacBusiness = Get <LICHCONGTACBusiness>();
            LichCongTacByDayViewModel viewModel = new LichCongTacByDayViewModel();

            viewModel.startDate         = new DateTime(date.Year, date.Month, date.Day);
            viewModel.currentUserId     = currentUser.ID;
            viewModel.title             = "LỊCH CÔNG TÁC CỦA CÁN BỘ TRONG TUẦN";
            viewModel.groupDateEntities = lichCongTacBusiness.GetLichCongTacOfUserByWeek(userId, date)
                                          .GroupBy(x => x.NGAY_CONGTAC).OrderBy(x => x.Key)
                                          .Select(x => new LichCongTacDateEntity()
            {
                date             = x.Key,
                title            = x.Key.GetNameOfDay() + " (" + x.Key.ToVietnameseDateFormat() + ")",
                groupOfCalendars = x.OrderBy(y => y.GIO_CONGTAC).ThenBy(y => y.PHUT_CONGTAC).ToList()
            }).ToList();
            return(PartialView("_LichCongTacOfUserByDay", viewModel));
        }
Ejemplo n.º 9
0
        public ActionResult UpdateLichCongTac(long id)
        {
            AssignUserInfo();
            JsonResultBO editResult = new JsonResultBO(true);

            cctcThanhPhanBusiness = Get <CCTC_THANHPHANBusiness>();
            dmNguoiDungBusiness   = Get <DM_NGUOIDUNGBusiness>();
            lichCongTacBusiness   = Get <LICHCONGTACBusiness>();
            dmDanhMucDataBusiness = Get <DM_DANHMUC_DATABusiness>();

            LICHCONGTAC entity = lichCongTacBusiness.Find(id);

            if (entity != null && entity.IS_DELETE != true && entity.NGAY_CONGTAC.IsOldWeek() == false)
            {
                EditLichCongTacViewModel model = new EditLichCongTacViewModel(entity);
                model.groupOfLanhDaos     = dmNguoiDungBusiness.GetDropDownByDeptParentId(currentUser.DeptParentID.GetValueOrDefault(), entity.LANHDAO_ID.GetValueOrDefault());
                model.groupOfDestinations = dmDanhMucDataBusiness.GetGroupTextByCode(DMLOAI_CONSTANT.DIEM_DEN);
                return(View("EditLichCongTac", model));
            }
            return(Redirect("/Home/UnAuthor"));
        }
Ejemplo n.º 10
0
        public ActionResult Create(long calendarId = 0)
        {
            AssignUserInfo();
            dmNguoiDungBusiness   = Get <DM_NGUOIDUNGBusiness>();
            lichCongTacBusiness   = Get <LICHCONGTACBusiness>();
            qlDangKyXeBusiness    = Get <QL_DANGKY_XEBusiness>();
            dmDanhMucDataBusiness = Get <DM_DANHMUC_DATABusiness>();

            DangKyXeEditViewModel model = new DangKyXeEditViewModel();

            model.dangKyXeEntity.DIEM_XUATPHAT = DEFAULT_START_POINT;
            model.groupOfLanhDaos = dmNguoiDungBusiness.GetListUserByDeptParentId(currentUser.DeptParentID.GetValueOrDefault(), 0);
            if (calendarId != 0)
            {
                LICHCONGTAC calendar = lichCongTacBusiness.Find(calendarId);
                //kiểm tra lịch công tác chưa bị xóa - mới nhất - chưa được đăng ký
                if (calendar != null && calendar.IS_DELETE != true && calendar.IS_LATTEST == true)
                {
                    QL_DANGKY_XE registration = qlDangKyXeBusiness.GetAvailableRegistrationByCalendarId(calendarId);
                    if (registration == null)
                    {
                        registration = new QL_DANGKY_XE();
                        registration.LICHCONGTAC_ID = calendar.ID;
                        registration.CANBO_ID       = calendar.LANHDAO_ID;
                        registration.MUCDICH        = calendar.TIEUDE;
                        registration.NGAY_XUATPHAT  = calendar.NGAY_CONGTAC;
                        registration.GIO_XUATPHAT   = calendar.GIO_CONGTAC;
                        registration.PHUT_XUATPHAT  = calendar.PHUT_CONGTAC;
                        registration.DIEM_KETTHUC   = calendar.DIADIEM;
                        registration.GHICHU         = calendar.GHICHU;
                        model = new DangKyXeEditViewModel(registration);
                        model.groupOfLanhDaos = dmNguoiDungBusiness
                                                .GetListUserByDeptParentId(currentUser.DeptParentID.GetValueOrDefault(), calendar.LANHDAO_ID.GetValueOrDefault());
                    }
                }
            }
            model.groupOfStartPoints  = dmDanhMucDataBusiness.GetGroupTextByCode(DMLOAI_CONSTANT.DIEM_XUATPHAT);
            model.groupOfDestinations = dmDanhMucDataBusiness.GetGroupTextByCode(DMLOAI_CONSTANT.DIEM_DEN);
            return(View("EditDangKyXe", model));
        }
        public ActionResult DetailVanBanDen(long id, int type = VANBANDEN_CONSTANT.CHUA_XULY)
        {
            AssignUserInfo();
            wfItemUserProcess     = Get <WF_ITEM_USER_PROCESSBusiness>();
            wfReviewUserBusiness  = Get <WF_REVIEW_USERBusiness>();
            dmDanhMucDataBusiness = Get <DM_DANHMUC_DATABusiness>();
            hscvVanBanDenBusiness = Get <HSCV_VANBANDENBusiness>();
            attachmentBusiness    = Get <TAILIEUDINHKEMBusiness>();
            var            HSCVREADVANBANBusiness = Get <HSCVREADVANBANBusiness>();
            HSCV_VANBANDEN entityVanBanDen        = hscvVanBanDenBusiness.Find(id);
            bool           canAccess = wfItemUserProcess.CheckPermissionProcess(id, true == entityVanBanDen.IS_NOIBO ? MODULE_CONSTANT.VANBANDENNOIBO : MODULE_CONSTANT.VANBANDEN, currentUser.ID);
            bool           canReview = wfReviewUserBusiness.CheckPermissionReview(id, true == entityVanBanDen.IS_NOIBO ? MODULE_CONSTANT.VANBANDENNOIBO : MODULE_CONSTANT.VANBANDEN, currentUser.ID);

            if ((!canAccess && !canReview) || entityVanBanDen == null)
            {
                return(Redirect("/Home/UnAuthor"));
            }

            var checkread = HSCVREADVANBANBusiness.repository.All()
                            .Where(x => x.USER_ID == currentUser.ID && x.TYPE == 1 && x.VANBAN_ID == id).FirstOrDefault();

            if (checkread == null)
            {
                HSCV_READVANBAN readObj = new HSCV_READVANBAN();
                readObj.TYPE      = 1;
                readObj.USER_ID   = currentUser.ID;
                readObj.VANBAN_ID = id;
                HSCVREADVANBANBusiness.Save(readObj);
            }

            DetailVanBanDenViewModel model                    = new DetailVanBanDenViewModel();
            DM_DANHMUC_DATA          entityDonViGui           = dmDanhMucDataBusiness.Find(entityVanBanDen.DONVI_ID);
            DM_DANHMUC_DATA          entityDoKhan             = dmDanhMucDataBusiness.Find(entityVanBanDen.DOKHAN_ID);
            DM_DANHMUC_DATA          entityDoUuTien           = dmDanhMucDataBusiness.Find(entityVanBanDen.DOMAT_ID);
            DM_DANHMUC_DATA          entityLinhVucVanBan      = dmDanhMucDataBusiness.Find(entityVanBanDen.LINHVUCVANBAN_ID);
            DM_DANHMUC_DATA          entityLoaiVanBan         = dmDanhMucDataBusiness.Find(entityVanBanDen.LOAIVANBAN_ID);
            DM_DANHMUC_DATA          entityLoaiCoQuan         = dmDanhMucDataBusiness.Find(entityVanBanDen.LOAI_COQUAN_ID);
            DM_DANHMUC_DATA          entityThongTinLoaiVanBan = dmDanhMucDataBusiness.Find(entityVanBanDen.THONGTIN_LOAI_ID);
            DM_DANHMUC_DATA          entityCongVanDen         = dmDanhMucDataBusiness.Find(entityVanBanDen.CONGVAN_DEN_ID);

            model.currentUserId         = currentUser.ID;
            model.entityVanBanDen       = entityVanBanDen;
            model.nameOfDonViGui        = entityDonViGui != null ? entityDonViGui.TEXT : string.Empty;
            model.nameOfDoKhan          = entityDoKhan != null ? entityDoKhan.TEXT : string.Empty;
            model.nameOfDoUuTien        = entityDoUuTien != null ? entityDoUuTien.TEXT : string.Empty;
            model.nameOfLinhVucVanBan   = entityLinhVucVanBan != null ? entityLinhVucVanBan.TEXT : string.Empty;
            model.nameOfLoaiVanBan      = entityLoaiVanBan != null ? entityLoaiVanBan.TEXT : string.Empty;
            model.nameOfLoaiCoQuan      = entityLoaiCoQuan != null ? entityLoaiCoQuan.TEXT : string.Empty;
            model.nameOfThongTinLoaiBan = entityThongTinLoaiVanBan != null ? entityThongTinLoaiVanBan.TEXT : string.Empty;
            model.nameOfCongVanDen      = entityCongVanDen != null ? entityCongVanDen.TEXT : string.Empty;

            model.groupOfTaiLieuDinhKems = attachmentBusiness.GetDataByItemID(entityVanBanDen.ID, LOAITAILIEU.VANBANDEN);
            model.typeOfVanBanDen        = type;

            bool isFinish = hscvVanBanDenBusiness.CheckIsFinish(id);

            model.canCreateCalendar = (entityVanBanDen.NGUOITAO == currentUser.ID && isFinish);
            if (isFinish == false && entityVanBanDen.NGAYCONGTAC != null)
            {
                //kiểm tra người dùng có bước xử lý hay không?
                bool hasSteps = false;
                wfProcessBusiness       = Get <WF_PROCESSBusiness>();
                wfReviewUserBusiness    = Get <WF_REVIEW_USERBusiness>();
                wfReviewBusiness        = Get <WF_REVIEWBusiness>();
                wfStateBusiness         = Get <WF_STATEBusiness>();
                wfStepBusiness          = Get <WF_STEPBusiness>();
                wfStateFunctionBusiness = Get <WF_STATE_FUNCTIONBusiness>();

                WF_PROCESS process = wfProcessBusiness.repository.All()
                                     .Where(x => x.ITEM_ID == id && x.ITEM_TYPE == MODULE_CONSTANT.VANBANDEN &&
                                            x.USER_ID == currentUser.ID).FirstOrDefault();

                WF_REVIEW reviewReject = wfReviewBusiness.repository.All()
                                         .Where(x => x.ITEMID == id && x.ITEMTYPE == MODULE_CONSTANT.VANBANDEN && x.IS_REJECT == true)
                                         .OrderByDescending(x => x.ID).FirstOrDefault();

                WF_FUNCTION       function      = null;
                bool              requireReview = false;
                List <WF_STEP>    nextSteps     = new List <WF_STEP>();
                List <StepBackBO> stepsBack     = new List <StepBackBO>();

                if (process != null)
                {
                    if (process != null || reviewReject != null)
                    {
                        WF_STATE startState = wfStateBusiness.Find(process.CURRENT_STATE);
                        if (startState != null)
                        {
                            if (startState.IS_KETTHUC != true)
                            {
                                nextSteps = wfStepBusiness.GetListNextStep(process.WF_ID.GetValueOrDefault(), startState.ID);
                                stepsBack = wfStepBusiness.GetListNextStepBack(process);
                            }

                            function = wfStateFunctionBusiness.CheckGetFunction(startState.ID, entityVanBanDen.ID, MODULE_CONSTANT.VANBANDEN);
                        }
                    }
                    else if (process.IS_PENDING == true)
                    {
                        WF_REVIEW reviewFinish = wfReviewBusiness.repository.All()
                                                 .Where(x => x.ITEMID == id && x.ITEMTYPE == MODULE_CONSTANT.VANBANDEN && x.IS_FINISH != true)
                                                 .OrderByDescending(x => x.ID).FirstOrDefault();
                        if (reviewFinish != null)
                        {
                            requireReview = wfReviewUserBusiness.CheckReviewing(reviewFinish.ID, currentUser.ID);
                        }
                    }

                    hasSteps = (nextSteps.Any() || stepsBack.Any() || function != null || requireReview == true);
                }
                model.hasSteps = hasSteps;
                if (hasSteps)
                {
                    entityVanBanDen.NGAYCONGTAC = new DateTime(entityVanBanDen.NGAYCONGTAC.Value.Year, entityVanBanDen.NGAYCONGTAC.Value.Month, entityVanBanDen.NGAYCONGTAC.Value.Day);
                    lichCongTacBusiness         = Get <LICHCONGTACBusiness>();
                    model.isDuplicateCalendar   = lichCongTacBusiness.repository.All()
                                                  .Where(x => x.LANHDAO_ID == currentUser.ID &&
                                                         x.NGAY_CONGTAC.Equals(entityVanBanDen.NGAYCONGTAC.Value)).Count() > 0;
                }
            }

            return(View(model));
        }
Ejemplo n.º 12
0
        public List <string> GetListPropertiesChangedOfCalendar(LICHCONGTAC_BO calendar, LICHCONGTACBusiness lichCongTacBusiness)
        {
            List <string> result     = new List <string>();
            Type          entityType = typeof(LICHCONGTAC);

            if (calendar.LICH_GOC_ID != null)
            {
                LICHCONGTAC oldEntity = lichCongTacBusiness.Find(calendar.LICH_GOC_ID);
                LICHCONGTAC newEntity = lichCongTacBusiness.Find(calendar.ID);
                if (oldEntity != null && newEntity != null)
                {
                    foreach (string propertyName in arrProperties)
                    {
                        PropertyInfo propertyInfo = entityType.GetProperty(propertyName);
                        var          oldValue     = propertyInfo.GetValue(oldEntity);
                        var          newValue     = propertyInfo.GetValue(newEntity);
                        if (oldValue != newValue)
                        {
                            result.Add(propertyName);
                        }
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 13
0
        private string GenerateLichCongTacDeleteEmailContent(List <LICHCONGTAC_BO> calendars)
        {
            string result = string.Empty;

            lichCongTacBusiness = Get <LICHCONGTACBusiness>();

            var groupDateEntities = calendars
                                    .GroupBy(x => x.NGAY_CONGTAC).OrderBy(x => x.Key)
                                    .Select(x => new LichCongTacDateEntity()
            {
                date             = x.Key,
                groupOfCalendars = x.OrderBy(y => y.GIO_CONGTAC).ThenBy(y => y.PHUT_CONGTAC).ToList()
            }).ToList();

            if (groupDateEntities.Any())
            {
                result += "<table style = 'width:100%;font-size:13px;border-color:#ddd;border-collapse: collapse' border = '1'>";
                result += "<thead>";
                result += "<tr style ='font-weight:bold;'>";
                result += "<th style ='width:10%;border: 1px solid #ddd'>Ngày</th>";
                result += "<th style ='border:1px solid #ddd'> Sáng </th>";
                result += "<th style ='border:1px solid #ddd'> Chiều </th>";
                result += "</tr>";
                result += "</thead>";
                result += "<tbody>";
                foreach (var entity in groupDateEntities)
                {
                    var morningCalendars   = entity.groupOfCalendars.Where(x => x.GIO_CONGTAC <= 12).ToList();
                    var afternoonCalendars = entity.groupOfCalendars.Where(x => x.GIO_CONGTAC > 12).ToList();
                    result += "<tr>";

                    result += "<td style='text-align:center; font-weight:bold; color:#FE1A1A;width:10%;vertical-align:middle;border:1px solid #ddd'>";
                    result += "<p>" + entity.date.GetNameOfDay() + "</p>";
                    result += "<p>" + string.Format("{0:dd/MM}", entity.date) + "</p>";
                    result += "</td>";

                    result += "<td style='border:1px solid #ddd;vertical-align: top;color:#FE1A1A;width:45%;'>";
                    foreach (var morningCal in morningCalendars)
                    {
                        List <string> changedProperties = GetListPropertiesChangedOfCalendar(morningCal, lichCongTacBusiness);

                        if (morningCalendars.IndexOf(morningCal) != morningCalendars.Count() - 1)
                        {
                            result += "<div style ='margin-bottom:10px; border-bottom:1px solid #ddd;text-align:left;padding:10px;'>";
                        }
                        else
                        {
                            result += "<div style ='margin-bottom:10px;text-align:left;padding:0 10px;'>";
                        }
                        result += "<p>";

                        result += "<strong>" + (morningCal.GIO_CONGTAC.ToString("D2") + "h" + morningCal.PHUT_CONGTAC.ToString("D2")) + ":&nbsp;</strong>";
                        result += "<span>" + (morningCal.TIEUDE) + "</span>";
                        result += "</p>";

                        result += "<p>";
                        result += "<strong>Địa điểm:&nbsp;</strong>";
                        result += "<span>" + (morningCal.DIADIEM) + "</span>";
                        result += "</p>";

                        result += "<p>";
                        result += "<strong>Ghi chú:&nbsp;</strong>";
                        result += "<span>" + (morningCal.GHICHU) + "</span>";
                        result += "</p>";
                        result += "</div>";
                    }
                    result += "</td>";

                    result += "<td style='border:1px solid #ddd;vertical-align: top;color:#FE1A1A;width:45%;'>";
                    foreach (var afternoonCal in afternoonCalendars)
                    {
                        List <string> changedProperties = GetListPropertiesChangedOfCalendar(afternoonCal, lichCongTacBusiness);

                        if (afternoonCalendars.IndexOf(afternoonCal) != afternoonCalendars.Count() - 1)
                        {
                            result += "<div style ='margin-bottom:10px; border-bottom:1px solid #ddd;text-align:left;padding:10px;'>";
                        }
                        else
                        {
                            result += "<div style ='margin-bottom:10px;text-align:left;padding:0 10px;'>";
                        }

                        result += "<strong>" + (afternoonCal.GIO_CONGTAC.ToString("D2") + "h" + afternoonCal.PHUT_CONGTAC.ToString("D2")) + ":&nbsp;</strong>";
                        result += "<span>" + (afternoonCal.TIEUDE) + "</span>";
                        result += "</p>";

                        result += "<p>";
                        result += "<strong>Địa điểm:&nbsp;</strong>";

                        result += "<span>" + (afternoonCal.DIADIEM) + "</span>";
                        result += "</p>";

                        result += "<p>";
                        result += "<strong>Tài nguyên sử dụng:&nbsp;</strong>";
                        //result += "<span>" + (afternoonCal.TAINGUYEN_SUDUNG) + "</span>";
                        result += "</p>";
                        result += "</div>";
                    }
                    result += "</td>";
                    result += "</tr>";
                }
                result += "</tbody>";
                result += "</table>";
            }
            return(result);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// @author: duynn
        /// @description: hàm generate nội dung email lấy từ trong
        /// </summary>
        /// <param name="calendars"></param>
        /// <returns></returns>
        private string GenerateLichCongTacEmailContent(List <LICHCONGTAC_BO> calendars)
        {
            string result = string.Empty;

            lichCongTacBusiness = Get <LICHCONGTACBusiness>();

            var groupDateEntities = calendars
                                    .GroupBy(x => x.NGAY_CONGTAC).OrderBy(x => x.Key)
                                    .Select(x => new LichCongTacDateEntity()
            {
                date             = x.Key,
                groupOfCalendars = x.OrderBy(y => y.GIO_CONGTAC).ThenBy(y => y.PHUT_CONGTAC).ToList()
            }).ToList();

            foreach (var entity in groupDateEntities)
            {
                var morningCalendars   = entity.groupOfCalendars.Where(x => x.GIO_CONGTAC <= 12).ToList();
                var afternoonCalendars = entity.groupOfCalendars.Where(x => x.GIO_CONGTAC > 12).ToList();
                result += "<tr>";

                result += "<td style='text-align:center; font-weight:bold; color:#016897;width:10%;vertical-align:middle;border:1px solid #ddd'>";
                result += "<p>" + entity.date.GetNameOfDay() + "</p>";
                result += "<p>" + string.Format("{0:dd/MM}", entity.date) + "</p>";
                result += "</td>";

                result += "<td style='border:1px solid #ddd;vertical-align: top;color:#003399;width:45%;'>";
                foreach (var morningCal in morningCalendars)
                {
                    List <string> changedProperties = GetListPropertiesChangedOfCalendar(morningCal, lichCongTacBusiness);

                    if (morningCalendars.IndexOf(morningCal) != morningCalendars.Count() - 1)
                    {
                        result += "<div style ='margin-bottom:10px; border-bottom:1px solid #ddd;text-align:left;padding:10px;'>";
                    }
                    else
                    {
                        result += "<div style ='margin-bottom:10px;text-align:left;padding:0 10px;'>";
                    }
                    result += "<p>";

                    //kiểm tra cập nhật thời gian lịch công tác
                    if (changedProperties.Contains("GIO_CONGTAC") || changedProperties.Contains("PHUT_CONGTAC"))
                    {
                        result += "<strong style='color:#f7b512'>" + (morningCal.GIO_CONGTAC.ToString("D2") + "h" + morningCal.PHUT_CONGTAC.ToString("D2")) + ":&nbsp;</strong>";
                    }
                    else
                    {
                        result += "<strong>" + (morningCal.GIO_CONGTAC.ToString("D2") + "h" + morningCal.PHUT_CONGTAC.ToString("D2")) + ":&nbsp;</strong>";
                    }

                    //kiểm tra thay đổi tiêu đề lịch công tác
                    if (changedProperties.Contains("TIEUDE"))
                    {
                        result += "<span style='color:#f7b512'>" + (morningCal.TIEUDE) + "</span>";
                    }
                    else
                    {
                        result += "<span>" + (morningCal.TIEUDE) + "</span>";
                    }
                    result += "</p>";

                    result += "<p>";
                    result += "<strong>Địa điểm:&nbsp;</strong>";

                    //kiểm tra thay đổi địa điểm lịch công tác
                    if (changedProperties.Contains("DIADIEM"))
                    {
                        result += "<span style='color:#f7b512'>" + (morningCal.DIADIEM) + "</span>";
                    }
                    else
                    {
                        result += "<span>" + (morningCal.DIADIEM) + "</span>";
                    }

                    result += "</p>";

                    result += "<p>";
                    result += "<strong>Ghi chú:&nbsp;</strong>";
                    //kiểm tra thay đổi tài nguyên sử dụng
                    if (changedProperties.Contains("GHICHU"))
                    {
                        result += "<span style='color:#f7b512'>" + (morningCal.GHICHU) + "</span>";
                    }
                    else
                    {
                        result += "<span>" + (morningCal.GHICHU) + "</span>";
                    }
                    result += "</p>";
                    result += "</div>";
                }
                result += "</td>";

                result += "<td style='border:1px solid #ddd;vertical-align: top;color:#003399;width:45%;'>";
                foreach (var afternoonCal in afternoonCalendars)
                {
                    List <string> changedProperties = GetListPropertiesChangedOfCalendar(afternoonCal, lichCongTacBusiness);

                    if (afternoonCalendars.IndexOf(afternoonCal) != afternoonCalendars.Count() - 1)
                    {
                        result += "<div style ='margin-bottom:10px; border-bottom:1px solid #ddd;text-align:left;padding:10px;'>";
                    }
                    else
                    {
                        result += "<div style ='margin-bottom:10px;text-align:left;padding:0 10px;'>";
                    }

                    //kiểm tra cập nhật thời gian lịch công tác
                    if (changedProperties.Contains("GIO_CONGTAC") || changedProperties.Contains("PHUT_CONGTAC"))
                    {
                        result += "<strong style='color:#f7b512'>" + (afternoonCal.GIO_CONGTAC.ToString("D2") + "h" + afternoonCal.PHUT_CONGTAC.ToString("D2")) + ":&nbsp;</strong>";
                    }
                    else
                    {
                        result += "<strong>" + (afternoonCal.GIO_CONGTAC.ToString("D2") + "h" + afternoonCal.PHUT_CONGTAC.ToString("D2")) + ":&nbsp;</strong>";
                    }

                    //kiểm tra thay đổi tiêu đề lịch công tác
                    if (changedProperties.Contains("TIEUDE"))
                    {
                        result += "<span style='color:#f7b512'>" + (afternoonCal.TIEUDE) + "</span>";
                    }
                    else
                    {
                        result += "<span>" + (afternoonCal.TIEUDE) + "</span>";
                    }
                    result += "</p>";

                    result += "<p>";
                    result += "<strong>Địa điểm:&nbsp;</strong>";

                    //kiểm tra thay đổi địa điểm lịch công tác
                    if (changedProperties.Contains("DIADIEM"))
                    {
                        result += "<span style='color:#f7b512'>" + (afternoonCal.DIADIEM) + "</span>";
                    }
                    else
                    {
                        result += "<span>" + (afternoonCal.DIADIEM) + "</span>";
                    }

                    result += "</p>";

                    result += "<p>";
                    result += "<strong>Ghi chú:&nbsp;</strong>";
                    //kiểm tra thay đổi tài nguyên sử dụng
                    if (changedProperties.Contains("GHICHU"))
                    {
                        result += "<span style='color:#f7b512'>" + (afternoonCal.GHICHU) + "</span>";
                    }
                    else
                    {
                        result += "<span>" + (afternoonCal.GHICHU) + "</span>";
                    }
                    result += "</p>";
                    result += "</div>";
                }
                result += "</td>";
                result += "</tr>";
            }
            return(result);
        }
Ejemplo n.º 15
0
        public PartialViewResult SearchLichCongTac(LICHCONGTAC_SEARCH searchModel)
        {
            AssignUserInfo();
            lichCongTacBusiness = Get <LICHCONGTACBusiness>();
            DM_THAOTAC userFunction = currentUser.ListThaoTac.Where(o => o.MA_THAOTAC.ToUpper() == "TAO_LICHCONGTAC").FirstOrDefault();

            searchModel.queryDeptId = currentUser.DeptParentID;
            if (searchModel.calendarDay == null)
            {
                searchModel.calendarDay = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            }
            else
            {
                var calendarDayValue = searchModel.calendarDay.Value;
                searchModel.calendarDay = new DateTime(calendarDayValue.Year, calendarDayValue.Month, calendarDayValue.Day);
            }
            var currentDay   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
            var day          = searchModel.calendarDay.Value;
            var groupOfYears = lichCongTacBusiness.GetListYears(day);
            var groupOfWeeks = Enumerable.Range(1, 52).Select(w => new SelectListItem()
            {
                Value    = w.ToString(),
                Text     = "Tuần " + w,
                Selected = (day.GetWeekNumber() == w)
            }).ToList();
            var groupOfMonths = Enumerable.Range(1, 12).Select(m => new SelectListItem()
            {
                Value    = m.ToString(),
                Text     = "Tháng " + m,
                Selected = (day.Month == m)
            }).ToList();

            if (searchModel.calendarType == LICH_CONSTANT.NGAY)
            {
                //nếu người dùng tìm kiếm không nhập ngày bắt đầu và kết thúc mặc định lấy của tuần này
                if (searchModel.startDate == null && searchModel.endDate == null)
                {
                    searchModel.startDate = day.GetStartDayOfWeek();
                    searchModel.endDate   = day.GetEndDayOfWeek();
                }
                LichCongTacByDayViewModel viewModel = new LichCongTacByDayViewModel();
                viewModel.currentUserId     = currentUser.ID;
                viewModel.startDate         = searchModel.startDate;
                viewModel.endDate           = searchModel.endDate;
                viewModel.groupOfYears      = groupOfYears;
                viewModel.title             = "Từ " + string.Format("{0:dd/MM/yyyy}", searchModel.startDate) + " đến " + string.Format("{0:dd/MM/yyyy}", searchModel.endDate);
                viewModel.groupDateEntities = lichCongTacBusiness.GetListLichCongTacs(searchModel)
                                              .GroupBy(x => x.NGAY_CONGTAC).OrderBy(x => x.Key)
                                              .Select(x => new LichCongTacDateEntity()
                {
                    title            = x.Key.GetNameOfDay() + " (" + x.Key.ToVietnameseDateFormat() + ")",
                    isToday          = x.Key.Equals(currentDay),
                    groupOfCalendars = x.OrderBy(y => y.GIO_CONGTAC).ThenBy(y => y.PHUT_CONGTAC).ToList()
                }).ToList();
                return(PartialView("_ListLichCongTacByDayOfWeek", viewModel));
            }
            else if (searchModel.calendarType == LICH_CONSTANT.TUAN)
            {
                LichCongTacByWeekViewModel viewModel = new LichCongTacByWeekViewModel();
                var startOfWeek = day.GetStartDayOfWeek();
                var endOfWeek   = day.GetEndDayOfWeek();
                viewModel.currentUserId = currentUser.ID;
                viewModel.canCreate     = (userFunction != null && userFunction.DM_THAOTAC_ID > 0);
                viewModel.title         = day.GetNameOfWeek() + " (" + startOfWeek.GetNameOfDay() + ", " + startOfWeek.ToVietnameseDateFormat() + " - " + endOfWeek.GetNameOfDay() + ", " + endOfWeek.ToVietnameseDateFormat() + ")";
                viewModel.groupOfYears  = groupOfYears;
                viewModel.groupOfWeeks  = groupOfWeeks;

                searchModel.startDate = startOfWeek;
                searchModel.endDate   = endOfWeek;
                List <LICHCONGTAC_BO> calendars = lichCongTacBusiness.GetListLichCongTacs(searchModel);

                //lấy các ngày trong tuần
                viewModel.groupOfDates = new List <DateTime>();
                for (var d = startOfWeek; d <= endOfWeek; d = d.AddDays(1))
                {
                    viewModel.groupOfDates.Add(d);
                }

                //lấy lịch theo từng khung giờ theo từng ngày
                viewModel.groupWeekHourEntities = new List <LichCongTacByWeekHourEntity>();
                for (int h = 0; h <= 23; h++)
                {
                    LichCongTacByWeekHourEntity hourEntity = new LichCongTacByWeekHourEntity();
                    hourEntity.title             = h.ToString("D2") + "h";
                    hourEntity.hour              = h;
                    hourEntity.groupDateEntities = new List <LichCongTacDateEntity>();
                    for (var d = startOfWeek; d <= endOfWeek; d = d.AddDays(1))
                    {
                        LichCongTacDateEntity hourDateEntity = new LichCongTacDateEntity();
                        hourDateEntity.date             = d;
                        hourDateEntity.groupOfCalendars = new List <LICHCONGTAC_BO>();
                        hourDateEntity.groupOfCalendars.AddRange(calendars
                                                                 .Where(x => x.NGAY_CONGTAC.Day == d.Day && x.GIO_CONGTAC == h)
                                                                 .OrderBy(x => x.GIO_CONGTAC).ThenBy(x => x.PHUT_CONGTAC).ToList());
                        hourDateEntity.isToday = (d.Equals(currentDay));
                        hourEntity.groupDateEntities.Add(hourDateEntity);
                    }
                    viewModel.groupWeekHourEntities.Add(hourEntity);
                }
                return(PartialView("_ListLichCongTacByWeek", viewModel));
            }
            else
            {
                LichCongTacByMonthViewModel viewModel = new LichCongTacByMonthViewModel();
                viewModel.currentUserId = currentUser.ID;
                viewModel.canCreate     = (userFunction != null && userFunction.DM_THAOTAC_ID > 0);
                viewModel.year          = day.Year;
                viewModel.month         = day.Month;
                viewModel.title         = "Tháng " + day.Month + ", năm " + day.Year;
                viewModel.groupOfYears  = groupOfYears;
                viewModel.groupOfMonths = groupOfMonths;

                //lấy ngày đầu tiên và cuối cùng trong tháng
                int lastDayInMonth = DateTime.DaysInMonth(day.Year, day.Month);
                searchModel.startDate = (new DateTime(day.Year, day.Month, 1));
                searchModel.endDate   = (new DateTime(day.Year, day.Month, lastDayInMonth));
                List <LICHCONGTAC_BO> calendars = lichCongTacBusiness.GetListLichCongTacs(searchModel);

                List <DateTime> datesOfMonth = Enumerable.Range(1, lastDayInMonth)
                                               .Select(x => new DateTime(day.Year, day.Month, x)).ToList();
                DateTime defaultDate = new DateTime(1, 1, 1);

                viewModel.groupWeekEntities = new List <LichCongTacByMonthWeekEntity>();
                for (int w = 1; w <= 6; w++)
                {
                    LichCongTacByMonthWeekEntity weekEntity = new LichCongTacByMonthWeekEntity();
                    List <DateTime> daysOfWeek = datesOfMonth.Where(x => x.GetWeekOfMonth() == w).ToList();
                    if (daysOfWeek.Any())
                    {
                        weekEntity.groupDateEntities = new List <LichCongTacDateEntity>();
                        for (int d = (int)DayOfWeek.Sunday; d <= (int)DayOfWeek.Saturday; d++)
                        {
                            DateTime weekDay = daysOfWeek.Where(x => (int)x.DayOfWeek == d).FirstOrDefault();
                            LichCongTacDateEntity dateEntity = new LichCongTacDateEntity();
                            if (weekDay != defaultDate)
                            {
                                dateEntity.isToday          = weekDay.Equals(currentDay);
                                dateEntity.date             = weekDay;
                                dateEntity.title            = weekDay.Day.ToString();
                                dateEntity.groupOfCalendars = calendars.Where(x => x.NGAY_CONGTAC.Day == weekDay.Day)
                                                              .OrderBy(x => x.GIO_CONGTAC)
                                                              .ThenBy(x => x.PHUT_CONGTAC)
                                                              .ToList();
                            }
                            weekEntity.groupDateEntities.Add(dateEntity);
                        }
                        viewModel.groupWeekEntities.Add(weekEntity);
                    }
                }
                return(PartialView("_ListLichCongTacByMonth", viewModel));
            }
        }
Ejemplo n.º 16
0
        public JsonResult SaveLichCongTac(LICHCONGTAC entity, FormCollection fc)
        {
            AssignUserInfo();
            qlDangKyXeBusiness    = Get <QL_DANGKY_XEBusiness>();
            lichCongTacBusiness   = Get <LICHCONGTACBusiness>();
            dmNhomDanhMucBusiness = Get <DM_NHOMDANHMUCBusiness>();
            dmDanhMucDataBusiness = Get <DM_DANHMUC_DATABusiness>();

            JsonResultBO editResult = new JsonResultBO(true);

            entity.NGAY_CONGTAC = fc["NGAY_CONGTAC"].ToDateTimeNotNull();

            bool isObsolete = entity.NGAY_CONGTAC.IsOldWeek();

            if (isObsolete)
            {
                editResult.Status  = false;
                editResult.Message = "Thời gian công tác đã quá hạn để thêm mới";
                return(Json(editResult));
            }

            entity.TIEUDE       = fc["TIEUDE"].Trim();
            entity.GIO_CONGTAC  = fc["GIO_CONGTAC"].ToIntOrZero();
            entity.PHUT_CONGTAC = fc["PHUT_CONGTAC"].ToIntOrZero();
            //entity.NGUOICHUTRI_ID = fc["NGUOICHUTRI_ID"].ToIntOrNULL();
            entity.LANHDAO_ID = fc["LANHDAO_ID"].ToIntOrNULL();
            entity.DIADIEM    = fc["DIADIEM"].Trim();
            entity.GHICHU     = fc["GHICHU"].Trim();
            entity.NGUOITAO   = currentUser.ID;
            entity.NGUOISUA   = currentUser.ID;
            entity.NGAYTAO    = DateTime.Now;
            entity.NGAYSUA    = DateTime.Now;
            entity.IS_LATTEST = true;
            entity.IS_DELETE  = false;
            string destination = fc["DIADIEM"].Trim();

            //kiểm tra trùng lịch của cán bộ trong ngày
            bool existed = lichCongTacBusiness.CheckIsDuplicate(entity.ID, entity.LANHDAO_ID.GetValueOrDefault(), entity.NGAY_CONGTAC, entity.GIO_CONGTAC, entity.PHUT_CONGTAC);

            if (existed == true)
            {
                editResult.Status  = false;
                editResult.Message = "Lịch công tác của cán bộ đã tồn tại";
                return(Json(editResult));
            }

            DM_DANHMUC_DATA dataItem = dmDanhMucDataBusiness.GetItemByCodeAndText(DMLOAI_CONSTANT.DIEM_DEN, destination);

            if (dataItem == null)
            {
                DM_NHOMDANHMUC  groupCategory     = dmNhomDanhMucBusiness.GetByCode(DMLOAI_CONSTANT.DIEM_DEN) ?? new DM_NHOMDANHMUC();
                DM_DANHMUC_DATA destinationEntity = new DM_DANHMUC_DATA();
                destinationEntity.DM_NHOM_ID = groupCategory.ID;
                destinationEntity.TEXT       = destination;
                dmDanhMucDataBusiness.Save(destinationEntity);
            }

            if (entity.ID <= 0)
            {
                lichCongTacBusiness.Save(entity);
                editResult.Message = "Thêm mới lịch công tác thành công";
            }
            else
            {
                LICHCONGTAC dbEntity = lichCongTacBusiness.Find(entity.ID);
                if (dbEntity != null && dbEntity.IS_DELETE != true)
                {
                    if (dbEntity.NGAY_CONGTAC.IsOldWeek())
                    {
                        editResult.Status  = false;
                        editResult.Message = "Thời gian công tác đã quá hạn cập nhật";
                        return(Json(editResult));
                    }

                    //so sánh 2 phiên bản nếu khác => tạo phiên bản mới có ROOT_LICH = 0;
                    bool hasChanged = CheckHasChanged(arrProperties, dbEntity, entity);
                    if (hasChanged)
                    {
                        entity.ID           = 0;
                        entity.LICH_GOC_ID  = dbEntity.ID;
                        dbEntity.IS_LATTEST = false; //cập nhật phiên bản trước đã cũ
                        lichCongTacBusiness.Save(entity);

                        //kiểm tra xem lịch công tác này đã được đăng ký xe hay chưa
                        //nếu có thì cập nhật đăng ký xe
                        QL_DANGKY_XE register = qlDangKyXeBusiness.GetAvailableRegistrationByCalendarId(dbEntity.ID);
                        if (register != null)
                        {
                            register.LICHCONGTAC_ID = entity.ID;
                            qlDangKyXeBusiness.Save(register);
                        }
                    }
                    lichCongTacBusiness.Save(dbEntity);
                    editResult.Message = "Cập nhật lịch công tác thành công";
                }
                else
                {
                    editResult.Status  = false;
                    editResult.Message = "Lịch công tác không tồn tại";
                    return(Json(editResult));
                }
            }

            return(Json(editResult));
        }