public DataTable GetIngredientsListWithCost() { DataTable ingredients = new DataTable(); ingredients.Columns.Add("1", typeof(String)); ingredients.Columns.Add("2"); ingredients.Columns.Add("3"); ingredients.Columns.Add("4"); ingredients.Columns.Add("5"); ingredients.Columns.Add("6"); ingredients.PrimaryKey = new DataColumn[] { ingredients.Columns["1"] }; RecipeBL recipeBL = new RecipeBL(); RecipeBO recipeBO = new RecipeBO(); CateringBL CatBL = new CateringBL(); CateringBO CatBO = new CateringBO(); recipeBO.recipeid = this.RecipeID; var dishesrecipe = recipeBL.getRecipeNameAndFormulaAndPriceByDish(recipeBO); foreach (DataRow ing in dishesrecipe.Rows) { string paxx = this.Pax.ToString(); string ins = ing[0].ToString(); decimal actualPrice = getPrice(ing.ItemArray[1].ToString(), paxx); if (this.TypeOfService == "Plated" && this.Category == "Main dish") { actualPrice = actualPrice * Properties.Settings.Default.Plated; } //decimal b = getPrice(ing.ItemArray[1].ToString(), paxx); if (ingredients.Rows.Contains(ins)) { for (int i = 0; i < ingredients.Rows.Count; i++) { string temp = ingredients.Rows[i][0].ToString(); if (ins == temp) { ingredients.Rows[i][2] = (Convert.ToDecimal(ingredients.Rows[i][2].ToString()) + Convert.ToDecimal(actualPrice)); i = ingredients.Rows.Count; } } } else { ingredients.Rows.Add(ing[0].ToString(), ing[2].ToString(), actualPrice); } } return(ingredients); }