Example #1
0
 public Order(string OrdreDate, int Quantity, Customer Customer, Product Product)
 {
     this.OrdreDate = OrdreDate;
     QuantityOrdered = Quantity;
     OrderedBy = Customer;
     OrderedProduct = Product;
 }
Example #2
0
        private void addCustomer()
        {
            int id, number;
            string name, address;
            try_again:
            try
            {
                Console.Clear();
                Console.WriteLine("Write the ID");
                id = int.Parse(Console.ReadLine());
                Console.WriteLine("Write the name");
                name = Console.ReadLine();
                Console.WriteLine("Write the address");
                address = Console.ReadLine();
                Console.WriteLine("Write the telephone number");
                number = int.Parse(Console.ReadLine());
                Console.Clear();
            }
            catch (Exception)
            {
                goto try_again;
            }
            Customer ps = new Customer(id, name, address, number);
            foreach (var item in customerList)
            {
                if (item.CustomerId1 == ps.CustomerId1)
                {
                    goto try_again;
                }
            }
            customerList.Add(ps);

            Console.WriteLine("Press enter to continue");
            Console.Read();
        }
Example #3
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();
        }