示例#1
0
文件: Stock.cs 项目: DotEmms/Project1
        public void ReadFile()
        {
            //This is how it will read file into memory database:
            string[] lines = File.ReadAllLines(filePath);

            for (int i = 1; i < lines.Length; i++)
            {
                string   catalogueLine = lines[i];
                string[] data          = catalogueLine.Split(',');
                Clothes  item          = new Clothes
                {
                    ID            = Convert.ToInt32(data[0]),
                    Category      = ConvertCategory(data[1]),
                    Name          = data[2],
                    ClothingSizes = ConvertClothingSize(data[3]),
                    ColorOptions  = ConvertColor(data[4]),
                    Price         = Convert.ToDouble(data[5])
                };
                Catalogue.Add(item);
            }
        }
示例#2
0
文件: Stock.cs 项目: DotEmms/Project1
        public void OwnerWriteText()
        {
            using StreamWriter writer = new StreamWriter(filePath, true);
            Clothes item = new Clothes();

            Console.Clear();
            Methods.PrintLogo();
            Methods.PrintBorder();

            Methods.WhiteSpace();
            Console.WriteLine("Enter the name of the clothing:");
            Methods.PrintBorder();
            Methods.WhiteSpace();
            item.Name = Console.ReadLine();
            Methods.WhiteSpace();
            Console.WriteLine("Name added, succesfully!");

            Console.Clear();
            Methods.PrintLogo();
            Console.WriteLine(@"
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::                                                                ::
            ::   Select an option:                                            ::
            ::                                                                ::
            ::   1) T-shirts                                                  ::
            ::   2) Longsleeve                                                ::
            ::   3) Jeans                                                     ::
            ::   4) DressPants                                                ::
            ::   5) Dress                                                     ::
            ::   6) Sweater                                                   ::
            ::   7) Pyjama                                                    ::
            ::   8) Intimates                                                 ::
            ::   9) Misc                                                      ::
            ::                                                                ::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ");
            Methods.WhiteSpace();
            string categoryChoice = Console.ReadLine();

            item.Category = ConvertCategory(categoryChoice);
            Methods.WhiteSpace();
            Console.WriteLine("Category added, succesfully!");

            Console.Clear();
            Methods.PrintLogo();
            Console.WriteLine(@"
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::                                                                ::
            ::   Select a size:                                               ::
            ::                                                                ::
            ::   1) XS                                                        ::
            ::   2) S                                                         ::
            ::   3) M                                                         ::
            ::   4) L                                                         ::
            ::   5) XL                                                        ::
            ::   6) XXL                                                       ::
            ::   7) Taille Unique                                             ::
            ::   8) Intimates                                                 ::
            ::   9) Misc                                                      ::
            ::                                                                ::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ");
            Methods.WhiteSpace();
            string clothingSizeChoice = Console.ReadLine();

            item.ClothingSizes = ConvertClothingSize(clothingSizeChoice);
            Methods.WhiteSpace();
            Console.WriteLine("Size added, succesfully!");

            Console.Clear();
            Methods.PrintLogo();
            Console.WriteLine(@"
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::                                                                ::
            ::   Select a color:                                              ::
            ::                                                                ::
            ::   1) Blue                                                      ::
            ::   2) Black                                                     ::
            ::   3) Red                                                       ::
            ::   4) Green                                                     ::
            ::   5) Yellow                                                    ::
            ::   6) Pink                                                      ::
            ::   7) White                                                     ::
            ::   8) Gold                                                      ::
            ::   9) Silver                                                    ::
            ::                                                                ::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
            ");
            Methods.WhiteSpace();
            string colorChoice = Console.ReadLine();

            item.ColorOptions = ConvertColor(colorChoice);
            Methods.WhiteSpace();
            Console.WriteLine("Color added, succesfully!");

            Console.Clear();
            Methods.PrintLogo();
            Methods.PrintBorder();
            Methods.WhiteSpace();
            Console.WriteLine("Enter the price of that piece of clothing:");
            Methods.PrintBorder();
            Methods.WhiteSpace();
            item.Price = Convert.ToDouble(Console.ReadLine());
            Methods.WhiteSpace();
            Console.WriteLine("Price added, succesfully!");
            item.ID = Catalogue.Count + 1;
            Catalogue.Add(item);
            writer.Write($"\n{item.ID},{categoryChoice},{item.Name},{clothingSizeChoice},{colorChoice},{item.Price:#.##}");

            writer.Close();
        }