コード例 #1
0
        static void ModificarPrecio(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 a eliminar: \n" +
                                     "Lista de repuestos: ");

                    E.ListaRepuestos();
                }


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

                try
                {
                    if (E.BuscarCodigoRepuesto(_codigoR) == null)
                    {
                        throw new RepuestoInexistenteException();
                    }
                    else
                    {
                        //PIDO EL NUEVO PRECIO
                        string _strPrecio;
                        double _precio = 0;
                        bool   _flag2;
                        do
                        {
                            _strPrecio = H.PedirPrecio();
                            _flag2     = V.ValidarPrecio(_strPrecio, ref _precio);
                        } while (!_flag2);

                        Repuesto R = new Repuesto();
                        E.ModificarPrecio(_codigoR, _precio, ref R);

                        H.MostrarMensaje("Precio modificado con Exito! \n");
                        H.MostrarMensaje("El repuesto de codigo {0} ahora tiene un precio de $ {1}", R.Codigo, R.Precio);
                    }
                }
                catch (RepuestoInexistenteException e)
                {
                    H.MostrarMensaje(e.Message);
                }
            }
            catch (ListaVaciaRepuestoException e)
            {
                H.MostrarMensaje(e.Message);
            }
        }
コード例 #2
0
        static void QuitarRepuesto(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 a eliminar: \n" +
                                     "Lista de repuestos: ");

                    E.ListaRepuestos();
                }


                //PIDO CODIGO A ELIMINAR
                string _srtCodigoC;
                int    _codigoC = 0;
                bool   _flag1;
                do
                {
                    _srtCodigoC = H.PedirCodigoEliminar();
                    _flag1      = V.ValidarCodigoRepuesto(_srtCodigoC, ref _codigoC);
                } while (!_flag1);

                try
                {
                    if (E.BuscarCodigoRepuesto(_codigoC) == null)
                    {
                        throw new RepuestoInexistenteException();
                    }

                    try
                    {
                        if (E.BuscarCodigoRepuesto(_codigoC).Stock > 0)
                        {
                            throw new RepuestoConStockException();
                        }

                        E.QuitarRepuesto(_codigoC);

                        H.MostrarMensaje("Repuesto eliminado con Exito!");
                    }
                    catch (RepuestoConStockException x)
                    {
                        H.MostrarMensaje(x.Message);
                    }
                }
                catch (RepuestoInexistenteException e)
                {
                    H.MostrarMensaje(e.Message);
                }
            }
            catch (ListaVaciaRepuestoException e)
            {
                H.MostrarMensaje(e.Message);
            }
        }