예제 #1
0
        private static void addPurchase(ShoppingList MainList)
        {
            string   name;
            string   comment;
            double   spentamount;
            DateTime dateofpurchase;

            Console.WriteLine("Enter name of purchase");
            name = Console.ReadLine();

            Console.WriteLine("Enter comment for purchase");
            comment = Console.ReadLine();

            Console.WriteLine("Enter amount of spent credit");
            while (!double.TryParse(Console.ReadLine(), out spentamount))
            {
                Console.WriteLine("Look's like you've made a mistake. Try one more time");
            }

            Console.WriteLine("Enter date of purchase in format dd MM yyyy");
            while (!DateTime.TryParseExact(Console.ReadLine(), "dd MM yyyy", new CultureInfo("ru-Ru"), DateTimeStyles.None, out dateofpurchase))
            {
                Console.WriteLine("Something went wrong. Try to input one more time");
            }

            switch (MainList.AddPurchase(name, comment, spentamount, dateofpurchase))
            {
            case Status.OK:
                Console.WriteLine("Purchase was successfully added\n");
                break;

            case Status.Unexpected:
                Console.WriteLine("Some of your inputed data quite suspision. Are you sure that everything alright?\n");
                break;
            }
        }