コード例 #1
0
        public Dto_ClientNode AddClient(Dto_Client client)
        {
            Dto_ClientNode clientNode = new Dto_ClientNode();

            clientNode.Client = client;

            if (Head == null)
            {
                Head = clientNode;
            }
            else
            {
                Dto_ClientNode last = Head;
                while (last.Next != null)
                {
                    last = last.Next;
                }
                last.Next = clientNode;
            }

            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_ClientNode UpdateClients(Dto_ClientNode clientsNode)
        {
            Dto_ClientNode   Head             = clientsNode;
            LogicStoreSystem logicStoreSystem = new LogicStoreSystem();
            int selectedMode = logicStoreSystem.selectedMode("cliente");

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

                Dto_ClientNode newClientNode = new Dto_ClientNode();
                newClientNode.Client = client;

                Dto_ClientNode last = Head;
                while (last.Next != null)
                {
                    last = last.Next;
                }
                client.Code = last.Client.Code + 1;
                last.Next   = newClientNode;
            }
            else if (selectedMode == 2)
            {
                Dto_ClientNode clients;
                Dto_ClientNode baseClientNode = clientsNode;
                Dto_ClientNode iterator       = clientsNode;
                Dto_ClientNode last           = clientsNode;
                string         type           = "false";

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

                int countClients = 1;

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

                    while (type == "false")
                    {
                        for (int i = 0; i < countClients; i++)
                        {
                            if (iterator.Client.Code == deleteCode)
                            {
                                clients = iterator.Next;
                                if (deleteCode == baseClientNode.Client.Code)
                                {
                                    clientsNode = baseClientNode.Next;
                                    type        = "true";
                                    break;
                                }
                                else
                                {
                                    while (baseClientNode.Client.Code != deleteCode)
                                    {
                                        if (baseClientNode.Next != null & baseClientNode.Next.Client.Code != deleteCode)
                                        {
                                            baseClientNode = baseClientNode.Next;
                                            type           = "true";
                                        }
                                        else
                                        {
                                            type = "true";
                                            break;
                                        }
                                    }
                                    baseClientNode.Next = clients;
                                }
                            }
                            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   = clientsNode;
                            Console.WriteLine(" ");
                        }
                    }
                }
                else
                {
                    Console.WriteLine("\nNo cuentas con ningun Cliente, por favor selecciona la opcion de agregar o continua");
                }
            }

            return(clientsNode);
        }