public Dto_SellerNode AddSeller(Dto_Seller seller)
        {
            Dto_SellerNode sellerNode = new Dto_SellerNode();

            sellerNode.Seller = seller;

            if (Head == null)
            {
                Head = sellerNode;
            }
            else
            {
                Dto_SellerNode last = Head;
                while (last.Next != null)
                {
                    last = last.Next;
                }
                last.Next = sellerNode;
            }

            return(Head);
        }
示例#2
0
        public Tuple <Dto_Client, Dto_Seller, Dto_Product> selectItemsForSale(string typeNode, Dto_ClientNode clientsNode, Dto_SellerNode sellersNode, Dto_ProductNode productsNode)
        {
            string          type              = "false";
            int             countProducts     = 1;
            int             countClients      = 1;
            int             countSellers      = 1;
            Dto_Client      client            = null;
            Dto_Seller      seller            = null;
            Dto_Product     product           = null;
            Dto_ProductNode lastProductsCount = productsNode;
            Dto_ClientNode  lastClientsCount  = clientsNode;
            Dto_SellerNode  lastSellersCount  = sellersNode;

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

            while (lastClientsCount.Next != null)
            {
                countClients++;
                lastClientsCount = lastClientsCount.Next;
            }

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

            Console.WriteLine("\nEscribe el codigo del " + typeNode + " que desea adicionar");
            int Code = int.Parse(Console.ReadLine());

            while (type == "false")
            {
                if (typeNode == "producto")
                {
                    Dto_ProductNode lastProduct = productsNode;

                    for (int i = 0; i < countProducts; i++)
                    {
                        if (lastProduct.Product.Code == Code)
                        {
                            product = lastProduct.Product;
                            type    = "true";
                        }
                        lastProduct = lastProduct.Next;
                    }
                }
                else if (typeNode == "cliente")
                {
                    Dto_ClientNode lastClient = clientsNode;

                    for (int i = 0; i < countClients; i++)
                    {
                        if (lastClient.Client.Code == Code)
                        {
                            client = lastClient.Client;
                            type   = "true";
                        }
                        lastClient = lastClient.Next;
                    }
                }
                else
                {
                    Dto_SellerNode lastSeller = sellersNode;

                    for (int i = 0; i < countSellers; i++)
                    {
                        if (lastSeller.Seller.Code == Code)
                        {
                            seller = lastSeller.Seller;
                            type   = "true";
                        }
                        lastSeller = lastSeller.Next;
                    }
                }

                if (type == "false")
                {
                    Console.WriteLine("\nEscribe otro codigo de " + typeNode + " ya que el codigo " + Code + " no se encuentra disponible");
                    Code = int.Parse(Console.ReadLine());
                }
            }
            return(Tuple.Create(client, seller, product));
        }
示例#3
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);
        }