Exemple #1
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);
                }
            }
        }
Exemple #2
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);
        }
        /// <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);
            }
        }
Exemple #4
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);
        }
Exemple #5
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);
        }
Exemple #6
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);
            }
        }
Exemple #7
0
        /// <summary>
        /// Método para modificar un reclamo
        /// </summary>
        /// <param name="e">Entidad que posteriormente será casteada a Reclamo</param>
        /// <returns>retorna el reclamo</returns>
        Entidad IDAO.Modificar(Entidad e)
        {
            Reclamo          reclamo        = (Reclamo)e;
            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_id, SqlDbType.Int, reclamo._id.ToString(), false));
                EjecutarStoredProcedure(M16Reclamos.procedimientoModificarReclamo, listaParametro);
                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);
            }
        }
Exemple #8
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);
            }
        }
Exemple #9
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);
            }
        }
        /// <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 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);
            }
        }
Exemple #12
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);
     }
 }
Exemple #13
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);
            //}
        }
Exemple #14
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);
            }
        }
Exemple #15
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);
            //}
        }
Exemple #16
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);
            }
        }
Exemple #17
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);
            //}
        }
Exemple #18
0
        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);
            }
        }