Exemple #1
0
        public static void AgregarRepuesto(VentaRepuesto vr)
        {
            int    codRep   = ConsoleHelper.ValidarInt("Ingrese el codigo del repuesto: ");
            string nombRep  = ConsoleHelper.ValidarStr("Ingrese el nombre del repuesto: ");
            double precRep  = ConsoleHelper.ValidarDouble("Ingrese el precio del repuesto: ");
            int    stockRep = ConsoleHelper.ValidarInt("Ingrese el stock del repuesto: ");

            Console.WriteLine("Categorias disponibles: ");
            CategoriaHelper.MostrarListaCat();
            int codCategoria = ConsoleHelper.ValidarInt("Ingrese el codigo de la categoria a la que pertenece el repuesto: ");

            try
            {
                Repuesto r1 = new Repuesto(codRep, nombRep, precRep, stockRep, codCategoria);
                vr.AgregarRepuesto(r1);
                Console.WriteLine("Repuesto agregado con exito." + Environment.NewLine + r1.ToString());
            }
            catch (RepuestoExistenteException ree)
            {
                Console.WriteLine(ree.Message);
            }
            catch (CategoriaInexistenteException cie)
            {
                Console.WriteLine(cie.Message);
            }
        }
Exemple #2
0
 public Repuesto(int cod, string nom, double pre, int stock, int codcat)
 {
     this._codigo    = cod;
     this._nombre    = nom;
     this._precio    = pre;
     this._stock     = stock;
     this._categoria = CategoriaHelper.GetCategoriaPorCodigo(codcat);
 }
 private static void ListarPorCategoria(VentaRepuesto local)
 {
     try
     {
         Console.WriteLine(CategoriaHelper.ListarCategorias());
         int categoria = ServValidac.PedirInt("ingrese codigo de categoría a listar");
         Console.WriteLine(local.ListaPorCategoria(categoria));
     }
     catch (CategoriaExistenteException ce)
     {
         Console.WriteLine(ce.Message);
     }
     catch (Exception ex)
     {
         Console.WriteLine("Error en uno de los datos ingresados. " + ex.Message + " Intente nuevamente.");
     }
 }