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 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.º 3
0
        public ActionResult CreateCalendarOfTheDay(int year, int month, int day, int hour = 0, int minute = 0)
        {
            LICHCONGTAC entityCalendar = new LICHCONGTAC();

            entityCalendar.NGAY_CONGTAC = new DateTime(year, month, day);
            entityCalendar.GIO_CONGTAC  = hour;
            entityCalendar.PHUT_CONGTAC = minute;
            SessionManager.SetValue("CreateCalendarOfTheDay", entityCalendar);
            return(RedirectToAction("CreateLichCongTac"));
        }
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 bool CheckHasChanged(string[] properties, LICHCONGTAC oldEntity, LICHCONGTAC newEntity)
        {
            bool isChange   = false;
            Type entityType = typeof(LICHCONGTAC);

            foreach (string propertyName in properties)
            {
                PropertyInfo propertyInfo = entityType.GetProperty(propertyName);
                var          oldValue     = propertyInfo.GetValue(oldEntity);
                var          newValue     = propertyInfo.GetValue(newEntity);

                if (oldValue != newValue)
                {
                    isChange = true;
                    break;
                }
            }
            return(isChange);
        }
Ejemplo n.º 6
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.º 7
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));
        }