Example #1
0
        public Dto_SaleNode UpdateSales(Dto_SaleNode salesNode, Dto_ClientNode clientsNode, Dto_SellerNode sellersNode, Dto_ProductNode productsNode)
        {
            Dto_SaleNode     Head             = salesNode;
            LogicStoreSystem logicStoreSystem = new LogicStoreSystem();
            int selectedModeSale = logicStoreSystem.selectedModeSale("venta");
            int quantity;
            int availableStock;

            if (selectedModeSale == 1)
            {
                string   type = "false";
                Dto_Sale sale = new Dto_Sale();
                sale.Product = logicStoreSystem.selectItemsForSale("producto", clientsNode, sellersNode, productsNode).Item3;
                sale.Client  = logicStoreSystem.selectItemsForSale("cliente", clientsNode, sellersNode, productsNode).Item1;
                sale.Seller  = logicStoreSystem.selectItemsForSale("vendedor", clientsNode, sellersNode, productsNode).Item2;
                Console.WriteLine("\nCantidad: ");
                quantity = int.Parse(Console.ReadLine());

                while (type == "false")
                {
                    availableStock = ReviewStockProducts(sale, salesNode);

                    if (quantity <= availableStock)
                    {
                        sale.Quantity = quantity;
                        type          = "true";
                    }
                    else if (availableStock == 0)
                    {
                        Console.WriteLine("\nPor favor selecciona otro producto, ya que cuenta con " + availableStock + " unidades disponibles");
                        sale.Product = logicStoreSystem.selectItemsForSale("producto", clientsNode, sellersNode, productsNode).Item3;
                        Console.WriteLine("\nCantidad: ");
                        quantity = int.Parse(Console.ReadLine());
                        Console.WriteLine(" ");
                    }
                    else
                    {
                        Console.WriteLine("\nPor favor selecciona otra cantidad, el producto solo cuenta con " + availableStock + " unidades disponibles");
                        quantity = int.Parse(Console.ReadLine());
                    }
                }

                Dto_SaleNode newSaleNode = new Dto_SaleNode();
                newSaleNode.Sale = sale;

                Dto_SaleNode last = Head;
                while (last.Next != null)
                {
                    last = last.Next;
                }
                sale.Code        = last.Sale.Code + 1;
                sale.Total_Price = sale.Quantity * sale.Product.Price;
                last.Next        = newSaleNode;
            }

            return(salesNode);
        }
Example #2
0
        public Dto_SaleNode returnPoint9(Dto_SaleNode salesNode, Dto_ClientNode clientsNode, Dto_SellerNode sellersNode, Dto_ProductNode productsNode)
        {
            string           type             = "false";
            LogicStoreSystem logicStoreSystem = new LogicStoreSystem();

            logicStoreSystem.PrintSales(salesNode);

            while (type == "false")
            {
                Console.WriteLine("\nEscribe 1 para volver a elegir una opcion u otro numero para finalizar ");
                int selectedMode = int.Parse(Console.ReadLine());

                if (selectedMode == 1)
                {
                    salesNode = logicStoreSystem.UpdateSales(salesNode, clientsNode, sellersNode, productsNode);
                    logicStoreSystem.PrintSales(salesNode);
                }
                else
                {
                    type = "true";
                }
            }
            return(salesNode);
        }
Example #3
0
        public Dto_SellerNode returnPoint8(Dto_SellerNode sellersNode)
        {
            string           type             = "false";
            LogicStoreSystem logicStoreSystem = new LogicStoreSystem();

            logicStoreSystem.PrintSellers(sellersNode);

            while (type == "false")
            {
                Console.WriteLine("\nEscribe 1 para volver a elegir una opcion u otro numero para continuar ");
                int selectedMode = int.Parse(Console.ReadLine());

                if (selectedMode == 1)
                {
                    sellersNode = logicStoreSystem.UpdateSellers(sellersNode);
                    logicStoreSystem.PrintSellers(sellersNode);
                }
                else
                {
                    type = "true";
                }
            }
            return(sellersNode);
        }
Example #4
0
        public Dto_SellerNode UpdateSellers(Dto_SellerNode sellersNode)
        {
            Dto_SellerNode   Head             = sellersNode;
            LogicStoreSystem logicStoreSystem = new LogicStoreSystem();
            int selectedMode = logicStoreSystem.selectedMode("vendedor");

            if (selectedMode == 1)
            {
                Dto_Seller seller = new Dto_Seller();
                Console.WriteLine("\nNombre: ");
                seller.Name = Console.ReadLine();
                Console.WriteLine("Documento: ");
                seller.Document = Int32.Parse(Console.ReadLine());
                Console.WriteLine("Genero: ");
                seller.Gender = Console.ReadLine();
                Console.WriteLine("Edad: ");
                seller.Age = int.Parse(Console.ReadLine());
                Console.WriteLine("Telefono: ");
                seller.Phone = Console.ReadLine();
                Console.WriteLine("Estrato: ");
                seller.Stratum = int.Parse(Console.ReadLine());

                Dto_SellerNode newSellerNode = new Dto_SellerNode();
                newSellerNode.Seller = seller;

                Dto_SellerNode last = Head;
                while (last.Next != null)
                {
                    last = last.Next;
                }
                seller.Code = last.Seller.Code + 1;
                last.Next   = newSellerNode;
            }
            else if (selectedMode == 2)
            {
                Dto_SellerNode sellers;
                Dto_SellerNode baseSellerNode = sellersNode;
                Dto_SellerNode iterator       = sellersNode;
                Dto_SellerNode last           = sellersNode;
                string         type           = "false";

                Console.WriteLine("\n¿Que codigo deseas eliminar?: ");
                int deleteCode = int.Parse(Console.ReadLine());

                int countSellers = 1;

                if (last != null)
                {
                    while (last.Next != null)
                    {
                        countSellers++;
                        last = last.Next;
                    }

                    while (type == "false")
                    {
                        for (int i = 0; i < countSellers; i++)
                        {
                            if (iterator.Seller.Code == deleteCode)
                            {
                                sellers = iterator.Next;
                                if (deleteCode == baseSellerNode.Seller.Code)
                                {
                                    sellersNode = baseSellerNode.Next;
                                    type        = "true";
                                    break;
                                }
                                else
                                {
                                    while (baseSellerNode.Seller.Code != deleteCode)
                                    {
                                        if (baseSellerNode.Next != null & baseSellerNode.Next.Seller.Code != deleteCode)
                                        {
                                            baseSellerNode = baseSellerNode.Next;
                                            type           = "true";
                                        }
                                        else
                                        {
                                            type = "true";
                                            break;
                                        }
                                    }
                                    baseSellerNode.Next = sellers;
                                }
                            }
                            iterator = iterator.Next;
                        }

                        if (type == "false")
                        {
                            Console.WriteLine("\nEl codigo que deseas eliminar no existe, por favor elige otro");
                            deleteCode = int.Parse(Console.ReadLine());
                            iterator   = sellersNode;
                            Console.WriteLine(" ");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("\nNo cuentas con ningun Vendedor, por favor selecciona la opcion de agregar o continua");
                }
            }
            return(sellersNode);
        }
Example #5
0
        public Dto_ProductNode UpdateProducts(Dto_ProductNode productsNode)
        {
            Dto_ProductNode  Head             = productsNode;
            LogicStoreSystem logicStoreSystem = new LogicStoreSystem();
            int selectedMode = logicStoreSystem.selectedMode("producto");

            if (selectedMode == 1)
            {
                Dto_Product product = new Dto_Product();
                Console.WriteLine("\nNombre: ");
                product.Name = Console.ReadLine();
                Console.WriteLine("Precio: ");
                product.Price = Double.Parse(Console.ReadLine());
                Console.WriteLine("Categoria: ");
                product.Category = Console.ReadLine();
                Console.WriteLine("Stock: ");
                product.Stock = int.Parse(Console.ReadLine());

                Dto_ProductNode newProductNode = new Dto_ProductNode();
                newProductNode.Product = product;

                Dto_ProductNode last = Head;
                while (last.Next != null)
                {
                    last = last.Next;
                }
                product.Code = last.Product.Code + 1;
                last.Next    = newProductNode;
            }
            else if (selectedMode == 2)
            {
                Dto_ProductNode products;
                Dto_ProductNode baseProductNode = productsNode;
                Dto_ProductNode iterator        = productsNode;
                Dto_ProductNode last            = productsNode;
                string          type            = "false";

                Console.WriteLine("\n¿Que codigo deseas eliminar?: ");
                int deleteCode = int.Parse(Console.ReadLine());

                int countProducts = 1;

                if (last != null)
                {
                    while (last.Next != null)
                    {
                        countProducts++;
                        last = last.Next;
                    }

                    while (type == "false")
                    {
                        for (int i = 0; i < countProducts; i++)
                        {
                            if (iterator.Product.Code == deleteCode)
                            {
                                products = iterator.Next;
                                if (deleteCode == baseProductNode.Product.Code)
                                {
                                    productsNode = baseProductNode.Next;
                                    type         = "true";
                                    break;
                                }
                                else
                                {
                                    while (baseProductNode.Product.Code != deleteCode)
                                    {
                                        if (baseProductNode.Next != null & baseProductNode.Next.Product.Code != deleteCode)
                                        {
                                            baseProductNode = baseProductNode.Next;
                                            type            = "true";
                                        }
                                        else
                                        {
                                            type = "true";
                                            break;
                                        }
                                    }
                                    baseProductNode.Next = products;
                                }
                            }
                            iterator = iterator.Next;
                        }

                        if (type == "false")
                        {
                            Console.WriteLine("\nEl codigo que deseas eliminar no existe, por favor elige otro");
                            deleteCode = int.Parse(Console.ReadLine());
                            iterator   = productsNode;
                            Console.WriteLine(" ");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("\nNo cuentas con ningun Producto, por favor selecciona la opcion de agregar o continua");
                }
            }
            return(productsNode);
        }