private static decimal?GetDecimal(DataTable dt, int rowindex, decimal?ret, string columnname) { string SD = ImportUtility.GetItem(dt, rowindex, columnname); if (SD != ImportUtility.EmptyNull) { ret = ConvertToDecimal(SD); } return(ret); }
private static DateTime?GetYM(DataTable dt, int rowindex, DateTime?ret, string columnname) { string SYM = ImportUtility.GetItem(dt, rowindex, columnname); if (SYM != ImportUtility.EmptyNull) { ret = ConvertToDateTime(SYM); } return(ret); }
private static string GetString(DataTable dt, int rowindex, string ret, string columnnanme) { string SS = ImportUtility.GetItem(dt, rowindex, columnnanme); if (SS != ImportUtility.EmptyNull) { ret = SS; } return(ret); }
/// <summary> /// 赋值并保存,将dt中的值赋值给salary /// </summary> private void ValueItemsAndSave(IEnumerable <EmployeeWelfare> employeeWelfare, DataTable dt) { foreach (EmployeeWelfare welfare in employeeWelfare) { //员工姓名在dt中的列号 int employeeRow = ImportUtility.GetEmployeeRow(dt, welfare.Owner.Name, _NameColumn); //该员工不存在则继续查找下一个 if (employeeRow == -1) { continue; } ValueItemInOneRow(employeeRow, dt, welfare); } }
protected override void ExcuteSelf() { string strConn; strConn = ImportUtility.GetstrConn(_FilePath); using (OleDbConnection conn = new OleDbConnection(strConn)) { conn.Open(); string sheetName = ImportUtility.FirstSheetName(conn); OleDbDataAdapter oada = new OleDbDataAdapter("select * from [" + sheetName + "]", strConn); DataSet ds = new DataSet(); oada.Fill(ds); Import(ds.Tables[0]); } }
private void ValueItemInOneRow(int rowindex, DataTable dt, EmployeeWelfare welfare) { SocialSecurityTypeEnum socialSecurityType = welfare.SocialSecurity.Type; decimal? socialBase = welfare.SocialSecurity.Base; decimal? yangLaoBase = welfare.SocialSecurity.YangLaoBase; decimal? shiYeBase = welfare.SocialSecurity.ShiYeBase; decimal? yiLiaoBase = welfare.SocialSecurity.YiLiaoBase; DateTime?socialYM = welfare.SocialSecurity.EffectiveYearMonth; string fundAccount = welfare.AccumulationFund.Account; DateTime?fundYM = welfare.AccumulationFund.EffectiveYearMonth; decimal? fundBase = welfare.AccumulationFund.Base; string operationName = _Operator.Name; string supplyAccount = welfare.AccumulationFund.SupplyAccount; decimal? supplyBase = welfare.AccumulationFund.SupplyBase; string SsocialSecurityType = ImportUtility.GetItem(dt, rowindex, EmployeeWelfare.ConstParemeter.SocialType); if (SsocialSecurityType != ImportUtility.EmptyNull) { socialSecurityType = ConvertToSocialSecurityTypeEnum(SsocialSecurityType); } socialBase = GetDecimal(dt, rowindex, socialBase, EmployeeWelfare.ConstParemeter.SocialBase); yangLaoBase = GetDecimal(dt, rowindex, yangLaoBase, EmployeeWelfare.ConstParemeter.YangLaoBase); shiYeBase = GetDecimal(dt, rowindex, shiYeBase, EmployeeWelfare.ConstParemeter.ShiYeBase); yiLiaoBase = GetDecimal(dt, rowindex, yiLiaoBase, EmployeeWelfare.ConstParemeter.YiLiaoBase); socialYM = GetYM(dt, rowindex, socialYM, EmployeeWelfare.ConstParemeter.SocialYM); fundAccount = GetString(dt, rowindex, fundAccount, EmployeeWelfare.ConstParemeter.FundAccount); fundYM = GetYM(dt, rowindex, fundYM, EmployeeWelfare.ConstParemeter.FundYM); fundBase = GetDecimal(dt, rowindex, fundBase, EmployeeWelfare.ConstParemeter.FundBase); supplyAccount = GetString(dt, rowindex, supplyAccount, EmployeeWelfare.ConstParemeter.SupplyAccount); supplyBase = GetDecimal(dt, rowindex, supplyBase, EmployeeWelfare.ConstParemeter.SupplyBase); SaveEmployeeWelfare saveEmployeeWelfare = new SaveEmployeeWelfare(welfare.Owner.Id, socialSecurityType, socialBase, socialYM, fundAccount, fundYM, fundBase, operationName, supplyAccount, supplyBase, yangLaoBase, shiYeBase, yiLiaoBase); saveEmployeeWelfare.Excute(); }