Пример #1
0
 public Order(string OrdreDate, int Quantity, Customer Customer, Product Product)
 {
     this.OrdreDate = OrdreDate;
     QuantityOrdered = Quantity;
     OrderedBy = Customer;
     OrderedProduct = Product;
 }
Пример #2
0
        private void load()
        {
            StreamReader sr = new StreamReader("../../Customers.txt");
            StreamReader sr2 = new StreamReader("../../Products.txt");
            StreamReader sr3 = new StreamReader("../../Orders.txt");

            while (sr.EndOfStream == false)
            {
                Customer customer = new Customer(sr.ReadLine());
                customerList.Add(customer);

            }
            while (sr2.EndOfStream == false)
            {
                Product product = new Product(sr2.ReadLine());
                productList.Add(product);

            }
            while (sr3.EndOfStream == false)
            {
                string[] str = sr3.ReadLine().Split(';');
                Customer customer = new Customer(int.Parse(str[2]), str[3], str[4], int.Parse(str[5]));
                Product product = new Product(int.Parse(str[6]), str[7], int.Parse(str[8]));
                Order order = new Order(str[0], int.Parse(str[1]), customer, product);

                Customer customer2 = findCustomerWithIndexX(customer.CustomerId1);
                customerList.Remove(customer2);
                customer2.AddOrderToList(order);
                customerList.Add(customer2);
                Console.WriteLine();
            }
            Console.WriteLine("Press enter to continue");
            Console.ReadLine();

            sr.Close();
            sr2.Close();
            sr3.Close();
        }
Пример #3
0
        private void addProduct()
        {
            int number;
            float price;
            string name;
            try_again:
            try
            {
                Console.Clear();
                Console.WriteLine("Write the ID");
                number = int.Parse(Console.ReadLine());
                Console.WriteLine("Write the name");
                name = Console.ReadLine();
                Console.WriteLine("Write the price");
                price = float.Parse(Console.ReadLine());
                Console.Clear();
            }
            catch (Exception)
            {
                goto try_again;
            }
            Product ps = new Product(number, name, price);
            foreach (var item in productList)
            {
                if (item.Itemnr1 == ps.Itemnr1)
                {
                    goto try_again;
                }
            }
            productList.Add(ps);

            Console.WriteLine("Press enter to continue");
            Console.Read();
        }