private int getPoliceAccountNatureIdByExcel(EmployeeAddExcle item, ref StringBuilder Message) { string search = "NameDDL_String&" + item.PoliceAccountNatureName; List <PoliceAccountNature> PoliceAccountNatureList = pan_BLL.GetByParam(0, "ASC", "Id", search); if (PoliceAccountNatureList == null || PoliceAccountNatureList.Count <= 0) { Message.Append("户口性质在系统不存在;\r\n"); } else if (PoliceAccountNatureList.Count == 1) { return(PoliceAccountNatureList[0].Id); } else { Message.Append("户口性质在系统中重复;\r\n"); } return(-1); }
private string getCityIdByExcel(EmployeeAddExcle item, ref StringBuilder Message) { string search = "NameDDL_String&" + item.City; List <City> CityList = city_BLL.GetByParam(string.Empty, "ASC", "Id", search); if (CityList == null || CityList.Count <= 0) { Message.Append("社保缴纳地在系统不存在;\r\n"); } else if (CityList.Count == 1) { //组建员工社保地关系信息 return(CityList[0].Id); } else { Message.Append("社保缴纳地在系统重复;\r\n"); } return(null); }
private int getCompanyIdByExcel(EmployeeAddExcle item, ref StringBuilder Message) { string search = "CompanyNameDDL_String&" + item.CompanyName; List <CRM_Company> empComList = crm_BLL.GetByParam(string.Empty, "ASC", "Id", search); if (empComList == null || empComList.Count <= 0) { //系统中不存在报增公司,抛出异常 Message.Append("单位在系统不存在;\r\n"); } else if (empComList.Count == 1) { //组建员工企业关系信息 return(empComList[0].ID); } else { Message.Append("单位在系统重复;\r\n"); } return(-1); }
private List <EmployeeAddExcle> CheckImportEmployeeAdd(DataTable table, ref string message) { List <EmployeeAddExcle> employeeList = new List <EmployeeAddExcle>(); #region 数据转换 foreach (DataRow dr in table.Rows) { EmployeeAddExcle employee = new EmployeeAddExcle(); employee.CompanyName = dr["单位"].ToString().Trim(); employee.City = dr["社保缴纳地"].ToString().Trim(); employee.Empname = dr["姓名"].ToString().Trim(); employee.CertificateNumber = dr["证件号码"].ToString().Trim(); employee.CertificateType = dr["证件类型"].ToString().Trim(); employee.Station = dr["岗位"].ToString().Trim(); employee.PoliceAccountNatureName = dr["户口性质"].ToString().Trim(); employee.AccountType = dr["户口类型"].ToString().Trim(); employee.MobilePhone = dr["移动电话"].ToString().Trim(); employee.Telephone = dr["固定电话"].ToString().Trim(); employee.Address = dr["联系地址"].ToString().Trim(); employee.Email = dr["邮箱"].ToString().Trim(); employee.AccountName = dr["开户名称"].ToString().Trim(); employee.BranchBank = dr["支行名称"].ToString().Trim(); employee.Bank = dr["开户银行"].ToString().Trim(); employee.Account = dr["账号"].ToString().Trim(); employeeList.Add(employee); } #endregion string search = string.Empty; StringBuilder errMessageAll = new StringBuilder(); string DataForm = "证件号:{0},姓名:{1},的异常信息为:{2}\r\n"; Regex r = new Regex(@"(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0-9]|170)\d{8}$"); foreach (EmployeeAddExcle item in employeeList) { StringBuilder errMessage = new StringBuilder(); #region 基础信息赋值 if (string.IsNullOrEmpty(item.CertificateNumber)) { errMessage.Append("证件号码为空;\r\n"); } else if (!CardCommon.CheckCardID18(item.CertificateNumber)) { errMessage.Append("身份证号不合法:" + item.CertificateNumber + ";\r\n"); } if (string.IsNullOrEmpty(item.Empname)) { errMessage.Append("姓名为空;\r\n"); } if (string.IsNullOrEmpty(item.CompanyName)) { errMessage.Append("单位为空;\r\n"); } else { item.CompanyId = getCompanyIdByExcel(item, ref errMessage); } if (string.IsNullOrEmpty(item.City)) { errMessage.Append("社保缴纳地为空;\r\n"); } else { item.City = getCityIdByExcel(item, ref errMessage); } if (string.IsNullOrEmpty(item.CertificateType)) { errMessage.Append("证件类型为空;\r\n"); } else { CertificateType certificateType = new CertificateType(); if (!Enum.TryParse <CertificateType>(item.CertificateType, out certificateType)) { errMessage.Append("证件类型不正确;\r\n"); } } if (string.IsNullOrEmpty(item.Station)) { errMessage.Append("岗位为空;\r\n"); } if (string.IsNullOrEmpty(item.PoliceAccountNatureName)) { errMessage.Append("户口性质为空;\r\n"); } else { item.PoliceAccountNature = getPoliceAccountNatureIdByExcel(item, ref errMessage); } if (string.IsNullOrEmpty(item.MobilePhone) && string.IsNullOrEmpty(item.Telephone)) { errMessage.Append("固定电话或者移动电话至少填一项;\r\n"); } else { if (!string.IsNullOrEmpty(item.MobilePhone)) { if (!Regex.IsMatch(item.MobilePhone, @"(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0-9]|170)\d{8}$")) { errMessage.Append("移动电话格式不正确;\r\n"); } ; } if (!string.IsNullOrEmpty(item.Telephone)) { if (!Regex.IsMatch(item.Telephone, @"(0[0-9]{2,3})-([2-9][0-9]{6,7})$")) { errMessage.Append("固定电话格式不正确;\r\n"); } ; } } if (!string.IsNullOrEmpty(item.Email)) { if (!Regex.IsMatch(item.Email, @"(\w)+(\.\w+)*@(\w)+((\.\w+)+)")) { errMessage.Append("邮箱格式不正确;\r\n"); } ; } if (!(string.IsNullOrEmpty(item.AccountName) && string.IsNullOrEmpty(item.Bank) && string.IsNullOrEmpty(item.BranchBank) && string.IsNullOrEmpty(item.Account))) { if (string.IsNullOrEmpty(item.AccountName) || string.IsNullOrEmpty(item.Bank) || string.IsNullOrEmpty(item.BranchBank) || string.IsNullOrEmpty(item.Account)) { errMessage.Append("请完善银行信息;\r\n"); } } #endregion if (!string.IsNullOrWhiteSpace(errMessage.ToString())) { errMessageAll.Append(string.Format(DataForm, item.CertificateNumber, item.Empname, errMessage.ToString())); } } message = errMessageAll.ToString(); return(employeeList); }