Exemple #1
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);
            }
        }
Exemple #2
0
        static void AgregarStock(VentaRepuestos E)
        {
            Validaciones  V = new Validaciones();
            ConsolaHelper H = new ConsolaHelper();

            try
            {
                if (E.CantidadRepuestos() == 0)
                {
                    throw new ListaVaciaRepuestoException();
                }
                else
                {
                    H.MostrarMensaje("\nPor favor seleccione el codigo de repuesto para agregar stock: \n" +
                                     "Lista de repuestos: ");

                    E.ListaRepuestos();
                }


                //PIDO CODIGO A MODIFICAR STOCK
                string _srtCodigoR;
                int    _codigoR = 0;
                bool   _flag1;
                do
                {
                    _srtCodigoR = H.PedirCodigoParaAgregarStock();
                    _flag1      = V.ValidarCodigoRepuesto(_srtCodigoR, ref _codigoR);
                } while (!_flag1);

                try
                {
                    if (E.BuscarCodigoRepuesto(_codigoR) == null)
                    {
                        throw new RepuestoInexistenteException();
                    }
                    else
                    {
                        //PIDO EL NUEVO STOCK
                        string _strStock;
                        int    _stock = 0;
                        bool   _flag2;
                        do
                        {
                            _strStock = H.PedirStock();
                            _flag2    = V.ValidarStock(_strStock, ref _stock);
                        } while (!_flag2);

                        Repuesto R = new Repuesto();
                        E.AgregarStock(_codigoR, _stock, ref R);

                        H.MostrarMensaje("Stock agregado con Exito! \n");
                        H.MostrarMensaje("El repuesto de codigo {0} ahora tiene un stock de {1} unidades", R.Codigo, R.Stock);
                    }
                }
                catch (RepuestoInexistenteException e)
                {
                    H.MostrarMensaje(e.Message);
                }
            }
            catch (ListaVaciaRepuestoException e)
            {
                H.MostrarMensaje(e.Message);
            }
        }