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); } }
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); } }
static void AgregarIndumentaria(TiendaRopa T) { try { //PIDO DATOS AL USUARIO string _STRtipoindumentaria; int _tipoindumentaria = 0; bool flag1 = false; do { _STRtipoindumentaria = ConsolaHelper.PedirTipoIndumentaria(); flag1 = Validaciones.ValidarTipoIndumentaria(_STRtipoindumentaria, ref _tipoindumentaria); } while (!flag1); string _STRmodelo; int _modelo = 0; bool flag2 = false; do { _STRmodelo = ConsolaHelper.PedirModelo(); flag2 = Validaciones.ValidarModelo(_STRmodelo, ref _modelo); } while (!flag2); string _talle; bool flag3 = false; do { _talle = ConsolaHelper.PedirTalle(); flag3 = Validaciones.ValidarTalle(_talle); } while (!flag3); string _strPrecio; double _precio = 0; bool _flag4; do { _strPrecio = ConsolaHelper.PedirPrecio(); _flag4 = Validaciones.ValidarPrecio(_strPrecio, ref _precio); } while (!_flag4); TipoIndumentaria Tipo = null; // es una clase abstracta, no se puede instanciar switch (_tipoindumentaria) { case 1: { IndumentariaCasual Casual = new IndumentariaCasual(_tipoindumentaria); Tipo = Casual; break; } case 2: { IndumentariaDeportiva Deportiva = new IndumentariaDeportiva(_tipoindumentaria); Tipo = Deportiva; break; } case 3: { IndumentariaFormal Formal = new IndumentariaFormal(_tipoindumentaria); Tipo = Formal; break; } } Indumentaria Aux = null; // es una clase abstracta, no se puede instanciar if (_modelo == 1) { Aux = new Camisa(T.GetProximoCodigoIndum(), _talle, _precio, Tipo); } else if (_modelo == 2) { Aux = new Pantalon(T.GetProximoCodigoIndum(), _talle, _precio, Tipo); } T.AgregarIndumentaria(Aux); ConsolaHelper.MostrarMensaje("Indumentaria agregada con exito"); ConsolaHelper.MostrarMensaje(Aux.ToString()); } catch (Exception e) { ConsolaHelper.MostrarMensaje(e.Message); } }