private void DecodeRuleDetails(CustomList <SalaryRule> ruleDetails) { try { foreach (SalaryRule item in ruleDetails) { var pattern = new Regex(@"(\@.*?\@)", RegexOptions.IgnorePatternWhitespace); foreach (Match m in pattern.Matches(item.Formula2.ToUpper())) { string[] parts = m.Groups[1].Value.Split('@'); SalaryRule obj = ruleDetails.Find(f => f.HeadName.ToUpper().Trim() == parts[1].ToUpper().Trim()); item.Formula2 = item.Formula2.ToUpper().Replace(m.Groups[1].Value, obj.Formula2); } NCalc.Expression exp = new NCalc.Expression(item.Formula2); object ret = exp.Evaluate(); item.Formula2 = ret.ToString(); decimal val = 0M; EmployeeSalaryTemp eST = new EmployeeSalaryTemp(); eST.SalaryRuleCode = item.SalaryRuleCode; eST.SalaryHeadKey = item.SalaryHeadKey; eST.IsFixed = item.IsFixed; if (decimal.TryParse(item.Formula2, out val)) { eST.Amount = Math.Round(val, 2); } _EmpSalaryTempList.Add(eST); } } catch (Exception ex) { throw ex; } }
public CustomList <SalaryRule> GetAllSalaryRuleFormula(string salaryRuleCode) { return(SalaryRule.GetAllSalaryRuleFormula(salaryRuleCode)); }