private static Recepta[] ReceptesDessades(Gabriel.Cat.BaseDeDades baseDeDades, Ingredient[] ingredients) { string[,] taula = baseDeDades.ConsultaTableDirect("Receptes"); SortedList <string, List <Ingredient> > indexIngredients = new SortedList <string, List <Ingredient> >(); List <Recepta> receptes = new List <Recepta>(); for (int i = 0; i < ingredients.Length; i++) { if (!indexIngredients.ContainsKey(ingredients[i].IdReceptaPerPosar)) { indexIngredients.Add(ingredients[i].IdReceptaPerPosar, new List <Ingredient>()); } indexIngredients[ingredients[i].IdReceptaPerPosar].Add(ingredients[i]); } if (taula != null) { for (int i = 1; i < taula.GetLength(1); i++) { receptes.Add(new Recepta(taula[0, i])); //por mirar try { receptes[receptes.Count - 1].Afegir(indexIngredients[receptes[receptes.Count - 1].PrimaryKey]); foreach (Ingredient ingredient in indexIngredients[receptes[receptes.Count - 1].PrimaryKey]) { ingredient.DessaCanvis(); } } catch { } } } return(receptes.ToArray <Recepta>()); }
public static Producte[] ProductesDessats(Gabriel.Cat.BaseDeDades baseDeDades, Recepta[] receptes) { List <Producte> productes = new List <Producte>(); SortedList <string, Recepta> indexReceptes = new SortedList <string, Recepta>(); for (int i = 0; i < receptes.Length; i++) { indexReceptes.Add(receptes[i].PrimaryKey, receptes[i]); } string[,] taula = baseDeDades.ConsultaTableDirect("Productes"); if (taula != null) { for (int i = 1; i < taula.GetLength(1); i++) { try { //por mirar productes.Add(new Producte(taula[0, i], taula[1, i], taula[2, i], ObjecteSql.StringToTimeSpan(taula[8, i]), ObjecteSql.StringToTimeSpan(taula[9, i]), ObjecteSql.StringToTimeSpan(taula[10, i]), indexReceptes[taula[3, i]], Convert.ToDecimal(taula[6, i]) / 100M, Convert.ToDecimal(taula[7, i]) / 100M) { rutaImatge = taula[4, i], infoExtra = taula[5, i] }); foreach (Ingredient ingredient in indexReceptes[taula[3, i]]) { if (ingredient.IdProductePerPosar == productes[productes.Count - 1].PrimaryKey) { ingredient.Producte = productes[productes.Count - 1]; ingredient.DessaCanvis(); } } } catch { } } } return(productes.ToArray <Producte>()); }
public static UnitatProducte[] UnitatsDessades(Gabriel.Cat.BaseDeDades baseDeDades, Recepta[] receptes, Producte[] productes) { string[,] taula = baseDeDades.ConsultaTableDirect("UnitatsProductes"); List <UnitatProducte> unitatsProductes = new List <UnitatProducte>(); SortedList <string, Recepta> indexRecepta = new SortedList <string, Recepta>(); SortedList <string, Producte> indexProducte = new SortedList <string, Producte>(); for (int i = 0; i < receptes.Length; i++) { indexRecepta.Add(receptes[i].PrimaryKey, receptes[i]); } for (int i = 0; i < productes.Length; i++) { indexProducte.Add(productes[i].PrimaryKey, productes[i]); } foreach (var recepta in indexRecepta) { foreach (var ingredient in recepta.Value) { try { if (indexProducte.ContainsKey(ingredient.IdProductePerPosar)) { ingredient.Producte = indexProducte[ingredient.IdProductePerPosar]; } } catch { } } } if (taula != null) { for (int i = 1; i < taula.GetLength(1); i++) { //por mirar unitatsProductes.Add(new UnitatProducte(indexProducte[taula[1, i]], Convert.ToDecimal(taula[3, i]) / 100M, ObjecteSql.StringToDateTime(taula[4, i]), ObjecteSql.StringToDateTime(taula[5, i]), indexRecepta[taula[2, i]])); unitatsProductes[unitatsProductes.Count - 1].PrimaryKey = taula[0, i]; unitatsProductes[unitatsProductes.Count - 1].DessaCanvis(); } } return(unitatsProductes.ToArray <UnitatProducte>()); }
public static Ingredient[] IngredientsDessats(Gabriel.Cat.BaseDeDades baseDeDades) { List <Ingredient> ingredients = new List <Ingredient>(); string[,] taula = baseDeDades.ConsultaTableDirect("Ingredients"); Ingredient ingredientDessat; if (taula != null) { for (int i = 1; i < taula.GetLength(1); i++) { ingredientDessat = new Ingredient(taula[2, i], taula[1, i], Convert.ToDecimal(taula[3, i]) / 100M); //por mirar if (ingredientDessat.PrimaryKey == "") { throw new Exception("FATAL ERROR"); } ingredients.Add(ingredientDessat); } } return(ingredients.ToArray <Ingredient>()); }
public static UnitatProducte[] UnitatsDessades(Gabriel.Cat.BaseDeDades baseDeDades) { Recepta[] receptesDessades = Recepta.ReceptesDessades(baseDeDades); return(UnitatsDessades(baseDeDades, receptesDessades, Producte.ProductesDessats(baseDeDades, receptesDessades))); }
public static Recepta[] ReceptesDessades(Gabriel.Cat.BaseDeDades baseDeDades) { return(ReceptesDessades(baseDeDades, Ingredient.IngredientsDessats(baseDeDades))); }
public static Producte[] ProductesDessats(Gabriel.Cat.BaseDeDades baseDeDades) { return(ProductesDessats(baseDeDades, Recepta.ReceptesDessades(baseDeDades))); }