public bool BuscarClienteAlquilerActivo(Cliente Cliente) { Alquilar Alquiler; AccesoDatos datos = new AccesoDatos(); try { datos.setearQuery("SELECT a.Id,a.FechaIngreso,a.DniCliente from alquiler as a where a.Estado=1 and a.DniCliente = " + Cliente.Dni); datos.ejecutarLector(); if (datos.lector.Read()) { Alquiler = new Alquilar(); Alquiler.Id = datos.lector.GetInt32(0); Alquiler.FechaIngreso = datos.lector.GetDateTime(1); Alquiler.Cliente = new Cliente(); Alquiler.Cliente.Dni = datos.lector.GetInt32(2); return(true); } } catch (Exception ex) { throw ex; } finally { datos.cerrarConexion(); } return(false); }
public List <TipoHabitacion> Reporte(Alquilar Alquilar) { List <TipoHabitacion> Lista = new List <TipoHabitacion>(); TipoHabitacion Aux; AccesoDatos datos = new AccesoDatos(); try { datos.setearQuery("select count(t.Id) as cantidad,t.Nombre from Alquiler as a inner join Habitacion as h on h.Numero=a.NumeroHabitacion inner join TipoHabitacion as t on t.Id=h.Tipo where a.Estado=0 and FechaIngreso >= @FechaIngreso and FechaEgreso<=@FechaEgreso or FechaEgreso is null group by t.Nombre"); datos.agregarParametro("@FechaEgreso", Alquilar.FechaEgreso); datos.agregarParametro("@FechaIngreso", Alquilar.FechaIngreso); datos.ejecutarLector(); while (datos.lector.Read()) { Aux = new TipoHabitacion(); Aux.Disponibles = datos.lector.GetInt32(0); Aux.Nombre = datos.lector.GetString(1); Lista.Add(Aux); } return(Lista); } catch (Exception ex) { throw ex; } finally { datos.cerrarConexion(); } }
public Alquilar BuscarAlquiler(int NumeroHabitacion) { Alquilar Alquiler; AccesoDatos datos = new AccesoDatos(); try { datos.setearQuery("SELECT a.Id,a.FechaIngreso,a.DniCliente,c.Nombre from ALQUILER as a inner join cliente as c on c.Dni= a.DniCliente where a.estado=1 and a.NumeroHabitacion = " + NumeroHabitacion); datos.ejecutarLector(); if (datos.lector.Read()) { Alquiler = new Alquilar(); Alquiler.Id = datos.lector.GetInt32(0); Alquiler.FechaIngreso = datos.lector.GetDateTime(1); Alquiler.Cliente = new Cliente(); Alquiler.Cliente.Dni = datos.lector.GetInt32(2); Alquiler.Cliente.Nombre = datos.lector.GetString(3); return(Alquiler); } } catch (Exception ex) { throw ex; } finally { datos.cerrarConexion(); } return(null); }
protected void Page_Load(object sender, EventArgs e) { try { AlquilerNegocio AlquilerNegocio = new AlquilerNegocio(); Alquilar Alquilar = new Alquilar(); Habitacion Habitacion = new Habitacion(); HabitacionNegocio HabitacionNegocio = new HabitacionNegocio(); int NumeroHabitacion = Convert.ToInt32(Request.QueryString["Habitacion"]); Alquilar = AlquilerNegocio.BuscarAlquiler(NumeroHabitacion); DateTime FechaI = Alquilar.FechaIngreso.Date; txtFechaIngreso.Text = FechaI.ToString("dd/MM/yyyy"); txtNombre.Text = Alquilar.Cliente.Nombre; txtDNI.Text = Alquilar.Cliente.Dni.ToString(); DateTime FechaE = System.DateTime.Now; txtFechaEgreso.Text = FechaE.Date.ToString("dd/MM/yyyy"); TimeSpan Dias = System.DateTime.Now - Alquilar.FechaIngreso; int Days = Convert.ToInt32(Dias.TotalDays); TxtDias.Text = Days.ToString(); Habitacion = HabitacionNegocio.BuscarHabitacion(NumeroHabitacion); Decimal Precio = HabitacionNegocio.BuscarPrecio(Habitacion); txtCosto.Text = Math.Truncate(Precio).ToString(); int PrecioFinal = Convert.ToInt32(Precio) * Days; txtFinal.Text = PrecioFinal.ToString(); } catch (Exception) { throw; } }
private void btnAceptarCliente_Click(object sender, EventArgs e) { try { string nombre = this.textNombre.Text.Trim(); string apellido = this.textApellido.Text.Trim(); string dni = this.textDni.Text.Trim(); if (nombre.EsNombreOApellidoValido() && apellido.EsNombreOApellidoValido() && dni.EsDniValido()) { Cliente aux = new Cliente(dni, nombre, apellido); Cliente cliente = this.clientes.AgregarCliente(aux); if (this.rdbAlquiler.Checked) { this.TipoOperacion = "Alquiler"; this.alquilar = new Alquilar(cliente); if (cliente != null) { MessageBox.Show("El cliente fue ingresado con exito"); } else { MessageBox.Show("ERROR AL INGRESAR EL CLIENTE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (this.rdbCompra.Checked) { this.TipoOperacion = "Compra"; this.compra = new Compra(cliente); if (cliente != null) { MessageBox.Show("El cliente fue ingresado con exito"); } else { MessageBox.Show("ERROR AL INGRESAR EL CLIENTE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("DEBE SELECCIONAR TIPO DE OPERACION", "VERIFICAR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Alguno de los datos ingresados es incorrecto"); this.LimpiarDatos(); } } catch (Exception ex) { MessageBox.Show(string.Format("Ocurrio un error en cliente {0}", ex.Message)); } }
public void LimpiarDatos() { this.textApellido.Text = ""; this.textNombre.Text = ""; this.textDni.Text = ""; this.textCantidad.Text = ""; this.textCantidadEnCarrito.Text = ""; this.textTotalAPagar.Text = ""; this.alquilar = null; this.compra = null; }
protected void BtnEntregar_Click(object sender, EventArgs e) { try { Alquilar Alquilar = new Alquilar(); AlquilerNegocio AlquilerNegocio = new AlquilerNegocio(); Habitacion Habitacion = new Habitacion(); HabitacionNegocio HabitacionNegocio = new HabitacionNegocio(); Empleado Empleado = new Empleado(); bool Estado1; bool Estado2; int NumeroHabitacion = Convert.ToInt32(Request.QueryString["Habitacion"]); Empleado = (Empleado)Session["EmpleadoLogueado"]; Alquilar = AlquilerNegocio.BuscarAlquiler(NumeroHabitacion); Alquilar.Observaciones = txtObservaciones.Text; Alquilar.FechaEgreso = System.DateTime.Now; TimeSpan Dias = System.DateTime.Now - Alquilar.FechaIngreso; int Days = Convert.ToInt32(Dias.TotalDays); Habitacion = HabitacionNegocio.BuscarHabitacion(NumeroHabitacion); Decimal Precio = HabitacionNegocio.BuscarPrecio(Habitacion); Alquilar.Precio = Convert.ToInt32(Precio) * Days; Estado1 = AlquilerNegocio.EntregarHabitacion(Alquilar, Empleado.Dni); Estado2 = HabitacionNegocio.VolverDisponibleHabitacion(NumeroHabitacion); if (Estado1 == true && Estado2 == true) { lblMensaje.Text = "Habitacion entregada correctamente"; BtnEntregar.Visible = false; BtnFactura.Visible = false; txtObservaciones.Text = ""; txtNombre.Text = ""; txtFinal.Text = ""; txtCosto.Text = ""; TxtDias.Text = ""; txtFechaEgreso.Text = ""; txtDNI.Text = ""; txtFechaIngreso.Text = ""; } else { lblMensaje.Text = "Error la habitacion no fue entregada correctamente"; } } catch (Exception) { throw; } }
public List <Alquilar> ListarAlquilerFinalizado() { List <Alquilar> Lista = new List <Alquilar>(); Alquilar Aux; AccesoDatos datos = new AccesoDatos(); try { datos.setearQuery("Select a.FechaEgreso,a.FechaIngreso,a.Precio,a.DniEmpleadoAlquila,a.DniEmpleadoEntrega,c.Dni,c.Nombre,h.Numero,h.Piso,t.Nombre,t.Descripcion,t.Precio from habitacion as h inner join TipoHabitacion as t on t.Id=h.Tipo inner join Alquiler as a on a.NumeroHabitacion=h.Numero inner join Cliente as c on c.Dni=a.DniCliente where a.Estado=0"); datos.ejecutarLector(); while (datos.lector.Read()) { Aux = new Alquilar(); Aux.FechaEgreso = datos.lector.GetDateTime(0); Aux.FechaIngreso = datos.lector.GetDateTime(1); Aux.Precio = datos.lector.GetDecimal(2); Aux.Empleado = new Empleado(); Aux.Empleado.Dni = datos.lector.GetInt32(3); Aux.Empleado2 = new Empleado(); Aux.Empleado2.Dni = datos.lector.GetInt32(4); Aux.Cliente = new Cliente(); Aux.Cliente.Dni = datos.lector.GetInt32(5); Aux.Cliente.Nombre = datos.lector.GetString(6); Aux.Habitacion = new Habitacion(); Aux.Habitacion.Numero = datos.lector.GetInt32(7); Aux.Habitacion.Piso = datos.lector.GetInt32(8); Aux.Tipo = new TipoHabitacion(); Aux.Tipo.Nombre = datos.lector.GetString(9); Aux.Tipo.Descripcion = datos.lector.GetString(10); Aux.Tipo.Precio = datos.lector.GetDecimal(11); Lista.Add(Aux); } return(Lista); } catch (Exception ex) { throw ex; } finally { datos.cerrarConexion(); datos = null; } }
private void btnAceptarCliente_Click(object sender, EventArgs e) { try { string nombre = this.textNombre.Text.Trim(); string apellido = this.textApellido.Text.Trim(); string dni = this.textDni.Text.Trim(); Cliente cliente = new Cliente(dni, nombre, apellido); if (this.rdbAlquiler.Checked) { this.TipoOperacion = "Alquiler"; this.alquilar = new Alquilar(cliente); if (cliente.IngresarCliente(cliente)) { MessageBox.Show("El cliente fue ingresado con exito"); } else { MessageBox.Show("ERROR AL INGRESAR EL CLIENTE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else if (this.rdbCompra.Checked) { this.TipoOperacion = "Compra"; this.compra = new Compra(cliente); if (cliente.IngresarCliente(cliente)) { MessageBox.Show("El cliente fue ingresado con exito"); } else { MessageBox.Show("ERROR AL INGRESAR EL CLIENTE", "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("DEBE SELECCIONAR TIPO DE OPERACION", "VERIFICAR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } catch (Exception ex) { MessageBox.Show(string.Format("Ocurrio un error ", ex.Message)); } }
protected void btnBuscar_Click(object sender, EventArgs e) { try { if (txtFechaInicio.Text == "" || txtFechaFin.Text == "") { lblMensaje.Text = "Error tiene que ingresar los parametros de busqueda."; } Alquilar Alquilar = new Alquilar(); AlquilerNegocio AlquilerNegocio = new AlquilerNegocio(); Alquilar.FechaIngreso = DateTime.Parse(txtFechaInicio.Text); Alquilar.FechaEgreso = DateTime.Parse(txtFechaFin.Text); Lista = AlquilerNegocio.Reporte(Alquilar); txtFechaInicio.Text = ""; txtFechaFin.Text = ""; } catch (Exception) { lblMensaje.Text = "Error tiene que ingresar los parametros de busqueda."; } }
public void TestMethod1() { Cliente cliente = new Cliente(0, "10222555", "Ramon", "Valdez"); Alquilar alquilar = new Alquilar(cliente); Producto producto = ProductosDAO.ListarProductosPorId(1); alquilar.AgregarProducto(producto, 5); bool retorno = false; if (alquilar.ListaDeProductos.Count > 0) { foreach (Producto p in alquilar.ListaDeProductos) { if (p == producto) { retorno = true; } } } Assert.IsTrue(retorno); }
public List <Alquilar> ListarEntregaUsuario(int DNI) { List <Alquilar> Lista = new List <Alquilar>(); Alquilar Aux; AccesoDatos datos = new AccesoDatos(); try { datos.setearQuery("select alquiler.Precio,FechaIngreso,FechaEgreso,DniCliente,cliente.Nombre,NumeroHabitacion,TipoHabitacion.Nombre from alquiler inner join Cliente on cliente.Dni = alquiler.DniCliente inner join Habitacion on habitacion.Numero = alquiler.NumeroHabitacion inner join TipoHabitacion on TipoHabitacion.Id = Habitacion.Tipo where alquiler.DniEmpleadoEntrega= @DNI and alquiler.estado = 0"); datos.agregarParametro("@DNI", DNI); datos.ejecutarLector(); while (datos.lector.Read()) { Aux = new Alquilar(); Aux.Precio = datos.lector.GetDecimal(0); Aux.FechaIngreso = datos.lector.GetDateTime(1); Aux.FechaEgreso = datos.lector.GetDateTime(2); Aux.Cliente = new Cliente(); Aux.Cliente.Dni = datos.lector.GetInt32(3); Aux.Cliente.Nombre = datos.lector.GetString(4); Aux.Habitacion = new Habitacion(); Aux.Habitacion.Numero = datos.lector.GetInt32(5); Aux.Tipo = new TipoHabitacion(); Aux.Tipo.Nombre = datos.lector.GetString(6); Lista.Add(Aux); } return(Lista); } catch (Exception ex) { throw ex; } finally { datos.cerrarConexion(); datos = null; } }
public bool EntregarHabitacion(Alquilar Alquilar, int DNI) { AccesoDatos datos = new AccesoDatos(); bool Estado = false; try { datos.setearQuery("update Alquiler set FechaEgreso = @FechaE where Id=@Id;update Alquiler set Observaciones=@Obs where Id=@Id; update Alquiler set Precio=@Precio where Id=@Id; update Alquiler set Estado=0 where Id=@Id;update Alquiler set DniEmpleadoEntrega=@Dni where Id=@Id;"); datos.agregarParametro("@Id", Alquilar.Id); datos.agregarParametro("@FechaE", Alquilar.FechaEgreso); datos.agregarParametro("@Obs", Alquilar.Observaciones); datos.agregarParametro("@Precio", Alquilar.Precio); datos.agregarParametro("@Dni", DNI); datos.ejecutarAccion(); Estado = true; } catch (Exception ex) { throw ex; } return(Estado); }
static void Main(string[] args) { Producto p1 = new Producto("AS01", "AGUAS", 20001, 50); Producto p2 = new Producto("AS02", "USHUAIA", 22300, 50); Producto p3 = new Producto("AS03", "BACOPE", 16700, 50); Producto p4 = new Producto("AS04", "TRIA", 18350, 50); Producto p5 = new Producto("AS05", "TERMOPLAST", 15600, 50); Producto p6 = new Producto("AS06", "AQUAWORD", 10350, 50); Productos productos = new Productos(); Clientes clientes = new Clientes(); productos += p1; productos += p2; productos += p3; productos += p4; productos += p5; productos += p6; Console.WriteLine("-------------LISTA DE PRODUCTOS--------------------"); Console.WriteLine(productos.Mostrar()); Console.WriteLine("---------------------------------------------------"); try { Cliente cliente = new Cliente("32556448", "chespirito", "barbosa"); cliente = clientes.AgregarCliente(cliente); Alquilar clienteAlquiler = new Alquilar(cliente); Console.WriteLine("---------------------------------"); clienteAlquiler.AgregarProducto(p1, 1000);//LANZA LA EXCEPCIO POR QUE NO HAY ESA CANTIDAD DISPONIBLE clienteAlquiler.AgregarProducto(p2, 1); clienteAlquiler.AgregarProducto(p3, 50); clienteAlquiler.ConcretarOperacion(); Console.WriteLine("------------factura------------"); Console.WriteLine(clienteAlquiler.Mostrar()); Console.WriteLine("---------------------------------"); } catch (ProductoDuplicadoExcepcion ex) { Console.WriteLine(ex.Message); } catch (CantidadNoDisponibleExcepcion ex) { Console.WriteLine(ex.Message); } Console.WriteLine("---------------------------------"); try { Cliente cliente2 = new Cliente("32556448", "DIEGO", "MARADONA"); cliente2 = clientes.AgregarCliente(cliente2); Alquilar clienteAlquiler2 = new Alquilar(cliente2); Console.WriteLine("---------------------------------"); clienteAlquiler2.AgregarProducto(p1, 10); clienteAlquiler2.AgregarProducto(p2, 1); clienteAlquiler2.AgregarProducto(p3, 5); clienteAlquiler2.ConcretarOperacion(); Console.WriteLine("------------factura------------"); Console.WriteLine(clienteAlquiler2.Mostrar()); Console.WriteLine("---------------------------------"); } catch (ProductoDuplicadoExcepcion ex) { Console.WriteLine(ex.Message); } catch (CantidadNoDisponibleExcepcion ex) { Console.WriteLine(ex.Message); } try { Cliente cliente3 = new Cliente("32557448", "SUSANA", "GIMENEZ"); cliente3 = clientes.AgregarCliente(cliente3); Compra compra = new Compra(cliente3); compra.AgregarProducto(p3, 1000);//LANZA EXCEPCION POR QUE NO HAY 1000 EN STOCK compra.AgregarProducto(p4, 1); compra.AgregarProducto(p5, 1); compra.ConcretarOperacion(); Console.WriteLine("-----------factura------------"); Console.WriteLine(compra.Mostrar()); Console.WriteLine("---------------------------------"); } catch (ProductoDuplicadoExcepcion ex) { Console.WriteLine(ex.Message); } catch (CantidadNoDisponibleExcepcion ex) { Console.WriteLine(ex.Message); } Console.WriteLine("---------------------------------"); try { Cliente cliente3 = new Cliente("32557448", "Juan", "Perez"); cliente3 = clientes.AgregarCliente(cliente3); Compra compra2 = new Compra(cliente3); compra2.AgregarProducto(p3, 10); compra2.AgregarProducto(p4, 1); compra2.AgregarProducto(p5, 1); compra2.ConcretarOperacion(); Console.WriteLine("-----------factura------------"); Console.WriteLine(compra2.Mostrar()); Console.WriteLine("---------------------------------"); } catch (ProductoDuplicadoExcepcion ex) { Console.WriteLine(ex.Message); } catch (CantidadNoDisponibleExcepcion ex) { Console.WriteLine(ex.Message); } Console.WriteLine("-------------LISTA DE PRODUCTOS--------------------"); Console.WriteLine(productos.Mostrar()); Console.WriteLine("---------------------------------"); Console.WriteLine("---------MOVIMIENTOS----------------"); List <string> movimientos = MovimientosDAO.RecuperarDatos(); if (movimientos.Count > 0) { foreach (string mov in movimientos) { Console.WriteLine(mov); } } Console.ReadKey(); }
static void Main(string[] args) { Producto p1 = new Producto("AS01", "AGUAS", 20001, 50); Producto p2 = new Producto("AS02", "USHUAIA", 22300, 50); Producto p3 = new Producto("AS03", "BACOPE", 16700, 50); Producto p4 = new Producto("AS04", "TRIA", 18350, 50); Producto p5 = new Producto("AS05", "TERMOPLAST", 15600, 50); Producto p6 = new Producto("AS06", "AQUAWORD", 10350, 50); Productos productos = new Productos(); try { productos += p1; productos += p2; productos += p3; productos += p4; productos += p5; productos += p6; Cliente cliente = new Cliente("32556448", "chespirito", "barbosa"); Alquilar clienteAlquiler = new Alquilar(cliente); clienteAlquiler.AgregarProducto(p1, 1); clienteAlquiler.AgregarProducto(p2, 1); clienteAlquiler.AgregarProducto(p3, 50); clienteAlquiler.ConcretarOperacion(); Console.WriteLine("------------factura------------"); Console.WriteLine(clienteAlquiler.Mostrar()); Console.WriteLine("---------------------------------"); } catch (ProductoDuplicadoExcepcion ex) { Console.WriteLine(ex.Message); } catch (CantidadNoDisponibleExcepcion ex) { Console.WriteLine(ex.Message); } //Productos productos = new Productos();//cuando se crea productos recupera la lista de productos de la BD try { Cliente cliente2 = new Cliente("32557448", "Juan", "Perez"); Compra compra = new Compra(cliente2); compra.AgregarProducto(p3, 1); compra.AgregarProducto(p4, 1); compra.AgregarProducto(p5, 1); compra.ConcretarOperacion(); Console.WriteLine("-----------factura------------"); Console.WriteLine(compra.Mostrar()); Console.WriteLine("---------------------------------"); Console.WriteLine("-------------LISTA DE PRODUCTOS--------------------"); Console.WriteLine(productos.Mostrar()); } catch (ProductoDuplicadoExcepcion ex) { Console.WriteLine(ex.Message); } catch (CantidadNoDisponibleExcepcion ex) { Console.WriteLine(ex.Message); } /* * * * Console.WriteLine("---------MOVIMIENTOS----------------"); * List<string> movimientos = clienteAlquiler.Movimientos(); * foreach(string mov in movimientos) * { * Console.WriteLine(mov); * }*/ Console.ReadKey(); }