Beispiel #1
0
        public StaffMovementsFactEditModel GetFactEditModel(int Id)
        {
            var entity = StaffMovementsFactDao.Load(Id);

            StaffMovementsFactEditModel model = new StaffMovementsFactEditModel();
            model.Signers = EmploymentSignersDao.LoadAll().Select(x=>new IdNameDto{ Id=x.Id, Name=x.Name}).ToList();
            model.SignerId = model.Signers.First().Id;
            model.IsDocsReceived = entity.IsDocumentsReceived;
            model.Id = entity.Id;
            model.User.Id = entity.User.Id;
            model.IsDocsAddAvailable = (CurrentUser.Id == model.User.Id || (CurrentUser.UserRole & UserRole.PersonnelManager)>0|| CheckIsChief(entity.User.Department.Id, CurrentUser)) && !model.IsDocsReceived;
            LoadUserData(model.User);
            var usr = UserDao.Load(model.User.Id);
            model.ActiveAdditions = GetUserActualAddition(model.User.Id);
            model.IsOrderAvailable = RequestPrintFormDao.QueryExpression(x => x.RequestId == Id && x.RequestTypeId == (int)RequestPrintFormTypeEnum.StaffMovementsOrder).Count>0;
            model.IsDMOAvailable = RequestPrintFormDao.QueryExpression(x => x.RequestId == Id && x.RequestTypeId == (int)RequestPrintFormTypeEnum.StaffMovementsDMO).Count > 0;
            model.IsAgreementAdditionAvailable = RequestPrintFormDao.QueryExpression(x => x.RequestId == Id && x.RequestTypeId == (int)RequestPrintFormTypeEnum.StaffMovementsAgreementAddition).Count > 0;
            model.IsAgreementAvailable = RequestPrintFormDao.QueryExpression(x => x.RequestId == Id && x.RequestTypeId == (int)RequestPrintFormTypeEnum.StaffMovementsAgreement).Count > 0;
            if (entity.AgreementAdditionalDoc.HasValue)
            {
                model.AgreementAdditionalDocDto = new UploadFileDto();
                var file = RequestAttachmentDao.Load(entity.AgreementAdditionalDoc.Value);
                model.AgreementAdditionalDocDto.FileName = file.FileName;
                model.AgreementAdditionalDocId = file.Id;
            }
            if (entity.AgreementDoc.HasValue)
            {
                model.AgreementDocDto = new UploadFileDto();
                var file = RequestAttachmentDao.Load(entity.AgreementDoc.Value);
                model.AgreementDocDto.FileName = file.FileName;
                model.AgreementDocId = file.Id;
            }
            if (entity.MaterialLiabilityDoc.HasValue)
            {
                model.MaterialLiabilityDocDto = new UploadFileDto();
                var file = RequestAttachmentDao.Load(entity.MaterialLiabilityDoc.Value);
                model.MaterialLiabilityDocDto.FileName = file.FileName;
                model.MaterialLiabilityDocAttachmentId  = file.Id;
            }
            if (entity.RequirementsOrderDoc.HasValue)
            {
                model.RequirementsOrderDocDto = new UploadFileDto();
                var file = RequestAttachmentDao.Load(entity.RequirementsOrderDoc.Value);
                model.RequirementsOrderDocDto.FileName = file.FileName;
                model.RequirementsOrderDocAttachmentId = file.Id;
            }
            if (entity.ServiceOrderDoc.HasValue)
            {
                model.ServiceOrderDocDto = new UploadFileDto();
                var file = RequestAttachmentDao.Load(entity.ServiceOrderDoc.Value);
                model.ServiceOrderDocDto.FileName = file.FileName;
                model.ServiceOrderDocAttachmentId = file.Id;
            }
            if (entity.OrderDoc.HasValue)
            {
                model.OrderDocDto = new UploadFileDto();
                var file = RequestAttachmentDao.Load(entity.OrderDoc.Value);
                model.OrderDocDto.FileName = file.FileName;
                model.OrderDocId = file.Id;
            }
            model.RegionCoefficient = StaffMovementsDao.GetUserRegionCoeff(model.User.Id);
            model.TotalSalary = StaffMovementsDao.GetUserTotalSalary(model.User.Id);
            model.Casing = StaffMovementsDao.GetUserSalary(model.User.Id);
            model.Salary = usr.Rate.HasValue ? usr.Rate.Value : 0;
            model.IsCheckByPersonelAvailable = ((CurrentUser.UserRole & UserRole.PersonnelManager) > 0 && !model.IsDocsReceived);
            model.IsSaveAvailable = model.IsDocsAddAvailable || model.IsCheckByPersonelAvailable;
            return model;
        }
Beispiel #2
0
 public StaffMovementsFactEditModel SaveFact(StaffMovementsFactEditModel model)
 {
     var entity = StaffMovementsFactDao.Load(model.Id);
     model.IsDocsAddAvailable = (CurrentUser.Id == model.User.Id || (CurrentUser.UserRole & UserRole.PersonnelManager) > 0 || CheckIsChief(entity.User.Department.Id, CurrentUser)) && !entity.IsDocumentsReceived;
     if ((CurrentUser.UserRole & UserRole.PersonnelManager) > 0)
     {
         entity.IsDocumentsReceived = model.IsDocsReceived;
     }
     if (model.IsDocsAddAvailable)
     {
         if (model.AgreementAdditionalDocDto != null)
         {
             string tmp = "";
             var id = SaveAttachment(model.Id, 0, model.AgreementAdditionalDocDto, RequestAttachmentTypeEnum.AgreementAdditionalDocDto, out tmp);
             if (id.HasValue)
             {
                 model.AgreementAdditionalDocId = id.Value;
                 model.AgreementAdditionalDocDto.FileName = tmp;
                 entity.AgreementAdditionalDoc = id.Value;
             }
         }
         if (model.AgreementDocDto != null)
         {
             string tmp = "";
             var id = SaveAttachment(model.Id, 0, model.AgreementDocDto, RequestAttachmentTypeEnum.AgreementDocDto, out tmp);
             if (id.HasValue)
             {
                 model.AgreementDocId = id.Value;
                 model.AgreementDocDto.FileName = tmp;
                 entity.AgreementDoc = id.Value;
             }
         }
         if (model.MaterialLiabilityDocDto != null)
         {
             string tmp = "";
             var id = SaveAttachment(model.Id, 0, model.MaterialLiabilityDocDto, RequestAttachmentTypeEnum.MaterialLiabilityDocDto, out tmp);
             if (id.HasValue)
             {
                 model.MaterialLiabilityDocAttachmentId = id.Value;
                 model.MaterialLiabilityDocDto.FileName = tmp;
                 entity.MaterialLiabilityDoc = id.Value;
             }
         }
         if (model.OrderDocDto != null)
         {
             string tmp = "";
             var id = SaveAttachment(model.Id, 0, model.OrderDocDto, RequestAttachmentTypeEnum.OrderDocDto, out tmp);
             if (id.HasValue)
             {
                 model.OrderDocId = id.Value;
                 model.OrderDocDto.FileName = tmp;
                 entity.OrderDoc = id.Value;
             }
         }
         if (model.RequirementsOrderDocDto != null)
         {
             string tmp = "";
             var id = SaveAttachment(model.Id, 0, model.RequirementsOrderDocDto, RequestAttachmentTypeEnum.RequirementsOrderDocDto, out tmp);
             if (id.HasValue)
             {
                 model.RequirementsOrderDocAttachmentId = id.Value;
                 model.RequirementsOrderDocDto.FileName = tmp;
                 entity.RequirementsOrderDoc = id.Value;
             }
         }
         if (model.ServiceOrderDocDto != null)
         {
             string tmp = "";
             var id = SaveAttachment(model.Id, 0, model.ServiceOrderDocDto, RequestAttachmentTypeEnum.ServiceOrderDocDto, out tmp);
             if (id.HasValue)
             {
                 model.ServiceOrderDocAttachmentId = id.Value;
                 model.ServiceOrderDocDto.FileName = tmp;
                 entity.ServiceOrderDoc = id.Value;
             }
         }
     }
     model.IsDocsAddAvailable = (CurrentUser.Id == model.User.Id) && !model.IsDocsReceived;
     model.IsSaveAvailable = model.IsDocsAddAvailable || ((CurrentUser.UserRole & UserRole.PersonnelManager) > 0 && !model.IsDocsReceived);
     model = GetFactEditModel(model.Id);
     StaffMovementsFactDao.SaveAndFlush(entity);
     return model;
 }
 public ActionResult StaffMovementsFactEdit(StaffMovementsFactEditModel model)
 {
     model.MaterialLiabilityDocDto = GetFileContext(Request, ModelState, "MaterialLiabilityDoc");
     model.AgreementDocDto = GetFileContext(Request, ModelState, "AgreementDoc");
     model.AgreementAdditionalDocDto = GetFileContext(Request, ModelState, "AgreementAdditionDoc");
     model.OrderDocDto = GetFileContext(Request, ModelState, "OrderDoc");
     model.RequirementsOrderDocDto = GetFileContext(Request, ModelState, "RequirementsOrderDoc");
     model.ServiceOrderDocDto = GetFileContext(Request, ModelState, "ServiceOrderDoc");
     model = StaffMovementsBl.SaveFact(model);
     return View(model);
 }