/// <summary> /// 创建一个导入其他社保费记录 /// </summary> /// <param name="validationErrors">返回的错误信息</param> /// <param name="db">数据库上下文</param> /// <param name="entity">一个导入其他社保费记录</param> /// <returns></returns> public bool Create(ref ValidationErrors validationErrors, EmployeeMiddleImportRecord entity) { try { repository.Create(entity); return(true); } catch (Exception ex) { validationErrors.Add(ex.Message); ExceptionsHander.WriteExceptions(ex); } return(false); }
/// <summary> /// 数据库导入 /// </summary> /// <param name="dt">DataTable数据</param> private bool ImportEmployeeMiddle(DataTable table, ref string message, out int SuccessNum, string FileName) { try { StringBuilder sbError = new StringBuilder(); SuccessNum = 0; if (table.Rows.Count > 0) { #region Excel数据提取 //校验并转换信息 List <EmployeeMiddle> employeeList = CheckImportEmployeeMiddle(table, ref message); if (!string.IsNullOrWhiteSpace(message)) { return(false); } EmployeeMiddleImportRecord emir = new EmployeeMiddleImportRecord(); emir.CreateTime = DateTime.Now; emir.CreateUserID = LoginInfo.UserID; emir.CreateUserName = LoginInfo.RealName; emir.ImportCount = employeeList.Count(); emir.URL = "/excel/" + FileName; decimal money1 = employeeList.Sum(a => a.CompanyPayment) ?? 0; decimal money2 = employeeList.Sum(a => a.EmployeePayment) ?? 0; emir.ImportPayment = money1 + money2; int num = empM_BLL.InsertList(employeeList); ValidationErrors validationErrors = new ValidationErrors(); empMIR_BLL.Create(ref validationErrors, emir); #endregion } } catch (Exception e) { throw e; } return(true); }
/// <summary> /// 创建 /// </summary> /// <param name="entity">实体对象</param> /// <returns></returns> public Common.ClientResult.Result Post([FromBody] EmployeeMiddleImportRecord entity) { Common.ClientResult.Result result = new Common.ClientResult.Result(); if (entity != null && ModelState.IsValid) { //string currentPerson = GetCurrentPerson(); //entity.CreateTime = DateTime.Now; //entity.CreatePerson = currentPerson; string returnValue = string.Empty; if (m_BLL.Create(ref validationErrors, entity)) { LogClassModels.WriteServiceLog(Suggestion.InsertSucceed + ",导入其他社保费记录的信息的Id为" + entity.Id, "导入其他社保费记录" );//写入日志 result.Code = Common.ClientCode.Succeed; result.Message = Suggestion.InsertSucceed; 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.InsertFail + returnValue; return(result); //提示插入失败 } } result.Code = Common.ClientCode.FindNull; result.Message = Suggestion.InsertFail + ",请核对输入的数据的格式"; //提示输入的数据的格式不对 return(result); }
/// <summary> /// 根据ID获取数据模型 /// </summary> /// <param name="id">编号</param> /// <returns></returns> public EmployeeMiddleImportRecord Get(int id) { EmployeeMiddleImportRecord item = m_BLL.GetById(id); return(item); }