예제 #1
0
        // do Insert Or Update The user Refresh Token [used in SignIn Action]
        private void _InsertOrUpdateRefreshToken(User user, string refreshToken, string deviceInfo)
        {
            int updatedRows = _UpdateRefreshToken(user, refreshToken, deviceInfo);

            if (updatedRows == -1)
            {
                _service.Add <RefreshToken>(new RefreshToken()
                {
                    Token = refreshToken, DeviceInfo = deviceInfo, UserId = user.UserId
                });
            }
        }
예제 #2
0
        /// <summary>
        /// 写入登录日志
        /// </summary>
        /// <param name="m_emp"></param>
        public void LoginLog(Sys_Employee m_emp)
        {
            BaseService <sys_LoginLog> _logService = new BaseService <sys_LoginLog>();

            //修改最后一次登录时间
            var m_LastLog = _logService.GetListBy <DateTime?>(null, c => c.LoginDate, false).FirstOrDefault();

            if (m_LastLog != null)
            {
                m_emp.LastLoginTime = m_LastLog.LoginDate;
                _empService.Update(m_emp);
            }

            //添加登录日志
            string       ip  = IpAddress.GetIP();
            sys_LoginLog log = new sys_LoginLog();

            log.LoginId          = Guid.NewGuid();
            log.LoginEmployee    = m_emp.EmployeeID;
            log.LoginEmployeeKey = m_emp.EmployeeID.ToString();
            log.LoginDate        = DateTime.Now;
            log.LoginCity        = IpAddress.GetAddressByIp(ip, 2);             //登录城市
            log.LoginIpAddress   = ip;                                          //外网Ip
            log.LoginInIp        = HttpContext.Current.Request.UserHostAddress; //内网Ip

            _logService.Add(log);
        }
예제 #3
0
 public CommandResult <Roles> Add(string roleName, long timestamp)
 {
     using (var db = new FrameContext())
     {
         var result = new CommandResult <Roles> {
             ResultStatus = ResultStatus.Error
         };
         if (BaseService.Exist(db, a => a.RoleName == roleName))
         {
             result.Message = "角色名称在系统中已存在!";
         }
         else
         {
             var entity = new Roles {
                 RoleName = roleName, Timestamp = timestamp
             };
             if (!BaseService.Add(db, entity))
             {
                 result.Message = "系统未知原因";
             }
             else
             {
                 result.ResultStatus = ResultStatus.Success;
                 result.Message      = "角色添加成功!";
                 result.Data         = entity;
             }
         }
         return(result);
     }
 }
예제 #4
0
        public virtual IHttpActionResult Add(T model)
        {
            T data = model;

            if (!ModelState.IsValid)
            {
                Logger.Warning("User {@AppUser} sent Invalid model state {@Data}", this.AppUser, data);
                return(BadRequest(ModelState));
            }

            try
            {
                var add = Service.Add(model);
                Logger.Debug("User {@UserName} ConnectionId {@ConnectionId} Added entity {TypeName} {@Id}", this.AppUser.UserName, this.AppUser.ConnectionId, typeName, data.Id);
                return(Ok(model.Id));
            }
            catch (Exception exception)
            {
                Logger.Fatal(
                    exception,
                    "Exception occurred while saving {@Data} by User {@AppUser}",
                    data,
                    this.AppUser);
                return(InternalServerError(exception));
            }
        }
예제 #5
0
        public static OpResult ReSave(StockTaking obj)
        {
            var op    = new OpResult();
            var stock = CurrentRepository.FindById(obj.Id);

            stock.ActualNumber = Math.Round(obj.ActualNumber.GetValueOrDefault(), 3);
            stock.CreateUID    = Sys.CurrentUser.UID;
            var CheckUID = HttpContext.Current.Request["CheckUID"];
            var log      = new StockTakingLog()
            {
                Barcode    = stock.Barcode,
                CheckBatch = stock.CheckBatch,
                CheckUID   = CheckUID,
                CreateUID  = stock.CreateUID,
                CreateDT   = DateTime.Now,
                Number     = stock.ActualNumber.GetValueOrDefault(),
                State      = 1,
                ActualDate = HttpContext.Current.Request["ActualDate"].ToType <DateTime>(),
                CompanyId  = CommonService.CompanyId,
                Source     = 1
            };

            op = BaseService <StockTakingLog> .Add(log);

            return(op);
        }
예제 #6
0
        public AjaxMessage CreateSaleType(string typeName)
        {
            AjaxMessage ajax = new AjaxMessage();

            ajax.IsSuccess = false;
            ajax.Message   = "";
            try
            {
                if (!string.IsNullOrEmpty(typeName))
                {
                    int         EmployeeId = LoginInfo.UserInfo.EmployeeId;
                    FD_SaleType saleType   = new FD_SaleType()
                    {
                        SaleTypeName   = typeName,
                        CreateEmployee = LoginInfo.UserInfo.EmployeeId,
                        CreateDate     = DateTime.Now,
                        Status         = 1
                    };

                    var result = _SaleTypeService.Add(saleType);
                    if (result != null)
                    {
                        ajax.Message   = "添加成功";
                        ajax.IsSuccess = true;
                    }
                }
            }
            catch (Exception e)
            {
                ajax.Message = e.Message;
            }
            return(ajax);
        }
예제 #7
0
        public CommandResult <NavBarGroups> Add(NavBarGroupsAddRequestModel requestModel)
        {
            var result = new CommandResult <NavBarGroups>();

            using (var db = new FrameContext())
            {
                if (Exist(a => a.Name == requestModel.NavBarGroupName))
                {
                    result.Message = $"新增失败,功能组名称“{requestModel.NavBarGroupName}”在系统中已存在!";
                }
                else
                {
                    var entity = new NavBarGroups
                    {
                        Name      = requestModel.NavBarGroupName,
                        Ico       = requestModel.IcoPath,
                        Sort      = requestModel.Sort,
                        Timestamp = requestModel.Timestamp
                    };
                    if (!BaseService.Add(db, entity))
                    {
                        result.Message = "未知原因";
                    }
                    else
                    {
                        result.ResultStatus = ResultStatus.Success;
                        result.Message      = "新增功能组菜单成功!";
                        result.Data         = entity;
                    }
                }
            }
            return(result);
        }
예제 #8
0
        public CommandResult <Log> Add(LogAddRequestModel requestModel)
        {
            var result = new CommandResult <Log>();

            using (var db = new FrameContext())
            {
                var entity = new Log
                {
                    LoginName = requestModel.LoginName,
                    LoginTime = requestModel.LoginTime,
                    LoginRole = requestModel.LoginRole,
                    LoginMach = requestModel.LoginMach,
                    LoginCpu  = requestModel.LoginCpu
                };
                if (!BaseService.Add(db, entity))
                {
                    result.Message = "未知原因";
                }
                else
                {
                    result.ResultStatus = ResultStatus.Success;
                    result.Message      = "登陆日志新增成功";
                    result.Data         = entity;
                }
            }
            return(result);
        }
예제 #9
0
 public CommandResult <Permissions> Add(PermissionsAddRequestModel model)
 {
     using (var db = new FrameContext())
     {
         var result = new CommandResult <Permissions>();
         if (BaseService.Exist(db, a => a.PermissionsName == model.PermissionsName))
         {
             result.Message = "权限名称在系统中已存在";
         }
         else
         {
             var entity = new Permissions {
                 PermissionsName = model.PermissionsName, Sort = model.Sort
             };
             if (!BaseService.Add(db, entity))
             {
                 result.Message = "系统未知原因";
             }
             else
             {
                 result.ResultStatus = ResultStatus.Success;
                 result.Message      = "权限信息添加成功";
             }
         }
         return(result);
     }
 }
예제 #10
0
        /// <summary>
        /// 保存新增或修改
        /// </summary>
        /// <param name="model">优惠券对象</param>
        /// <returns>保存结果</returns>
        public OpResult SaveOrUpdate(MakingCouponCard model)
        {
            OpResult result = new OpResult();

            if (model.Id == 0)
            {
                model.CreateDT  = DateTime.Now;
                model.CreateUID = Sys.CurrentUser.UID;
                model.CompanyId = CommonService.CompanyId;
                model.State     = 0;
                #region 批次
                var firstBatchSN    = DateTime.Now.ToString("yyMMdd") + "01";
                var firstBatchToInt = long.Parse(firstBatchSN);
                var batchCount      = GetBatchCount();
                model.BatchSN = (firstBatchToInt + batchCount).ToString();//批次:6位日期 + 2位序号,示例:16081601
                #endregion
                result = BaseService <MakingCouponCard> .Add(model);

                return(result);
            }
            else
            {
                var obj = BaseService <MakingCouponCard> .FindById(model.Id);

                if (obj != null)
                {
                    Pharos.Utility.Helpers.ExtendHelper.ToCopyProperty(model, obj);
                    result = BaseService <MakingCouponCard> .Update(obj);
                }
                return(result);
            }
        }
예제 #11
0
        public virtual IHttpActionResult Post([FromBody] TEntity request)
        {
            HttpResponseMessage response = new HttpResponseMessage();

            try
            {
                if (!ModelState.IsValid)
                {
                    response = Request.CreateResponse(HttpStatusCode.BadRequest, ModelState);
                    response.Headers.Add("X-Server-Message", "Formato ou inexistência de dados necessários a inserção em nossa base de dados.");

                    return(ResponseMessage(response));
                }

                BaseService <TEntity> service = new BaseService <TEntity>();
                var entidade = service.Add(request);

                response = Request.CreateResponse(HttpStatusCode.OK, entidade);
                response.Headers.Add("X-Server-Message", $"{typeof(TEntity).Name} Cadastrado com sucesso.");
            }
            catch (Exception ex)
            {
                response = Request.CreateResponse(HttpStatusCode.InternalServerError, ex);
                response = ExceptionFilter.Find(ref response, ex);
            }

            return(ResponseMessage(response));
        }
예제 #12
0
 /// <summary>
 /// 新增一条规则
 /// </summary>
 /// <param name="_rule"></param>
 /// <returns></returns>
 public OpResult CreateReturnRule(ReturnRules _rule)
 {
     _rule.CompanyId = CommonService.CompanyId;
     _rule.CreateDT  = DateTime.Now;
     _rule.CreateUID = Sys.CurrentUser.UID;
     return(BaseService <ReturnRules> .Add(_rule));
 }
예제 #13
0
        /// <summary>
        /// 后台换货
        /// </summary>
        /// <param name="reason">换货理由(字典值)</param>
        /// <param name="retprice">顾客补价</param>
        /// <param name="returnDetailsStr">换货明细JSON字符串</param>
        /// <param name="insertnewed"></param>
        /// <param name="payno">销售单流水号</param>
        /// <returns>OpResult</returns>
        public static OpResult SaveHuang(int reason, decimal?retprice, string returnDetailsStr, string payno)
        {
            var op   = OpResult.Fail();
            var olds = returnDetailsStr.ToObject <List <TuiHuan> >();

            if (!olds.Any())
            {
                op.Message = "换货商品信息不能为空";
            }
            else
            {
                payno = CommonRules.PaySN;
                var saleObj = new SaleOrders()
                {
                    ApiCode           = "11",
                    MachineSN         = "-1",
                    CreateDT          = DateTime.Now,
                    CreateUID         = Sys.CurrentUser.UID,
                    PaySN             = payno,
                    TotalAmount       = retprice.GetValueOrDefault(),
                    Receive           = retprice.GetValueOrDefault(),
                    PreferentialPrice = 0,
                    StoreId           = Sys.CurrentUser.StoreId,
                    Type      = 1,
                    Reason    = reason,
                    CompanyId = CommonService.CompanyId,
                    Memo      = "后台换货新单"
                };
                var newSaleDetails = new List <SaleDetail>();
                olds.Each(o =>
                {
                    newSaleDetails.Add(new SaleDetail()
                    {
                        ActualPrice     = o.SysPrice,
                        SysPrice        = o.SysPrice,
                        Total           = o.Total,
                        BuyPrice        = 0,
                        Barcode         = o.OldBarcode,
                        ScanBarcode     = o.Barcode,
                        ProductCode     = o.ProductCode,
                        Title           = o.Title,
                        PaySN           = saleObj.PaySN,
                        PurchaseNumber  = o.Number,
                        SalesClassifyId = 0,
                        CompanyId       = saleObj.CompanyId,
                        Memo            = ""
                    });
                });
                BaseService <SaleOrders> .Add(saleObj, false);

                op = BaseService <SaleDetail> .AddRange(newSaleDetails);

                if (op.Successed)
                {
                    dal.UpdateTuiHuanStock();
                }
            }
            return(op);
        }
        public CommandResult <StaffRoleRelationships> ModifyRelationships(int staffId, int roleId, bool check)
        {
            var result = new CommandResult <StaffRoleRelationships>();

            using (var db = new FrameContext())
            {
                if (check)
                {
                    if (BaseService.Exist(db, a => a.StaffId == staffId && a.RoleId == roleId))
                    {
                        result.ResultStatus = ResultStatus.Success;
                        result.Message      = "角色授权成功";
                        result.Data         = BaseService.Find(db, a => a.StaffId == staffId && a.RoleId == roleId);
                    }
                    else
                    {
                        var entity = new StaffRoleRelationships
                        {
                            StaffId = staffId,
                            RoleId  = roleId
                        };
                        if (!BaseService.Add(db, entity))
                        {
                            result.Message = "未知原因";
                        }
                        else
                        {
                            result.ResultStatus = ResultStatus.Success;
                            result.Message      = "角色授权成功";
                            result.Data         = entity;
                        }
                    }
                }
                else
                {
                    if (!BaseService.Exist(db, a => a.StaffId == staffId && a.RoleId == roleId))
                    {
                        result.ResultStatus = ResultStatus.Success;
                        result.Message      = "授权取消成功";
                    }
                    else
                    {
                        var entity = BaseService.Find(db, a => a.StaffId == staffId && a.RoleId == roleId);
                        if (!BaseService.Delete(db, entity))
                        {
                            result.Message = "未知原因";
                        }
                        else
                        {
                            result.ResultStatus = ResultStatus.Success;
                            result.Message      = "授权取消成功";
                            result.Data         = entity;
                        }
                    }
                }
            }
            return(result);
        }
예제 #15
0
        public virtual TView Add(TCreate dto)
        {
            if (!ModelState.IsValid)
            {
                throw new BadRequestException("Invalid Request");
            }

            return(_crudService.Add(dto));
        }
        /// <summary>
        /// 修改权限
        /// </summary>
        /// <returns></returns>
        public CommandResult <object> ModifyPermissions(ModifyPermissionsRequestModel requestModel)
        {
            var result = new CommandResult <object>();

            using (var db = new FrameContext())
            {
                if (!_rolesService.Exist(db, a => a.Id == requestModel.RoleId))
                {
                    result.Message = "该角色在系统中已不存在,请刷新后再试";
                }
                else if (!_leftMenusService.Exist(db, a => a.Id == requestModel.LeftMenuId))
                {
                    result.Message = "该菜单在系统中已不存在,请刷新后再试";
                }
                else if (!_permissionsService.Exist(db, a => a.Id == requestModel.PermissionsId))
                {
                    result.Message = "该权限系统中已不存在,请刷新后再试";
                }
                else
                {
                    var entity = BaseService.Find(db, a =>
                                                  a.RoleId == requestModel.RoleId && a.LeftMenuId == requestModel.LeftMenuId &&
                                                  a.PermissionsId == requestModel.PermissionsId);
                    if (entity != null)
                    {
                        entity.Have = requestModel.Have;
                        if (!BaseService.Update(db, entity))
                        {
                            result.Message = "系统未知原因";
                        }
                        else
                        {
                            result.ResultStatus = ResultStatus.Success;
                        }
                    }
                    else
                    {
                        var model = new LeftMenuPermissions
                        {
                            RoleId        = requestModel.RoleId,
                            LeftMenuId    = requestModel.LeftMenuId,
                            PermissionsId = requestModel.PermissionsId,
                            Have          = requestModel.Have
                        };
                        if (!BaseService.Add(db, model))
                        {
                            result.Message = "系统未知原因";
                        }
                        else
                        {
                            result.ResultStatus = ResultStatus.Success;
                        }
                    }
                }
            }
            return(result);
        }
예제 #17
0
        public IHttpActionResult Post(L entity)
        {
            if (string.IsNullOrWhiteSpace(entity.ID))
            {
                entity.ID = Guid.NewGuid().ToString();
            }

            return(Ok(baseService.Add(entity)));
        }
예제 #18
0
        public virtual IHttpActionResult Add([FromBody] ViewModel entity)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var newEntity = entityService.Add(entity);

            return(Json((newEntity), BOT_SERIALIZER_SETTINGS));
        }
예제 #19
0
        public IHttpActionResult Post(T model)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(ModelState));
            }
            bool add = service.Add(model);

            return(this.Ok(add));
        }
예제 #20
0
        public async Task <IHttpActionResult> Post(T model)
        {
            model.Id = Guid.NewGuid().ToString();
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var add = Service.Add(model);

            return(Ok(model.Id));
        }
예제 #21
0
        public IHttpActionResult Post(T entity)
        {
            // StudentService service = new StudentService(new StudentRepository(new BusinessDbContext()));
            if (string.IsNullOrWhiteSpace(entity.Id))
            {
                entity.Id = Guid.NewGuid().ToString();
            }
            // this is a test
            var addedId = Service.Add(entity);

            return(Ok(addedId));
        }
예제 #22
0
 public IActionResult Post([FromBody] PlaneTypeDto value)
 {
     if (ModelState.IsValid)
     {
         try
         {
             service.Add(value);
         }
         catch (Exception) { return(BadRequest()); }
         return(Ok());
     }
     return(BadRequest());
 }
예제 #23
0
        public String Register(FormCollection fd)
        {
            var user = new User();

            TryUpdateModel <User>(user, fd);
            if (baseServiceU.Exist(p => p.UserName == user.UserName))
            {
                return("0");
            }
            user.AddTime    = DateTime.UtcNow;
            user.UpdateTime = DateTime.UtcNow;
            baseServiceU.Add(user);
            return("1");
        }
예제 #24
0
        public virtual IHttpActionResult Post(T model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            model.Id       = Guid.NewGuid().ToString();
            model.Created  = Convert.ToDateTime(model.Created);
            model.Modified = Convert.ToDateTime(model.Modified);

            var add = Service.Add(model);

            return(Ok(model.Id));
        }
예제 #25
0
        public async Task <IActionResult> Post([FromBody] CrewDto value)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await Task.Run(() => service.Add(mapper.Map <CrewDto, Crew>(value)));

                    await service.SaveChangesAsync();
                }
                catch (Exception) { return(BadRequest()); }
                return(Ok());
            }
            return(BadRequest());
        }
예제 #26
0
        /// <summary>
        /// 库存操作写入日志(事务中)
        /// </summary>
        /// <param name="records">写入对象,Barcode、StoreId、Number和Source必填</param>
        /// <param name="isSave">是否立即保存,即不在事务中</param>
        public static void SaveRecord(List <InventoryRecord> records, bool isSave = false)
        {
            var recordList = new List <InventoryRecord>();
            var storeIds   = records.Select(o => o.StoreId).Distinct();
            var barcodes   = records.Select(o => o.Barcode).Distinct();
            var inventList = BaseService <Inventory> .FindList(o => barcodes.Contains(o.Barcode) && storeIds.Contains(o.StoreId));

            foreach (var rd in records)
            {
                if (rd.StoreId.IsNullOrEmpty() || rd.Barcode.IsNullOrEmpty() ||
                    rd.Number == 0 || rd.Source == 0)
                {
                    throw new Exception("操作日志中Barcode、StoreId、Number、OperatType和Source必填!");
                }
                var invent = inventList.FirstOrDefault(o => o.StoreId == rd.StoreId && o.Barcode == rd.Barcode);
                if (invent != null)
                {
                    if (rd.OperatType == 2)
                    {
                        invent.StockNumber -= rd.Number;
                    }
                    else
                    {
                        invent.StockNumber += rd.Number;
                    }
                }
                else
                {
                    invent = new Inventory()
                    {
                        Barcode     = rd.Barcode,
                        StoreId     = rd.StoreId,
                        StockNumber = rd.OperatType == 2? 0 - rd.Number:rd.Number
                    };
                    BaseService <Inventory> .Add(invent, false);
                }
                recordList.Add(new InventoryRecord()
                {
                    Barcode   = rd.Barcode,
                    CreateDT  = DateTime.Now,
                    CreateUID = Sys.CurrentUser.UID,
                    StoreId   = rd.StoreId,
                    Source    = rd.Source,
                    Number    = invent.StockNumber
                });
            }
            AddRange(recordList, isSave);
        }
예제 #27
0
        /// <summary>
        /// 新增或编辑一条分期记录
        /// </summary>
        /// <returns></returns>
        public OpResult CreateOrUpdateStageRule(ReturnStageRules _stageRule)
        {
            var entity = _service.GetStageRuleByReturnRuleId(_stageRule.ReturnRuleId);

            if (entity.Id == 0)
            {//新建
                _stageRule.CompanyId = CommonService.CompanyId;
                _stageRule.CreateDT  = DateTime.Now;
                _stageRule.CreateUID = Sys.CurrentUser.UID;
                return(BaseService <ReturnStageRules> .Add(_stageRule));
            }
            else
            { //编辑
                return(_service.UpdateStageRule(_stageRule));
            }
        }
예제 #28
0
        public IHttpActionResult Add(T model)
        {
            if (!ModelState.IsValid)
            {
                return(this.BadRequest(ModelState));
            }

            model.ModifiedBy = User.Identity.GetUserName();
            model.CreatedBy  = User.Identity.GetUserName();

            model.Id = Guid.NewGuid().ToString();

            var add = service.Add(model);

            return(this.Ok(add));
        }
예제 #29
0
 /// <summary>
 /// 添加
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public virtual Result <long> Add(T model)
 {
     try
     {
         var chk = Check(model);
         if (!chk.IsSuccess())
         {
             return(chk);
         }
         var id = _service.Add(model, "");
         return(Result <long> .SuccessBack(id));
     }
     catch (Exception ex)
     {
         return(Result <long> .FailBack(ex.Message));
     }
 }
예제 #30
0
        /// <summary>
        /// add a new entity
        /// </summary>
        /// <param name="_rechargeGift"></param>
        /// <returns></returns>
        public OpResult CreateRechargeGift(Entity.RechargeGifts _rechargeGift)
        {
            if (_rechargeGift.Id == 0)
            {//add
                _rechargeGift.RuleId    = Pharos.Logic.CommonRules.GUID;
                _rechargeGift.CreateDT  = DateTime.Now;
                _rechargeGift.CreateUID = Sys.CurrentUser.UID;
                _rechargeGift.CompanyId = CommonService.CompanyId;
                var currentDate = DateTime.Now;
                if (!string.IsNullOrEmpty(_rechargeGift.ExpiryStart) && !string.IsNullOrEmpty(_rechargeGift.ExpiryEnd))
                {
                    //get state

                    if ((Convert.ToDateTime(_rechargeGift.ExpiryStart) > currentDate && currentDate < Convert.ToDateTime(_rechargeGift.ExpiryEnd).AddDays(1)) || currentDate.ToString("yyyy-MM-dd") == _rechargeGift.ExpiryStart)
                    {
                        _rechargeGift.State = 1;//activing
                    }
                    else if (Convert.ToDateTime(_rechargeGift.ExpiryStart) > currentDate)
                    {
                        _rechargeGift.State = 0;
                    }
                    else if (Convert.ToDateTime(_rechargeGift.ExpiryEnd).AddDays(1) < currentDate)
                    {
                        _rechargeGift.State = 2;//actived
                    }
                }
                else if (!string.IsNullOrEmpty(_rechargeGift.ExpiryStart))
                {
                    //ExpiryEnd is null
                    if (Convert.ToDateTime(_rechargeGift.ExpiryStart) > currentDate)
                    {
                        _rechargeGift.State = 0;
                    }
                    else
                    {
                        _rechargeGift.State = 1;
                    }
                }
                return(BaseService <Entity.RechargeGifts> .Add(_rechargeGift));
            }
            else
            {
                //update
                return(_service.UpdateRechargeGift(_rechargeGift));
            }
        }
예제 #31
0
        public CommandResultViewModel UserReg(string userName, string pwd, string email, string QQ, string companyName)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                IUserService serv = new UserService();
                bool isExists = serv.ExistsUser(userName);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("用户名" + userName + "已经存在,请重新输入!");
                    return vm;
                }

                IEMTenantService tenantServ = new EMTenantService();
                var tempTenant = tenantServ.SelectByName(companyName);
                if (tempTenant != null)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("姓名/公司名" + companyName + "已经存在,请重新输入!");
                    return vm;
                }
                
                IdentityNoService identityNoServ = new IdentityNoService();
                string tenantCode = identityNoServ.GetTenantSerialNo();
                EMTenant tenant = GetTenant(tenantCode,email,QQ,companyName,userName);
                EMUserGroup userGroup = GetEMUserGroup(identityNoServ, tenantCode);
                EMVehicleGroup vehicleGroup = GetEMVehicleGroup(identityNoServ,userName, tenantCode);
                EMUser user = GetEMUser(identityNoServ,userName, pwd, email,QQ, tenant, userGroup);
                IBaseService baseServ = new BaseService();
                tenant.RegisterUserCode = user.UserCode;
                baseServ.Add<EMTenant>(tenant);
                baseServ.Add<EMUserGroup>(userGroup);
                baseServ.Add<EMVehicleGroup>(vehicleGroup);
                baseServ.Add<EMUser>(user);

                vm.CommandResult = EnumCommandResult.Success;
                return vm;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
                return vm;
            }
        }
예제 #32
0
        public ActionResult GetComputeBackPayList([DataSourceRequest] DataSourceRequest request, Can_ComputeBackPaySearchModel model)
        {
            string status = string.Empty;
            string note = "Tổng Hợp Trả Lại Tiền Ăn ";

            var baseService = new BaseService();
            var dataComputes = GetListData<Can_ComputeBackPayModel, Can_ComputeBackPayModel, Can_ComputeBackPaySearchModel>(request, model, ConstantSql.hrm_can_sp_get_ComputeBackPay, ref status);
            var computeBackPayModels = new List<Can_ComputeBackPayModel>();
            if (dataComputes.Any() && model != null && model.MonthYear.HasValue)
            {
                var month = model.MonthYear.Value.Month;
                var year = model.MonthYear.Value.Year;

                var backPays = baseService.GetAllUseEntity<Can_BackPayEntity>(ref status).Where(p => p.MonthYear.HasValue && p.MonthYear.Value.Year == year && p.MonthYear.Value.Month == month).ToList();

                foreach (var canComputeBackPayModel in dataComputes)
                {
                    var backPay = backPays.Where(p => p.ProfileID == canComputeBackPayModel.ProfileID && p.MealAllowanceTypeSettingID == canComputeBackPayModel.MealAllowanceTypeSettingID).FirstOrDefault();

                    #region Thêm mới vào Can_BackPay
                    if (backPay == null)
                    {
                        var backPayEntity = new Can_BackPayEntity
                        {
                            ProfileID = canComputeBackPayModel.ProfileID,
                            MonthYear = model.MonthYear,
                            MealAllowanceTypeSettingID = canComputeBackPayModel.MealAllowanceTypeSettingID
                        };

                        if (canComputeBackPayModel.IsFullPay.HasValue && canComputeBackPayModel.IsFullPay.Value)
                        {
                            //neu isFullPay => cap nhat count , amount
                            backPayEntity.Count = (int?)canComputeBackPayModel.Total;
                            backPayEntity.Amount = (canComputeBackPayModel.Amount * canComputeBackPayModel.Total);
                        }
                        else
                        {
                            //neu ko la isFullPay => cap nhat CountByFomular,AmountByFomular
                            backPayEntity.CountByFomular = (int?)ComputeAmountBackPay(canComputeBackPayModel.Total);
                            backPayEntity.AmountByFomular = canComputeBackPayModel.Amount * ComputeAmountBackPay(canComputeBackPayModel.Total);
                        }
                        //add
                        backPayEntity.Note = note + canComputeBackPayModel.MonthYear;
                        baseService.Add<Can_BackPayEntity>(backPayEntity);
                        backPays.Add(backPayEntity);
                    }
                    #endregion

                    #region Chỉnh sửa Can_BackPay
                    else
                    {
                        //edit
                        //neu isFullPay => cap nhat count , amount
                        //neu ko la isFullPay => cap nhat CountByFomular,AmountByFomular
                        if (canComputeBackPayModel.IsFullPay.HasValue && canComputeBackPayModel.IsFullPay.Value)
                        {
                            //neu isFullPay => cap nhat count , amount
                            backPay.Count = (int?)canComputeBackPayModel.Total;
                            backPay.Amount = canComputeBackPayModel.Amount * canComputeBackPayModel.Total;
                        }
                        else
                        {
                            //neu ko la isFullPay => cap nhat CountByFomular,AmountByFomular
                            backPay.CountByFomular = (int?)ComputeAmountBackPay(canComputeBackPayModel.Total);
                            backPay.AmountByFomular = canComputeBackPayModel.Amount * ComputeAmountBackPay(canComputeBackPayModel.Total);
                        }

                        if (!string.IsNullOrEmpty(backPay.Note))
                        {
                            canComputeBackPayModel.Note = backPay.Note;
                        }
                        backPay.Note = note + canComputeBackPayModel.MonthYear;
                        baseService.Edit<Can_BackPayEntity>(backPay);
                    }
                    #endregion
                }

                #region List hiển thị
                var profileIds = dataComputes.Select(p => p.ProfileID).ToList();

                var modelSearch = new Can_BackPaySearchModel();
                modelSearch.ProfileName = null;
                modelSearch.DateFrom = null;
                modelSearch.DateTo = null;

                var datas = GetListData<Can_BackPayModel, Can_BackPayEntity, Can_BackPaySearchModel>(request, modelSearch, ConstantSql.hrm_can_sp_get_BackPay, ref status);
                computeBackPayModels = datas.Where(p => p.MonthYear.HasValue && p.MonthYear.Value.Year == year && p.MonthYear.Value.Month == month)
                     .Select(p => new Can_ComputeBackPayModel
                     {
                         ProfileName = p.ProfileName,
                         MonthYear = p.MonthYear.HasValue ? p.MonthYear.Value.ToString("MM-yyyy") : string.Empty,
                         Note = p.Note,
                         Amount = p.Amount ?? 0,
                         MealAllowanceTypeSettingID = p.MealAllowanceTypeSettingID,
                         Type = p.MealAllowanceTypeName,
                         CountByFomular = ComputeAmountBackPay(p.CountByFomular ?? 0),
                         AmountByFomular = p.AmountByFomular,
                         Summary = ComputeAmountBackPay(p.CountByFomular ?? 0) + (p.Count ?? 0),
                         Total = p.Count ?? 0
                     })
                     .ToList();

                request.Page = 1;
                var dataSourceResult = computeBackPayModels.ToDataSourceResult(request);
                dataSourceResult.Total = computeBackPayModels.Count() <= 0 ? 0 : datas.FirstOrDefault().TotalRow;
                return Json(dataSourceResult);
                #endregion
            }

            return Json(null);
            #region Phân Trang


            #endregion


            // return Json(computeBackPayModels.ToDataSourceResult(request));
        }
예제 #33
0
        public string SaveContractAndNextSalaryApprovedEvaluation(Hre_ContractEntity contract, string userLogin)
        {

            using (var context = new VnrHrmDataContext())
            {
                var contractServices = new Hre_ContractServices();
                string message = string.Empty;
                var baseServices = new BaseService();
                string status = string.Empty;
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));

                if (contract.DateEndNextContract == null)
                {
                    return string.Empty;
                }

                #region Lấy WorkHistory
                var repoWorkhistory = new Hre_WorkHistoryRepository(unitOfWork);
                var lstWorkhistory = new List<Hre_WorkHistory>().Select(d => new
                {
                    d.ProfileID,
                    d.SalaryClassID
                }).ToList();

                lstWorkhistory.AddRange(repoWorkhistory.FindBy(s => s.IsDelete == null).Select(d => new
                        {
                            d.ProfileID,
                            d.SalaryClassID
                        }).ToList());
                #endregion

                // Lấy biến Dateend này gắn cho quá trình công tác khi cập nhật quá trinh công tác ở dưới
                DateTime? dateEnd = contract.DateEnd;

                var profile = baseServices.GetData<Hre_ProfileEntity>(contract.ProfileID, ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault();

                var lstObjSalaryRank = new List<object>();
                lstObjSalaryRank.Add(null);
                lstObjSalaryRank.Add(null);
                lstObjSalaryRank.Add(1);
                lstObjSalaryRank.Add(int.MaxValue - 1);
                var lstSalaryRank = baseServices.GetData<Cat_SalaryRankEntity>(lstObjSalaryRank, ConstantSql.hrm_cat_sp_get_SalaryRank, userLogin, ref status).ToList();

                #region Lấy Att_Grade
                var att_GradeRepository = new Att_GradeRepository(unitOfWork);
                var lstAttGrade = new List<Att_Grade>().Select(d => new
                {
                    d.ProfileID,
                    d.MonthEnd
                }).ToList();

                lstAttGrade.AddRange(att_GradeRepository.FindBy(s => s.IsDelete == null).Select(d => new
                {
                    d.ProfileID,
                    d.MonthEnd
                }).ToList());
                #endregion

                #region Lấy Sal_Grade
                var salGradeRepository = new Sal_GradeRepository(unitOfWork);
                var lstSalGrade = new List<Sal_Grade>().Select(d => new
                {
                    d.ProfileID,
                    d.MonthEnd
                }).ToList();

                lstSalGrade.AddRange(salGradeRepository.FindBy(s => s.IsDelete == null).Select(d => new
                {
                    d.ProfileID,
                    d.MonthEnd
                }).ToList());

                #endregion

                var lstObjGradePayroll = new List<object>();
                lstObjGradePayroll.Add(null);
                lstObjGradePayroll.Add(null);
                lstObjGradePayroll.Add(1);
                lstObjGradePayroll.Add(int.MaxValue - 1);
                var lstGradePayroll = baseServices.GetData<Cat_GradePayrollEntity>(lstObjGradePayroll, ConstantSql.hrm_cat_sp_get_GradePayroll, userLogin, ref status).ToList();

                var lstObjGradeAtt = new List<object>();
                lstObjGradeAtt.AddRange(new object[10]);
                lstObjGradeAtt[8] = 1;
                lstObjGradeAtt[9] = int.MaxValue - 1;
                var lstGradeAtt = baseServices.GetData<Cat_GradeAttendanceEntity>(lstObjGradeAtt, ConstantSql.hrm_cat_sp_get_Cat_GradeAttendance, userLogin, ref status).ToList();

                var lstObjCurrency = new List<object>();
                lstObjCurrency.Add(null);
                lstObjCurrency.Add(null);
                lstObjCurrency.Add(1);
                lstObjCurrency.Add(int.MaxValue - 1);
                var lstCurrency = baseServices.GetData<Cat_CurrencyEntity>(lstObjCurrency, ConstantSql.hrm_cat_sp_get_Currency, userLogin, ref status).ToList();
                var lstCurrencyNew = lstCurrency.Where(s => s.CurrencyName == "VND").FirstOrDefault();

                var lstObjContractType = new List<object>();
                lstObjContractType.Add(null);
                lstObjContractType.Add(null);
                lstObjContractType.Add(null);
                lstObjContractType.Add(null);
                lstObjContractType.Add(1);
                lstObjContractType.Add(int.MaxValue - 1);
                var lstContractType = baseServices.GetData<Cat_ContractTypeEntity>(lstObjContractType, ConstantSql.hrm_cat_sp_get_ContractType, userLogin, ref status).ToList();

                var objInsuranceConfig = new List<object>();
                objInsuranceConfig.Add(1);
                objInsuranceConfig.Add(int.MaxValue - 1);
                var lstInsuranceConfig = baseServices.GetData<Cat_InsuranceConfigEntity>(objInsuranceConfig, ConstantSql.hrm_cat_sp_get_InsuranceConfig, userLogin, ref status).ToList();


                #region Lấy Sal_InsuranceSalary
                var objInsurance = new List<object>();
                objInsurance.AddRange(new object[9]);
                objInsurance[7] = 1;
                objInsurance[8] = int.MaxValue - 1;
                var lstInsurance = baseServices.GetData<Sal_InsuranceSalaryEntity>(objInsurance, ConstantSql.hrm_sal_sp_get_InsuranceSalary, userLogin, ref status).ToList();

                #endregion

                #region Lấy Hre_Contract
                var hreContractRepository = new Hre_ContractRepository(unitOfWork);
                var lstContractIdByProfileID = new List<Hre_Contract>().Select(d => new
                {
                    d.ProfileID,
                    d.ContractTypeID
                }).ToList();

                lstContractIdByProfileID.AddRange(hreContractRepository.FindBy(s => s.IsDelete == null && s.ProfileID == contract.ProfileID).Select(d => new
                {
                    d.ProfileID,
                    d.ContractTypeID
                }).ToList());

                #endregion

                var listIdContract = string.Empty;

                if (lstContractIdByProfileID != null)
                {
                    listIdContract = string.Join(",", lstContractIdByProfileID.Select(d => d.ContractTypeID));
                }
                var contractTypeEntity = new Cat_ContractTypeEntity();
                if (contract.NextContractTypeID != null)
                {
                    contractTypeEntity = lstContractType.Where(s => contract.NextContractTypeID.Value == s.ID).FirstOrDefault();
                }
                else
                {
                    message = ConstantMessages.WarningContractHaveNotNextContract.ToString().TranslateString();
                    return message;
                }

                if (contractTypeEntity != null)
                {
                    if (contractTypeEntity.Type == EnumDropDown.TypeContract.E_NODURATION.ToString())
                    {
                        return string.Empty;
                    }
                }

                var workingHistoryEntity = lstWorkhistory.Where(s => s.ProfileID == contract.ProfileID).FirstOrDefault();


                #region Lấy Sal_Grade by profileid
                var objSalGrade = new List<object>();
                objSalGrade.Add(contract.ProfileID);
                objSalGrade.Add(null);
                objSalGrade.Add(1);
                objSalGrade.Add(int.MaxValue - 1);
                var salGradeByProfileIDEntity = baseServices.GetData<Sal_GradeEntity>(objSalGrade, ConstantSql.hrm_sal_sp_get_GradeAndAllownaceByProId, userLogin, ref status).FirstOrDefault();
                #endregion

                #region Lấy Att_Grade by profileid
                var objAttGrade = new List<object>();
                objAttGrade.Add(contract.ProfileID);
                objAttGrade.Add(null);
                objAttGrade.Add(1);
                objAttGrade.Add(int.MaxValue - 1);
                var attGradeByProfileIDEntity = baseServices.GetData<Att_GradeEntity>(objAttGrade, ConstantSql.hrm_att_sp_get_GradeAttendanceByProIdCutID, userLogin, ref status).FirstOrDefault();
                #endregion

                if (contractTypeEntity == null)
                {
                    return string.Empty;
                }

                // Theo task 0049932 - sinh ra lương với ngày hiệu lực = ngày bắt đầu hd.
                var dateEffect = DateTime.Now;

                var contracttypeByContract = lstContractType.Where(s => s.ID == contract.ContractTypeID).FirstOrDefault();
                if (contract.ContractResult == EnumDropDown.ResultContract.PASS.ToString())
                {
                    if (contract.ContractEvaType == EnumDropDown.ContractEvaType.E_EXPIRED_APPRENTICE.ToString())
                    {

                        //chưa tìm dc cách xử lý nên hard code 
                        var lstSalaryRankNew = new Cat_SalaryRankEntity();
                        if (contract.RankDetailForNextContract != null)
                        {
                            lstSalaryRankNew = lstSalaryRank.Where(s => contract.RankDetailForNextContract != null && s.ID == contract.RankDetailForNextContract.Value).FirstOrDefault();
                        }
                        else
                        {
                            lstSalaryRankNew = lstSalaryRank.Where(s => contract.RankRateID != null && s.ID == contract.RankRateID.Value).FirstOrDefault();
                        }

                        #region Xử lý Hre_Contract
                        if (contract.TypeOfPass == EnumDropDown.TypeOfPass.E_SIGNED_NEXTCONTRACT.ToString())
                        {
                            int month = 0;
                            if (contractTypeEntity != null && contractTypeEntity.ValueTime != null)
                            {
                                month = (int)contractTypeEntity.ValueTime.Value;
                                if (contractTypeEntity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                                {
                                    month = month * 12;
                                }
                                contractTypeEntity.DateStart = contract.DateEnd.Value.AddDays(1);

                                //chưa tìm dc cách xử lý nên hard code 
                                //  var nextContractTypeID = Common.ConvertToGuid(contractTypeEntity.ContractNextID).ToString();
                                var contractEntity = new Hre_ContractEntity
                                {
                                    ProfileID = contract.ProfileID,
                                    ProfileName = contract.ProfileName,
                                    DateStart = contract.DateEnd.Value.AddDays(1),
                                    DateSigned = contract.DateEnd.Value.AddDays(1),
                                    JobTitleID = contract.JobTitleID,
                                    PositionID = contract.PositionID,
                                    DateEnd = contractTypeEntity.DateStart.Value.AddMonths(month),
                                    Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                    RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                                    ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                    ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                    SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                    ContractTypeID = contractTypeEntity.ID,
                                    DateEndNextContract = contract.DateEndNextContract,
                                };
                                if (contract.DateEndNextContract != null)
                                {
                                    contractEntity.DateEnd = contract.DateEndNextContract.Value;
                                }

                                contractEntity = SetNewCodeContract(contractEntity, listIdContract, userLogin);

                                #region Nếu là loại hđ xác định thời hạn thì update lại cột TimesContract theo task 0049731
                                if (contracttypeByContract != null && contracttypeByContract.Type == HRM.Infrastructure.Utilities.EnumDropDown.TypeContract.E_DURATION.ToString())
                                {
                                    try
                                    {
                                        string times = contractEntity.ContractNo.Substring(contractEntity.ContractNo.Length - 1, 1);
                                        int Year = int.Parse(times);
                                        contractEntity.TimesContract = Year;
                                    }
                                    catch
                                    {
                                    }
                                }
                                #endregion
                                contractEntity.Status = "E_APPROVED";
                                contractEntity.StatusEvaluation = "E_APPROVED";
                                contractEntity.DateExtend = contractEntity.DateEnd;
                                if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                                {
                                    return string.Empty;
                                }
                                message = contractServices.Add(contractEntity);
                                dateEffect = contractEntity.DateStart;
                            }
                            else
                            {
                                contractTypeEntity.DateStart = contract.DateEnd.Value.AddDays(1);

                                //chưa tìm dc cách xử lý nên hard code 
                                var contractEntity = new Hre_ContractEntity
                                {
                                    ProfileID = contract.ProfileID,
                                    ProfileName = contract.ProfileName,
                                    DateStart = contract.DateEnd.Value.AddDays(1),
                                    DateSigned = contract.DateEnd.Value.AddDays(1),
                                    JobTitleID = contract.JobTitleID,
                                    PositionID = contract.PositionID,
                                    Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                    RankRateID = lstSalaryRankNew == null ? contract.RankRateID : lstSalaryRankNew.ID,
                                    ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                    ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                    SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                    ContractTypeID = contractTypeEntity.ID
                                };

                                if (contract.DateEndNextContract != null)
                                {
                                    contractEntity.DateEnd = contract.DateEndNextContract.Value;
                                }

                                contractEntity.DateExtend = contract.DateEnd;
                                contractEntity.StatusEvaluation = "E_APPROVED";

                                if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                                {
                                    return string.Empty;
                                }

                                message = contractServices.Add(contractEntity);
                                dateEffect = contractEntity.DateStart;
                            }
                        }

                        //Edit lai StatusEvaluation 
                        contract.StatusEvaluation = "E_APPROVED";
                        message = contractServices.Edit(contract);

                        #endregion

                        #region Xử Lý Sal_BasicSalary
                        var salaryEntity = new Sal_BasicSalaryEntity
                        {
                            ProfileID = contract.ProfileID,
                            ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                            RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                            GrossAmount = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryStandard.ToString(),
                            DateOfEffect = dateEffect,
                            CurrencyID = lstCurrencyNew.ID,
                            Note = contract.Remark,
                            Status = "E_APPROVED"
                        };
                        message = baseServices.Add(salaryEntity);

                        #endregion

                        #region Xử Lý Hre_Profile
                        var profileEntity = profile.CopyData<Hre_ProfileEntity>();
                        Guid? _AbilityTileID = null;
                        profileEntity.SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID;
                        if (profileEntity.SalaryClassID != null)
                        {
                            var abilityTitleBySalaryClass = baseServices.GetData<Cat_AbilityTileEntity>(Common.DotNetToOracle(profileEntity.SalaryClassID.ToString()), ConstantSql.hrm_cat_sp_get_AbilityTileBySalaryClassId, userLogin, ref status).FirstOrDefault();
                            if (abilityTitleBySalaryClass != null)
                            {
                                _AbilityTileID = abilityTitleBySalaryClass.ID;
                                profileEntity.AbilityTileID = _AbilityTileID;
                            }
                        }

                        baseServices.Edit(profileEntity);

                        if (workingHistoryEntity != null)
                        {
                            if (workingHistoryEntity.SalaryClassID != lstSalaryRankNew.SalaryClassID)
                            {
                                var workhistoryEntity = new Hre_WorkHistoryEntity
                                {
                                    ProfileID = contract.ProfileID,
                                    SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                    DateEffective = dateEnd != null ? dateEnd.Value.AddDays(1) : DateTime.Now,
                                    AbilityTileID = _AbilityTileID,
                                    Status = "E_APPROVED"

                                };
                                message = baseServices.Add(workhistoryEntity);
                            }
                        }
                        else
                        {
                            var workhistoryEntity = new Hre_WorkHistoryEntity
                            {
                                ProfileID = contract.ProfileID,
                                SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                DateEffective = dateEnd != null ? dateEnd.Value.AddDays(1) : DateTime.Now,
                                Status = "E_APPROVED",

                            };
                            message = baseServices.Add(workhistoryEntity);
                        }

                        #endregion

                        #region Sal_Grade
                        var lstGradeByProfileID = lstSalGrade.Where(s => contract.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                        var lstGradePayrollByProfileID = lstGradePayroll.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                        if (salGradeByProfileIDEntity != null)
                        {
                            if (salGradeByProfileIDEntity.GradePayrollID != lstGradePayrollByProfileID.ID)
                            {
                                var gradeEntity = new Sal_GradeEntity
                                {
                                    ProfileID = contract.ProfileID,
                                    GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                    MonthStart = contract.DateSigned != null ? contract.DateSigned.Value : DateTime.Now,
                                };
                                message = baseServices.Add(gradeEntity);
                            }
                        }
                        else
                        {
                            var gradeEntity = new Sal_GradeEntity
                            {
                                //   ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                ProfileID = contract.ProfileID,
                                GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                MonthStart = contract.DateSigned != null ? contract.DateSigned.Value : DateTime.Now,
                            };
                            message = baseServices.Add(gradeEntity);
                        }
                        #endregion

                        #region Att_Grade
                        var lstAttGradeByProfileID = lstAttGrade.Where(s => contract.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                        var lstGradeAttByProfileID = lstGradeAtt.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                        if (attGradeByProfileIDEntity != null)
                        {
                            if (attGradeByProfileIDEntity.GradeAttendanceID != lstGradeAttByProfileID.ID)
                            {
                                var gradeAttEntity = new Att_GradeEntity
                                {
                                    ProfileID = contract.ProfileID,
                                    GradeAttendanceID = lstAttGradeByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                    MonthStart = contract.DateSigned != null ? contract.DateSigned.Value : DateTime.Now,
                                };
                                message = baseServices.Add(gradeAttEntity);
                            }
                        }
                        else
                        {
                            var gradeAttEntity = new Att_GradeEntity
                            {
                                // ID = lstGradeAttByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                ProfileID = contract.ProfileID,
                                GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                MonthStart = contract.DateSigned != null ? contract.DateSigned.Value : DateTime.Now,
                            };
                            message = baseServices.Add(gradeAttEntity);
                        }
                        #endregion

                        #region Xử Lý Lương BHXH
                        if (contractTypeEntity.NoneTypeInsuarance == true)
                        {
                            var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == contract.ProfileID && s.DateEffect == contract.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                            var insuranceEntity = new Sal_InsuranceSalaryEntity
                            {
                                ProfileID = contract.ProfileID,
                                InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                DateEffect = dateEffect,
                                IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance,
                                IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance,
                                IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance,
                                CurrencyID = lstCurrencyNew.ID
                            };
                            if (insuranceEntityByProfileID != null)
                            {
                                insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                insuranceEntityByProfileID.IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance;
                                insuranceEntityByProfileID.IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance;
                                insuranceEntityByProfileID.IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance;
                                message = baseServices.Edit(insuranceEntityByProfileID);
                            }
                            else
                            {
                                message = baseServices.Add(insuranceEntity);
                            }
                        }
                        if (contractTypeEntity.NoneTypeInsuarance == false)
                        {

                            var insuranceConfigEntity = lstInsuranceConfig.Where(s => s.ContractTypeID != null && s.ContractTypeID.Value == contractTypeEntity.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                            if (insuranceConfigEntity != null)
                            {
                                var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == contract.ProfileID && s.DateEffect == contract.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                                var insuranceEntity = new Sal_InsuranceSalaryEntity
                                {
                                    ProfileID = contract.ProfileID,
                                    InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                    DateEffect = dateEffect,
                                    IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial,
                                    IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy,
                                    IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth,
                                    CurrencyID = lstCurrencyNew.ID
                                };

                                if (insuranceEntityByProfileID != null)
                                {
                                    insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                    insuranceEntityByProfileID.IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial;
                                    insuranceEntityByProfileID.IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy;
                                    insuranceEntityByProfileID.IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth;
                                    message = baseServices.Edit(insuranceEntityByProfileID);
                                }
                                else
                                {
                                    message = baseServices.Add(insuranceEntity);
                                }

                            }
                        }
                        #endregion
                    }

                    if (contract.ContractEvaType == EnumDropDown.ContractEvaType.E_ANNUAL_EVALUATION.ToString() && contract.ContractResult == EnumDropDown.ResultContract.PASS.ToString())
                    {
                        var lstSalaryRankNew = new Cat_SalaryRankEntity();
                        if (contract.RankDetailForNextContract != null)
                        {
                            lstSalaryRankNew = lstSalaryRank.Where(s => contract.RankDetailForNextContract != null && s.ID == contract.RankDetailForNextContract.Value).FirstOrDefault();
                        }
                        else
                        {
                            lstSalaryRankNew = lstSalaryRank.Where(s => contract.RankRateID != null && s.ID == contract.RankRateID.Value).FirstOrDefault();
                        }

                        #region Xử lý Hre_Contract
                        int month = 0;
                        if (contractTypeEntity != null && contractTypeEntity.ValueTime != null)
                        {
                            month = (int)contractTypeEntity.ValueTime.Value;
                            if (contractTypeEntity.UnitTime == HRM.Infrastructure.Utilities.EnumDropDown.UnitType.E_YEAR.ToString())
                            {
                                month = month * 12;
                            }
                            contractTypeEntity.DateStart = contract.DateEnd.Value.AddDays(1);

                            //chưa tìm dc cách xử lý nên hard code 

                            var contractEntity = new Hre_ContractEntity
                            {
                                ProfileID = contract.ProfileID,
                                ProfileName = contract.ProfileName,
                                DateStart = new DateTime(DateTime.Now.Year, 6, 1),
                                DateSigned = new DateTime(DateTime.Now.Year, 6, 1),
                                JobTitleID = contract.JobTitleID,
                                PositionID = contract.PositionID,
                                DateEnd = contractTypeEntity.DateStart.Value.AddMonths(month),
                                Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                                ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                ContractTypeID = contractTypeEntity.ID
                            };

                            if (contract.DateEndNextContract != null)
                            {
                                contractEntity.DateEnd = contract.DateEndNextContract.Value;
                            }
                            contractEntity = SetNewCodeContract(contractEntity, listIdContract, userLogin);

                            #region Nếu là loại hđ xác định thời hạn thì update lại cột TimesContract theo task 0049731
                            if (contracttypeByContract != null && contracttypeByContract.Type == HRM.Infrastructure.Utilities.EnumDropDown.TypeContract.E_DURATION.ToString())
                            {
                                try
                                {
                                    string times = contractEntity.ContractNo.Substring(contractEntity.ContractNo.Length - 1, 1);
                                    int Year = int.Parse(times);
                                    contractEntity.TimesContract = Year;
                                }
                                catch
                                {
                                }
                            }
                            #endregion

                            contractEntity.Status = "E_APPROVED";
                            contractEntity.DateExtend = contractEntity.DateEnd;
                            contractEntity.StatusEvaluation = "E_APPROVED";

                            if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                            {
                                return string.Empty;
                            }
                            message = contractServices.Add(contractEntity);
                            dateEffect = contractEntity.DateStart;
                        }
                        else
                        {
                            contractTypeEntity.DateStart = contract.DateEnd.Value.AddDays(1);

                            //chưa tìm dc cách xử lý nên hard code 

                            var contractEntity = new Hre_ContractEntity
                            {
                                // ContractNo = getContractNo(item, item.DateSigned),
                                ProfileID = contract.ProfileID,
                                ProfileName = contract.ProfileName,
                                DateStart = new DateTime(DateTime.Now.Year, 6, 1),
                                DateSigned = new DateTime(DateTime.Now.Year, 6, 1),
                                JobTitleID = contract.JobTitleID,
                                PositionID = contract.PositionID,
                                // DateEnd = null,
                                Salary = lstSalaryRankNew == null ? 0 : lstSalaryRankNew.SalaryStandard,
                                RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                                ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                ClassRateName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryClassName,
                                SalaryRankName = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryRankName,
                                ContractTypeID = contractTypeEntity.ID
                            };

                            if (contract.DateEndNextContract != null)
                            {
                                contractEntity.DateEnd = contract.DateEndNextContract.Value;
                            }
                            contractEntity.DateExtend = contract.DateEnd;
                            contractEntity.StatusEvaluation = "E_APPROVED";
                            if (!string.IsNullOrEmpty(contractEntity.ErrorMessage))
                            {

                                return string.Empty;
                            }
                            message = contractServices.Add(contractEntity);
                            dateEffect = contractEntity.DateStart;
                        }
                        //Edit lai StatusEvaluation 
                        contract.StatusEvaluation = "E_APPROVED";
                        message = contractServices.Edit(contract);

                        #endregion

                        #region Xử Lý Sal_BasicSalary
                        var salaryEntity = new Sal_BasicSalaryEntity
                        {
                            ProfileID = contract.ProfileID,
                            ClassRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                            RankRateID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.ID,
                            GrossAmount = lstSalaryRankNew == null ? string.Empty : lstSalaryRankNew.SalaryStandard.ToString(),
                            DateOfEffect = new DateTime(DateTime.Now.Year, 6, 1),
                            CurrencyID = lstCurrencyNew.ID,
                            Note = contract.Remark,
                            Status = "E_APPROVED"

                        };
                        message = baseServices.Add(salaryEntity);

                        #endregion

                        #region Xử Lý Hre_Profile
                        var profileEntity = profile.CopyData<Hre_ProfileEntity>();
                        profileEntity.SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID;
                        Guid? _AbilityTileID = null;
                        if (profileEntity.SalaryClassID != null)
                        {
                            var abilityTitleBySalaryClass = baseServices.GetData<Cat_AbilityTileEntity>(Common.DotNetToOracle(profileEntity.SalaryClassID.ToString()), ConstantSql.hrm_cat_sp_get_AbilityTileBySalaryClassId, userLogin, ref status).FirstOrDefault();
                            if (abilityTitleBySalaryClass != null)
                            {
                                _AbilityTileID = abilityTitleBySalaryClass.ID;
                                profileEntity.AbilityTileID = _AbilityTileID;
                            }
                        }
                        message = baseServices.Edit(profileEntity);
                        if (workingHistoryEntity != null)
                        {
                            if (workingHistoryEntity.SalaryClassID != lstSalaryRankNew.SalaryClassID)
                            {
                                var workhistoryEntity = new Hre_WorkHistoryEntity
                                {
                                    ProfileID = contract.ProfileID,
                                    SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                    DateEffective = dateEnd != null ? dateEnd.Value.AddDays(1) : DateTime.Now,
                                    AbilityTileID = _AbilityTileID,
                                    Status = "E_APPROVED"
                                };
                                message = baseServices.Add(workhistoryEntity);
                            }
                        }
                        else
                        {
                            var workhistoryEntity = new Hre_WorkHistoryEntity
                            {
                                ProfileID = contract.ProfileID,
                                SalaryClassID = lstSalaryRankNew == null ? Guid.Empty : lstSalaryRankNew.SalaryClassID,
                                DateEffective = dateEnd != null ? dateEnd.Value.AddDays(1) : DateTime.Now,
                                Status = "E_APPROVED"

                            };
                            message = baseServices.Add(workhistoryEntity);
                        }
                        #endregion

                        #region Sal_Grade
                        var lstGradeByProfileID = lstSalGrade.Where(s => contract.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                        var lstGradePayrollByProfileID = lstGradePayroll.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                        if (salGradeByProfileIDEntity != null)
                        {
                            if (salGradeByProfileIDEntity.GradePayrollID != lstGradePayrollByProfileID.ID)
                            {
                                var gradeEntity = new Sal_GradeEntity
                                {
                                    //   ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                    ProfileID = contract.ProfileID,
                                    GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                    MonthStart = new DateTime(DateTime.Now.Year, 6, 1),

                                };
                                message = baseServices.Add(gradeEntity);
                            }
                        }
                        else
                        {
                            var gradeEntity = new Sal_GradeEntity
                            {
                                //  ID = lstGradeByProfileID == null ? Guid.Empty : lstGradeByProfileID.ID,
                                ProfileID = contract.ProfileID,
                                GradePayrollID = lstGradePayrollByProfileID == null ? Guid.Empty : lstGradePayrollByProfileID.ID,
                                MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                            };
                            message = baseServices.Add(gradeEntity);
                        }


                        #endregion

                        #region Att_Grade
                        var lstAttGradeByProfileID = lstAttGrade.Where(s => contract.ProfileID == s.ProfileID).ToList().OrderByDescending(s => s.MonthEnd <= DateTime.Now).FirstOrDefault();
                        var lstGradeAttByProfileID = lstGradeAtt.Where(s => s.Code == lstSalaryRankNew.Code).FirstOrDefault();
                        if (attGradeByProfileIDEntity != null)
                        {
                            if (attGradeByProfileIDEntity.GradeAttendanceID != lstGradeAttByProfileID.ID)
                            {
                                var gradeAttEntity = new Att_GradeEntity
                                {
                                    //ID = lstAttGradeByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                    ProfileID = contract.ProfileID,
                                    GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                    MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                                };
                                message = baseServices.Add(gradeAttEntity);
                            }
                        }
                        else
                        {
                            var gradeAttEntity = new Att_GradeEntity
                            {
                                //ID = lstAttGradeByProfileID == null ? Guid.Empty: lstAttGradeByProfileID.ID,
                                ProfileID = contract.ProfileID,
                                GradeAttendanceID = lstGradeAttByProfileID == null ? Guid.Empty : lstGradeAttByProfileID.ID,
                                MonthStart = new DateTime(DateTime.Now.Year, 6, 1)
                            };
                            message = baseServices.Add(gradeAttEntity);
                        }


                        #endregion

                        #region Xử Lý Lương BHXH
                        if (contractTypeEntity.NoneTypeInsuarance == true)
                        {
                            var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == contract.ProfileID && s.DateEffect == contract.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                            var insuranceEntity = new Sal_InsuranceSalaryEntity
                            {
                                ProfileID = contract.ProfileID,
                                InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                DateEffect = dateEffect,
                                IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance,
                                IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance,
                                IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance,
                                CurrencyID = lstCurrencyNew.ID,

                            };

                            if (insuranceEntityByProfileID != null)
                            {
                                insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                insuranceEntityByProfileID.IsSocialIns = contractTypeEntity.IsSocialInsurance == null ? null : contractTypeEntity.IsSocialInsurance;
                                insuranceEntityByProfileID.IsUnimploymentIns = contractTypeEntity.IsUnEmployInsurance == null ? null : contractTypeEntity.IsUnEmployInsurance;
                                insuranceEntityByProfileID.IsMedicalIns = contractTypeEntity.IsHealthInsurance == null ? null : contractTypeEntity.IsHealthInsurance;
                                message = baseServices.Edit(insuranceEntityByProfileID);
                            }
                            else
                            {
                                message = baseServices.Add(insuranceEntity);
                            }
                        }
                        if (contractTypeEntity.NoneTypeInsuarance == false)
                        {
                            var insuranceConfigEntity = lstInsuranceConfig.Where(s => s.ContractTypeID != null && s.ContractTypeID.Value == contractTypeEntity.ID).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                            if (insuranceConfigEntity != null)
                            {
                                var insuranceEntityByProfileID = lstInsurance.Where(s => s.ProfileID == contract.ProfileID && s.DateEffect == contract.DateEnd.Value.AddDays(1)).OrderByDescending(s => s.DateUpdate).FirstOrDefault();
                                var insuranceEntity = new Sal_InsuranceSalaryEntity
                                {
                                    ProfileID = contract.ProfileID,
                                    InsuranceAmount = lstSalaryRankNew.SalaryStandard,
                                    DateEffect = dateEffect,
                                    IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial,
                                    IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy,
                                    IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth,
                                    CurrencyID = lstCurrencyNew.ID
                                };
                                if (insuranceEntityByProfileID != null)
                                {
                                    insuranceEntityByProfileID.InsuranceAmount = lstSalaryRankNew.SalaryStandard;
                                    insuranceEntityByProfileID.IsSocialIns = insuranceConfigEntity.IsSocial == null ? null : insuranceConfigEntity.IsSocial;
                                    insuranceEntityByProfileID.IsUnimploymentIns = insuranceConfigEntity.IsUnEmploy == null ? null : insuranceConfigEntity.IsUnEmploy;
                                    insuranceEntityByProfileID.IsMedicalIns = insuranceConfigEntity.IsHealth == null ? null : insuranceConfigEntity.IsHealth;
                                    message = baseServices.Edit(insuranceEntityByProfileID);
                                }
                                else
                                {
                                    message = baseServices.Add(insuranceEntity);
                                }
                            }
                        }
                        #endregion
                    }
                }
                return message;
            }
        }
예제 #34
0
        public ActionResult CreateInCellLateEarly([Bind(Prefix = "models")] List<CatLateEarlyRuleModel> model, Guid id)
        {
            var service = new BaseService();
            string status = string.Empty;
            //var t = service.GetAllUserEntity<Cat_GradeMultiEntity>(ref status);
            var GradeCfg = GetData<CatLateEarlyRuleMultiModel, Cat_GradeMultiEntity>("", ConstantSql.hrm_cat_sp_get_Grade_multi);
            //var service = new RestServiceClient<CatLateEarlyRuleModel>();
            //service.SetCookies(this.Request.Cookies, _hrm_Cat_Service);

            if (model != null)
            {
                if (GradeCfg != null && GradeCfg.Count > 0 && id != Guid.Empty)
                {
                    foreach (var i in model)
                    {
                        i.GradeCfgID = GradeCfg.FirstOrDefault().ID;
                        i.GradeAttID = id;
                        //item = service.Add<Cat_LateEarlyRuleEntity, CatLateEarlyRuleModel>(i);
                        service.Add<Cat_LateEarlyRuleEntity>(i.CopyData<Cat_LateEarlyRuleEntity>());
                    }
                }

            }
            return Json("");

        }
예제 #35
0
        public GridBuilderModel Post(GridBuilderModel model)
        {
            if (model != null)
            {
                ActionService service = new ActionService(UserLogin);
                List<object> lstObj = new List<object>() { model.UserID, model.GridControlName };
                var status = string.Empty;
                var entity = service.GetDataByListParameter<Sys_ColumnModeEntity>(lstObj, ConstantSql.hrm_sys_sp_get_ColumnMode, ref status);
                model.ActionStatus = status;
                if (entity != null && model.IsGet)
                {
                    model = entity.CopyData<GridBuilderModel>();
                    model.StringXml = entity.ColumnMode;
                    return model;
                }

                if (!string.IsNullOrEmpty(model.StringXml))
                {
                    XmlDocument doc = JsonConvert.DeserializeXmlNode(model.StringXml);
                    var baseService = new BaseService();
                    Sys_ColumnModeEntity newEntity = new Sys_ColumnModeEntity()
                    {
                        UserInfoID = model.UserID,
                        GridControlName = model.GridControlName,
                        ColumnMode = doc.InnerXml + "|" + model.PageSize
                    };
                    if (entity != null)
                    {
                        newEntity.ID = entity.ID;
                        baseService.Edit<Sys_ColumnModeEntity>(newEntity);
                    }
                    else
                    {
                        baseService.Add<Sys_ColumnModeEntity>(newEntity);
                    }

                    return model;
                }
            }
            return model;
        }
예제 #36
0
        public string SaveListRoster(List<ImportRosterModel> listRosterImport)
        {
            var ImportRoster = listRosterImport.CopyData<Att_RosterEntity>();
            BaseService _ba = new BaseService();
            var result = _ba.Add<Att_RosterEntity>(ImportRoster);


            // DataErrorCode errCode= DataErrorCode.Error;
            //using (var context = new VnrHrmDataContext())
            //{
            //    var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
            //    var repo = new CustomBaseRepository<Att_Roster>(unitOfWork);
            //    repo.Add(ImportRoster);
            //    errCode  =  repo.SaveChanges();
            //    if(errCode== DataErrorCode.Success)
            //    {
            //        NotificationType.Success.ToString();
            //    }
            //    else
            //    {
            //        NotificationType.Error.ToString();
            //    }
            //}



            return result;
        }
예제 #37
0
 public string SaveListLeave(List<ImportLeavedayModel> listLeaveImport)
 {
     var ImportLeave = listLeaveImport.CopyData<Att_LeaveDayEntity>();
     BaseService _ba = new BaseService();
     var result = _ba.Add<Att_LeaveDayEntity>(ImportLeave);
     return result;
 }
예제 #38
0
        public CommandResultViewModel AddCustomer(CustomerInfoVM customerVM)
        {
            CommandResultViewModel vm = new CommandResultViewModel();
            try
            {
                UserService serv = new UserService();
                bool isExists = serv.ExistsUser(customerVM.UserInfo.UserName);
                if (isExists)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("用户名" + customerVM.UserInfo.UserName + "已经存在,请重新输入!");
                    return vm;
                }
                EMTenantService tenantServ = new EMTenantService();
                var tempTenant = tenantServ.SelectByName(customerVM.Tenant.TenantName);
                if (tempTenant != null)
                {
                    vm.CommandResult = EnumCommandResult.MisMatchCondition;
                    vm.Msg = string.Format("客户名称" + customerVM.Tenant.TenantName + "已经存在,请重新输入!");
                    return vm;
                }

                IdentityNoService identityNoServ = new IdentityNoService();
                string tenantCode = identityNoServ.GetTenantSerialNo();
                EMTenant tenant = GetEMTenant(tenantCode,customerVM.Tenant);
                EMUserGroup userGroup = GetEMUserGroup(identityNoServ, tenantCode,customerVM.UserInfo);
                EMVehicleGroup vehicleGroup = GetEMVehicleGroup(identityNoServ, customerVM.UserInfo.UserName, tenantCode);
                EMUser user = GetEMUser(identityNoServ, customerVM.UserInfo, tenant, userGroup);
                IBaseService baseServ = new BaseService();
                tenant.RegisterUserCode = user.UserCode;
                tenant.RegisterUserName = user.UserName;
                baseServ.Add<EMTenant>(tenant);
                baseServ.Add<EMUserGroup>(userGroup);
                baseServ.Add<EMVehicleGroup>(vehicleGroup);
                baseServ.Add<EMUser>(user);

                vm.CommandResult = EnumCommandResult.Success;
                vm.Msg = "新增用户成功!";
                return vm;
            }
            catch (Exception ex)
            {
                Logger.Error(ex.Message, ex);
                vm.CommandResult = EnumCommandResult.Failed;
                vm.Msg = ex.Message;
                return vm;
            }
        }
예제 #39
0
        public string ApplyPerformance(Guid? profileID, Guid? rankdetailID, DateTime? dateEffect,string userLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                string result = ConstantMessages.Succeed;
                var profileservices = new Hre_ProfileServices();
                BaseService service = new BaseService();
                string message = string.Empty;
                string status = string.Empty;
                var contractservices = new Hre_ContractServices();
                var basicSalaryServices = new Sal_BasicSalaryServices();
                var InsuranceSalaryServices = new Sal_InsuranceSalaryServices();
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repoCandidate = new Rec_CandidateRepository(unitOfWork);
                var repoHistory = new Rec_RecruitmentHistoryRepository(unitOfWork);
                var profile = service.GetData<Hre_ProfileEntity>(Common.DotNetToOracle(profileID.ToString()), ConstantSql.hrm_hr_sp_get_ProfileById, userLogin, ref status).FirstOrDefault();
                var salaryRank = service.GetData<Cat_SalaryRankEntity>(Common.DotNetToOracle(rankdetailID.ToString()), ConstantSql.hrm_cat_sp_get_SalaryRankById, userLogin, ref status).FirstOrDefault();

                Guid? _AbilitiTitleID = null;
                if (salaryRank != null && salaryRank.SalaryClassID != null)
                {
                    var abilityTitleBySalaryClass = service.GetData<Cat_AbilityTileEntity>(Common.DotNetToOracle(salaryRank.SalaryClassID.ToString()), ConstantSql.hrm_cat_sp_get_AbilityTileBySalaryClassId, userLogin, ref status).FirstOrDefault();
                    if (abilityTitleBySalaryClass != null)
                    {
                        _AbilitiTitleID = abilityTitleBySalaryClass.ID;
                    }
                }

                // theo task 0049950 - không làm gì liên quan đến hđ hết.
                //var contractybyProfile = service.GetData<Hre_ContractEntity>(Common.DotNetToOracle(profileID.ToString()), ConstantSql.hrm_hr_sp_get_ContractsByProfileId, userLogin, ref status)
                //    .OrderByDescending(s => s.DateUpdate).FirstOrDefault();

                ////if (contractybyProfile == null)
                ////{
                ////    result = ConstantDisplay.HRM_Common_ProfileNotHaveContract.ToString();
                ////    return result;
                ////}
                ////if (contractybyProfile != null && contractybyProfile.ContractNextID == null)
                ////{
                ////    result = ConstantDisplay.HRM_Common_ProfileNotHaveNextContract.ToString();
                ////    return result;
                ////}
                //if (contractybyProfile != null && contractybyProfile.ContractNextID != null)
                //{
                    //var contractype = service.GetData<Cat_ContractTypeEntity>(Guid.Parse(Common.DotNetToOracle(contractybyProfile.ContractNextID.ToString())), ConstantSql.hrm_cat_sp_get_ContractTypeById, userLogin, ref status).FirstOrDefault();
                    //if (contractype == null)
                    //{
                    //    result = ConstantDisplay.HRM_Common_ProfileNotHaveNextContract.ToString();
                    //    return result;
                    //}
                    //Hre_ContractEntity contract = new Hre_ContractEntity();
                    //contract.ProfileID = profile.ID;
                    //contract.DateStart = dateEffect.Value;
                    //contract.DateSigned = dateEffect;
                    //contract.RankRateID = rankdetailID;
                    //contract.ClassRateID = salaryRank != null ? salaryRank.SalaryClassID : null;
                    //contract.Salary = salaryRank != null ? salaryRank.SalaryStandard : null;
                    //contract.ContractTypeID = contractype.ID;
                    //if (!string.IsNullOrEmpty(contractype.Formula))
                    //{
                    //    contract = SetNewDateEndContract(contract,userLogin);
                    //}

                    //if (contractybyProfile.DateEndNextContract != null)
                    //{
                    //    contractybyProfile.DateEnd = contractybyProfile.DateEndNextContract.Value;
                    //}
                    //contractservices.Add(contract);

                    // Thêm mới lương cơ bản + lương BHXH
                    string defaultcur = null;
                    string ConfigHre = AppConfig.HRM_HRE_CONFIG.ToString();
                    List<object> lstOb = new List<object>();
                    lstOb.Add(ConfigHre);
                    lstOb.Add(null);
                    lstOb.Add(null);
                    var config = GetData<Sys_AllSettingEntity>(lstOb, ConstantSql.hrm_sys_sp_get_AllSetting, userLogin, ref status);
                    string valueConfig = AppConfig.HRM_HRE_CONFIG_DEFAULTCURRENCY.ToString();
                    if (config != null)
                    {
                        defaultcur = config.Where(s => s.Name == valueConfig).Select(s => s.Value1).FirstOrDefault().ToString();
                        List<object> listObjCurrency = new List<object>();
                        listObjCurrency.Add(null);
                        listObjCurrency.Add(defaultcur);
                        listObjCurrency.Add(1);
                        listObjCurrency.Add(Int32.MaxValue - 1);
                        var lstCurrency = service.GetData<Cat_CurrencyEntity>(listObjCurrency, ConstantSql.hrm_cat_sp_get_Currency, userLogin, ref status).FirstOrDefault();

                        var basicsalarybyprofile = service.GetData<Sal_BasicSalaryEntity>(Common.DotNetToOracle(profileID.ToString()), ConstantSql.hrm_sal_sp_get_BasicSalaryByProfileIds, userLogin, ref status)
                            .OrderByDescending(s => s.DateOfEffect).FirstOrDefault();
                        var insuransalarybyprofile = service.GetData<Sal_InsuranceSalaryEntity>(Common.DotNetToOracle(profileID.ToString()), ConstantSql.hrm_sal_sp_get_InsuranceSalaryByProfileIds, userLogin, ref status)
                     .OrderByDescending(s => s.DateEffect).FirstOrDefault();

                        if (basicsalarybyprofile != null && salaryRank != null && basicsalarybyprofile.RankRateID != rankdetailID && salaryRank.SalaryClassID == basicsalarybyprofile.ClassRateID)
                        {
                            Sal_BasicSalaryEntity basicSalary = new Sal_BasicSalaryEntity();
                            basicSalary.ProfileID = profile.ID;
                            basicSalary.GrossAmount = (salaryRank != null && salaryRank.SalaryStandard != null) ? salaryRank.SalaryStandard.Value.ToString() : null;
                            basicSalary.Amount = basicSalary.GrossAmount != null ? basicSalary.GrossAmount.Encrypt() : "";
                            basicSalary.InsuranceAmount = (salaryRank != null && salaryRank.SalaryStandard != null) ? salaryRank.SalaryStandard.Value : 0;
                            basicSalary.DateOfEffect = dateEffect.Value;
                            basicSalary.CurrencyID = lstCurrency.ID;
                            basicSalary.Status = EnumDropDown.Sal_BasicSalaryStatus.E_WATTING_APPROVED.ToString();
                            basicSalary.AmountTotal = salaryRank != null ? salaryRank.SalaryStandard : null;
                            basicSalary.ClassRateID = salaryRank.SalaryClassID;
                            basicSalary.RankRateID = salaryRank.ID;
                            basicSalaryServices.Add(basicSalary);

                            if(insuransalarybyprofile != null)
                            {
                                Sal_InsuranceSalaryEntity insuranceSalary = new Sal_InsuranceSalaryEntity();
                                insuranceSalary.ProfileID = profile.ID;
                                insuranceSalary.InsuranceAmount = salaryRank != null ? salaryRank.SalaryStandard : null;
                                insuranceSalary.DateEffect = dateEffect;
                                insuranceSalary.CurrencyID = lstCurrency.ID;
                                insuranceSalary.IsSocialIns = insuransalarybyprofile.IsSocialIns;
                                insuranceSalary.IsMedicalIns = insuransalarybyprofile.IsMedicalIns;
                                insuranceSalary.IsUnimploymentIns = insuransalarybyprofile.IsUnimploymentIns;
                                InsuranceSalaryServices.Add(insuranceSalary);
                            }
                          
                        }
                        else
                        {
                            profile.SalaryClassID = salaryRank == null ? Guid.Empty : salaryRank.SalaryClassID;
                            profile.AbilityTileID = _AbilitiTitleID;
                            profile.DateOfEffect = dateEffect;
                            service.Edit(profile);

                            var workHistoryEntity = service.GetData<Hre_WorkHistoryEntity>(Common.DotNetToOracle(profileID.ToString()), ConstantSql.hrm_hr_sp_get_WorkHistoryByProfileId, userLogin, ref status)
                                .OrderByDescending(s => s.DateEffective).FirstOrDefault();


                            if (workHistoryEntity == null || workHistoryEntity.DateEffective != dateEffect)
                            {
                                var workHistory = new Hre_WorkHistoryEntity();
                                workHistory.ProfileID = profile.ID;
                                workHistory.SalaryClassID = salaryRank != null ? salaryRank.SalaryClassID : null;
                                workHistory.DateEffective = dateEffect != null ? dateEffect.Value : DateTime.Now;
                                workHistory.AbilityTileID = _AbilitiTitleID;
                                service.Add(workHistory);
                            }
                            else
                            {
                                workHistoryEntity.SalaryClassID = salaryRank != null ? salaryRank.SalaryClassID : null;
                                workHistoryEntity.DateEffective = dateEffect != null ? dateEffect.Value : DateTime.Now;
                                workHistoryEntity.AbilityTileID = _AbilitiTitleID;
                                service.Edit(workHistoryEntity);
                            }

                            Sal_BasicSalaryEntity basicSalary = new Sal_BasicSalaryEntity();
                            basicSalary.ProfileID = profile.ID;
                            basicSalary.GrossAmount = (salaryRank != null && salaryRank.SalaryStandard != null) ? salaryRank.SalaryStandard.Value.ToString() : null;
                            basicSalary.Amount = basicSalary.GrossAmount != null ? basicSalary.GrossAmount.Encrypt() : "";
                            basicSalary.InsuranceAmount = (salaryRank != null && salaryRank.SalaryStandard != null) ? salaryRank.SalaryStandard.Value : 0;
                            basicSalary.AmountTotal = salaryRank != null ? salaryRank.SalaryStandard : null;
                            basicSalary.DateOfEffect = dateEffect.Value;
                            basicSalary.CurrencyID = lstCurrency.ID;
                            basicSalary.Status = EnumDropDown.Sal_BasicSalaryStatus.E_WATTING_APPROVED.ToString();
                            basicSalaryServices.Add(basicSalary);

                            if (insuransalarybyprofile != null)
                            {
                                Sal_InsuranceSalaryEntity insuranceSalary = new Sal_InsuranceSalaryEntity();
                                insuranceSalary.ProfileID = profile.ID;
                                insuranceSalary.InsuranceAmount = salaryRank != null ? salaryRank.SalaryStandard : null;
                                insuranceSalary.DateEffect = dateEffect;
                                insuranceSalary.CurrencyID = lstCurrency.ID;
                                insuranceSalary.IsSocialIns = insuransalarybyprofile.IsSocialIns;
                                insuranceSalary.IsMedicalIns = insuransalarybyprofile.IsMedicalIns;
                                insuranceSalary.IsUnimploymentIns = insuransalarybyprofile.IsUnimploymentIns;
                                InsuranceSalaryServices.Add(insuranceSalary);
                            }
                        }
                }
                return result;
            }
        }
예제 #40
0
        public void ImportRecruitmentHistory(string candidateIds, string UserLogin)
        {
            using (var context = new VnrHrmDataContext())
            {
                var unitOfWork = (IUnitOfWork)(new UnitOfWork(context));
                var repo = new Rec_RecruitmentCampaignRepository(unitOfWork);
                var repoCandidate = new Rec_CandidateRepository(unitOfWork);
                var lstIds = candidateIds.Split(',');
                List<Guid> listID = new List<Guid>();
                for (int i = 0; i < lstIds.Length; i++)
                {
                    try
                    {
                        listID.Add(Guid.Parse(lstIds[i].ToString()));
                    }
                    catch
                    { }
                }
                BaseService baseService = new BaseService();
                string status = string.Empty;
                var listCandidates = repoCandidate.FindBy(x => listID.Contains(x.ID)).ToList();
                foreach (var candidateModel in listCandidates)
                {
                    List<object> lstObjhistory = new List<object>();
                    lstObjhistory.Add(candidateModel.IdentifyNumber);
                    lstObjhistory.Add(candidateModel.CandidateName);
                    lstObjhistory.Add(candidateModel.DateOfBirth);
                    lstObjhistory.Add(candidateModel.DateApply);
                    
                    var recruimentHistory = baseService.ActionData<Rec_RecruitmentHistoryEntity>(lstObjhistory, ConstantSql.hrm_rec_sp_checkduplidaterecruimentHistory, true, UserLogin, ref status).FirstOrDefault();
                    if (recruimentHistory != null)
                    {
                        recruimentHistory.CandidateName = candidateModel.CandidateName;
                        recruimentHistory.DateOfBirth = candidateModel.DateOfBirth;
                        recruimentHistory.Gender = candidateModel.Gender;
                        recruimentHistory.Phone = candidateModel.Phone;
                        recruimentHistory.Mobile = candidateModel.Mobile;
                        recruimentHistory.Email = candidateModel.Email;
                        recruimentHistory.YearOfExperience = candidateModel.YearOfExperience.Value != null ? candidateModel.YearOfExperience.Value : 0;
                        recruimentHistory.PositionID = candidateModel.PositionID;
                        recruimentHistory.JobVacancyID = candidateModel.JobVacancyID;
                        recruimentHistory.DateApply = candidateModel.DateApply;
                        recruimentHistory.ScorePotential = candidateModel.ScorePotential;
                        recruimentHistory.HealthStatus = candidateModel.HealthStatus;
                        recruimentHistory.IdentifyNumber = candidateModel.IdentifyNumber;
                        baseService.Edit(recruimentHistory);
                    }
                    else
                    {
                        Rec_RecruitmentHistoryEntity recruimentHistoryentity = new Rec_RecruitmentHistoryEntity();
                        recruimentHistoryentity.CandidateID = candidateModel.ID;
                        recruimentHistoryentity.CandidateName = candidateModel.CandidateName;
                        recruimentHistoryentity.DateOfBirth = candidateModel.DateOfBirth;
                        recruimentHistoryentity.Gender = candidateModel.Gender;
                        recruimentHistoryentity.Phone = candidateModel.Phone;
                        recruimentHistoryentity.Mobile = candidateModel.Mobile;
                        recruimentHistoryentity.Email = candidateModel.Email;
                        recruimentHistoryentity.YearOfExperience = candidateModel.YearOfExperience.Value != null ? candidateModel.YearOfExperience.Value : 0;
                        recruimentHistoryentity.PositionID = candidateModel.PositionID;
                        recruimentHistoryentity.JobVacancyID = candidateModel.JobVacancyID;
                        recruimentHistoryentity.DateApply = candidateModel.DateApply;
                        recruimentHistoryentity.ScorePotential = candidateModel.ScorePotential;
                        recruimentHistoryentity.HealthStatus = candidateModel.HealthStatus;
                        recruimentHistoryentity.PassFilterResume = candidateModel.PassFilterResume;
                        recruimentHistoryentity.Status = candidateModel.Status;
                        recruimentHistoryentity.IdentifyNumber = candidateModel.IdentifyNumber;
                        baseService.Add(recruimentHistoryentity);
                    } 
                }
                repo.SaveChanges();

            }
        }
예제 #41
0
        public ActionResult CreateTemplate(string t1, bool t2, string t3, string t4, bool t5, bool t6)
        {
            var service = new BaseService();
            Cat_ExportEntity exportEntity = new Cat_ExportEntity()
            {
                ExportName = t1,
                IsColumnDynamic = t2,
                ScreenName = t4,
                TemplateFile = t3,
                IsReadOnly = t5,
                IsProtected = t6,
                IsSmartMarkers = true
            };

            service.Add(exportEntity);
            return Json("");
        }