public bool Agregar(Entidad e) { //Metodo para escribir en el archivo log.xml que se ha ingresado en el metodo Log.EscribirInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, RecursoDAOM08.MensajeInicioMetodoLogger, System.Reflection.MethodBase.GetCurrentMethod().Name); //Se castea de tipo Entidad a tipo Automovil Automovil automovil = (Automovil)e; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.matricula, SqlDbType.VarChar, automovil.matricula, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.modelo, SqlDbType.VarChar, automovil.modelo, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.fabricante, SqlDbType.VarChar, automovil.fabricante, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.anio, SqlDbType.Int, automovil.anio.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.kilometraje, SqlDbType.VarChar, automovil.kilometraje.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.cantpasajero, SqlDbType.Decimal, automovil.cantpasajeros.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.tipovehiculo, SqlDbType.Int, automovil.tipovehiculo, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.preciocompra, SqlDbType.Decimal, automovil.preciocompra.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.precioalquiler, SqlDbType.Decimal, automovil.precioalquiler.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.penalidaddiaria, SqlDbType.Decimal, automovil.penalidaddiaria.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.fecharegistro, SqlDbType.Date, automovil.fecharegistro.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.color, SqlDbType.VarChar, automovil.color, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.disponibilidad, SqlDbType.Int, automovil.disponibilidad.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.transmision, SqlDbType.VarChar, automovil.transmision, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.fk_ciudad, SqlDbType.Int, automovil.ciudad.ToString(), false)); EjecutarStoredProcedure(RecursoDAOM08.procedimientoAgregarAutomovil, listaParametro); return(true); } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Argumento con _idHotel invalido", ex); } catch (FormatException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Datos con un formato invalido", ex); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error al realizar operacion ", ex); } }
/// <summary> /// Método para consultar todos los reclamos en la BD /// </summary> /// <returns> Lista de reclamos</returns> Dictionary <int, Entidad> IDAO.ConsultarTodos() { List <Reclamo> listareclamos = new List <Reclamo>(); Dictionary <int, Entidad> listaReclamos = new Dictionary <int, Entidad>(); SqlConnection conexion = Connection.getInstance(_connexionString); List <Reclamo> reclamos = FabricaEntidad.InstanciarListaReclamo(); List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); DataTable tablaDeDatos; int rec_id, rec_estatus, rec_fk_usuario; String rec_titulo, rec_descripcion, rec_fecha; int placeholder = 0; try { parametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_id, SqlDbType.Int, placeholder.ToString(), false)); tablaDeDatos = EjecutarStoredProcedureTuplas(M16Reclamos.procedimientoConsultarReclamos, parametro); foreach (DataRow filaReclamo in tablaDeDatos.Rows) { rec_id = int.Parse(filaReclamo[M16Reclamos.recId].ToString()); rec_estatus = int.Parse(filaReclamo[M16Reclamos.recEstatus].ToString()); rec_fk_usuario = int.Parse(filaReclamo[M16Reclamos.recFkUsuario].ToString()); rec_titulo = filaReclamo[M16Reclamos.rectitulo].ToString(); rec_descripcion = filaReclamo[M16Reclamos.recDescripcion].ToString(); String[] divisor = filaReclamo[M16Reclamos.recFecha].ToString().Split(' '); rec_fecha = divisor[0]; Reclamo reclamo = (Reclamo)FabricaEntidad.InstanciarReclamo(rec_id, rec_titulo, rec_descripcion, rec_fecha, rec_estatus, rec_fk_usuario); listaReclamos.Add(rec_id, reclamo); } return(listaReclamos); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (NullReferenceException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } }
/// <summary> /// Método para consultar un reclamo en la BD /// </summary> /// <param name="id">id del reclamo</param> /// <returns> reclamo </returns> Entidad IDAO.Consultar(int id) { List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); int rec_id, rec_estatus, rec_fk_usuario; String rec_titulo, rec_descripcion, rec_fecha; Entidad reclamoE = FabricaEntidad.InstanciarReclamo(); Reclamo reclamo = (Reclamo)reclamoE; try { parametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_id, SqlDbType.Int, id.ToString(), false)); DataTable filaReclamo = EjecutarStoredProcedureTuplas(M16Reclamos.procedimientoConsultarReclamoPorId, parametro); DataRow Fila = filaReclamo.Rows[0]; rec_id = int.Parse(Fila[M16Reclamos.recId].ToString()); rec_estatus = int.Parse(Fila[M16Reclamos.recEstatus].ToString()); rec_fk_usuario = int.Parse(Fila[M16Reclamos.recFkUsuario].ToString()); rec_titulo = Fila[M16Reclamos.rectitulo].ToString(); rec_descripcion = Fila[M16Reclamos.recDescripcion].ToString(); String[] divisor = Fila[M16Reclamos.recFecha].ToString().Split(' '); rec_fecha = divisor[0]; reclamo = (Reclamo)FabricaEntidad.InstanciarReclamo(rec_id, rec_titulo, rec_descripcion, rec_fecha, rec_estatus, rec_fk_usuario); return(reclamo); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (NullReferenceException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } }
/// <summary> /// Metodo para hacer el insert de un reclamo en la BD /// </summary> /// <param name="e">Entidad que posteriormente será casteada a Reclamo</param> /// <returns>Integer con el codigo de respuesta</returns> int IDAO.Agregar(Entidad e) { Reclamo reclamo = (Reclamo)e; reclamo._estadoReclamo = 1; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_titulo, SqlDbType.VarChar, reclamo._tituloReclamo, false)); listaParametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_descripcion, SqlDbType.VarChar, reclamo._detalleReclamo, false)); listaParametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_fecha, SqlDbType.VarChar, reclamo._fechaReclamo, false)); listaParametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_estatus, SqlDbType.Int, reclamo._estadoReclamo.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_fk_usuario, SqlDbType.Int, reclamo._usuario.ToString(), false)); EjecutarStoredProcedure(M16Reclamos.procedimientoAgregarReclamo, listaParametro); return(1); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (NullReferenceException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (LogException ex) { throw new ReservaExceptionM16(ex.Message, ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } }
/*int IDAO.Agregar(Entidad e) * { * Usuario usuario = (Usuario)e; * * SqlConnection conexion = Connection.getInstance(_connexionString); * try * { * conexion.Open(); * * usuario.fechaCreacionf = DateTime.Now; * * String sql = "INSERT INTO Usuario VALUES ('" + usuario.nombre + "','" + usuario.apellido + "','" + usuario.correo + "','" + usuario.contrasena + "','"+ usuario.rol +"','" + usuario.fechaCreacionf.ToString("yyyy-MM-dd") + "','" + usuario.activo + "')"; * * Debug.WriteLine(sql); * SqlCommand cmd = new SqlCommand(sql, conexion); * cmd.ExecuteNonQuery(); * cmd.Dispose(); * * conexion.Close(); * * return 1; * } * catch (SqlException ex) * { * Debug.WriteLine("Ocurrio un SqlException"); * Debug.WriteLine(ex.ToString()); * conexion.Close(); * return 2; * } * catch (NullReferenceException ex) * { * Debug.WriteLine("Ocurrio una NullReferenceException"); * Debug.WriteLine(ex.ToString()); * conexion.Close(); * return 3; * } * catch (ArgumentNullException ex) * { * Debug.WriteLine("Ocurrio una ArgumentNullException"); * Debug.WriteLine(ex.ToString()); * conexion.Close(); * return 4; * } * catch (Exception ex) * { * Debug.WriteLine("Ocurrio una Exception"); * Debug.WriteLine(ex.ToString()); * conexion.Close(); * return 5; * } * }*/ /// <summary> /// Ejemplo para los Store Procedure /// </summary> /// <param name="e"></param> /// <returns></returns> int IDAO.Agregar(Entidad e) { List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); Usuario usuario = (Usuario)e; try { usuario.fechaCreacionf = DateTime.Now; listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_nombre, SqlDbType.VarChar, usuario.nombre, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_apellido, SqlDbType.VarChar, usuario.apellido, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_correo, SqlDbType.VarChar, usuario.correo, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_contraseña, SqlDbType.VarChar, usuario.contrasena, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_fk_rol, SqlDbType.Int, usuario.rol.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_fechaCreacion, SqlDbType.Date, usuario.fechaCreacionf.ToString("yyyy-MM-dd"), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_activo, SqlDbType.VarChar, usuario.activo, false)); //listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_id, SqlDbType.Int, usuario.id.ToString(), false)); EjecutarStoredProcedure(RecursoDAOM12.ProcedimientoAgregarUsuario, listaParametro); return(1); } catch (SqlException ex) { Debug.WriteLine("Ocurrio un SqlException"); Debug.WriteLine(ex.ToString()); return(2); } catch (NullReferenceException ex) { Debug.WriteLine("Ocurrio una NullReferenceException"); Debug.WriteLine(ex.ToString()); return(3); } catch (ArgumentNullException ex) { Debug.WriteLine("Ocurrio una ArgumentNullException"); Debug.WriteLine(ex.ToString()); return(4); } catch (Exception ex) { Debug.WriteLine("Ocurrio una Exception"); Debug.WriteLine(ex.ToString()); return(5); } }
// public String eliminarUsuario(int id) /*string IDAOUsuario.eliminarUsuario(int id) * { * SqlConnection conexion = Connection.getInstance(_connexionString); * try * { * conexion.Open(); * String sql = "DELETE FROM Usuario WHERE usu_id = " + id; * SqlCommand cmd = new SqlCommand(sql, conexion); * cmd.ExecuteNonQuery(); * cmd.Dispose(); * conexion.Close(); * return "1"; * } * catch (SqlException ex) * { * conexion.Close(); * return ex.Message; * } * }*/ /// <summary> /// Metodo implementado de IDAO para eliminar hoteles de la BD /// </summary> /// <param name="id">Id del hotel a eliminar</param> /// <returns>Retorna un string</returns> string IDAOUsuario.eliminarUsuario(int id) { List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_id, SqlDbType.Int, id.ToString(), false)); EjecutarStoredProcedure(RecursoDAOM12.ProcedimientoBorrarUsuario, listaParametro); return("1"); } catch (SqlException ex) { return(ex.Message); } }
/*Entidad IDAO.Consultar(int id) * { * SqlConnection conexion = Connection.getInstance(_connexionString); * Usuario usuario = new Usuario(); * try * { * conexion.Open(); * String sql = "SELECT usu_nombre as nombre, usu_apellido as apellido, usu_correo as email, usu_contraseña as Contraseña, rol_nombre as rol, rol_id as id_rol, usu_activo as status FROM Usuario, Rol WHERE rol_id=usu_fk_rol and usu_id=" + id; * * SqlCommand cmd = new SqlCommand(sql, conexion); * using (SqlDataReader reader = cmd.ExecuteReader()) * { * Rol rol; * int idRol; * String nombreRol; * * int idUsuario = id; * * while (reader.Read()) * { * //SE AGREGA CREA UN OBJECTO VEHICLE SE PASAN LOS ATRIBUTO ASI reader["<etiqueta de la columna en la tabla Automovil>"] * //Y SE AGREGA a listavehiculos * //public Hotel(int id, String nombre, String direccion, String email, String paginaWeb, int clasificacion, int capacidad, Ciudad ciudad) * idRol = Int32.Parse(reader["id_rol"].ToString()); * nombreRol = reader["rol"].ToString(); * rol = new Rol(idRol, nombreRol); * * * usuario = new Usuario( * idUsuario, * reader["nombre"].ToString(), * reader["apellido"].ToString(), * reader["email"].ToString(), * reader["Contraseña"].ToString(), * rol, * reader["status"].ToString() * ); * } * } * * cmd.Dispose(); * conexion.Close(); * return usuario; * } * catch (SqlException ex) * { * Debug.WriteLine(ex.ToString()); * conexion.Close(); * return null; * } * }*/ /// <summary> /// Metodo implementado de IDAO para consultar un usuario de la BD /// </summary> /// <param name="id">Id del usuario a buscar</param> /// <returns>Retorna el usuario</returns> Entidad IDAO.Consultar(int id) { DataTable tablaDeDatos; List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); Usuario usuario; Rol rol; int idRol; String nombreRol; int idUsuario; try { parametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_id, SqlDbType.Int, id.ToString(), false)); tablaDeDatos = EjecutarStoredProcedureTuplas(RecursoDAOM12.ProcedimientoVisualizarUnUsuario, parametro); foreach (DataRow row in tablaDeDatos.Rows) { idRol = Int32.Parse(row[RecursoDAOM12.id_rol].ToString()); nombreRol = row[RecursoDAOM12.nombre_rol].ToString(); rol = new Rol(idRol, nombreRol); idUsuario = Int32.Parse(row["usu_id"].ToString()); usuario = new Usuario( idUsuario, row["usu_nombre"].ToString(), row["usu_apellido"].ToString(), row["usu_correo"].ToString(), row["usu_contraseña"].ToString(), rol, Convert.ToDateTime(row["usu_fechaCreacion"]), row["usu_activo"].ToString() ); return(usuario); } return(null); } catch (SqlException ex) { Debug.WriteLine(ex.ToString()); return(null); } }
/// </summary> string IDAOAvion.eliminarAvion(int id) { { List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_id, SqlDbType.Int, id.ToString(), false)); EjecutarStoredProcedure(RecursoDAOM02.ProcedimientoEliminarAvion, listaParametro); return("1"); } catch (SqlException ex) { return(ex.Message); } } }
/// <summary> /// Método que agrega una comida a un vuelo /// </summary> /// <returns>Retorna un booleano true si insertó correctamente, sino false</returns> public bool agregarComidaVuelo(Entidad entidad) { ComidaVuelo comida = (ComidaVuelo)entidad; List <Parametro> lista = FabricaDAO.asignarListaDeParametro(); try { lista.Add(FabricaDAO.asignarParametro("@com_vue_id", SqlDbType.Int, comida._id.ToString(), false)); lista.Add(FabricaDAO.asignarParametro(RecursoM06.com_vue_fk_comida, SqlDbType.Int, comida._comida, false)); lista.Add(FabricaDAO.asignarParametro("@com_vue_cantidad", SqlDbType.Int, comida._cantidad.ToString(), false)); EjecutarStoredProcedure(RecursoM06.procedimientoAgregarComidaVuelo, lista); } catch (Exception e) { return(false); } return(true); }
/// <summary> /// Metodo para hacer el insert de un reclamo de equipaje en la BD /// </summary> /// <param name="e">Entidad que posteriormente será casteada a Reclamo</param> /// <returns>Codigo numerico segun respuesta de Insert</returns> int IDAO.Agregar(Entidad e) { ReclamoEquipaje reclamo = (ReclamoEquipaje)e; //reclamo._estadoReclamo = "Abierto"; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(M07ReclamoEquipaje.rec_fk_pasajero, SqlDbType.VarChar, reclamo._pasajero.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(M07ReclamoEquipaje.rec_descripcion, SqlDbType.VarChar, reclamo._descripcionReclamo, false)); listaParametro.Add(FabricaDAO.asignarParametro(M07ReclamoEquipaje.rec_fecha, SqlDbType.VarChar, reclamo._fechaReclamo, false)); listaParametro.Add(FabricaDAO.asignarParametro(M07ReclamoEquipaje.rec_status, SqlDbType.Int, reclamo._estadoReclamo, false)); listaParametro.Add(FabricaDAO.asignarParametro(M07ReclamoEquipaje.rec_fk_equipaje, SqlDbType.Int, reclamo._pasajero.ToString(), false)); EjecutarStoredProcedure(M07ReclamoEquipaje.procedimientoAgregarReclamo, listaParametro); return(1); } catch (SqlException ex) { Debug.WriteLine("Ocurrio un SqlException"); Debug.WriteLine(ex.ToString()); return(2); } catch (NullReferenceException ex) { Debug.WriteLine("Ocurrio una NullReferenceException"); Debug.WriteLine(ex.ToString()); return(3); } catch (ArgumentNullException ex) { Debug.WriteLine("Ocurrio una ArgumentNullException"); Debug.WriteLine(ex.ToString()); return(4); } catch (Exception ex) { Debug.WriteLine("Ocurrio una Exception"); Debug.WriteLine(ex.ToString()); return(5); } }
/// <summary> /// Método que crea una comida /// </summary> /// <returns>Retorna un booleano true si insertó correctamente, sino false</returns> public bool crear(Entidad entidad) { Comida comida = (Comida)entidad; List <Parametro> lista = FabricaDAO.asignarListaDeParametro(); try { lista.Add(FabricaDAO.asignarParametro(RecursoM06.com_nombre, SqlDbType.VarChar, comida._nombre, false)); lista.Add(FabricaDAO.asignarParametro(RecursoM06.com_tipo, SqlDbType.VarChar, comida._tipo, false)); lista.Add(FabricaDAO.asignarParametro(RecursoM06.com_estatus, SqlDbType.Int, comida._estatus.ToString(), false)); lista.Add(FabricaDAO.asignarParametro(RecursoM06.com_descripcion, SqlDbType.VarChar, comida._descripcion, false)); EjecutarStoredProcedure(RecursoM06.procedimientoAgregarComida, lista); } catch (Exception e) { return(false); } return(true); }
/// <summary> /// Método que cambia el estado de la comida entre disponible y no disponible /// </summary> /// <returns>Retorna un booleano true si fue exitoso, sino false</returns> public bool cambiarEstadoComida(Entidad entidad) { Comida comida = (Comida)entidad; bool resultado = false; List <Parametro> lista = FabricaDAO.asignarListaDeParametro(); try { lista.Add(FabricaDAO.asignarParametro(RecursoM06.com_id, SqlDbType.Int, comida._id.ToString(), false)); lista.Add(FabricaDAO.asignarParametro(RecursoM06.com_estatus, SqlDbType.Int, comida._estatus.ToString(), false)); EjecutarStoredProcedure(RecursoM06.procedimientoCambiarEstatusComida, lista); return(true); } catch (Exception ex) { throw ex; } return(false); }
/*public String statusUsuario(Entidad e, string status) * { * Usuario usuario = (Usuario)e; * SqlConnection conexion = Connection.getInstance(_connexionString); * try * { * conexion.Open(); * String sql = "UPDATE Usuario SET usu_activo = '" + status + "' WHERE usu_id = " + usuario._id; * SqlCommand cmd = new SqlCommand(sql, conexion); * cmd.ExecuteNonQuery(); * cmd.Dispose(); * conexion.Close(); * usuario.nombre = "1"; * Entidad resultado = usuario; * return "1"; * } * catch (SqlException ex) * { * conexion.Close(); * usuario.nombre = ex.Message; * Entidad resultado = usuario; * return ex.Message; * } * }*/ /// <summary> /// Metodo implementado de IDAO para cambiar el status de los usuarios de la BD /// </summary> /// <param name="e">Usuario a modificar</param> /// <param name="disponibilidad">status nuevo</param> /// <returns></returns> string IDAOUsuario.statusUsuario(Entidad e, string status) { Usuario usuario = (Usuario)e; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_activo, SqlDbType.VarChar, status, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_id, SqlDbType.Int, usuario._id.ToString(), false)); EjecutarStoredProcedure(RecursoDAOM12.ProcedimientoStatusUsuario, listaParametro); return("1"); } catch (SqlException ex) { usuario.nombre = ex.Message; Entidad resultado = usuario; return(ex.Message); } }
/// <summary> /// Metodo para hacer el insert de un reclamo de equipaje en la BD /// </summary> /// <param name="e">Entidad que posteriormente será casteada a Reclamo</param> /// <returns>Codigo numerico segun respuesta de Insert</returns> int IDAO.Agregar(Entidad e) { Equipaje equipaje = (Equipaje)e; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(M07Equipaje.equ_peso, SqlDbType.VarChar, equipaje._peso.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(M07Equipaje.equ_fk_pase_abordaje, SqlDbType.VarChar, equipaje._abordaje.ToString(), false)); EjecutarStoredProcedure(M07Equipaje.procedimientoAgregarEquipaje, listaParametro); return(1); } catch (SqlException ex) { Debug.WriteLine("Ocurrio un SqlException"); Debug.WriteLine(ex.ToString()); return(2); } catch (NullReferenceException ex) { Debug.WriteLine("Ocurrio una NullReferenceException"); Debug.WriteLine(ex.ToString()); return(3); } catch (ArgumentNullException ex) { Debug.WriteLine("Ocurrio una ArgumentNullException"); Debug.WriteLine(ex.ToString()); return(4); } catch (Exception ex) { Debug.WriteLine("Ocurrio una Exception"); Debug.WriteLine(ex.ToString()); return(5); } }
public bool ActivarDesactivar(Entidad e) { Automovil automovil = (Automovil)e; List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); try { parametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.aut_matricula, SqlDbType.VarChar, automovil.matricula, false)); EjecutarStoredProcedure(RecursoDAOM08.procedimientoCambiarEstatus, parametro); return(true); } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Argumento con _idHotel invalido", ex); } catch (FormatException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Datos con un formato invalido", ex); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error al realizar operacion ", ex); } }
/// <summary> /// Método para consultar todos los reclamos de equipaje en la BD /// </summary> /// <returns> Lista de reclamos de equipaje</returns> Dictionary <int, Entidad> IDAO.ConsultarTodos() { List <ReclamoEquipaje> listareclamos = new List <ReclamoEquipaje>(); Dictionary <int, Entidad> listaReclamos = new Dictionary <int, Entidad>(); SqlConnection conexion = Connection.getInstance(_connexionString); List <ReclamoEquipaje> reclamos = FabricaEntidad.InstanciarListaReclamoEquipaje(); List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); DataTable tablaDeDatos; int rec_id, rec_fk_pasajero, rec_fk_equipaje; String rec_titulo, rec_descripcion, rec_fecha, rec_estatus; int placeholder = 0; try { parametro.Add(FabricaDAO.asignarParametro(M07ReclamoEquipaje.rec_id, SqlDbType.Int, placeholder.ToString(), false)); tablaDeDatos = EjecutarStoredProcedureTuplas(M07ReclamoEquipaje.procedimientoConsultarReclamoPorID, parametro); foreach (DataRow filaReclamo in tablaDeDatos.Rows) { rec_id = int.Parse(filaReclamo[M07ReclamoEquipaje.recId].ToString()); rec_estatus = filaReclamo[M07ReclamoEquipaje.recStatus].ToString(); rec_fk_pasajero = int.Parse(filaReclamo[M07ReclamoEquipaje.recFkPasajero].ToString()); rec_fk_equipaje = int.Parse(filaReclamo[M07ReclamoEquipaje.recFkEquipaje].ToString()); rec_descripcion = filaReclamo[M07ReclamoEquipaje.recDescripcion].ToString(); String[] divisor = filaReclamo[M07ReclamoEquipaje.recFecha].ToString().Split(' '); rec_fecha = divisor[0]; ReclamoEquipaje reclamo = (ReclamoEquipaje)FabricaEntidad.InstanciarReclamoEquipaje(rec_id, rec_descripcion, rec_fecha, rec_estatus, rec_fk_pasajero, rec_fk_equipaje); listaReclamos.Add(rec_id, reclamo); } return(listaReclamos); } catch (SqlException ex) { Debug.WriteLine(ex.ToString()); return(null); } }
/// <summary> /// Método para actualizar el estado de un reclamo /// </summary> /// <param name="id"> recibe el id del reclamo</param> /// <param name="estado">recibe el estado del reclamo</param> /// <returns>retorna un entero</returns> public int modificarEstado(int id, int estado) { try { List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); parametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_id, SqlDbType.Int, id.ToString(), false)); parametro.Add(FabricaDAO.asignarParametro(M16Reclamos.rec_estatus, SqlDbType.Int, estado.ToString(), false)); EjecutarStoredProcedure(M16Reclamos.procedimientoActualizarReclamo, parametro); return(1); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (NullReferenceException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM16(ex.Message, ex); } }
/// <summary> /// Método para consultar un reclamo en la BD /// </summary> /// <param name="id">id del reclamo a consultar</param> /// <returns> reclamo conseguido</returns> Entidad IDAO.Consultar(int id) { List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); int rec_id, rec_fk_pasajero, rec_fk_equipaje; String rec_descripcion, rec_fecha, rec_status; Entidad reclamoE = FabricaEntidad.InstanciarReclamoEquipaje(); ReclamoEquipaje reclamo = (ReclamoEquipaje)reclamoE; try { parametro.Add(FabricaDAO.asignarParametro(M07ReclamoEquipaje.rec_id, SqlDbType.Int, id.ToString(), false)); DataTable filaReclamo = EjecutarStoredProcedureTuplas(M07ReclamoEquipaje.procedimientoConsultarReclamoPorID, parametro); DataRow Fila = filaReclamo.Rows[0]; rec_id = int.Parse(Fila[M07ReclamoEquipaje.recId].ToString()); rec_status = Fila[M07ReclamoEquipaje.recStatus].ToString(); rec_fk_pasajero = int.Parse(Fila[M07ReclamoEquipaje.recFkPasajero].ToString()); rec_fk_equipaje = int.Parse(Fila[M07ReclamoEquipaje.recFkEquipaje].ToString()); rec_descripcion = Fila[M07ReclamoEquipaje.recDescripcion].ToString(); String[] divisor = Fila[M07ReclamoEquipaje.recFecha].ToString().Split(' '); rec_fecha = divisor[0]; reclamo = (ReclamoEquipaje)FabricaEntidad.InstanciarReclamoEquipaje(rec_id, rec_descripcion, rec_fecha, rec_status, rec_fk_pasajero, rec_fk_equipaje); return(reclamo); } catch (SqlException ex) { Debug.WriteLine(ex.ToString()); return(null); } catch (Exception ex) { Debug.WriteLine(ex.ToString()); return(null); } }
/// <summary> /// Metodo de DAO para modificar Avion /// </summary> Entidad IDAO.Modificar(Entidad e) { Avion avion = (Avion)e; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_id, SqlDbType.Int, avion._id.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_matricula, SqlDbType.VarChar, avion._matricula, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_modelo, SqlDbType.VarChar, avion._modelo, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_pasajeros_turista, SqlDbType.Int, avion._capacidadTurista.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_pasajeros_ejecutiva, SqlDbType.Int, avion._capacidadEjecutiva.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_pasajeros_vip, SqlDbType.Int, avion._capacidadVIP.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_cap_equipaje, SqlDbType.Float, avion._capacidadEquipaje.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_max_dist, SqlDbType.Float, avion._distanciaMaximaVuelo.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_max_vel, SqlDbType.Float, avion._velocidadMaxima.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_max_comb, SqlDbType.Float, avion._capacidadCombustible.ToString(), false)); EjecutarStoredProcedure(RecursoDAOM02.ProcedimientoModificarAvion, listaParametro); avion._matricula = "1"; return(avion); } catch (SqlException ex) { avion._matricula = ex.Message; Entidad resultado = avion; return(resultado); } //catch (SqlException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (NullReferenceException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (ArgumentNullException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (ExceptionBD ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (Exception ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} }
public bool existeMatricula(Entidad e) { //Metodo para escribir en el archivo log.xml que se ha ingresado en el metodo Log.EscribirInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, RecursoDAOM08.MensajeInicioMetodoLogger, System.Reflection.MethodBase.GetCurrentMethod().Name); //Se castea de tipo Entidad a tipo Automovil Automovil automovil = (Automovil)e; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); //Atributos tabla Automovil String matricula; String matriculaAux; try { //Aqui se asignan los valores que recibe el procedimieto para realizar el select, se repite tantas veces como atributos //se requiera en el where, para este caso solo el ID del Automovil @rst_id (parametro que recibe el store procedure) //se coloca true en Input listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.matricula, SqlDbType.VarChar, automovil.matricula, false)); matriculaAux = automovil.matricula; //Se devuelve la fila del Automovil consultado segun el Id, para este caso solo se devuelve una fila DataTable filaAutomovil = EjecutarStoredProcedureTuplas(RecursoDAOM08.procedimientoExisteMatriculaAutomovil, listaParametro); //Se guarda la fila devuelta de la base de datos DataRow Fila = filaAutomovil.Rows[0]; //Se preinicializan los atrubutos de la clase Automovil matricula = Fila[RecursoDAOM08.matricula].ToString(); if (matriculaAux.Equals(matricula)) { return(true); } else { return(false); } } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Argumento con valor invalido", ex); } catch (FormatException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Datos con un formato invalido", ex); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error al realizar operacion ", ex); } }
public List <Entidad> ConsultarTodos() { //Metodo para escribir en el archivo log.xml que se ha ingresado en el metodo Log.EscribirInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, RecursoDAOM08.MensajeInicioMetodoLogger, System.Reflection.MethodBase.GetCurrentMethod().Name); List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); List <Entidad> listaDeAutomoviles = FabricaEntidad.asignarListaDeEntidades(); DataTable tablaDeDatos; Entidad auto; //Atributos tabla Automovil String matricula; String modelo; String fabricante; String anio; String kilometraje; String cantpasajero; String tipovehiculo; String preciocompra; String precioalquiler; String penalidaddiaria; String fecharegistro; String color; String disponibilidad; String transmision; String fk_ciudad; String ciudad; String pais; try { //el metodo Ejecutar Store procedure recibe la lista de parametros como el query, este ultimo es el nombre del procedimietno en la BD //e.g. dbo.M10_ConsultarRestarurante tablaDeDatos = EjecutarStoredProcedureTuplas(RecursoDAOM08.procedimientoConsultarAutomovil); foreach (DataRow Fila in tablaDeDatos.Rows) { //Se preinicializan los atrubutos de la clase Automovil matricula = Fila[RecursoDAOM08.matricula].ToString(); modelo = Fila[RecursoDAOM08.modelo].ToString(); fabricante = Fila[RecursoDAOM08.fabricante].ToString(); anio = Fila[RecursoDAOM08.anio].ToString(); kilometraje = Fila[RecursoDAOM08.kilometraje].ToString(); cantpasajero = Fila[RecursoDAOM08.cantpasajero].ToString(); tipovehiculo = Fila[RecursoDAOM08.tipovehiculo].ToString(); preciocompra = Fila[RecursoDAOM08.preciocompra].ToString(); precioalquiler = Fila[RecursoDAOM08.precioalquiler].ToString(); penalidaddiaria = Fila[RecursoDAOM08.penalidaddiaria].ToString(); fecharegistro = Fila[RecursoDAOM08.fecharegistro].ToString(); color = Fila[RecursoDAOM08.color].ToString(); disponibilidad = Fila[RecursoDAOM08.disponibilidad].ToString(); transmision = Fila[RecursoDAOM08.transmision].ToString(); pais = Fila[RecursoDAOM08.pais].ToString(); ciudad = Fila[RecursoDAOM08.ciudad].ToString(); fk_ciudad = Fila[RecursoDAOM08.fk_ciudad].ToString(); //se crea el objeto Automovil auto = FabricaEntidad.CrearAutomovil(matricula, modelo, fabricante, anio, kilometraje, cantpasajero, tipovehiculo, preciocompra, precioalquiler, penalidaddiaria, fecharegistro, color, disponibilidad, transmision, pais, ciudad, fk_ciudad); //se agregan los Automovil a la lista listaDeAutomoviles.Add(auto); } return(listaDeAutomoviles); //se retorna la lista de Automovil a mostrar por la vista } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Argumento con _idHotel invalido", ex); } catch (FormatException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Datos con un formato invalido", ex); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error al realizar operacion ", ex); } }
/// <summary> /// AgregarAvion para los Store Procedure /// </summary> /// <param name="e"></param> /// <returns></returns> int IDAO.Agregar(Entidad e) { List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); Avion avion = (Avion)e; try { listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_matricula, SqlDbType.VarChar, avion._matricula, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_modelo, SqlDbType.VarChar, avion._modelo, false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_pasajeros_turista, SqlDbType.Int, avion._capacidadTurista.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_pasajeros_ejecutiva, SqlDbType.Int, avion._capacidadEjecutiva.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_pasajeros_vip, SqlDbType.Int, avion._capacidadVIP.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_cap_equipaje, SqlDbType.Float, avion._capacidadEquipaje.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_max_dist, SqlDbType.Float, avion._distanciaMaximaVuelo.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_max_vel, SqlDbType.Float, avion._velocidadMaxima.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_max_comb, SqlDbType.Float, avion._capacidadCombustible.ToString(), false)); EjecutarStoredProcedure(RecursoDAOM02.ProcedimientoAgregarAvion, listaParametro); return(1); } catch (SqlException ex) { Debug.WriteLine("Ocurrio un SqlException"); Debug.WriteLine(ex.ToString()); return(2); } catch (NullReferenceException ex) { Debug.WriteLine("Ocurrio una NullReferenceException"); Debug.WriteLine(ex.ToString()); return(3); } catch (ArgumentNullException ex) { Debug.WriteLine("Ocurrio una ArgumentNullException"); Debug.WriteLine(ex.ToString()); return(4); } catch (Exception ex) { Debug.WriteLine("Ocurrio una Exception"); Debug.WriteLine(ex.ToString()); return(5); } //catch (SqlException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (NullReferenceException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (ArgumentNullException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (ExceptionBD ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (Exception ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} }
/// <summary> /// Metodo diccionario del DAO para consultar todos los Aviones /// </summary> Dictionary <int, Entidad> IDAO.ConsultarTodos() { Dictionary <int, Entidad> listaAviones = new Dictionary <int, Entidad>(); DataTable tablaDeDatos; List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); Avion avion; int idAvion; try { tablaDeDatos = EjecutarStoredProcedureTuplas(RecursoDAOM02.ProcedimientoConsultarAvion, parametro); foreach (DataRow row in tablaDeDatos.Rows) { idAvion = Int32.Parse(row["avi_id"].ToString()); avion = new Avion( idAvion, row["avi_matricula"].ToString(), row["avi_modelo"].ToString(), Int32.Parse(row["avi_pasajeros_turista"].ToString()), Int32.Parse(row["avi_pasajeros_ejecutiva"].ToString()), Int32.Parse(row["avi_pasajeros_vip"].ToString()), float.Parse(row["avi_cap_equipaje"].ToString()), float.Parse(row["avi_max_dist"].ToString()), float.Parse(row["avi_max_vel"].ToString()), float.Parse(row["avi_max_comb"].ToString()), Int32.Parse(row["avi_disponibilidad"].ToString())); listaAviones.Add(idAvion, avion); } return(listaAviones); } catch (SqlException ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } catch (NullReferenceException ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } catch (ArgumentNullException ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } catch (ExceptionBD ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } catch (Exception ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } }
/// <summary> /// Metodo de DAO para cambiar disponibilidad del Avion /// </summary> string IDAOAvion.disponibilidadAvion(Entidad e, int disponibilidad) { Avion avion = (Avion)e; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); try { listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_id, SqlDbType.Int, avion._id.ToString(), false)); listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_disponibilidad, SqlDbType.Int, disponibilidad.ToString(), false)); EjecutarStoredProcedure(RecursoDAOM02.ProcedimientoDisponibilidad, listaParametro); return("1"); } catch (SqlException ex) { avion._matricula = ex.Message; Entidad resultado = avion; return(ex.Message); } //catch (SqlException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (NullReferenceException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (ArgumentNullException ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (ExceptionBD ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} //catch (Exception ex) //{ // try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } // catch (LogException exi) // { throw new ReservaExceptionM02(ex.Message, exi); } // throw new ReservaExceptionM02(ex.Message, ex); //} }
/// <summary> /// Metodo de DAO para consultar Avion /// </summary> Entidad IDAO.Consultar(int id) { DataTable tablaDeDatos; List <Parametro> parametro = FabricaDAO.asignarListaDeParametro(); Avion avion; int idAvion; try { parametro.Add(FabricaDAO.asignarParametro(RecursoDAOM02.avi_id, SqlDbType.Int, id.ToString(), false)); tablaDeDatos = EjecutarStoredProcedureTuplas(RecursoDAOM02.ProcedimientoConsultarID, parametro); foreach (DataRow row in tablaDeDatos.Rows) { idAvion = Int32.Parse(row["id"].ToString()); avion = new Avion( idAvion, row["matricula"].ToString(), row["modelo"].ToString(), Int32.Parse(row["pturista"].ToString()), Int32.Parse(row["pejecutiva"].ToString()), Int32.Parse(row["pvip"].ToString()), float.Parse(row["equipaje"].ToString()), float.Parse(row["maxdistancia"].ToString()), float.Parse(row["maxvelocidad"].ToString()), float.Parse(row["maxcombustible"].ToString())); return(avion); } return(null); } catch (SqlException ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } catch (NullReferenceException ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } catch (ArgumentNullException ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } catch (ExceptionBD ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } catch (Exception ex) { try { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); } catch (LogException exi) { throw new ReservaExceptionM02(ex.Message, exi); } throw new ReservaExceptionM02(ex.Message, ex); } }
public Entidad Consultar(Entidad e) { //Metodo para escribir en el archivo log.xml que se ha ingresado en el metodo Log.EscribirInfo(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, RecursoDAOM08.MensajeInicioMetodoLogger, System.Reflection.MethodBase.GetCurrentMethod().Name); //Se castea de tipo Entidad a tipo Automovil Automovil automovil = (Automovil)e; List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro(); //Atributos tabla Automovil String matricula; String modelo; String fabricante; String anio; String kilometraje; String cantpasajero; String tipovehiculo; String preciocompra; String precioalquiler; String penalidaddiaria; String fecharegistro; String color; String disponibilidad; String transmision; String fk_ciudad; String ciudad; String pais; Entidad entidad; try { //Aqui se asignan los valores que recibe el procedimieto para realizar el select, se repite tantas veces como atributos //se requiera en el where, para este caso solo el ID del Automovil @rst_id (parametro que recibe el store procedure) //se coloca true en Input listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM08.matricula, SqlDbType.VarChar, automovil.matricula, false)); //Se devuelve la fila del Automovil consultado segun el Id, para este caso solo se devuelve una fila DataTable filaAutomovil = EjecutarStoredProcedureTuplas(RecursoDAOM08.procedimientoConsultarAutomovilMatricula, listaParametro); //Se guarda la fila devuelta de la base de datos DataRow Fila = filaAutomovil.Rows[0]; //Se preinicializan los atrubutos de la clase Automovil matricula = Fila[RecursoDAOM08.matricula].ToString(); modelo = Fila[RecursoDAOM08.modelo].ToString(); fabricante = Fila[RecursoDAOM08.fabricante].ToString(); anio = Fila[RecursoDAOM08.anio].ToString(); kilometraje = Fila[RecursoDAOM08.kilometraje].ToString(); cantpasajero = Fila[RecursoDAOM08.cantpasajero].ToString(); tipovehiculo = Fila[RecursoDAOM08.tipovehiculo].ToString(); preciocompra = Fila[RecursoDAOM08.preciocompra].ToString(); precioalquiler = Fila[RecursoDAOM08.precioalquiler].ToString(); penalidaddiaria = Fila[RecursoDAOM08.penalidaddiaria].ToString(); fecharegistro = Fila[RecursoDAOM08.fecharegistro].ToString(); color = Fila[RecursoDAOM08.color].ToString(); disponibilidad = Fila[RecursoDAOM08.disponibilidad].ToString(); transmision = Fila[RecursoDAOM08.transmision].ToString(); pais = Fila[RecursoDAOM08.pais].ToString(); ciudad = Fila[RecursoDAOM08.ciudad].ToString(); fk_ciudad = Fila[RecursoDAOM08.fk_ciudad].ToString(); entidad = FabricaEntidad.CrearAutomovil(matricula, modelo, fabricante, anio, kilometraje, cantpasajero, tipovehiculo, preciocompra, precioalquiler, penalidaddiaria, fecharegistro, color, disponibilidad, transmision, pais, ciudad, fk_ciudad); //se retorna la entidad de Automovil a mostrar en la vista return(entidad); } catch (ArgumentNullException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Argumento con _idHotel invalido", ex); } catch (FormatException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Datos con un formato invalido", ex); } catch (SqlException ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (ExceptionBD ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error Conexion Base de Datos", ex); } catch (Exception ex) { Log.EscribirError(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name, ex); throw new ReservaExceptionM08("Reserva-404", "Error al realizar operacion ", ex); } }