Example #1
0
    public static List <Member> getData()
    {
        string Folder = AppDomain.CurrentDomain.BaseDirectory;
        string Path   = $"{Folder}Resources\\Data\\Members.txt";

        MyFileManager.CheckFilePath(Path);

        var Data   = File.ReadAllLines(Path);
        var result = new List <Member>();

        foreach (var Line in Data)
        {
            var Items = Line.Split('|');

            if (Items.Count() != 6)
            {
                continue;
            }
            else /*Do nothing*/ } {
            result.Add(new Member {
                    Name = Items[0], ID = Items[1], BirthDay = Items[2], School = Items[3], Faculty = Items[4], Class = Items[5], ImgSource = $"Resources\\Images\\{Items[1]}.jpg"
                });
    }

    return(result);
}
Example #2
0
    public static List <Dish_Type> getData()
    {
        string Folder = AppDomain.CurrentDomain.BaseDirectory;
        string Path   = $"{Folder}Resources\\Data\\Dish_Type.txt";

        MyFileManager.CheckFilePath(Path);

        var Data   = File.ReadAllLines(Path);
        var result = new List <Dish_Type>();

        foreach (var Line in Data)
        {
            var Items = Line.Split('|');

            if (Items.Count() != 2)
            {
                continue;
            }
            else /*Do nothing*/ } {
            result.Add(new Dish_Type {
                    dishID = Items[0], typeID = Items[1]
                });
    }

    return(result);
}
Example #3
0
    public static List <RecipeDetail> getData()
    {
        string Folder = AppDomain.CurrentDomain.BaseDirectory;
        string Path   = $"{Folder}Resources\\Data\\RecipeDetail.txt";

        MyFileManager.CheckFilePath(Path);

        var Data   = File.ReadAllLines(Path);
        var result = new List <RecipeDetail>();

        foreach (var Line in Data)
        {
            var Items = Line.Split('|');

            if (Items.Count() != 4)
            {
                continue;
            }
            else /*Do nothing*/ } {
            var Des = Items[2].Replace("\\r\\n", System.Environment.NewLine);

            result.Add(new RecipeDetail {
                    dishID = Items[0], step = int.Parse(Items[1]), stepDetail = Des, quantityOfImage = int.Parse(Items[3])
                });
    }

    return(result);
}
Example #4
0
        /// <summary>
        /// Read data from file
        /// </summary>
        /// <returns>BindingList</returns>
        private static BindingList <Dish> ReadData()
        {
            var          folder    = AppDomain.CurrentDomain.BaseDirectory;
            var          filepath  = $"{folder}Resources\\Data\\Dish.txt";
            const string comma     = "|";
            var          separator = new string[] { comma };

            MyFileManager.CheckFilePath(filepath);
            var fileLines = File.ReadAllLines(filepath).ToList();

            BindingList <Dish> result = new BindingList <Dish>();


            foreach (string line in fileLines)
            {
                string[] temp = line.Split(separator, StringSplitOptions.None);

                if (temp.Length == 7)
                {
                    Dish dish = new Dish();
                    dish.Id   = temp[0].Trim();
                    dish.Name = temp[1].Trim();

                    var Des = temp[2].Replace("\\r\\n", System.Environment.NewLine);
                    dish.Description = Des;

                    var Ing = temp[3].Replace("\\r\\n", System.Environment.NewLine);
                    dish.Ingredient = Ing;

                    dish.LinkVideo = temp[4];
                    dish.Source    = $"Resources/Images/{dish.Id}.jpg";
                    dish.Fav       = bool.Parse(temp[5].Trim());
                    dish.Date      = temp[6];
                    result.Add(dish);
                }
                else
                {
                    //do nothing
                }
            }
            return(result);
        }