Exemplo n.º 1
0
        static void TraerPorCatego(VentaRepuestos E)
        {
            Validaciones  V = new Validaciones();
            ConsolaHelper H = new ConsolaHelper();

            try
            {
                string _srtCodigoC;
                int    _codigoC = 0;
                bool   _flag1;
                do
                {
                    _srtCodigoC = H.PedirCodigo("categoria");
                    _flag1      = V.ValidarCodigoRepuesto(_srtCodigoC, ref _codigoC);
                } while (!_flag1);


                if (E.TraerPorCategoria(_codigoC).Count == 0)
                {
                    throw new ListaVaciaCategoriaException();
                }
                else
                {
                    foreach (Repuesto Rf in E.TraerPorCategoria(_codigoC))
                    {
                        H.MostrarMensaje(Rf.ToString());
                    }
                }
            }
            catch (ListaVaciaCategoriaException e)
            {
                H.MostrarMensaje(e.Message);
            }
        }
Exemplo n.º 2
0
        static void AgregarRepuestos(VentaRepuestos E)
        {
            Validaciones  V = new Validaciones();
            ConsolaHelper H = new ConsolaHelper();
            Repuesto      R = new Repuesto();

            try
            {
                // PIDO DATOS AL USUARIO
                string _srtCodigoR;
                int    _codigoR = 0;
                bool   _flag1;
                do
                {
                    _srtCodigoR = H.PedirCodigo("repuesto");
                    _flag1      = V.ValidarCodigoRepuesto(_srtCodigoR, ref _codigoR);
                } while (!_flag1);

                string _nombreR;
                bool   _flag2;
                do
                {
                    _nombreR = H.PedirNombre("repuesto");
                    _flag2   = V.ValidarStringNULL(_nombreR);
                } while (!_flag2);

                string _strPrecio;
                double _precio = 0;
                bool   _flag3;
                do
                {
                    _strPrecio = H.PedirPrecio();
                    _flag3     = V.ValidarPrecio(_strPrecio, ref _precio);
                } while (!_flag3);

                string _strStock;
                int    _stock = 0;
                bool   _flag4;
                do
                {
                    _strStock = H.PedirStock();
                    _flag4    = V.ValidarStock(_strStock, ref _stock);
                } while (!_flag4);

                string _srtCodigoC;
                int    _codigoC = 0;
                bool   _flag5;
                do
                {
                    _srtCodigoC = H.PedirCodigo("categoria");
                    _flag5      = V.ValidarCodigoRepuesto(_srtCodigoC, ref _codigoC);
                } while (!_flag5);

                string _nombreC;
                bool   _flag6;
                do
                {
                    _nombreC = H.PedirNombre("categoria");
                    _flag6   = V.ValidarStringNULL(_nombreC);
                } while (!_flag6);

                Categoria C = new Categoria(_codigoC, _nombreC);
                R = new Repuesto(_codigoR, _nombreR, _precio, _stock, C);
                E.AgregarRepuesto(R);
                H.MostrarMensaje("Repuesto agregado con Exito!");
            }
            catch (Exception e)
            {
                H.MostrarMensaje(e.Message);
            }
        }