public static void ListarIndumentaria(TiendaRopa T) { try { if (T.CantidadIndumentaria() == 0) { throw new ListaVaciaIndumentariaException(); } else { foreach (Indumentaria I in T.Listar()) { ConsolaHelper.MostrarMensaje(I.ToString()); } } } catch (ListaVaciaIndumentariaException e) { ConsolaHelper.MostrarMensaje(e.Message); } }
static void AgregarAlumnos(Facultad a) { ConsolaHelper H = new ConsolaHelper(); Validaciones V = new Validaciones(); try { string nombre; string apellido; DateTime Fechanac = new DateTime(); bool flag = false; do { nombre = H.PedirNombre(); flag = V.ValidarStringNULL(nombre); } while (!flag); bool flag2 = false; do { apellido = H.PedirApellido(); flag2 = V.ValidarStringNULL(apellido); } while (!flag2); bool flag3 = false; do { string fechanac = H.PedirFechaNac(); flag3 = V.ValidarFecha(fechanac, ref Fechanac); } while (!flag3); Alumno A = new Alumno(nombre, apellido, Fechanac); a.AgregarAlumno(A); } catch (Exception e) { H.MostrarMensaje(e.ToString()); } }
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 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); } }
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 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); } }
static void Main(string[] args) { ConsolaHelper H = new ConsolaHelper(); MenuConsola M = new MenuConsola(); Validaciones V = new Validaciones(); VentaRepuestos E = new VentaRepuestos(); M.PantallaInicio(); int _opcion; int salida = 0; do { _opcion = M.PedirMenu(); switch (_opcion) { case 1: { AgregarRepuestos(E); break; } case 2: { QuitarRepuesto(E); break; } case 3: { ModificarPrecio(E); break; } case 4: { AgregarStock(E); break; } case 5: { QuitarStock(E); break; } case 6: { TraerPorCatego(E); break; } case 7: { salida = 7; break; } } } while (salida != 7); H.MostrarMensaje("HASTA LUEGO"); //System.Console.Clear(); Console.ReadKey(); }
static void ModificarEmpleado(Facultad F) { ConsolaHelper H = new ConsolaHelper(); Validaciones V = new Validaciones(); try { if (F.CantidadEmpleados() == 0) { throw new ListaEmpleadoVaciaException(); } else { try { string leg; bool flag = false; do { leg = H.PedirLegajoAModificar(); flag = V.ValidarLegajoEmpleado(leg); } while (!flag); try { if (F.TraerEmpleadoporLegajo(Convert.ToInt32(leg)) == null) { throw new EmpleadoInexistenteException(); } else { Empleado E = F.TraerEmpleadoporLegajo(Convert.ToInt32(leg)); H.MostrarMensaje("Nombre: " + E.Nombre + " Apellido: " + E.Apellido); bool flag2 = false; bool flag3 = false; string pedirN; string pedirA; do { H.MostrarMensaje("Ingrese el nuevo nombre o presione la tecla 'F' para saltear este paso: "); pedirN = H.PedirModificar(); flag2 = V.ValidarStringNULL(pedirN); } while (!flag2); do { H.MostrarMensaje("Ingrese el nuevo apellido o presione la tecla 'F' para saltear este paso: "); pedirA = H.PedirModificar(); flag3 = V.ValidarStringNULL(pedirA); } while (!flag3); F.ModificarEmpleado(pedirN, pedirA, Convert.ToInt32(leg)); } } catch (EmpleadoInexistenteException e) { H.MostrarMensaje(e.Message); } } catch (Exception e) { H.MostrarMensaje(e.Message); } } } catch (ListaEmpleadoVaciaException e) { H.MostrarMensaje(e.Message); } }
static void AgregarEmpleado(Facultad F) { ConsolaHelper H = new ConsolaHelper(); Validaciones V = new Validaciones(); try { string nombre; string apellido; DateTime Fechanac = new DateTime(); string tipoemp; DateTime _fechalaboral = new DateTime(); string apodo = ""; double bruto = 0; bool _fl = false; do { tipoemp = H.PedirTipoEmpleado(); _fl = V.ValidarTipoEmpleado(tipoemp); } while (!_fl); bool flag = false; do { nombre = H.PedirNombre(); flag = V.ValidarStringNULL(nombre); } while (!flag); bool flag2 = false; do { apellido = H.PedirApellido(); flag2 = V.ValidarStringNULL(apellido); } while (!flag2); bool flag3 = false; do { string fechanac = H.PedirFechaNac(); flag3 = V.ValidarFecha(fechanac, ref Fechanac); } while (!flag3); bool flag4 = false; do { string fechala = H.PedirFechaIngresoLaboral(); flag4 = V.ValidarFecha(fechala, ref _fechalaboral); } while (!flag4); bool flag6 = false; do { string brutostr = H.PedirSalarioBruto(); flag6 = V.ValidarSalarioBruto(brutostr, ref bruto); } while (!flag6); if (tipoemp == "B") { bool flag5 = false; do { apodo = H.PedirApodo(); flag5 = V.ValidarStringNULL(apodo); } while (!flag5); } F.AgregarEmpleado(nombre, apellido, _fechalaboral, tipoemp, apodo, bruto, Fechanac); } catch (Exception e) { H.MostrarMensaje(e.Message); } }
static void Main(string[] args) { MenuConsola M = new MenuConsola(); Facultad F = new Facultad(); ConsolaHelper H = new ConsolaHelper(); Validaciones V = new Validaciones(); M.PantallaInicio(); string seguir; do { int _opcion = M.EleccionMenu(); // elijo una opcion del menu try { switch (_opcion) { case 1: { AgregarAlumnos(F); break; } case 2: { F.TraerAlumnos(); break; } case 3: { EliminarAlumno(F); break; } case 4: { AgregarEmpleado(F); break; } case 5: { F.TraerEmpleados(); break; } case 6: { MostrarEmpleadoporLegajo(F); break; } case 7: { MostrarEmpleadoporNombre(F); break; } case 8: { ModificarEmpleado(F); break; } case 9: { EliminarEmpleado(F); break; } } } catch (Exception ex) { H.MostrarMensaje((ex.Message)); } bool ok; do { seguir = H.SeguirMenu(); ok = V.ValidarSalida(seguir); } while (!ok); } while (seguir == "S"); H.MostrarMensaje("HASTA LUEGO"); //System.Console.Clear(); Console.ReadKey(); }
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); } }
static void IngresarOrden(TiendaRopa T) { try { //LISTO LAS INDUMENTARIAS DISPONIBLES if (T.CantidadIndumentaria() == 0) { throw new ListaVaciaIndumentariaException(); } else { ListarIndumentaria(T); string _salida; List <VentaItem> ListaItem = new List <VentaItem>(); Cliente Cliente = null; do { //PIDO LA PRENDA A INGRESAR A LA ORDEN string _strCodigo; int _codigo = 0; bool flag = false; do { _strCodigo = ConsolaHelper.PedirCodigoAIngresarpedido(); flag = Validaciones.ValidarCodigoIndumentaria(_strCodigo, ref _codigo); } while (!flag); Indumentaria I = T.BuscarIndumentaria(_codigo); if (I is null) { throw new Exception("No existe dicha indumentaria"); } else { //PIDO LA CANTIDAD string cantidad; int _cant = 0; bool flag1 = false; do { cantidad = ConsolaHelper.PedirCantidad(); flag1 = Validaciones.ValidarCodigoIndumentaria(cantidad, ref _cant); } while (!flag1); if (_cant > I.Stock) { throw new Exception("No puede ingresar mas del stock que existe."); } VentaItem Item = new VentaItem(I, _cant); T.QuitarStock(I, _cant); // quito el stock al objeto ListaItem.Add(Item); //PEDIR SI QUIERE INGRESAR MAS bool _essalida = false; do { ConsolaHelper.MostrarMensaje("Desea seguir ingresando productos? S / N"); _salida = Console.ReadLine(); _essalida = Validaciones.ValidarSalida(_salida); } while (!_essalida); } } while (_salida == "S"); //PEDIR QUE INGRESE AL CLIENTE //lista de clientes foreach (Cliente C in T.MostrarClientes()) { ConsolaHelper.MostrarMensaje(C.ToString()); } string strcliente; int _cliente = 0; bool flag5 = false; do { ConsolaHelper.MostrarMensaje("Ingrese al cliente: "); strcliente = Console.ReadLine(); flag5 = Validaciones.ValidarCliente(strcliente, ref _cliente); } while (!flag5); Cliente = T.BuscarCliente(_cliente); if (Cliente is null) { throw new Exception("No existe dicho cliente"); } Venta Venta = new Venta(ListaItem, Cliente, Convert.ToInt32(EstadoVenta.Procesada), T.GetProximoCodigoVenta()); T.IngresarOrden(Venta); ConsolaHelper.MostrarMensaje("Venta ingresada con exito!"); } } catch (ListaVaciaIndumentariaException a) { ConsolaHelper.MostrarMensaje(a.Message); } catch (Exception e) { ConsolaHelper.MostrarMensaje(e.Message); } }
static void ModificarIndumentaria(TiendaRopa T) { try { if (T.CantidadIndumentaria() == 0) { throw new ListaVaciaIndumentariaException(); } else { //PIDO CODIGO A MODIFICAR string _strCodigo; int _codigo = 0; bool flag = false; do { _strCodigo = ConsolaHelper.PedirCodigoAModificar(); flag = Validaciones.ValidarCodigoIndumentaria(_strCodigo, ref _codigo); } while (!flag); Indumentaria A = T.BuscarIndumentaria(_codigo); if (A is null) { throw new Exception("No existe dicho codigo de indumentaria"); } else { ConsolaHelper.MostrarMensaje(A.ToString());// muestro la indumentaria que quiere modificar //PIDO QUE DATOS QUIERE MODIFICAR string _talle; bool flag1 = false; do { _talle = ConsolaHelper.PedirTalleAModificar(); flag1 = Validaciones.ValidarTalle(_talle); } while (!flag1); string _strPrecio; double _precio = 0; bool _flag4; do { _strPrecio = ConsolaHelper.PedirPrecioAModificar(); _flag4 = Validaciones.ValidarPrecioAModificar(_strPrecio, ref _precio); } while (!_flag4); T.ModificarIndumentaria(A, _talle, _precio); ConsolaHelper.MostrarMensaje("Prenda modificada con Exito!"); } } } catch (ListaVaciaIndumentariaException e) { ConsolaHelper.MostrarMensaje(e.Message); } catch (Exception r) { ConsolaHelper.MostrarMensaje(r.Message); } }
static void Main(string[] args) { TiendaRopa T = new TiendaRopa(); MenuConsola.PantallaInicio(); int _opcion; int salida = 0; do { _opcion = MenuConsola.PedirMenu(); switch (_opcion) { case 1: { AgregarIndumentaria(T); break; } case 2: { ModificarIndumentaria(T); break; } case 3: { QuitarIndumentaria(T); break; } case 4: { ListarIndumentaria(T); break; } case 5: { IngresarOrden(T); break; } case 6: { DevolverOrden(T); break; } case 7: { ListarOrdenes(T); break; } case 8: { salida = 8; break; } } } while (salida != 8); ConsolaHelper.MostrarMensaje("HASTA LUEGO"); //System.Console.Clear(); Console.ReadKey(); }