Example #1
0
        // Parameters to delete an article
        static void deleteArticle(ArticleList listArt)
        {
            Console.WriteLine("Enter the ID of the item to remove:");
            int id = Int32.Parse(Console.ReadLine());

            listArt.deleteArticleByID(id);
        }
Example #2
0
 public Invoice(int idInvoice, CustomerNode customer, ArticleList itemsList, Double invoiceValue)
 {
     this.idInvoice    = idInvoice;
     this.date         = DateTime.Now;
     this.customer     = customer;
     this.itemsList    = itemsList;
     this.invoiceValue = invoiceValue;
 }
Example #3
0
        // Parameters to add a new invoice
        static Invoice loadInvoice()
        {
            Console.WriteLine("Enter the details of the new invoice:");
            Console.WriteLine("Id Invoice:");
            int id = Int32.Parse(Console.ReadLine());

            Console.WriteLine("ID Customer:");
            int          idCli    = Int32.Parse(Console.ReadLine());
            CustomerNode customer = customerList.returnCustomerByID(idCli);

            Console.WriteLine("List articles:");
            ArticleList listItems = new ArticleList();
            int         var       = 1;

            do
            {
                Console.WriteLine("Enter the ID of the article you want to add:");
                int     idA        = Int32.Parse(Console.ReadLine());
                Article newArticle = articleList.returnArticleByID(idA).Article;
                Console.WriteLine("Enter the amount you want to carry:");
                int cant = Int32.Parse(Console.ReadLine());
                if (cant > newArticle.Stock)
                {
                    Console.WriteLine("Not all these drives are available.");
                    Console.WriteLine("Do you want to enter another quantity less than: {0}", newArticle.Stock, "units.");
                    Console.WriteLine("1- YES");
                    Console.WriteLine("0- NO");
                    Console.WriteLine("Please select an option:");
                    int a = Int32.Parse(Console.ReadLine());
                    if (a == 1)
                    {
                        Console.WriteLine("Enter the amount you want to carry:");
                        cant = Int32.Parse(Console.ReadLine());
                        newArticle.Quantity   = cant;
                        newArticle.TotalPrice = newArticle.Quantity * newArticle.Price;
                        articleList.returnArticleByID(idA).Article.updateStock(newArticle.Stock - cant);
                        listItems.addArticle(newArticle);
                    }
                    else
                    {
                        listItems.addArticle(null);
                    }
                }
                else
                {
                    newArticle.Quantity   = cant;
                    newArticle.TotalPrice = newArticle.Quantity * newArticle.Price;
                    articleList.returnArticleByID(idA).Article.updateStock(newArticle.Stock - cant);
                    listItems.addArticle(newArticle);
                }

                Console.WriteLine("You want to add another item to the invoice:");
                Console.WriteLine("1- YES");
                Console.WriteLine("0- NO");
                Console.WriteLine("Please select an option:");
                var = Int32.Parse(Console.ReadLine());
                Console.Write("Press any key to continue...");
                Console.ReadKey();
                Console.Clear();
            } while (var != 0);
            Double  valueInvoice = listItems.totalValue();
            Invoice invoice      = new Invoice(id, customer, listItems, valueInvoice);

            return(invoice);
        }