public void addAlteredDish() { catBL = new CateringBL(); catBO = new CateringBO(); RecBO = new RecipeBO(); RecBL = new RecipeBL(); decimal dishprice = 0; SupplierBL SuppBL = new SupplierBL(); SupplierBO SuppBO = new SupplierBO(); int recipeid = 0; decimal price = 0; int count = 0; int counter = 0; int pricecounter = 0; List <decimal> popoy = new List <decimal>(); List <decimal> cdad = new List <decimal>(); List <decimal> supp = new List <decimal>(); List <decimal> popoyP = new List <decimal>(); List <decimal> cdadP = new List <decimal>(); List <decimal> suppP = new List <decimal>(); List <decimal> totalPrice = new List <decimal>(); List <decimal> IngredientPrice = new List <decimal>(); List <string> Categories = new List <string>(); string typeofevent = ""; DataTable Suppliers = new DataTable(); Suppliers.Columns.Add("Supplier", typeof(string)); Suppliers.Columns.Add("Amount", typeof(decimal)); Suppliers.PrimaryKey = new DataColumn[] { Suppliers.Columns["Supplier"] }; var SuppAmount = new Dictionary <string, decimal>(); int paramcounter = 0; if (dataGridView2.Rows.Count != 0) { foreach (DataGridViewRow row in dataGridView2.Rows) { dishselected++; RecBO.recipe = row.Cells[0].Value.ToString(); RecBO.cat = comboBox1.Text.Trim(); DataTable Recipe = RecBL.searchRecipeSingle(RecBO); foreach (DataRow rows in Recipe.Rows) { catBO.recipeid = rows.ItemArray[0].ToString(); DataTable supps = catBL.getSuppPrices(catBO); foreach (DataRow prices in supps.Rows) { if (!SuppAmount.Keys.Contains(prices.ItemArray[1].ToString())) { SuppAmount[prices.ItemArray[1].ToString()] = 0; } if (!Suppliers.Rows.Contains(prices.ItemArray[1].ToString())) { Suppliers.Rows.Add(prices.ItemArray[1].ToString()); } IngredientPrice.Add(Convert.ToDecimal(prices.ItemArray[0].ToString())); } recipeid = Convert.ToInt32(rows.ItemArray[0].ToString()); catBO.recipeid = rows.ItemArray[0].ToString(); catBO.catID = catID; } result.Rows.Add(dishselected + ": " + row.Cells[0].Value.ToString() + " (PAX:" + txtGuest.Text + " SERVICE:" + comboBox3.Text + ")", "Quantity", "Price"); ResultQty.Rows.Add(dishselected + ": " + row.Cells[0].Value.ToString() + " (PAX:" + txtGuest.Text + " SERVICE:" + comboBox3.Text + ")", "Quantity"); reserve.Rows.Add(dishselected + ": " + row.Cells[0].Value.ToString() + " (PAX:" + txtGuest.Text + " SERVICE:" + comboBox3.Text + ")"); RecBO.recipeid = Convert.ToString(recipeid); DataTable dt = RecBL.getIngByRecIdOrig(RecBO); decimal priceout = 0; decimal qty = 0; foreach (DataRow rowss in dt.Rows) { //AddDish price = price + getPrice(rowss.ItemArray[2].ToString(), row.Cells[1].Value.ToString()); if (totalPrice.Count == 0) { qty = IngredientPrice[pricecounter] * Convert.ToDecimal(price); if (comboBox1.Text == "Main dish" && comboBox3.Text == "Plated") { qty = qty * Properties.Settings.Default.Plated; price = price * Properties.Settings.Default.Plated; } dishprice = dishprice + qty; SuppAmount[rowss.ItemArray[3].ToString()] = Convert.ToDecimal((SuppAmount[rowss.ItemArray[3].ToString()] + qty)); totalPrice.Add(qty); result.Rows.Add(" " + rowss.ItemArray[4].ToString(), price + " " + rowss.ItemArray[5].ToString(), "P. " + qty.ToString("0.##")); ResultQty.Rows.Add(" " + rowss.ItemArray[4].ToString(), price + " " + rowss.ItemArray[5].ToString()); } else { qty = IngredientPrice[pricecounter] * Convert.ToDecimal(price); if (comboBox1.Text == "Main dish" && comboBox3.Text == "Plated") { qty = qty * Properties.Settings.Default.Plated; price = price * Properties.Settings.Default.Plated; } dishprice = dishprice + qty; SuppAmount[rowss.ItemArray[3].ToString()] = Convert.ToDecimal((SuppAmount[rowss.ItemArray[3].ToString()] + qty)); totalPrice[paramcounter] = totalPrice[paramcounter] + qty; result.Rows.Add(" " + rowss.ItemArray[4].ToString(), price + " " + rowss.ItemArray[5].ToString(), "P. " + qty.ToString("0.##")); ResultQty.Rows.Add(" " + rowss.ItemArray[4].ToString(), price + " " + rowss.ItemArray[5].ToString()); } pricecounter = pricecounter + 1; price = 0; } ResultQty.Rows.Add("", ""); result.Rows.Add("Total ", "-------------", "P " + dishprice.ToString("0.##")); result.Rows.Add("", "", ""); dishprice = 0; } if (totalPrice.Count != 0) { totalExpense = totalPrice[0] + totalExpense; } notifier("Dish deleted!"); } }