/// <summary> /// 获取审批设置相关信息 /// </summary> private void GetResApproval(HttpContext context) { long resId = 0; if (!string.IsNullOrEmpty(context.Request.QueryString["resId"]) && long.TryParse(context.Request.QueryString["resId"], out resId)) { int typeId = (int)DTO.DicEnum.APPROVE_TYPE.TIMESHEET_APPROVE; if (!string.IsNullOrEmpty(context.Request.QueryString["type"]) && context.Request.QueryString["type"] == "expense") { typeId = (int)DTO.DicEnum.APPROVE_TYPE.EXPENSE_APPROVE; } BLL.UserResourceBLL userBll = new BLL.UserResourceBLL(); List <sys_resource_approver> approList = userBll.GetApprover(resId, typeId); List <sys_resource> allResList = new DAL.sys_resource_dal().GetSourceList(); List <ResAndWorkGroDto> appDtoList = new List <ResAndWorkGroDto>(); if (approList != null && approList.Count > 0 && allResList != null && allResList.Count > 0) { appDtoList = (from a in approList join b in allResList on a.resource_id equals b.id select new ResAndWorkGroDto { name = b.name, id = b.id, isActive = b.is_active == 1?"":"unActive", tier = a.tier.ToString() }).ToList(); } List <sys_resource> noAppRes = userBll.GetResourceNoApprover(resId, typeId); WriteResponseJson(new { appro = appDtoList, noAppro = noAppRes }); } }
/// <summary> /// 删除员工内部成本 /// </summary> /// <param name="context"></param> private void DeleteResInternalCost(HttpContext context) { long userId = long.Parse(context.Request.QueryString["userId"]); if (userId == 0) { var costList = context.Session["ResInternalCost"] as List <sys_resource_internal_cost>; if (costList == null || costList.Count == 1) { context.Response.Write(new Tools.Serialize().SerializeJson(false)); return; } long id = long.Parse(context.Request.QueryString["id"]); int idx = costList.FindIndex(_ => _.id == id); if (idx == -1) { context.Response.Write(new Tools.Serialize().SerializeJson(false)); return; } if (idx == 0) // 第一个 { costList[1].start_date = null; } else if (idx == costList.Count - 1) // 最后一个 { costList[idx - 1].end_date = null; } else { costList[idx - 1].end_date = costList[idx].end_date; } costList.RemoveAt(idx); context.Session["ResInternalCost"] = costList; context.Response.Write(new Tools.Serialize().SerializeJson(costList)); return; } else { var rtn = new BLL.UserResourceBLL().DeleteInternalCost(userId, long.Parse(context.Request.QueryString["id"]), LoginUserId); if (rtn == null) { context.Response.Write(new Tools.Serialize().SerializeJson(false)); return; } else { context.Response.Write(new Tools.Serialize().SerializeJson(rtn)); return; } } }
/// <summary> /// 删除员工工作组员工 /// </summary> /// <param name="context"></param> private void DeleteGroupResource(HttpContext context) { var result = false; long id = 0; if (!string.IsNullOrEmpty(context.Request.QueryString["id"])) { if (long.TryParse(context.Request.QueryString["id"], out id)) { result = new BLL.UserResourceBLL().DeleteGroupResource(id, LoginUserId); } } WriteResponseJson(result); }
/// <summary> /// 更改用户的周目标设置 /// </summary> private void ChangeResourceGoal(HttpContext context) { long resAvaId; decimal goal; long.TryParse(context.Request.QueryString["id"], out resAvaId); decimal.TryParse(context.Request.QueryString["goal"], out goal); bool result = false; if (resAvaId != 0) { result = new BLL.UserResourceBLL().EditResAvaGoal(resAvaId, goal, LoginUserId); } context.Response.Write(new Tools.Serialize().SerializeJson(result)); }
/// <summary> /// 编辑用户的被保护权限 /// </summary> private void ChangeUserDataProtected(HttpContext context) { long resId = 0; bool result = false; if (long.TryParse(context.Request.QueryString["id"], out resId)) { var thisRes = new BLL.UserResourceBLL().GetResourceById(resId); if (thisRes != null) { result = new BLL.UserResourceBLL().EditResProtected(resId, context.Request.QueryString["isEdit"] == "1", context.Request.QueryString["isView"] == "1", context.Request.QueryString["isEditUn"] == "1", context.Request.QueryString["isViewUn"] == "1", LoginUserId); } } context.Response.Write(new Tools.Serialize().SerializeJson(result)); }
/// <summary> /// 删除员工审批 /// </summary> void DeleteApproval(HttpContext context) { string resId = context.Request.QueryString["resId"]; int type = (int)DTO.DicEnum.APPROVE_TYPE.TIMESHEET_APPROVE; if (!string.IsNullOrEmpty(context.Request.QueryString["type"]) && context.Request.QueryString["type"] == "expense") { type = (int)DTO.DicEnum.APPROVE_TYPE.EXPENSE_APPROVE; } bool result = false; if (!string.IsNullOrEmpty(resId)) { result = new BLL.UserResourceBLL().DeleteUserApproval(long.Parse(resId), type, LoginUserId); } WriteResponseJson(result); }
/// <summary> /// 添加员工内部成本 /// </summary> /// <param name="context"></param> private void AddResInternalCost(HttpContext context) { var costList = context.Session["ResInternalCost"] as List <sys_resource_internal_cost>; if (string.IsNullOrEmpty(context.Request.QueryString["userId"])) { if (costList == null) { costList = new List <sys_resource_internal_cost>(); } context.Response.Write(new Tools.Serialize().SerializeJson(costList)); return; } long userId = long.Parse(context.Request.QueryString["userId"]); if (userId == 0) { if (costList == null) { costList = new List <sys_resource_internal_cost>(); } sys_resource_internal_cost cost = new sys_resource_internal_cost(); if (!string.IsNullOrEmpty(context.Request.QueryString["date"])) { cost.start_date = DateTime.Parse(context.Request.QueryString["date"]); } if (cost.start_date != null) // 填写了开始时间,计算其他项结束时间 { var fd = costList.Find(_ => _.start_date == cost.start_date); if (fd != null) // 开始时间不能重复 { context.Response.Write(new Tools.Serialize().SerializeJson(false)); return; } if (costList[0].end_date != null && costList[0].end_date.Value >= cost.start_date.Value) // 生效时间最前,作为第二条 { costList[0].end_date = cost.start_date.Value.AddDays(-1); cost.end_date = costList[1].start_date.Value.AddDays(-1); costList.Insert(1, cost); } else if (costList[0].end_date == null) // 当前只有一条,作为第二条 { costList[0].end_date = cost.start_date.Value.AddDays(-1); costList.Insert(1, cost); } else if (cost.start_date.Value > costList[costList.Count - 1].start_date.Value) // 生效时间最后,最后一条 { costList[costList.Count - 1].end_date = cost.start_date.Value.AddDays(-1); costList.Add(cost); } else // 生效时间在中间 { for (int i = 1; i < costList.Count - 2; i++) { if (costList[i].start_date.Value <cost.start_date.Value && costList[i + 1].start_date.Value> cost.start_date.Value) // 找到按顺序的时间前后项 { costList[i].end_date = cost.start_date.Value.AddDays(-1); cost.end_date = costList[i + 1].start_date.Value.AddDays(-1); costList.Insert(i + 1, cost); } } } } else if (costList.Count > 0) // 有其他项需要填写开始时间 { context.Response.Write(new Tools.Serialize().SerializeJson(false)); return; } else // 第一条 { costList.Add(cost); } cost.hourly_rate = decimal.Parse(context.Request.QueryString["rate"]); if (costList.Count == 0) { cost.id = 1; } else { cost.id = costList.Max(_ => _.id) + 1; } context.Session["ResInternalCost"] = costList; context.Response.Write(new Tools.Serialize().SerializeJson(costList)); return; } else { if (!string.IsNullOrEmpty(context.Request.QueryString["add"])) { context.Response.Write(new Tools.Serialize().SerializeJson(new BLL.UserResourceBLL().GetInternalCostList(userId))); return; } DateTime dt = DateTime.MinValue; if (!string.IsNullOrEmpty(context.Request.QueryString["date"])) { dt = DateTime.Parse(context.Request.QueryString["date"]); } var rtn = new BLL.UserResourceBLL().AddInternalCost(userId, dt, decimal.Parse(context.Request.QueryString["rate"]), LoginUserId); context.Response.Write(new Tools.Serialize().SerializeJson(rtn)); } }