Ejemplo n.º 1
0
        static void QuitarStock(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 quitar stock: \n" +
                                     "Lista de repuestos: ");

                    E.ListaRepuestos();
                }


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

                try
                {
                    if (E.BuscarCodigoRepuesto(_codigoR) == null)
                    {
                        throw new RepuestoInexistenteException();
                    }
                    else
                    {
                        //PIDO CUANTAS UNIDADES QUIERO RESTAR
                        string _strStock;
                        int    _stock = 0;
                        bool   _flag2;
                        do
                        {
                            _strStock = H.PedirStockAQuitar();
                            _flag2    = V.ValidarStock(_strStock, ref _stock);
                        } while (!_flag2);

                        try
                        {
                            Repuesto R = new Repuesto();
                            E.QuitarStock(_codigoR, _stock, ref R);

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