public string DicsSaveChanges(string jsonString, string action) { try { DicEntity ue = JsonConvert.DeserializeObject <DicEntity>(jsonString); DicManager dm = new DicManager(); if (action == "add") { ue.iId = Guid.NewGuid().ToString(); ue.iKey = ue.iValue; ue.iCreatedBy = SessionHelper.CurrentUser.iUserName; ue.iUpdatedBy = SessionHelper.CurrentUser.iUserName; dm.Insert(ue); } else { DicEntity ueOld = dm.GetDic(ue.iId); ue.iUpdatedBy = SessionHelper.CurrentUser.iUserName; ue.iKey = ueOld.iKey; ue.iCreatedBy = ueOld.iCreatedBy; ue.iCreatedOn = ueOld.iCreatedOn; dm.Update(ue); } return("success"); } catch (Exception e) { return(e.ToString()); } }
private List <HRInfoEntity> GetExportData() { string paraString = Request.Params["searchpara"]; Dictionary <string, string> paraDic = JsonConvert.DeserializeObject <Dictionary <string, string> >(paraString); paraDic.Add("iEmployeeDate[d]", paraDic["iEmployeeDateFrom"] + "§" + paraDic["iEmployeeDateTo"]); paraDic.Add("iContractDeadLine[d]", paraDic["iContractDeadLineFrom"] + "§" + paraDic["iContractDeadLineTo"]); paraDic.Add("iResignDate[d]", paraDic["iResignDateFrom"] + "§" + paraDic["iResignDateTo"]); paraDic.Add("iUpdatedOn[d]", paraDic["iModifyOnFrom"] + "§" + paraDic["iModifyOnTo"]); paraDic.Remove("iEmployeeDateFrom"); paraDic.Remove("iEmployeeDateTo"); paraDic.Remove("iContractDeadLineFrom"); paraDic.Remove("iContractDeadLineTo"); paraDic.Remove("iResignDateFrom"); paraDic.Remove("iResignDateTo"); paraDic.Remove("iModifyOnFrom"); paraDic.Remove("iModifyOnTo"); HRInfoManager service = new HRInfoManager(); List <HRInfoEntity> list = service.GetSearchAll(SessionHelper.CurrentUser.UserType, paraDic); DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); var projects = dm.GetAllProjects(); Dictionary <string, string> comDic = companies.ToDictionary(i => i.iGuid, i => i.iName); Dictionary <string, string> proDic = projects.ToDictionary(i => i.iGuid, i => i.iName); foreach (var item in list) { item.iCompany = comDic[item.iCompany]; item.iItemName = proDic[item.iItemName]; } return(list); }
public ActionResult ReturnFeeIndex() { DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); ViewBag.Companies = companies; var projects = dm.GetAllProjects(); ViewBag.Projects = projects; return(View()); }
public ActionResult UserIndex() { DicManager dm = new DicManager(); var companies = dm.GetDicByType("公司"); ViewBag.Companies = companies; var contents = GetStandardMenuTree(false); ViewBag.treeNodes = JsonConvert.SerializeObject(contents); return(View()); }
public void GetAllUsers() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); int total = 0; UserManager um = new UserManager(); List <UserEntity> list = um.GetSearch(searchKey, sort, order, offset, pageSize, out total); DicManager dm = new DicManager(); List <DicEntity> companyDicE = dm.GetDicByType("公司"); Dictionary <string, string> companyDic = new Dictionary <string, string>(); foreach (var item in companyDicE) { companyDic.Add(item.iKey, item.iValue); } List <UserViewModel> listView = new List <UserViewModel>(); foreach (var item in list) { listView.Add(new UserViewModel { iCompanyCode = item.iCompanyCode, iCompanyName = companyDic[item.iCompanyCode], iEmployeeCodeId = item.iEmployeeCodeId, iPassWord = item.iPassWord, iUserName = item.iUserName, iUserType = item.iUserType, iUpdatedOn = item.iUpdatedOn.ToString("yyyyMMdd HH:mm") }); } //给分页实体赋值 PageModels <UserViewModel> model = new PageModels <UserViewModel>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = listView; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
private List <ReturnFeeModel> GetExportData() { string paraString = Request.Params["searchpara"]; Dictionary <string, string> paraDic = JsonConvert.DeserializeObject <Dictionary <string, string> >(paraString); Dictionary <string, string> bizParaDic = new Dictionary <string, string>(); bizParaDic.Add("search", paraDic["search"]); paraDic.Remove("search"); bizParaDic.Add("editType", paraDic["sEditType"]); paraDic.Remove("sEditType"); foreach (var item in paraDic) { if (item.Key.EndsWith("2")) { continue; } if (paraDic.ContainsKey(item.Key + "2")) { bizParaDic.Add("i" + item.Key.Substring(1, item.Key.Length - 1) + "[d]", item.Value + "§" + paraDic[item.Key + "2"]); } else { bizParaDic.Add("i" + item.Key.Substring(1, item.Key.Length - 1), item.Value); } } ReturnFeeManager service = new ReturnFeeManager(); List <ReturnFeeModel> list = service.GetSearchAll(SessionHelper.CurrentUser.UserType, bizParaDic); DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); var projects = dm.GetAllProjects(); Dictionary <string, string> comDic = companies.ToDictionary(i => i.iGuid, i => i.iName); Dictionary <string, string> proDic = projects.ToDictionary(i => i.iGuid, i => i.iName); foreach (var item in list) { item.iCompany = comDic[item.iCompany]; item.iItemName = proDic[item.iItemName]; } return(list); }
public void GetAllDics() { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); int total = 0; DicManager dm = new DicManager(); List <DicEntity> list = dm.GetSearch(searchKey, sort, order, offset, pageSize, out total); List <DicViewModel> listView = new List <DicViewModel>(); foreach (var item in list) { listView.Add(new DicViewModel { iId = item.iId, iKey = item.iKey, iValue = item.iValue, iType = item.iType, iUpdatedOn = item.iUpdatedOn.ToString("yyyyMMdd HH:mm") }); } //给分页实体赋值 PageModels <DicViewModel> model = new PageModels <DicViewModel>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = listView; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); }
public void GetAllReturnFee() { try { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); jss.MaxJsonLength = Int32.MaxValue; //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); string editType = HttpContext.Request.Params["sEditType"]; Dictionary <string, string> bizParaDic = new Dictionary <string, string>(); bizParaDic.Add("search", searchKey); bizParaDic.Add("editType", editType); Dictionary <string, string> bizParaDicTemp = new Dictionary <string, string>(); foreach (string para in HttpContext.Request.Params.Keys) { if (para.StartsWith("s") && (ReturnFeeManager.ReturnFeeDic.ContainsValue("i" + para.Substring(1, para.Length - 1)) || (para.Length > 2 && ReturnFeeManager.ReturnFeeDic.ContainsValue("i" + para.Substring(1, para.Length - 2))))) { bizParaDicTemp.Add("i" + para.Substring(1, para.Length - 1), HttpContext.Request.Params[para]); } } foreach (var item in bizParaDicTemp) { if (item.Key.EndsWith("2")) { continue; } if (bizParaDicTemp.ContainsKey(item.Key + "2")) { bizParaDic.Add(item.Key + "[d]", item.Value + "§" + bizParaDicTemp[item.Key + "2"]); } else { bizParaDic.Add(item.Key, item.Value); } } int total = 0; ReturnFeeManager service = new ReturnFeeManager(); List <ReturnFeeModel> list = service.GetSearch(SessionHelper.CurrentUser.UserType, bizParaDic, sort, order, offset, pageSize, out total); DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); var projects = dm.GetAllProjects(); Dictionary <string, string> comDic = companies.ToDictionary(i => i.iGuid, i => i.iName); Dictionary <string, string> proDic = projects.ToDictionary(i => i.iGuid, i => i.iName); foreach (var item in list) { item.iCompany = comDic[item.iCompany]; item.iItemName = proDic[item.iItemName]; } //给分页实体赋值 PageModels <ReturnFeeModel> model = new PageModels <ReturnFeeModel>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); } catch (Exception ex) { log4net.ILog log = log4net.LogManager.GetLogger(this.GetType()); log.Error(ex); } }
private List <ReturnFeeEntity> ExcelSheetToEntityList(ISheet sheet, ref string errorLog) { //需要验证权限,如果是普通用户,不能导入已存在的返回信息。 DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); var projects = dm.GetAllProjects(); ReturnFeeManager service = new ReturnFeeManager(); List <ReturnFeeEntity> list = new List <ReturnFeeEntity>(); Dictionary <string, string> keycolumnp = ReturnFeeManager.ReturnFeeDic; Dictionary <string, int> keycolumns = new Dictionary <string, int>(); for (int co = 0; co < sheet.GetRow(0).LastCellNum; co++) { if (keycolumnp.ContainsKey(sheet.GetRow(0).GetCell(co).ToString().Trim())) { keycolumns.Add(keycolumnp[sheet.GetRow(0).GetCell(co).ToString().Trim()], co); } } //遍历数据行 for (int i = (sheet.FirstRowNum + 1), len = sheet.LastRowNum + 1; i < len; i++) { CompanyEntity currentCompany = null; ProjectEntity currentProject = null; ReturnFeeEntity en = new ReturnFeeEntity(); try { string project = sheet.GetRow(i).GetCell(keycolumns["iItemName"]).ToString().Trim(); string company = sheet.GetRow(i).GetCell(keycolumns["iCompany"]).ToString().Trim(); string empcode = sheet.GetRow(i).GetCell(keycolumns["iEmpNo"]).ToString().Trim(); string idcard = sheet.GetRow(i).GetCell(keycolumns["iIdCard"]).ToString().Trim(); if (string.IsNullOrEmpty(empcode)) { errorLog += "第【" + (i + 1).ToString() + "】行工号不能为空,临时工用-;"; } if (!CheckIDCard18(idcard)) { errorLog += "第【" + (i + 1).ToString() + "】行身份证号不合法;"; } currentCompany = companies.FirstOrDefault(pj => pj.iName == company); currentProject = projects.FirstOrDefault(pj => pj.iName == project); if (currentCompany == null || currentProject == null) { if (currentCompany == null) { errorLog += "第【" + (i + 1).ToString() + "】行公司名称不存在;"; } if (currentProject == null) { errorLog += "第【" + (i + 1).ToString() + "】行项目名称不存在;"; } if (SessionHelper.CurrentUser.UserType == "普通用户" && currentProject.iGuid != SessionHelper.CurrentUser.CurrentProject) { errorLog += "第【" + (i + 1).ToString() + "】行只能导入您当前所在的项目;"; } } else { string hrId = service.GetValidReturnFeeHrId(currentCompany.iGuid, empcode, idcard, currentProject.iGuid); if (string.IsNullOrEmpty(hrId)) { errorLog += "第【" + (i + 1).ToString() + "】行在人事里的当前项目中没有给出返费信息;"; } else { en = service.FirstOrDefault(hrId); if (en == null) { en = new ReturnFeeEntity(); en.iHRInfoGuid = hrId; } else { if (SessionHelper.CurrentUser.UserType == "普通用户") { errorLog += "第【" + (i + 1).ToString() + "】行已编辑过,您无权限再修改,请联系管理员!;"; } } } } } catch { errorLog += "第【" + (i + 1).ToString() + "】行所在公司,工号,身份证号不能有缺失;"; } foreach (var kvp in keycolumns) { if (sheet.GetRow(i).GetCell(kvp.Value) == null || sheet.GetRow(i).GetCell(kvp.Value).ToString() == "" || en.GetType().GetProperty(kvp.Key) == null) { //en.GetType().GetProperty(kvp.Key).SetValue(en, null, null); //空的不填写,保持原数据不变 ,没有该属性就忽略 } else { object value = null; ICell cell = sheet.GetRow(i).GetCell(kvp.Value); if (cell.CellType == CellType.Blank) { value = ""; } else { string propertyName = en.GetType().GetProperty(kvp.Key).PropertyType.FullName.ToLower(); if (cell.CellType == CellType.Numeric && HSSFDateUtil.IsCellDateFormatted(cell)) { try { value = sheet.GetRow(i).GetCell(kvp.Value).DateCellValue; } catch (Exception ex) { errorLog += "第【" + (i + 1).ToString() + "】行,第【" + (kvp.Value + 1).ToString() + "】列不是标准日期格式;"; } if (!propertyName.Contains("datetime") && value != null) { value = ((DateTime)value).ToString("yyyy-MM-dd"); } } else { value = sheet.GetRow(i).GetCell(kvp.Value).ToString().Trim(); if (propertyName.Contains("datetime") && value != null) { DateTime dt = DateTime.Now; if (DateTime.TryParse(value.ToString(), out dt)) { value = dt; } else { errorLog += "第【" + (i + 1).ToString() + "】行,第【" + (kvp.Value + 1).ToString() + "】列不是标准日期格式;"; } } } } en.GetType().GetProperty(kvp.Key).SetValue(en, value, null); } } string[] paidArray = { "已付", "未付" }; Dictionary <string, string[]> checkdic = new Dictionary <string, string[]>(); checkdic.Add("一级付款情况$iFirstReturnFeePayment", paidArray); checkdic.Add("二级付款情况$iSecondReturnFeePayment", paidArray); checkdic.Add("三级付款情况$iThirdReturnFeePayment", paidArray); checkdic.Add("四级付款情况$iFourthReturnFeePayment", paidArray); checkdic.Add("五级付款情况$iFifthReturnFeePayment", paidArray); //是否有效校验 foreach (var item in checkdic) { foreach (var subitem in item.Key.Split('|')) { PropertyInfo property = en.GetType().GetProperty(subitem.Split('$')[1]); if (property.GetValue(en, null) != null && property.GetValue(en, null).ToString() != "" && !item.Value.Contains(property.GetValue(en, null))) { errorLog += "第【" + (i + 1).ToString() + "】行" + subitem.Split('$')[0] + "不合法,只能输入【"; foreach (var value in item.Value) { errorLog += value + ","; } errorLog = errorLog.TrimEnd(','); errorLog += "】;"; } } } list.Add(en); } return(list); }
public void GetAllHRInfo() { try { //用于序列化实体类的对象 JavaScriptSerializer jss = new JavaScriptSerializer(); jss.MaxJsonLength = Int32.MaxValue; //请求中携带的条件 string order = HttpContext.Request.Params["order"]; string sort = HttpContext.Request.Params["sort"]; string searchKey = HttpContext.Request.Params["search"]; int offset = Convert.ToInt32(HttpContext.Request.Params["offset"]); //0 int pageSize = Convert.ToInt32(HttpContext.Request.Params["limit"]); Dictionary <string, string> bizParaDic = new Dictionary <string, string>(); bizParaDic.Add("search", searchKey); string itemName = HttpContext.Request.Params["iItemName"]; string company = HttpContext.Request.Params["iCompany"]; string idcard = HttpContext.Request.Params["iIdCard"]; string name = HttpContext.Request.Params["iName"]; string empId = HttpContext.Request.Params["iEmpNo"]; string status = HttpContext.Request.Params["iEmployeeStatus"]; string employeedate1 = HttpContext.Request.Params["iEmployeeDateFrom"]; string employeedate2 = HttpContext.Request.Params["iEmployeeDateTo"]; string contractdeadline1 = HttpContext.Request.Params["iContractDeadLineFrom"]; string contractdeadline2 = HttpContext.Request.Params["iContractDeadLineTo"]; string resigndate1 = HttpContext.Request.Params["iResignDateFrom"]; string resigndate2 = HttpContext.Request.Params["iResignDateTo"]; string modifyon1 = HttpContext.Request.Params["iModifyOnFrom"]; string modifyon2 = HttpContext.Request.Params["iModifyOnTo"]; bizParaDic.Add("iItemName", itemName); bizParaDic.Add("iCompany", company); bizParaDic.Add("iIdCard", idcard); bizParaDic.Add("iName", name); bizParaDic.Add("iEmpNo", empId); bizParaDic.Add("iEmployeeStatus", status); bizParaDic.Add("iEmployeeDate[d]", employeedate1 + "§" + employeedate2); bizParaDic.Add("iContractDeadLine[d]", contractdeadline1 + "§" + contractdeadline2); bizParaDic.Add("iResignDate[d]", resigndate1 + "§" + resigndate2); bizParaDic.Add("iUpdatedOn[d]", modifyon1 + "§" + modifyon2); int total = 0; HRInfoManager service = new HRInfoManager(); List <HRInfoEntity> list = service.GetSearch(SessionHelper.CurrentUser.UserType, bizParaDic, sort, order, offset, pageSize, out total); DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); var projects = dm.GetAllProjects(); Dictionary <string, string> comDic = companies.ToDictionary(i => i.iGuid, i => i.iName); Dictionary <string, string> proDic = projects.ToDictionary(i => i.iGuid, i => i.iName); foreach (var item in list) { item.iCompany = comDic[item.iCompany]; item.iItemName = proDic[item.iItemName]; } //给分页实体赋值 PageModels <HRInfoEntity> model = new PageModels <HRInfoEntity>(); model.total = total; if (total % pageSize == 0) { model.page = total / pageSize; } else { model.page = (total / pageSize) + 1; } model.rows = list; //将查询结果返回 HttpContext.Response.Write(jss.Serialize(model)); } catch (Exception e) { log4net.ILog log = log4net.LogManager.GetLogger(this.GetType()); log.Error(e); } }
private List <HRInfoEntity> ExcelSheetToEntityList(ISheet sheet, ref string errorLog) { string[] sexArray = { "男", "女" }; string[] residencePropertyArray = { "农业户口", "非农业户口" }; string[] bloodTypeArray = { "A", "B", "AB", "O" }; string[] marriageArray = { "已婚", "未婚" }; string[] yesnoArray = { "是", "否" }; string[] poliArray = { "群众", "团员", "共产党员", "其它" }; string[] eduArray = { "小学", "初中", "中专", "高中", "大专", "本科", "硕士", "博士" }; string[] empstaArray = { "在职", "离职" }; string[] contratypeArray = { "派遣", "外包" }; string[] resigntypeArray = { "自离", "旷工", "辞职", "辞退", "开除" }; string[] resignressonArray = { "身体原因", "工作原因", "家族原因", "其他" }; string[] contractsignArray = { "一次签订", "二次签订", "三次签订", "否" }; Dictionary <string, string[]> checkdic = new Dictionary <string, string[]>(); checkdic.Add("性别$iSex", sexArray); checkdic.Add("户口性质$iResidenceProperty", residencePropertyArray); //checkdic.Add("血型$iBloodType", bloodTypeArray); checkdic.Add("婚姻状况$iMariage", marriageArray); checkdic.Add("体检$iHealthCheck|是否返费$iIsReturnFee|是否缴纳保险$iIsSocialInsurancePaid|是否缴纳公积金$iIsProvidentPaid|是否缴纳商业保险$iIsCommercialInsurancePaid", yesnoArray); checkdic.Add("合同签订情况$iContractSignStatus", contractsignArray); checkdic.Add("政治面貌$iPolitical", poliArray); checkdic.Add("文化水平$iEducationLevel", eduArray); checkdic.Add("员工状态$iEmployeeStatus", empstaArray); checkdic.Add("合同类型$iContractType", contratypeArray); checkdic.Add("离职类型$iResignType", resigntypeArray); checkdic.Add("离职原因(公司)$iResignReason", resignressonArray); DicManager dm = new DicManager(); var companies = dm.GetAllCompanies(); var projects = dm.GetAllProjects(); HRInfoManager service = new HRInfoManager(); List <HRInfoEntity> list = new List <HRInfoEntity>(); Dictionary <string, string> keycolumnp = HRInfoManager.hrDic; Dictionary <string, int> keycolumns = new Dictionary <string, int>(); for (int co = 0; co < sheet.GetRow(0).LastCellNum; co++) { if (keycolumnp.ContainsKey(sheet.GetRow(0).GetCell(co).ToString().Trim())) { keycolumns.Add(keycolumnp[sheet.GetRow(0).GetCell(co).ToString().Trim()], co); } } //遍历数据行 for (int i = (sheet.FirstRowNum + 1), len = sheet.LastRowNum + 1; i < len; i++) { CompanyEntity currentCompany = null; ProjectEntity currentProject = null; HRInfoEntity en = new HRInfoEntity(); try { if (keycolumns.ContainsKey("iGuid")) { string iguid = sheet.GetRow(i).GetCell(keycolumns["iGuid"]).ToString(); if (!string.IsNullOrEmpty(iguid)) { en = service.GetFirstOrDefault(iguid); } } if (string.IsNullOrEmpty(en.iGuid)) { string project = sheet.GetRow(i).GetCell(keycolumns["iItemName"]).ToString().Trim(); string company = sheet.GetRow(i).GetCell(keycolumns["iCompany"]).ToString().Trim(); string empcode = sheet.GetRow(i).GetCell(keycolumns["iEmpNo"]).ToString().Trim(); string idcard = sheet.GetRow(i).GetCell(keycolumns["iIdCard"]).ToString().Trim(); currentCompany = companies.FirstOrDefault(pj => pj.iName == company); currentProject = projects.FirstOrDefault(pj => pj.iName == project); if (currentCompany == null || currentProject == null) { if (currentCompany == null) { errorLog += "第【" + (i + 1).ToString() + "】行公司名称不存在;"; } if (currentProject == null) { errorLog += "第【" + (i + 1).ToString() + "】行项目名称不存在;"; } if (SessionHelper.CurrentUser.UserType == "普通用户" && currentProject.iName != SessionHelper.CurrentUser.CurrentProject) { errorLog += "第【" + (i + 1).ToString() + "】行只能导入您当前所在的项目;"; } } else { en = service.GetUniqueFirstOrDefault(currentProject.iGuid, currentCompany.iGuid, empcode, idcard); if (en == null) { en = new HRInfoEntity(); } } } } catch { errorLog += "第【" + (i + 1).ToString() + "】行所在公司,工号,身份证号不能有缺失;"; } foreach (var kvp in keycolumns) { if (sheet.GetRow(i).GetCell(kvp.Value) == null || sheet.GetRow(i).GetCell(kvp.Value).ToString() == "") { //en.GetType().GetProperty(kvp.Key).SetValue(en, null, null); //空的不填写,保持原数据不变 } else { object value = null; ICell cell = sheet.GetRow(i).GetCell(kvp.Value); if (cell.CellType == CellType.Blank) { value = ""; } else { string propertyName = en.GetType().GetProperty(kvp.Key).PropertyType.FullName.ToLower(); if (cell.CellType == CellType.Numeric && HSSFDateUtil.IsCellDateFormatted(cell)) { try { value = sheet.GetRow(i).GetCell(kvp.Value).DateCellValue; } catch (Exception ex) { errorLog += "第【" + (i + 1).ToString() + "】行,第【" + (kvp.Value + 1).ToString() + "】列不是标准日期格式;"; } if (!propertyName.Contains("datetime") && value != null) { value = ((DateTime)value).ToString("yyyy-MM-dd"); } } else { value = sheet.GetRow(i).GetCell(kvp.Value).ToString().Trim(); if (propertyName.Contains("datetime") && value != null) { DateTime dt = DateTime.Now; if (DateTime.TryParse(value.ToString(), out dt)) { value = dt; } else { errorLog += "第【" + (i + 1).ToString() + "】行,第【" + (kvp.Value + 1).ToString() + "】列不是标准日期格式;"; } } } } en.GetType().GetProperty(kvp.Key).SetValue(en, value, null); } } if (currentProject != null) { en.iItemName = currentProject.iGuid; } if (currentCompany != null) { en.iCompany = currentCompany.iGuid; } if (SessionHelper.CurrentUser.UserType == "普通用户" && en.iItemName != SessionHelper.CurrentUser.CurrentProject) { errorLog += "第【" + (i + 1).ToString() + "】行项目名称不正确,只能导入当前项目;"; } if (string.IsNullOrEmpty(en.iEmpNo)) { errorLog += "第【" + (i + 1).ToString() + "】行工号不能为空,临时工用-;"; } if (string.IsNullOrEmpty(en.iName)) { errorLog += "第【" + (i + 1).ToString() + "】行姓名不能为空;"; } if (!CheckIDCard18(en.iIdCard)) { errorLog += "第【" + (i + 1).ToString() + "】行身份证号不合法;"; } //是否有效校验 foreach (var item in checkdic) { foreach (var subitem in item.Key.Split('|')) { PropertyInfo property = en.GetType().GetProperty(subitem.Split('$')[1]); if (property.GetValue(en, null) != null && property.GetValue(en, null).ToString() != "" && !item.Value.Contains(property.GetValue(en, null))) { errorLog += "第【" + (i + 1).ToString() + "】行" + subitem.Split('$')[0] + "不合法,只能输入【"; foreach (var value in item.Value) { errorLog += value + ","; } errorLog = errorLog.TrimEnd(','); errorLog += "】;"; } } } list.Add(en); } return(list); }