/// <summary> /// 创建一个员工停缴 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个员工停缴</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, EmployeeStopPayment entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
public Common.ClientResult.Result Post(string parameters) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (!string.IsNullOrEmpty(parameters)) { List <EmployeeStopPayment> list = new List <EmployeeStopPayment>(); string[] kinds = parameters.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries); foreach (string kind in kinds) { string[] param = kind.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);//EmployeeStopPaymentID,报减类型 EmployeeStopPayment stop = new EmployeeStopPayment() { Id = Convert.ToInt32(param[0]), PoliceOperationId = Convert.ToInt32(param[1]) }; list.Add(stop); } string returnValue = string.Empty; if (m_BLL.EditStopPaymentOperation(list)) { //LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",员工停缴的信息的Id为" + entity.Id, "员工停缴");//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示修改成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.InsertFail + ",员工停缴手续的信息," + returnValue, "员工停缴");//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示修改失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
// PUT api/<controller>/5 /// <summary> /// 编辑 /// </summary> /// <param name="entity"></param> /// <returns></returns> public Common.ClientResult.Result Put([FromBody] EmployeeStopPayment entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { //数据校验 //string currentPerson = GetCurrentPerson(); //entity.UpdateTime = DateTime.Now; //entity.UpdatePerson = currentPerson; string returnValue = string.Empty; if (m_BLL.Edit(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.UpdateSucceed + ",员工停缴信息的Id为" + entity.Id, "员工停缴" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.UpdateSucceed; return(result); //提示更新成功 } else { if (validationErrors != null && validationErrors.Count > 0) { validationErrors.All(a => { returnValue += a.ErrorMessage; return(true); }); } LogClassModels.WriteServiceLog(Suggestion.UpdateFail + ",员工停缴信息的Id为" + entity.Id + "," + returnValue, "员工停缴" );//写入日志 result.Code = Common.ClientCode.Fail; result.Message = Suggestion.UpdateFail + returnValue; return(result); //提示更新失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.UpdateFail + "请核对输入的数据的格式"; return(result); //提示输入的数据的格式不对 }
/// <summary> /// 数据库导入 /// </summary> /// <param name="table">DataTable数据</param> /// <param name="cId">页面所选企业编号</param> /// <param name="message"></param> private bool ImportEmployeeAdd(DataTable table, ref string message) { bool result = false; IEmployeeBLL eadd_BLL = new EmployeeBLL(); IEmployeeStopPaymentBLL stopBll = new EmployeeStopPaymentBLL(); List <EmployeeStopPaymentSingle> lstStopPayments = new List <EmployeeStopPaymentSingle>(); StringBuilder sbError = new StringBuilder(); if (table.Rows.Count > 0) { for (int i = 1; i < table.Rows.Count; i++) { DataRow row = table.Rows[i]; string rowId = row["NO."].ToString(); string cName = row["COMPANY_NAME"].ToString(); string eName = row["EMPLOYEE_NAME"].ToString(); string cardId = row["CARD_ID"].ToString(); string yanglaoType = row["YANGLAO_TYPE"].ToString(); string shiyeType = row["SHIYE_TYPE"].ToString(); string gongshangType = row["GONGSHANG_TYPE"].ToString(); string yiliaoType = row["YILIAO_TYPE"].ToString(); string shengyuType = row["SHENGYU_TYPE"].ToString(); string gongjijinType = row["GONGJIJIN_TYPE"].ToString(); string daeType = row["DAE_TYPE"].ToString(); string buchonggongjijinType = row["BUCHONG_GONGJIJIN_TYPE"].ToString(); StringBuilder errMsg = new StringBuilder(); #region 验证 int companyId = stopBll.GetCompanyIdByNameAndUserZRId(cName, this.LoginInfo.UserID); if (companyId == 0) { errMsg.Append(string.Format("序号[{0}]:企业名称[{1}]系统中不存在.", rowId, cName)); } else if (companyId == -1) { errMsg.Append(string.Format("序号[{0}]:企业名称[{1}]不是你负责的企业.", rowId, cName)); } //string companyName = stopBll.GetCompanyNameById(companyId); //if (cName != companyName) //{ // errMsg.Append(string.Format("序号[{0}]:企业名称[{1}]和选择的企业不一致.", rowId, cName)); //} int employeeId = stopBll.GetEmployeeIdByNameAndCardId(eName, cardId); if (employeeId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:没找到姓名[{1}]身份证号[{2}]的员工.", rowId, eName, cardId)); } int relationId = stopBll.GetCompanyEmployeeRelationId(companyId, employeeId); if (relationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]不在所选企业内.", rowId, eName)); } int yanglaoAddId = 0, yanglaoOperationId = 0; if (!string.IsNullOrEmpty(yanglaoType)) { yanglaoAddId = stopBll.GetEmployeeAddIdByKindIdAndRelationId(EmployeeAdd_InsuranceKindId.养老, relationId); if (yanglaoAddId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]没有申报成功的养老保险.", rowId, eName)); } else { yanglaoOperationId = stopBll.GetPoliceOperationIdByEmployeeAddIdAndOperationName(yanglaoAddId, yanglaoType); if (yanglaoOperationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:养老报减方式[{1}]不存在.", rowId, yanglaoType)); } if (stopBll.IsHaveStopingByEmployeeAddId(yanglaoAddId)) { errMsg.AppendLine(string.Format("序号[{0}]:已存在正在报减的养老记录.", rowId)); } } } int shiyeAddId = 0, shiyeOperationId = 0; if (!string.IsNullOrEmpty(shiyeType)) { shiyeAddId = stopBll.GetEmployeeAddIdByKindIdAndRelationId(EmployeeAdd_InsuranceKindId.失业, relationId); if (shiyeAddId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]没有申报成功的失业保险.", rowId, eName)); } else { shiyeOperationId = stopBll.GetPoliceOperationIdByEmployeeAddIdAndOperationName(shiyeAddId, shiyeType); if (shiyeOperationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:失业报减方式[{1}]不存在.", rowId, shiyeType)); } if (stopBll.IsHaveStopingByEmployeeAddId(shiyeAddId)) { errMsg.AppendLine(string.Format("序号[{0}]:已存在正在报减的失业记录.", rowId)); } } } int gongshangAddId = 0, gongshangOperationId = 0; if (!string.IsNullOrEmpty(gongshangType)) { gongshangAddId = stopBll.GetEmployeeAddIdByKindIdAndRelationId(EmployeeAdd_InsuranceKindId.工伤, relationId); if (gongshangAddId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]没有申报成功的工伤保险.", rowId, eName)); } else { gongshangOperationId = stopBll.GetPoliceOperationIdByEmployeeAddIdAndOperationName(gongshangAddId, gongshangType); if (gongshangOperationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:工伤报减方式[{1}]不存在.", rowId, gongshangType)); } if (stopBll.IsHaveStopingByEmployeeAddId(gongshangAddId)) { errMsg.AppendLine(string.Format("序号[{0}]:已存在正在报减的工伤记录.", rowId)); } } } int yiliaoAddId = 0, yiliaoOperationId = 0; if (!string.IsNullOrEmpty(yiliaoType)) { yiliaoAddId = stopBll.GetEmployeeAddIdByKindIdAndRelationId(EmployeeAdd_InsuranceKindId.医疗, relationId); if (yiliaoAddId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]没有申报成功的医疗保险.", rowId, eName)); } else { yiliaoOperationId = stopBll.GetPoliceOperationIdByEmployeeAddIdAndOperationName(yiliaoAddId, yiliaoType); if (yiliaoOperationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:医疗报减方式[{1}]不存在.", rowId, yiliaoType)); } if (stopBll.IsHaveStopingByEmployeeAddId(yiliaoAddId)) { errMsg.AppendLine(string.Format("序号[{0}]:已存在正在报减的医疗记录.", rowId)); } } } int shengyuAddId = 0, shengyuOperationId = 0; if (!string.IsNullOrEmpty(shengyuType)) { shengyuAddId = stopBll.GetEmployeeAddIdByKindIdAndRelationId(EmployeeAdd_InsuranceKindId.生育, relationId); if (shengyuAddId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]没有申报成功的生育保险.", rowId, eName)); } else { shengyuOperationId = stopBll.GetPoliceOperationIdByEmployeeAddIdAndOperationName(shengyuAddId, shengyuType); if (shengyuOperationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:生育报减方式[{1}]不存在.", rowId, shengyuType)); } if (stopBll.IsHaveStopingByEmployeeAddId(shengyuAddId)) { errMsg.AppendLine(string.Format("序号[{0}]:已存在正在报减的生育记录.", rowId)); } } } int gongjijinAddId = 0, gongjijinOperationId = 0; if (!string.IsNullOrEmpty(gongjijinType)) { gongjijinAddId = stopBll.GetEmployeeAddIdByKindIdAndRelationId(EmployeeAdd_InsuranceKindId.公积金, relationId); if (gongjijinAddId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]没有申报成功的公积金.", rowId, eName)); } else { gongjijinOperationId = stopBll.GetPoliceOperationIdByEmployeeAddIdAndOperationName(gongjijinAddId, gongjijinType); if (gongjijinOperationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:公积金报减方式[{1}]不存在.", rowId, gongjijinType)); } if (stopBll.IsHaveStopingByEmployeeAddId(gongjijinAddId)) { errMsg.AppendLine(string.Format("序号[{0}]:已存在正在报减的公积金记录.", rowId)); } } } int daeAddId = 0, daeOperationId = 0; if (!string.IsNullOrEmpty(daeType)) { daeAddId = stopBll.GetEmployeeAddIdByKindIdAndRelationId(EmployeeAdd_InsuranceKindId.大病, relationId); if (daeAddId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]没有申报成功的大病保险.", rowId, eName)); } else { daeOperationId = stopBll.GetPoliceOperationIdByEmployeeAddIdAndOperationName(daeAddId, daeType); if (daeOperationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:大病报减方式[{1}]不存在.", rowId, daeType)); } if (stopBll.IsHaveStopingByEmployeeAddId(daeAddId)) { errMsg.AppendLine(string.Format("序号[{0}]:已存在正在报减的大病记录.", rowId)); } } } int buchonggongjijinAddId = 0, buchonggongjijinOperationId = 0; if (!string.IsNullOrEmpty(buchonggongjijinType)) { buchonggongjijinAddId = stopBll.GetEmployeeAddIdByKindIdAndRelationId(EmployeeAdd_InsuranceKindId.补充公积金, relationId); if (buchonggongjijinAddId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:员工[{1}]没有申报成功的补充公积金.", rowId, eName)); } else { buchonggongjijinOperationId = stopBll.GetPoliceOperationIdByEmployeeAddIdAndOperationName(buchonggongjijinAddId, buchonggongjijinType); if (buchonggongjijinOperationId == 0) { errMsg.AppendLine(string.Format("序号[{0}]:补充公积金报减方式[{1}]不存在.", rowId, buchonggongjijinType)); } if (stopBll.IsHaveStopingByEmployeeAddId(buchonggongjijinAddId)) { errMsg.AppendLine(string.Format("序号[{0}]:已存在正在报减的补充公积金记录.", rowId)); } } } if (!string.IsNullOrEmpty(errMsg.ToString())) { sbError.AppendLine(errMsg.ToString()); continue; } #endregion DateTime yearMonth = DateTime.Now; #region 养老 if (!string.IsNullOrEmpty(yanglaoType) && yanglaoAddId > 0 && yanglaoOperationId > 0) { var policeInsurance = stopBll.GetPoliceInsuranceByEmployeeAddId(yanglaoAddId); DateTime insuranceMonth = yearMonth.AddMonths(policeInsurance.InsuranceReduce ?? 0); EmployeeStopPayment stopPayment = new EmployeeStopPayment() { EmployeeAddId = yanglaoAddId, InsuranceMonth = insuranceMonth, PoliceOperationId = yanglaoOperationId, State = EmployeeStopPayment_State.待员工客服确认.ToString(), CreateTime = yearMonth, CreatePerson = LoginInfo.UserName, UpdateTime = yearMonth, UpdatePerson = LoginInfo.UserName, YearMonth = Convert.ToInt32(yearMonth.ToString("yyyyMM")), }; EmployeeStopPaymentSingle stopPaymentSingle = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(EmployeeAdd_InsuranceKindId.养老), CompanyEmployeeRelationId = relationId, PoliceInsuranceId = policeInsurance.Id, StopPayment = stopPayment, }; lstStopPayments.Add(stopPaymentSingle); } #endregion #region 失业 if (!string.IsNullOrEmpty(shiyeType) && shiyeAddId > 0 && shiyeOperationId > 0) { var policeInsurance = stopBll.GetPoliceInsuranceByEmployeeAddId(shiyeAddId); DateTime insuranceMonth = yearMonth.AddMonths(policeInsurance.InsuranceReduce ?? 0); EmployeeStopPayment stopPayment = new EmployeeStopPayment() { EmployeeAddId = shiyeAddId, InsuranceMonth = insuranceMonth, PoliceOperationId = shiyeOperationId, State = EmployeeStopPayment_State.待员工客服确认.ToString(), CreateTime = yearMonth, CreatePerson = LoginInfo.UserName, UpdateTime = yearMonth, UpdatePerson = LoginInfo.UserName, YearMonth = Convert.ToInt32(yearMonth.ToString("yyyyMM")), }; EmployeeStopPaymentSingle stopPaymentSingle = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(EmployeeAdd_InsuranceKindId.失业), CompanyEmployeeRelationId = relationId, PoliceInsuranceId = policeInsurance.Id, StopPayment = stopPayment, }; lstStopPayments.Add(stopPaymentSingle); } #endregion #region 工伤 if (!string.IsNullOrEmpty(gongshangType) && gongshangAddId > 0 && gongshangOperationId > 0) { var policeInsurance = stopBll.GetPoliceInsuranceByEmployeeAddId(gongshangAddId); DateTime insuranceMonth = yearMonth.AddMonths(policeInsurance.InsuranceReduce ?? 0); EmployeeStopPayment stopPayment = new EmployeeStopPayment() { EmployeeAddId = gongshangAddId, InsuranceMonth = insuranceMonth, PoliceOperationId = gongshangOperationId, State = EmployeeStopPayment_State.待员工客服确认.ToString(), CreateTime = yearMonth, CreatePerson = LoginInfo.UserName, UpdateTime = yearMonth, UpdatePerson = LoginInfo.UserName, YearMonth = Convert.ToInt32(yearMonth.ToString("yyyyMM")), }; EmployeeStopPaymentSingle stopPaymentSingle = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(EmployeeAdd_InsuranceKindId.工伤), CompanyEmployeeRelationId = relationId, PoliceInsuranceId = policeInsurance.Id, StopPayment = stopPayment, }; lstStopPayments.Add(stopPaymentSingle); } #endregion #region 医疗 if (!string.IsNullOrEmpty(yiliaoType) && yiliaoAddId > 0 && yiliaoOperationId > 0) { var policeInsurance = stopBll.GetPoliceInsuranceByEmployeeAddId(yiliaoAddId); DateTime insuranceMonth = yearMonth.AddMonths(policeInsurance.InsuranceReduce ?? 0); EmployeeStopPayment stopPayment = new EmployeeStopPayment() { EmployeeAddId = yiliaoAddId, InsuranceMonth = insuranceMonth, PoliceOperationId = yiliaoOperationId, State = EmployeeStopPayment_State.待员工客服确认.ToString(), CreateTime = yearMonth, CreatePerson = LoginInfo.UserName, UpdateTime = yearMonth, UpdatePerson = LoginInfo.UserName, YearMonth = Convert.ToInt32(yearMonth.ToString("yyyyMM")), }; EmployeeStopPaymentSingle stopPaymentSingle = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(EmployeeAdd_InsuranceKindId.医疗), CompanyEmployeeRelationId = relationId, PoliceInsuranceId = policeInsurance.Id, StopPayment = stopPayment, }; lstStopPayments.Add(stopPaymentSingle); } #endregion #region 生育 if (!string.IsNullOrEmpty(shengyuType) && shengyuAddId > 0 && shengyuOperationId > 0) { var policeInsurance = stopBll.GetPoliceInsuranceByEmployeeAddId(shengyuAddId); DateTime insuranceMonth = yearMonth.AddMonths(policeInsurance.InsuranceReduce ?? 0); EmployeeStopPayment stopPayment = new EmployeeStopPayment() { EmployeeAddId = shengyuAddId, InsuranceMonth = insuranceMonth, PoliceOperationId = shengyuOperationId, State = EmployeeStopPayment_State.待员工客服确认.ToString(), CreateTime = yearMonth, CreatePerson = LoginInfo.UserName, UpdateTime = yearMonth, UpdatePerson = LoginInfo.UserName, YearMonth = Convert.ToInt32(yearMonth.ToString("yyyyMM")), }; EmployeeStopPaymentSingle stopPaymentSingle = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(EmployeeAdd_InsuranceKindId.生育), CompanyEmployeeRelationId = relationId, PoliceInsuranceId = policeInsurance.Id, StopPayment = stopPayment, }; lstStopPayments.Add(stopPaymentSingle); } #endregion #region 公积金 if (!string.IsNullOrEmpty(gongjijinType) && gongjijinAddId > 0 && gongjijinOperationId > 0) { var policeInsurance = stopBll.GetPoliceInsuranceByEmployeeAddId(gongjijinAddId); DateTime insuranceMonth = yearMonth.AddMonths(policeInsurance.InsuranceReduce ?? 0); EmployeeStopPayment stopPayment = new EmployeeStopPayment() { EmployeeAddId = gongjijinAddId, InsuranceMonth = insuranceMonth, PoliceOperationId = gongjijinOperationId, State = EmployeeStopPayment_State.待员工客服确认.ToString(), CreateTime = yearMonth, CreatePerson = LoginInfo.UserName, UpdateTime = yearMonth, UpdatePerson = LoginInfo.UserName, YearMonth = Convert.ToInt32(yearMonth.ToString("yyyyMM")), }; EmployeeStopPaymentSingle stopPaymentSingle = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(EmployeeAdd_InsuranceKindId.公积金), CompanyEmployeeRelationId = relationId, PoliceInsuranceId = policeInsurance.Id, StopPayment = stopPayment, }; lstStopPayments.Add(stopPaymentSingle); } #endregion #region 大病 if (!string.IsNullOrEmpty(daeType) && daeAddId > 0 && daeOperationId > 0) { var policeInsurance = stopBll.GetPoliceInsuranceByEmployeeAddId(daeAddId); DateTime insuranceMonth = yearMonth.AddMonths(policeInsurance.InsuranceReduce ?? 0); EmployeeStopPayment stopPayment = new EmployeeStopPayment() { EmployeeAddId = daeAddId, InsuranceMonth = insuranceMonth, PoliceOperationId = daeOperationId, State = EmployeeStopPayment_State.待员工客服确认.ToString(), CreateTime = yearMonth, CreatePerson = LoginInfo.UserName, UpdateTime = yearMonth, UpdatePerson = LoginInfo.UserName, YearMonth = Convert.ToInt32(yearMonth.ToString("yyyyMM")), }; EmployeeStopPaymentSingle stopPaymentSingle = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(EmployeeAdd_InsuranceKindId.大病), CompanyEmployeeRelationId = relationId, PoliceInsuranceId = policeInsurance.Id, StopPayment = stopPayment, }; lstStopPayments.Add(stopPaymentSingle); } #endregion #region 补充公积金 if (!string.IsNullOrEmpty(buchonggongjijinType) && buchonggongjijinAddId > 0 && buchonggongjijinOperationId > 0) { var policeInsurance = stopBll.GetPoliceInsuranceByEmployeeAddId(buchonggongjijinAddId); DateTime insuranceMonth = yearMonth.AddMonths(policeInsurance.InsuranceReduce ?? 0); EmployeeStopPayment stopPayment = new EmployeeStopPayment() { EmployeeAddId = buchonggongjijinAddId, InsuranceMonth = insuranceMonth, PoliceOperationId = buchonggongjijinOperationId, State = EmployeeStopPayment_State.待员工客服确认.ToString(), CreateTime = yearMonth, CreatePerson = LoginInfo.UserName, UpdateTime = yearMonth, UpdatePerson = LoginInfo.UserName, YearMonth = Convert.ToInt32(yearMonth.ToString("yyyyMM")), }; EmployeeStopPaymentSingle stopPaymentSingle = new EmployeeStopPaymentSingle() { InsuranceKindId = Convert.ToInt32(EmployeeAdd_InsuranceKindId.补充公积金), CompanyEmployeeRelationId = relationId, PoliceInsuranceId = policeInsurance.Id, StopPayment = stopPayment, }; lstStopPayments.Add(stopPaymentSingle); } #endregion } message = sbError.ToString().Replace("\r\n", "<br />"); if (lstStopPayments.Any() && string.IsNullOrEmpty(message)) { result = stopBll.InsertStopPayment(lstStopPayments); } } return(result); }
public string InsertStopPaymentInfo(SysEntities db, List <PostInfo> lstStopPaymentEmployeeInfo, int CompanyId) { string result = string.Empty; StringBuilder error = new StringBuilder(); List <EmployeeStopPayment> lstStopPayment = new List <EmployeeStopPayment>(); DateTime now = DateTime.Now; List <string> lstStopingKind = new List <string> { "待责任客服确认", "待员工客服经理分配", "员工客服确认", "社保专员已提取" }; #region 验证 try { foreach (PostInfo emp in lstStopPaymentEmployeeInfo) { StringBuilder err = new StringBuilder(); var e = db.Employee.FirstOrDefault(o => o.CertificateNumber == emp.IDNumber); if (e == null) { err.AppendLine(string.Format("不存在员工 {0} - {1},不能报减。", emp.Name, emp.IDNumber)); continue; } emp.EmployeeId = e.Id; var cer = db.CompanyEmployeeRelation.Where( o => o.CompanyId == CompanyId && o.EmployeeId == emp.EmployeeId && o.State == "在职") .OrderByDescending(o => o.Id) .FirstOrDefault(); if (cer == null) { err.AppendLine(string.Format("{0} 没有任何申报成功的社保或公积金,不能报减。", emp.Name)); continue; } var empAdd = db.EmployeeAdd.Where(o => o.CompanyEmployeeRelationId == cer.Id && o.State == "申报成功"); if (!empAdd.Any()) { err.AppendLine(string.Format("{0} 没有任何申报成功的社保或公积金,不能报减。", emp.Name)); continue; } foreach (InsuranceType k in emp.InsuranceType) { var add = empAdd.FirstOrDefault(o => o.PoliceInsuranceId == k.PoliceInsuranceId); if (add == null) { err.AppendLine(string.Format(" {1} 没有申报成功 {2},不能报减。", "", emp.Name, k.Insurance)); } else { var stopingKind = add.EmployeeGoonPayment.Where(o => lstStopingKind.Contains(o.State)); if (stopingKind.Any()) { err.AppendLine(string.Format("{0} 的员工 {1} {2} 正在报减,不能重复报减。", "", emp.Name, k.Insurance)); } else { EmployeeStopPayment stopPayment = new EmployeeStopPayment(); stopPayment.EmployeeAddId = add.Id; stopPayment.InsuranceMonth = k.ReductionTime; stopPayment.PoliceOperationId = k.PoliceOperationId; stopPayment.Remark = ""; stopPayment.State = "待责任客服确认"; stopPayment.CreateTime = now; stopPayment.CreatePerson = "1"; stopPayment.UpdateTime = now; stopPayment.UpdatePerson = "1"; stopPayment.YearMonth = Convert.ToInt32(DateTime.Now.ToString("yyyyMM")); lstStopPayment.Add(stopPayment); } } } if (!string.IsNullOrEmpty(err.ToString())) { error.AppendLine(err.ToString()); continue; } } } catch (Exception ex) { throw ex; } #endregion result = error.ToString(); try { if (lstStopPayment.Any() && string.IsNullOrEmpty(result)) { foreach (EmployeeStopPayment stopPayment in lstStopPayment) { db.EmployeeStopPayment.Add(stopPayment); db.SaveChanges(); } } } catch (Exception ex) { throw ex; } return(result); }