private DataTable GetFareCalculatedExpense(DataTable ds, string entity, string dcrCode, string dcrDate, string interMediatePlace, double travelKm, string dcrFlag) { try { ds.Columns.Add(new DataColumn("Total_Fare")); string[] hopArray; string hopNeed = "NO"; if (interMediatePlace != string.Empty) { hopArray = interMediatePlace.Split(','); foreach (string s in hopArray) { if (s.Trim().ToUpper() == "DCR") { hopNeed = "YES"; break; } } } Models.FareCalculationDTO objFarCalcParams = new Models.FareCalculationDTO(); objFarCalcParams.Entity = entity; objFarCalcParams.DcrCode = dcrCode; objFarCalcParams.DcrDate = dcrDate; objFarCalcParams.DcrFalg = dcrFlag; objFarCalcParams.IntermediatePlace = hopNeed; objFarCalcParams.TravelKm = travelKm; objFarCalcParams.DCR_Version = "DCR V3"; foreach (DataRow dr in ds.Rows) { ISFCFareCalculator FareCalcEngine = SFCFareCalculationFactory.GetSFCFareCalculationEngine(dr["SFC_Type"].ToString().Trim().ToUpper()); if (FareCalcEngine != null) { objFarCalcParams.Sum_Distance_Needed = dr["Sum_Distance_Needed"].ToString().Trim().ToUpper(); objFarCalcParams.EligibilityAmount = (dr["Eligibility_Amount"] != System.DBNull.Value) ? Convert.ToDouble(dr["Eligibility_Amount"]) : 0.0; double calculatedSFCFare = FareCalcEngine.CalculateSFCFare(objFarCalcParams); dr["Total_Fare"] = calculatedSFCFare; } else { dr["Total_Fare"] = 0.0; } } return(ds); } catch (Exception ex) { throw ex; } }
private DataTable GetFareCalculatedExpense(DataTable dt, string entity, string dcrCode, string dcrDate, double travelKm, string dcrFlag) { try { dt.Columns.Add(new DataColumn("Total_Fare")); Models.FareCalculationDTO objFarCalcParams = new Models.FareCalculationDTO(); objFarCalcParams.Entity = entity; objFarCalcParams.DcrCode = dcrCode; objFarCalcParams.DcrDate = dcrDate; objFarCalcParams.DcrFalg = dcrFlag; objFarCalcParams.TravelKm = travelKm; objFarCalcParams.DCR_Version = "DCR V4"; foreach (DataRow dr in dt.Rows) { ISFCFareCalculator FareCalcEngine = SFCFareCalculationFactory.GetSFCFareCalculationEngine(dr["SFC_Type"].ToString().Trim().ToUpper()); if (FareCalcEngine != null) { objFarCalcParams.Sum_Distance_Needed = dr["Sum_Distance_Needed"].ToString().Trim().ToUpper(); objFarCalcParams.EligibilityAmount = (dr["Eligibility_Amount"] != System.DBNull.Value) ? Convert.ToDouble(dr["Eligibility_Amount"]) : 0.0; double calculatedSFCFare = FareCalcEngine.CalculateSFCFare(objFarCalcParams); dr["Total_Fare"] = calculatedSFCFare; } else { dr["Total_Fare"] = 0.0; } } return(dt); } catch { throw; } }