/// <summary> /// 家属信息 /// </summary> private void SaveEveryForm(IList <string> entStrList, UsrTravelWelfare Ent) { if (entStrList != null && entStrList.Count > 0) { UsrTravelInfo.DoBatchDelete(entStrList.ToArray()); IList <UsrTravelInfo> triEnts = entStrList.Select(tent => JsonHelper.GetObject <UsrTravelInfo>(tent) as UsrTravelInfo).ToList(); foreach (UsrTravelInfo triEnt in triEnts) { if (string.IsNullOrEmpty(triEnt.Id)) { triEnt.WelfareTravelId = Ent.Id; triEnt.DoCreate(); } else { triEnt.DoUpdate(); } } if (Ent.NeedMoney > 0) { try { Ent.XLMoney = Ent.NeedMoney * (triEnts.Count + 1); //包括家属在内的旅游费用 Ent.DoUpdate(); } catch { } } } else { string sql = "delete FL_Culture..UsrTravelInfo where WelfareTravelId='" + Ent.Id + "'"; DataHelper.ExecSql(sql); } }
private void AnalysUser(DataTable Dt) { //判断文件是否为模板格式 if (Dt.Columns.Count != 11 && Dt.Columns[0].ColumnName != "姓名") { throw new Exception("文件内容格式不符合模板定义的格式!"); } string guid = string.Empty; //guid for (int i = 0; i < Dt.Rows.Count; i++) { SysUser UserEnt = null; // try { if (!string.IsNullOrEmpty(Dt.Rows[i]["姓名"] + "")) { UsrTravelWelfare UW = new UsrTravelWelfare(); UW.DoCreate(); //guid = Guid.NewGuid().ToString(); //guid guid = UW.Id; //guid UserEnt = SysUser.FindFirstByProperties(SysUser.Prop_WorkNo, Dt.Rows[i]["工号"]); UW.Id = guid; UW.UserId = UserEnt.UserID; UW.WorkNo = UserEnt.WorkNo; if (UserEnt.Name != Dt.Rows[i]["姓名"] + "") { UW.UserName = Dt.Rows[i]["姓名"] + "/[" + UserEnt.Name + "]"; } else { UW.UserName = UserEnt.Name; } UW.Sex = UserEnt.Sex; UW.ImpState = "1"; //导入状态 1成功 UW.WorkFlowState = "2"; //标识 同意 UW.Result = "同意"; UW.ApplyTime = DateTime.Now; //申请日期 //公司 SysGroup GroupEnt = SysGroup.TryFind(UserEnt.Pk_corp); if (GroupEnt != null) { UW.CompanyName = Dt.Rows[i]["公司"] + ""; UW.CompanyId = GroupEnt.GroupID; //通过工号 强制关联公司和部门 } //部门 GroupEnt = SysGroup.TryFind(UserEnt.Pk_deptdoc); if (GroupEnt != null) { UW.DeptId = GroupEnt.GroupID; UW.DeptName = Dt.Rows[i]["部门"] + ""; } UW.TravelAddr = Dt.Rows[i]["旅游地点"] + ""; //旅游地点 UW.TravelTime = Dt.Rows[i]["出行时间"] + ""; //出行时间 UW.TravelMoney = (decimal)GetMoney(UserEnt, ""); //旅游金额 //入职日期 if (!string.IsNullOrEmpty(UserEnt.Indutydate)) { UW.IndutyDate = DateTime.Parse(UserEnt.Indutydate); } //员工类型 正式员工,实习生 string WorkerType = DataHelper.QueryValue("select psnclassname from HR_OA_MiddleDB..fld_rylb where pk_fld_rylb='" + UserEnt.Pk_rylb + "'") + ""; UW.WorkerType = WorkerType; //HaveFamily Y if (!string.IsNullOrEmpty(Dt.Rows[i]["家属姓名"] + "")) { UW.HaveFamily = "Y"; UsrTravelInfo UT = new UsrTravelInfo(); //家属姓名 if (!string.IsNullOrEmpty(Dt.Rows[i]["家属姓名"] + "")) { UT.Name = Dt.Rows[i]["家属姓名"] + ""; UT.WelfareTravelId = guid; //* 关联的主键ID UT.CreateTime = DateTime.Now; } //家属年龄 int age = 0; if (int.TryParse(Dt.Rows[i]["家属年龄"] + "", out age)) { UT.Age = age; if (age <= 13) //14 岁为标志 { UT.IsChild = "是"; } } //家属性别 if (!string.IsNullOrEmpty(Dt.Rows[i]["家属性别"] + "")) { UT.Sex = Dt.Rows[i]["家属性别"] + ""; } //家属身高 if (!string.IsNullOrEmpty(Dt.Rows[i]["家属身高"] + "")) { Decimal dlb = 0; if (Decimal.TryParse(Dt.Rows[i]["家属身高"] + "", out dlb)) { UT.Height = dlb; } } UT.DoCreate(); //创建家属记录 } //计算金额 UW.CreateId = UserInfo.UserID; UW.CreateName = UserInfo.Name; UW.CreateTime = DateTime.Now; UW.DoUpdate(); } else { //家属信息 UsrTravelInfo UT = null; if (!string.IsNullOrEmpty(Dt.Rows[i]["家属姓名"] + "")) { UT = new UsrTravelInfo(); //家属姓名 if (!string.IsNullOrEmpty(Dt.Rows[i]["家属姓名"] + "")) { UT.Name = Dt.Rows[i]["家属姓名"] + ""; UT.WelfareTravelId = guid; //* 关联的主键ID UT.CreateTime = DateTime.Now; } //家属年龄 int age = 0; if (int.TryParse(Dt.Rows[i]["家属年龄"] + "", out age)) { UT.Age = age; if (age <= 13) //14 岁为标志 { UT.IsChild = "是"; } } //家属性别 if (!string.IsNullOrEmpty(Dt.Rows[i]["家属性别"] + "")) { UT.Sex = Dt.Rows[i]["家属性别"] + ""; } //家属身高 if (!string.IsNullOrEmpty(Dt.Rows[i]["家属身高"] + "")) { Decimal dlb = 0; if (Decimal.TryParse(Dt.Rows[i]["家属身高"] + "", out dlb)) { UT.Height = dlb; } } UT.DoCreate(); //创建家属记录 } } } catch { UsrTravelWelfare UW = new UsrTravelWelfare(); UW.ImpState = "0"; //无该人员或异常 UW.WorkFlowState = "Exception"; //异常标识 UW.UserName = Dt.Rows[i]["姓名"] + " [异常]"; UW.WorkNo = Dt.Rows[i]["工号"] + ""; UW.CompanyName = Dt.Rows[i]["公司"] + ""; UW.DeptName = Dt.Rows[i]["部门"] + ""; UW.TravelAddr = Dt.Rows[i]["旅游地点"] + ""; UW.TravelTime = Dt.Rows[i]["出行时间"] + ""; UW.OtherName = Dt.Rows[i]["家属姓名"] + " [异常]"; UW.CreateTime = DateTime.Now; UW.DoCreate(); } } }