예제 #1
0
        static void Main(string[] args)
        {
            Console.WriteLine("Welcome. Point of menu you want to start");

            ShoppingList MainList = new ShoppingList();


            for (; ;)
            {
                Console.WriteLine(
                    "1. Add new purchase\n" +
                    "2. Remove previous purchase\n" +
                    "3. Show purchases in period of time\n" +
                    "4. Show all purchases in one day\n" +
                    "5. Show total cost of purchases in period of time\n" +
                    "6. Exit from this program\n");
                Console.Write(">> ");
                switch (Console.ReadLine())
                {
                case "1":
                    addPurchase(MainList);
                    break;

                case "2":
                    removePurchase(MainList);
                    break;

                case "3":
                    showPurchase(MainList);
                    break;

                case "4":
                    showDatePurchase(MainList);
                    break;

                case "5":
                    totalPurchase(MainList);
                    break;

                case "6":
                    return;
                }
            }
        }
예제 #2
0
        private static void removePurchase(ShoppingList MainList)
        {
            long number;

            Console.WriteLine("Enter a number in list of purchase you want to delete");
            while (!long.TryParse(Console.ReadLine(), out number))
            {
                Console.WriteLine("Looks like you misstaped some keys. Try to input INTEGER one more time");
            }

            switch (MainList.RemovePurchase(number))
            {
            case Status.OK:
                Console.WriteLine("Purchase note was successfully deleted\n");
                break;

            case Status.Failed:
                Console.WriteLine("An error has occured. Possible, note that you want to delete doesn't exist?\n");
                break;
            }
        }
예제 #3
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;
            }
        }
예제 #4
0
        private static void showDatePurchase(ShoppingList MainList)
        {
            DateTime day;

            Console.WriteLine("Enter day in format dd MM yyyy");

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


            Console.WriteLine();
            List <string> return_list = MainList.PurchasesRange(day, day);

            if (return_list.Count() == 0)
            {
                Console.WriteLine("Not found any notes in this period of time\n");
            }
            else
            {
                return_list.ForEach(x => Console.WriteLine(x));
            }
        }