Example #1
0
        public static void ShowMenu()
        {
            ICrud manageClient = ManageClient.Instancia;

            Console.Clear();
            try
            {
                Console.ForegroundColor = ConsoleColor.White;
                Console.WriteLine("Menu de Clientes");
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine("1 - Crear \n2 - Listar \n3 - Editar \n4 - Eliminar \n5- Menu Principal");
                Console.Write("Digite una opcion: ");
                int opcion = Convert.ToInt32(Console.ReadLine());

                switch (opcion)
                {
                case 1:
                    manageClient.Crear();
                    break;

                case 2:
                    manageClient.Listar();
                    break;

                case 3:
                    manageClient.Editar();
                    break;

                case 4:
                    manageClient.Eliminar();
                    break;

                case 5:
                    MenuPrincipal.ShowMenu();
                    break;

                default:
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Error! opcion invalida");
                    Console.ReadKey();
                    ShowMenu();
                    break;
                }
            }
            catch (Exception)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Error! opcion invalida");
                Console.ReadKey();
                ShowMenu();
            }
        }
Example #2
0
        private void VentaCompletada(Factura factura)
        {
            Console.Clear();
            double total = 0;

            Console.WriteLine("Factura id: {0}", factura.Id);
            Console.WriteLine("Factura completada a nombre de {0}", factura.NombreCliente);
            Console.WriteLine("----------------------------------------------------");
            Console.WriteLine("|Nombre | Cant | Precio | Subtotal");
            Console.WriteLine("----------------------------------------------------");
            foreach (var item in factura.ProductList)
            {
                Console.WriteLine("{0}     {1}     {2}     {3}", item.Nombre, item.Cantidad, item.Precio, item.subtotal);
                total += item.subtotal;
            }
            Console.WriteLine("------------------------------------------------------------");
            Console.WriteLine("Total factura: {0}", total);
            Console.ReadKey();
            MenuPrincipal.ShowMenu();
        }
Example #3
0
        static void Main(string[] args)
        {
            MenuPrincipal menuPrincipal = new MenuPrincipal();

            menuPrincipal.ImprimirMenu();
        }
Example #4
0
 static void Main(string[] args)
 {
     MenuPrincipal.ShowMenu();
 }
Example #5
0
        public void Crear()
        {
            string   nombre, nombreProducto;
            double   precioProducto;
            Producto producto = new Producto();
            Factura  factura  = new Factura();

            Console.Clear();
            Console.ForegroundColor = ConsoleColor.White;
            Console.WriteLine("Para editar un cliente comience escribiendo el nombre");
            Console.ForegroundColor = ConsoleColor.Cyan;
            if (string.IsNullOrEmpty(persistenciaData[0]))
            {
                Console.Write("Nombre de cliente: ");
                nombre = Console.ReadLine();
            }
            else
            {
                Console.WriteLine("Nombre de cliente: {0}", persistenciaData[0]);
                nombre = persistenciaData[0];
            }

            if (!string.IsNullOrEmpty(nombre))
            {
                bool result = manageClient.ConsultaCliente(nombre);
                if (result)
                {
                    persistenciaData[0] = nombre;
                    if (string.IsNullOrEmpty(persistenciaData[1]))
                    {
                        Console.Write("Nombre producto: ");
                        nombreProducto = Console.ReadLine();
                    }
                    else
                    {
                        Console.WriteLine("Nombre producto: {0}", persistenciaData[1]);
                        nombreProducto = persistenciaData[1];
                    }

                    bool searchProduct = manageProduct.ConsultaProducto <bool>(nombreProducto, "nombre");
                    if (searchProduct)
                    {
                        precioProducto      = manageProduct.ConsultaProducto <double>(nombreProducto, "precio");
                        persistenciaData[1] = nombreProducto;
                        producto.Nombre     = nombreProducto;
                        Console.Write("Cantidad: ");
                        int cantProducto = Convert.ToInt32(Console.ReadLine());

                        int stockProduct = manageProduct.ConsultaProducto <int>(nombreProducto, "cantidad");

                        if (cantProducto > stockProduct)
                        {
                            Console.ForegroundColor = ConsoleColor.Yellow;
                            Console.WriteLine("La cantidad introducida es mayor que el stock disponible: ", stockProduct);
                            Console.WriteLine("1 - Introducir otra cantidad \n2 - Buscar otro producto \n3 - Cancelar venta");
                            try
                            {
                                int opcion = Convert.ToInt32(Console.ReadLine());
                                switch (opcion)
                                {
                                case 1:
                                    Crear();
                                    break;

                                case 2:
                                    persistenciaData[1] = "";
                                    Crear();
                                    break;

                                case 3:
                                    MenuPrincipal.ShowMenu();
                                    break;

                                default:
                                    persistenciaData[0]     = "";
                                    persistenciaData[1]     = "";
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("Error en factura.");
                                    Console.ReadKey();
                                    Crear();
                                    break;
                                }
                            }
                            catch (Exception)
                            {
                                persistenciaData[0]     = "";
                                persistenciaData[1]     = "";
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("Error en factura.");
                                Console.ReadKey();
                                Crear();
                            }
                        }
                        else
                        {
                            producto.Cantidad = cantProducto;
                            producto.subtotal = cantProducto * precioProducto;
                            producto.Precio   = precioProducto;
                            productList.Add(producto);
                            Console.WriteLine("Agregar otro producto? 1-Si 2-No");
                            try
                            {
                                int opcion = Convert.ToInt32(Console.ReadLine());
                                switch (opcion)
                                {
                                case 1:
                                    persistenciaData[1] = "";
                                    Crear();
                                    break;

                                case 2:

                                    persistenciaData[0]   = "";
                                    persistenciaData[1]   = "";
                                    factura.NombreCliente = nombre;
                                    factura.Id            = generadorId.GetIdRnd();
                                    factura.ProductList   = productList;
                                    productList.Clear();
                                    facturaLista.Add(factura);
                                    VentaCompletada(factura);
                                    break;

                                default:
                                    persistenciaData[1]     = "";
                                    Console.ForegroundColor = ConsoleColor.Red;
                                    Console.WriteLine("Error en factura.");
                                    Console.ReadKey();
                                    MenuVentas.ShowMenu();
                                    break;
                                }
                            }
                            catch (Exception)
                            {
                                Console.ForegroundColor = ConsoleColor.Red;
                                Console.WriteLine("Error en factura.");
                                Console.ReadKey();
                                MenuVentas.ShowMenu();
                            }
                        }
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("**Producto no encontrado**");
                        Console.ReadKey();
                        Crear();
                    }
                }
                else
                {
                    Console.ForegroundColor = ConsoleColor.Yellow;
                    Console.WriteLine("**Cliente no encontrado**");
                    Console.ReadKey();
                    Crear();
                }
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("**entrada invalida**");
                Console.ReadKey();
                Crear();
            }
        }