public static void SearchSplit() { Console.WriteLine("Search person : "); string sText = Console.ReadLine(); string[] stText = sText.Split(new char[] { ' ' }); if (stText.Count() == 1) { SearchPD(stText[0].TrimEnd(new char[] { ' ' })); } int iter = 1; string sNameSearch = ""; string sSurnameSearch = ""; foreach (string Ing in stText) { if (iter == 1) { sNameSearch = Ing.TrimEnd(new char[] { ' ' }); //Console.WriteLine(sNameSearch); iter++; } if (iter == 2) { sSurnameSearch = Ing.TrimEnd(new char[] { ' ' }); //Console.WriteLine(sSurnameSearch); } } SearchPD(sNameSearch, sSurnameSearch); Console.ReadKey(); Menu.Choice(); }
public static void WriteJson(this Ing value, JsonWriter writer, JsonSerializer serializer) { switch (value) { case Ing.The0: serializer.Serialize(writer, "0"); break; } }
public int Add_ing(Ing ing) { dbc = new DataAccess(); string sql = "Insert into Ads_on_ing(ing_name,ing_price,cat_id) values('" + ing.Ing_name + "'," + ing.ing_price + "," + ing.Ing_cat + ")"; int res = dbc.ExecuteQuery(sql); dbc.Dispose(); return(res); }
public List <Ing> Get_ingId_by_fid(int id) { dbc = new DataAccess(); string sql = " select ing_id from extra_ing where food_id=" + id + " group by ing_id"; SqlDataReader reader = dbc.GetData(sql); List <Ing> ing_id_list = new List <Ing>(); while (reader.Read()) { Ing ingr = new Ing(); ingr.Ing_id = Convert.ToInt32(reader["ing_id"]); ing_id_list.Add(ingr); } return(ing_id_list); }
public List <Ing> Get_food_added_ing(int food_id) { dbc = new DataAccess(); string sql = "select Ads_on_ing.ing_id,Ads_on_ing.ing_name,Ads_on_ing.ing_price from Ads_on_ing,extra_ing where Ads_on_ing.ing_id=extra_ing.ing_id and extra_ing.food_id=" + food_id + ""; SqlDataReader reader = dbc.GetData(sql); List <Ing> ingList = new List <Ing>(); while (reader.Read()) { Ing ingr = new Ing(); ingr.Ing_id = Convert.ToInt32(reader["ing_id"]); ingr.Ing_name = Convert.ToString(reader["ing_name"]); ingr.ing_price = Convert.ToInt32(reader["ing_price"]); ingList.Add(ingr); } return(ingList); }
/// <summary> /// Converts recipe string to a list of RecipeIngredients /// </summary> /// <param name="recipeString">recipe string [id„amount„scale ƒ]</param> /// <returns>List of RecipeIngredient </returns> public static List <RecipeIngredient> ToRecipeList(string recipeString) { List <RecipeIngredient> Recipe = new List <RecipeIngredient>(); string[] ingredients = recipeString.Split(char.Parse(ingredientDelimiter)); foreach (string Ing in ingredients) { string[] fields = Ing.Split(char.Parse(fieldDelimiter)); if (fields[0] == "") { continue; } Recipe.Add(new RecipeIngredient { IngId = long.Parse(fields[0].Trim()), IngAmount = double.Parse(fields[1].Trim()), IngScale = fields[2].Trim() }); } return(Recipe.Count == 0 ? null : Recipe); }
public List <Ing> Get_ing(int cat) { dbc = new DataAccess(); string sql = "select Ads_on_ing.ing_id,Ads_on_ing.ing_name,Ads_on_ing.ing_price from Ads_on_ing where cat_id = " + cat + ""; SqlDataReader reader = dbc.GetData(sql); List <Ing> ingr_list = new List <Ing>(); while (reader.Read()) { Ing ingr = new Ing(); ingr.Ing_id = Convert.ToInt32(reader["ing_id"]); ingr.Ing_name = Convert.ToString(reader["ing_name"]); ingr.ing_price = Convert.ToInt32(reader["ing_price"]); ingr_list.Add(ingr); } dbc.Dispose(); return(ingr_list); }