Ejemplo n.º 1
0
        public void consoleMenu()
        {
            sale s = new sale();

            Console.WriteLine("Enter Desired operation:");
            Console.WriteLine("1. New Sale.");
            Console.WriteLine("2. Print Invoices.");

            int option1 = int.Parse(Console.ReadLine());

            if (option1 == 1)
            {
                s.newSale();
            }
            else if (option1 == 2)
            {
                ArrayList list = s.getAllSales();
                for (int i = 0; i < list.Count; i++)
                {
                    sale obj = list[i] as sale;
                    obj.printInvoice();
                }
            }
            else
            {
                Console.WriteLine("Invalid Input");
            }
        }
        public void saveNewSale(sale s)
        {
            StreamWriter writeFile = new StreamWriter("TeaShop.txt", true);

            writeFile.WriteLine(s.customerNameProperty);
            writeFile.WriteLine(s.localDateProperty);
            writeFile.WriteLine(s.flavourProperty);
            writeFile.WriteLine(s.refreshmentProperty);
            writeFile.WriteLine(s.totalCostProperty);
            writeFile.WriteLine(s.cashReceivedProperty);
            writeFile.WriteLine(s.cashReturnedProperty);
            writeFile.Close();
        }
        public ArrayList collectAllSale()
        {
            ArrayList    list     = new ArrayList();
            StreamReader readFile = new StreamReader("TeaShop.txt");
            sale         s;

            while (!readFile.EndOfStream)
            {
                s = new sale();
                s.customerNameProperty = readFile.ReadLine();
                s.localDateProperty    = DateTime.Parse(readFile.ReadLine());
                s.flavourProperty      = readFile.ReadLine();
                s.refreshmentProperty  = readFile.ReadLine();
                s.totalCostProperty    = int.Parse(readFile.ReadLine());
                s.cashReceivedProperty = int.Parse(readFile.ReadLine());
                s.cashReturnedProperty = int.Parse(readFile.ReadLine());
                list.Add(s);
            }
            readFile.Close();
            return(list);
        }