/// <summary> /// 将excel的数据绑定到AccountSet上 /// </summary> /// <param name="ds"></param> /// <param name="indexRow"></param> /// <param name="accountSet"></param> private static void BindAccountSetData(DataTable dt, int indexRow, ModelPayModule.AccountSet accountSet) { if (accountSet.Items == null) { return; } foreach (AccountSetItem item in accountSet.Items) { if (item.AccountSetPara.FieldAttribute.Id != FieldAttributeEnum.FixedField.Id) { continue; } int indexAccountSetParaName = GetDataSetColumnIndex(dt, item.AccountSetPara.AccountSetParaName); if (indexAccountSetParaName == -1) { continue; } decimal data; if (decimal.TryParse(dt.Rows[indexRow][indexAccountSetParaName].ToString().Trim(), out data)) { item.CalculateResult = data; } } }
/// <summary> /// 开始更新员工的帐套 /// </summary> /// <param name="ds"></param> /// <param name="indexAccountSetName"></param> /// <param name="indexEmployeeName"></param> private void ToInsertUpdateEmployeeAccountSet(DataTable dt, int indexAccountSetName, int indexEmployeeName) { List <Account> allAccount = _IAccountBll.GetAllAccount(); allAccount = Tools.RemoteUnAuthAccount(allAccount, AuthType.HRMIS, _Operator, HrmisPowers.A604); for (int i = 0; i < dt.Rows.Count; i++) { ModelPayModule.AccountSet accountSet = null; //有没有当前账号 Account account = _IAccountBll.GetAccountByName(dt.Rows[i][indexEmployeeName].ToString().Trim()); if (account == null || !Tools.ContainsAccountById(allAccount, account.Id)) { continue; } //当前账号有没有工资套,如果有则给accountSet赋上当前帐套,以便更新 bool IsEmployeeHaveAccountSet = false; EmployeeSalary employeeSalary = new GetEmployeeAccountSet().GetEmployeeAccountSetByEmployeeID(account.Id); if (employeeSalary != null && employeeSalary.AccountSet != null) { accountSet = employeeSalary.AccountSet; IsEmployeeHaveAccountSet = true; } //excel是否有帐套名称列,如果有则需要确定是否要更新帐套 if (indexAccountSetName != -1) { ModelPayModule.AccountSet accountSetInExcel = new GetAccountSet().GetAccountSetByName( dt.Rows[i][indexAccountSetName].ToString().Trim()); if (accountSetInExcel != null) { //如果accountSet是空,则将accountSetInExcel赋值给accountSet if (accountSet == null) { accountSet = new GetAccountSet().GetWholeAccountSetByPKID(accountSetInExcel.AccountSetID); } //如果accountSet不是空,是否和accountSetInExcel的帐套一致,如果不一致,则要覆盖accountSet,并且做AccountSet信息的数据Merge,保留原有的固定值信息 else if (accountSetInExcel.AccountSetID != accountSet.AccountSetID) { accountSet = new GetAccountSet().GetWholeAccountSetByPKID(accountSetInExcel.AccountSetID); if (employeeSalary != null && employeeSalary.AccountSet != null) { //AccountSet信息的数据Merge,保留原有的固定值信息 MergeAccountSetData(accountSet, employeeSalary.AccountSet); } } } } if (accountSet == null) { continue; } BindAccountSetData(dt, i, accountSet); if (IsEmployeeHaveAccountSet) { new UpdateEmployeeAccountSet(account.Id, accountSet, _Operator.Name, DateTime.Now, EmployeeAccount_DataString).Excute(); } else { new CreateEmployeeAccountSet(account.Id, accountSet, _Operator.Name, DateTime.Now, EmployeeAccount_DataString).Excute(); } } }