/// <summary> /// 添加员工请假 /// </summary> /// <returns></returns> //[HttpPost] //[HttpGet] public JsonResult ApiAddLeaveInfo(LeaveInfoDto dto) { OperationResult oper = new OperationResult(OperationResultType.Error); try { dto.VerifyType = (int)VerifyFlag.Verifing; if (dto.LeaveMethod == 1) { dto.UseAnnualLeaveDay = 0; } else { dto.RestHours = 0; //dto.LeaveDays = 0; } oper = _leaveInfoContract.Insert_API(dto); return(Json(oper, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { _Logger.Error <string>(ex.ToString()); oper.Message = "服务器忙,请稍后访问"; return(Json(oper, JsonRequestBehavior.AllowGet)); } }
public ActionResult Verify(int verifyType, params int[] Ids) { var res = new OperationResult(OperationResultType.Error); int countSuccess = 0; int countFail = 0; foreach (var item in Ids) { LeaveInfo info = _leaveInfoContract.LeaveInfos.Where(x => x.Id == item).FirstOrDefault(); if (info != null && info.VerifyType == 0) { LeaveInfoDto dto = new LeaveInfoDto(); dto.Id = item; dto.LeaveReason = info.LeaveReason; dto.VacationType = info.VacationType; dto.StartTime = info.StartTime; dto.EndTime = info.EndTime; dto.LeaveDays = info.LeaveDays; dto.VerifyType = verifyType; dto.AdminId = info.AdminId; dto.VerifyAdminId = AuthorityHelper.OperatorId; dto.AnnualLeaveDays = info.AnnualLeaveDays; dto.RestHours = info.RestHours; dto.LeaveMethod = info.LeaveMethod; dto.UseAnnualLeaveDay = info.UseAnnualLeaveDay; res = _leaveInfoContract.Verify(dto); if (res.ResultType == OperationResultType.Success) { countSuccess++; string content = string.Empty; string title = "请假通知"; if (dto.VerifyType == (int)VerifyFlag.NoPass) { content = "审核不通过"; } else { content = "审核通过"; } EntityContract._notificationContract.SendNotice(dto.AdminId, title, content, sendNotificationAction); } else { countFail++; } } } var strResult = string.Format("操作完成:成功{0}个,失败{1}个", countSuccess, countFail); var oper = new OperationResult(OperationResultType.Success, strResult); return(Json(res)); }
public JsonResult Update(LeaveInfoDto dto) { dto.VerifyAdminId = AuthorityHelper.OperatorId; var res = _leaveInfoContract.Verify(dto); if (res.ResultType == OperationResultType.Success) { string content = string.Empty; string title = "请假通知"; if (dto.VerifyType == (int)VerifyFlag.NoPass) { content = "审核不通过"; } else { content = "审核通过"; } EntityContract._notificationContract.SendNotice(dto.AdminId, title, content, sendNotificationAction); } return(Json(res, JsonRequestBehavior.AllowGet)); }
public JsonResult Update(LeaveInfoDto dto) { dto.AdminId = AuthorityHelper.OperatorId ?? 0; if (dto.LeaveMethod != 1) { //dto.EndTime = dto.StartTime; if (dto.UseAnnualLeaveDay == 1) { dto.AmOrPm = 0; } } else { dto.AmOrPm = -1; } OperationResult oper = CalculationHour(dto.StartTime, dto.EndTime, dto.AdminId, dto.LeaveMethod, dto.UseAnnualLeaveDay, dto.AmOrPm); if (oper.ResultType != OperationResultType.Success) { return(Json(oper)); } string strDay = oper.Data.ToString(); if (dto.LeaveMethod == 1) { dto.UseAnnualLeaveDay = 0; dto.LeaveDays = double.Parse(strDay) - dto.RestHours; } else { dto.RestHours = 0; dto.LeaveDays = double.Parse(strDay); } if (dto.LeaveMethod == 1) { AdministratorDto adm = _administratorContract.Edit(dto.AdminId); int memberId = adm.MemberId ?? 0; MemberDto member = _memberContract.Edit(memberId); //返还上次扣除的积分 oper = _memberContract.ReturnPoints(memberId, dto.DeductionLeavePoints); if (oper.ResultType != OperationResultType.Success) { return(Json(oper)); } oper = _memberContract.CheckLeavePointsInfo(Convert.ToDecimal(dto.LeaveDays), -1, "leave"); if (oper.ResultType != OperationResultType.Success) { return(Json(oper)); } decimal deductionLeavePoints = 0; if (oper.Data != null && decimal.TryParse(oper.Data.ToString(), out deductionLeavePoints)) { dto.DeductionLeavePoints = deductionLeavePoints; //扣除修改后需要的积分 oper = _memberContract.ReturnPoints(memberId, -dto.DeductionLeavePoints); if (oper.ResultType != OperationResultType.Success) { return(Json(oper)); } } } oper = _leaveInfoContract.Update(dto); return(Json(oper)); }