Exemple #1
0
        public static void DisplayByDate(Bookkeeping obj)
        {
            var display = from i in obj.data
                          orderby i.date
                          select i;

            Console.Write("Введите желаемую дату: ");
            int userdate = Convert.ToInt32(Console.ReadLine());

            if (userdate < 0)
            {
                ExccessDisplayDate err = new ExccessDisplayDate("ERROR!!!\n There is no negative year");
                throw err;
            }

            foreach (Document i in display)
            {
                if (i.date <= userdate)
                {
                    Console.WriteLine(i.name);
                }
            }
        }
Exemple #2
0
        public static void CheckCount(Bookkeeping obj)
        {
            var check = from i in obj.data
                        orderby i.TypeDoc()
                        select i;

            int count = 0;

            foreach (Document i in check)
            {
                if (i.TypeDoc() == "Чек бумажный." || i.TypeDoc() == "Чек электронный.")
                {
                    count++;
                }
            }

            if (count == 0)
            {
                ExccessCheckCount err = new ExccessCheckCount("Error!!!\n There are no manuals in the library");
                throw err;
            }

            Console.WriteLine($"Количество чеков составляет: {count}.");
        }
Exemple #3
0
        static void Main(string[] args)
        {
            try {
                Receipt Receipt_1 = new Receipt("Красная звезда", "финансовый", 2018, 300, "Receipt");
                Receipt_1.Display();
                Receipt_1.DisplayInfo();

                Console.WriteLine();

                Invoice Invoice_1 = new Invoice("Светлое будущее", "реализации", 2019, 355, "Invoice");
                Invoice_1.Display();
                Invoice_1.DisplayInfo();

                Console.WriteLine();

                Check Check_1 = new Check("Черная линия", "расчетный", 2020, 460, "Check");
                Check Check_2 = new Check("Черная линия", "расчетный", 2019, 290, "Check");
                Check_1.Display();
                Check_1.DisplayInfo();

                Console.WriteLine();

                if (Receipt_1 is Receipt)
                {
                    Console.WriteLine("Объект Receipt_1 принадлежит классу Receipt.");
                }
                else
                {
                    Console.WriteLine("Объект Receipt_1 не принадлежит классу Receipt.");
                }

                List <Organization> list = new List <Organization>()
                {
                    Receipt_1, Invoice_1, Check_1, Check_2
                };

                foreach (Organization i in list)
                {
                    Printer.iAmPrinting(i);
                }

                Bookkeeping lib = new Bookkeeping();

                lib.Push(Receipt_1);
                lib.Push(Invoice_1);
                lib.Push(Check_1);
                lib.Push(Check_2);
                lib.Output();


                Controller.DisplayByDate(lib);
                Controller.CheckCount(lib);
                Controller.CostInvoice(lib);

                Bookkeeping libr = new Bookkeeping();

                //libr.Output();//err_1
                //Controller.CheckCount( libr );//err_3

                Invoice Invoice_2 = new Invoice("Красная звезда", "финансовый", 2017, -1000, "Invoice");
                Invoice Invoice_3 = new Invoice("Черная линия", "расчетный", 2017, -1000, "Invoice");

                libr.Push(Invoice_2);
                libr.Push(Invoice_3);

                //Controller.CostInvoice( librrrrrrr );//err_4
                int zero = 0;
                // int x = 45454 / zero;

                Debug.Assert(zero > 0, "Переменная не больше 0.");

                //Exception exception = new Exception();
                //exception.
            }
            catch (ExccessBookkeepingEmpty err_1) {
                Console.WriteLine(err_1);
            }
            catch (ExccessDisplayDate err_2) {
                Console.WriteLine(err_2);
            }
            catch (ExccessCheckCount err_3) {
                Console.WriteLine(err_3);
            }
            catch (ExccessCostInvoice err_4) {
                Console.WriteLine(err_4);
            }
            catch (Exception err_5) {
                Console.WriteLine(err_5);
            }
            finally {
                Console.WriteLine("The End!");
            }
        }