Exemplo n.º 1
0
        /// <summary>
        /// Lista de pases de un pasajero
        /// </summary>
        /// <param name="pasaporte"></param>
        /// <returns></returns>
        public List <Entidad> ListarPasesPasajero(int pasaporte)
        {
            List <Entidad> listaboletos = new List <Entidad>();
            IDAOLugar      c            = (DAOLugar)FabricaDAO.instanciarDaoLugar();

            try
            {
                SqlConnection con = Connection.getInstance(_connexionString);
                con.Open();
                String sql = "SELECT P.pas_id AS numpas, P.pas_fk_lugar_origen AS origen, P.pas_fk_lugar_destino AS destino, P.pas_fk_vuelo AS vuelo" +
                             " FROM Pase_Abordaje P, Boleto B " +
                             " WHERE B.bol_fk_pasajero = " + pasaporte +
                             " AND P.pas_fk_boleto = B.bol_id";
                SqlCommand cmd = new SqlCommand(sql, con);
                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        BoardingPass boleto = new BoardingPass(Int32.Parse(reader["numpas"].ToString()),
                                                               MBuscarnombreciudad(Int32.Parse(reader["origen"].ToString())),
                                                               MBuscarnombreciudad(Int32.Parse(reader["destino"].ToString())),
                                                               Int32.Parse(reader["vuelo"].ToString()));
                        listaboletos.Add(boleto);
                    }
                }
                cmd.Dispose();
                con.Close();
                return(listaboletos);
            }
            catch (SqlException)
            {
                return(null);
            }
        }
Exemplo n.º 2
0
        /*Entidad IDAO.Modificar(Entidad e)
         * {
         *  Usuario usuario = (Usuario)e;
         *  SqlConnection conexion = Connection.getInstance(_connexionString);
         *  try
         *  {
         *      conexion.Open();
         *      String sql = "UPDATE Usuario " +
         *                      "SET usu_nombre = '"+ usuario.nombre +"', usu_apellido = '"+ usuario.apellido +"', usu_correo = '"+ usuario.correo +"', usu_contraseña = '"+ usuario.contrasena +"', usu_fk_rol = "+ usuario.rol +", usu_activo = '"+ usuario.activo+"' where usu_id = "+ usuario._id;
         *      SqlCommand cmd = new SqlCommand(sql, conexion);
         *      cmd.ExecuteNonQuery();
         *      cmd.Dispose();
         *
         *      conexion.Close();
         *
         *      usuario.nombre = "1";
         *      Entidad resultado = usuario;
         *
         *      return resultado;
         *  }
         *  catch (SqlException ex)
         *  {
         *      conexion.Close();
         *      usuario.nombre = ex.Message;
         *      Entidad resultado = usuario;
         *      return resultado;
         *  }
         * }*/

        /// <summary>
        /// Metodo implementado de IDAO para modificar usuarios de la BD
        /// </summary>
        /// <param name="e">Usuario a modificar</param>
        /// <returns>Retorna el usuario</returns>
        Entidad IDAO.Modificar(Entidad e)
        {
            Usuario          usuario        = (Usuario)e;
            List <Parametro> listaParametro = FabricaDAO.asignarListaDeParametro();

            try
            {
                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_activo, SqlDbType.VarChar, usuario.activo, false));
                listaParametro.Add(FabricaDAO.asignarParametro(RecursoDAOM12.usu_id, SqlDbType.Int, usuario._id.ToString(), false));

                EjecutarStoredProcedure(RecursoDAOM12.ProcedimientoEditarUsuario, listaParametro);

                usuario.nombre = "1";
                return(usuario);
            }
            catch (SqlException ex)
            {
                usuario.nombre = ex.Message;
                Entidad resultado = usuario;
                return(resultado);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Método que lee los datos de una comida para editarla
        /// </summary>
        /// <returns>Retorna una comida</returns>
        public Entidad rellenarComida(Entidad entidad)
        {
            Comida           comida = (Comida)entidad;
            List <Parametro> lista  = FabricaDAO.asignarListaDeParametro();
            DataTable        resultado;

            try
            {
                lista.Add(FabricaDAO.asignarParametro(RecursoM06.com_id, SqlDbType.Int, comida._id.ToString(), false));

                resultado = EjecutarStoredProcedureTuplas(RecursoM06.procedimientoConsultarDatosComida, lista);

                if (resultado != null)
                {
                    foreach (DataRow row in resultado.Rows)
                    {
                        comida._nombre      = row[RecursoM06.com_nombre_consultar].ToString();
                        comida._tipo        = row[RecursoM06.com_tipo_consultar].ToString();
                        comida._estatus     = Int32.Parse(row[RecursoM06.com_estatus_consultar].ToString());
                        comida._descripcion = row[RecursoM06.com_descripcion_consultar].ToString();
                    }
                    return(comida);
                }

                return(null);
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(null);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Permite obtener una instancia de la clase DAORevision.
 /// </summary>
 /// <returns>Instancia DAORevision.</returns>
 public static DAOComida Singleton()
 {
     if (DAOComida.instance == null)
     {
         DAOComida.instance = (DAOComida)FabricaDAO.instanciarComida();
     }
     return(DAOComida.instance);
 }
Exemplo n.º 5
0
 public static DAOAutomovil Singleton()
 {
     if (DAOAutomovil.instance == null)
     {
         DAOAutomovil.instance = (DAOAutomovil)FabricaDAO.CrearDaoAutomovil();
     }
     return(DAOAutomovil.instance);
 }
Exemplo n.º 6
0
        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);
            }
        }
Exemplo n.º 7
0
        /// <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);
            }
        }
Exemplo n.º 8
0
        /// <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);
            }
        }
Exemplo n.º 9
0
        /// <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);
            }
        }
Exemplo n.º 10
0
        /*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);
            }
        }
Exemplo n.º 11
0
        // 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);
            }
        }
Exemplo n.º 12
0
        /*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);
            }
        }
Exemplo n.º 13
0
        /// </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);
                }
            }
        }
Exemplo n.º 14
0
        /// <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);
        }
Exemplo n.º 15
0
        /// <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);
            }
        }
Exemplo n.º 16
0
        /// <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);
        }
Exemplo n.º 17
0
        /*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);
            }
        }
Exemplo n.º 18
0
        /// <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);
        }
Exemplo n.º 19
0
        /// <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);
            }
        }
Exemplo n.º 20
0
        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);
            }
        }
Exemplo n.º 21
0
        /// <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);
            }
        }
Exemplo n.º 22
0
 /// <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);
     }
 }
Exemplo n.º 23
0
        /// <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);
            }
        }
Exemplo n.º 24
0
        /// <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);
            }
        }
Exemplo n.º 25
0
        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);
            }
        }
Exemplo n.º 26
0
        /// <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);
            //}
        }
Exemplo n.º 27
0
        List <Entidad> IDAOBoleto.M05ListarVuelosIdaBD(string fecha_ida, string fecha_vuelta, int id_origen, int id_destino, string tipo)
        {
            List <Entidad> listavuelos = new List <Entidad>();

            try
            {
                IDAOBoleto    ver = (IDAOBoleto)FabricaDAO.instanciarDaoBoleto();
                SqlConnection con = new SqlConnection(_connexionString);
                con.Open();

                //Busco la capacidad del avion del vuelo, segun el tipo de boleto


                String sql = "SELECT v.vue_id as id,v.vue_fecha_despegue as despegue,v.vue_fecha_aterrizaje as aterrizaje,r.rut_id as id_ruta,r.rut_FK_lugar_origen as id_origen,r.rut_FK_lugar_destino as id_destino,lo.lug_nombre as nombre_origen,ld.lug_nombre as nombre_destino FROM Vuelo v, Ruta r, Lugar lo, Lugar ld WHERE v.vue_fk_ruta=r.rut_id AND r.rut_fk_lugar_origen = lo.lug_id AND r.rut_fk_lugar_destino = ld.lug_id AND r.rut_FK_lugar_origen=" + id_origen + "AND r.rut_FK_lugar_destino=" + id_destino + " AND v.vue_fecha_despegue >= '" + fecha_ida + "' AND v.vue_fecha_despegue <=  DATEADD(day, 1, '" + fecha_ida + "')";
                System.Diagnostics.Debug.WriteLine(sql);
                SqlCommand cmd = new SqlCommand(sql, con);


                using (SqlDataReader reader = cmd.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        Random rnd = new Random();

                        //Tengo que ver en cada vuelo que la cantidad de fk_vuelo en Boleto_Vuelo sea menor que la capacidad del tipo de boleto en el avion
                        int cant_bol_vue = 0; //Cantidad de fk_vuelo en Boleto_Vuelo
                        int cap          = 0; //capacidad del tipo de boleto en el avión
                        //Si tipo de boleto = Turista entonces busco cap turista, si es ejecutivo cap ejecutivo y si es vip cap vip
                        //Obtengo el id del vuelo
                        System.Diagnostics.Debug.WriteLine("METODO DE LISTAR VUELOS IDA");

                        int id_vuelo = Int32.Parse(reader["id"].ToString());


                        //Obtengo cantidad de fk_vuelo en Boleto_vuelo
                        cant_bol_vue = BuscarCantBolVue(id_vuelo);


                        cap = ver.MConteoCapacidad(id_vuelo, tipo);

                        System.Diagnostics.Debug.WriteLine("Capacidad en tipo " + tipo + " : " + cap);

                        if (cant_bol_vue < cap)
                        {
                            BoletoVuelo vuelo = new BoletoVuelo(Int32.Parse(reader["id"].ToString()),
                                                                reader.GetDateTime(reader.GetOrdinal("despegue")),
                                                                reader.GetDateTime(reader.GetOrdinal("aterrizaje")),
                                                                Int32.Parse(reader["id_ruta"].ToString()),
                                                                Int32.Parse(reader["id_origen"].ToString()),
                                                                Int32.Parse(reader["id_destino"].ToString()),
                                                                reader.GetString(reader.GetOrdinal("nombre_origen")),
                                                                reader.GetString(reader.GetOrdinal("nombre_destino")),
                                                                rnd.Next(300, 1001), tipo, fecha_vuelta);

                            listavuelos.Add(vuelo);
                        }
                        else
                        {
                            System.Diagnostics.Debug.WriteLine("CAPACIDAD MAXIMA ALCANZADA EN EL AVION PARA BOLETOS DEL TIPO: " + tipo);
                        }
                    }
                }
                cmd.Dispose();
                con.Close();
                return(listavuelos);
            }
            catch (SqlException)
            {
                return(null);
            }
        }
Exemplo n.º 28
0
        /// <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);
            //}
        }
Exemplo n.º 29
0
        /// <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);
            }
        }
Exemplo n.º 30
0
        /// <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);
            //}
        }