public int AltaLibro(object obj)
        {
            LibroBO data = (LibroBO)obj;

            cmd            = new SQLiteCommand();
            dsLibros       = new DataSet();
            da             = new SQLiteDataAdapter();
            con            = new Conexion();
            cmd.Connection = con.establecerConexion();
            con.abrirConexion();

            sql = "INSERT INTO Libro(Titulo,Autor,Editorial,Precio,Imagen)" +
                  "VALUES('" +
                  data.Titulo.Trim() + "','" +
                  data.Autor.Trim() + "','" +
                  data.Editorial.Trim() + "','" +
                  data.Precio.ToString() + "','" +
                  data.Imagen.Trim() + "')";
            cmd.CommandText = sql;
            int i = cmd.ExecuteNonQuery();

            if (i <= 0)
            {
                return(0);
            }
            return(1);
        }
        public int modificaLibro(object obj)
        {
            LibroBO data = (LibroBO)obj;

            cmd            = new SQLiteCommand();
            dsLibros       = new DataSet();
            da             = new SQLiteDataAdapter();
            con            = new Conexion();
            cmd.Connection = con.establecerConexion();
            con.abrirConexion();


            sql = "UPDATE Libro SET Titulo='" + data.Titulo.Trim() +
                  "',Autor='" + data.Autor.Trim() +
                  "',Editorial='" + data.Editorial.Trim() +
                  "',Precio='" + data.Precio.ToString() +
                  "' WHERE ISBN='" + data.ISBN.ToString() + "'";
            cmd.CommandText = sql;
            int i = cmd.ExecuteNonQuery();

            if (i <= 0)
            {
                return(0);
            }
            return(1);
        }
        public int creaAlumno(object obj)
        {
            AlumnoBO data = (AlumnoBO)obj;

            cmd            = new SQLiteCommand();
            dsAlumno       = new DataSet();
            da             = new SQLiteDataAdapter();
            con            = new Conexion();
            cmd.Connection = con.establecerConexion();
            con.abrirConexion();

            sql = "INSERT INTO Alumno(Nombre,ApellidoPaterno,ApellidoMaterno,Direccion,Telefono,Grado,Grupo)" +
                  "VALUES('" +
                  data.Nombre.Trim() + "','" +
                  data.Apellidopaterno.Trim() + "','" +
                  data.Apellidomaterno.Trim() + "','" +
                  data.Direccion.Trim() + "','" +
                  data.Telefono.ToString() + "','" +
                  data.Grado.ToString() + "','" +
                  data.Grupo.Trim() + "')";
            cmd.CommandText = sql;

            int i = cmd.ExecuteNonQuery();

            if (i <= 0)
            {
                return(0);
            }
            return(1);
        }
        public int modificaAlumno(object obj)
        {
            AlumnoBO data = (AlumnoBO)obj;

            cmd            = new SQLiteCommand();
            dsAlumno       = new DataSet();
            da             = new SQLiteDataAdapter();
            con            = new Conexion();
            cmd.Connection = con.establecerConexion();
            con.abrirConexion();


            sql = "UPDATE Alumno SET Nombre='" + data.Nombre.Trim() +
                  "',ApellidoPaterno='" + data.Apellidopaterno.Trim() +
                  "',ApellidoMaterno='" + data.Apellidomaterno.Trim() +
                  "',Direccion='" + data.Direccion.Trim() +
                  "',Telefono='" + data.Telefono.Trim() +
                  "',Grado='" + data.Grado.ToString() +
                  "',Grupo='" + data.Grupo.Trim() +
                  "' WHERE Matricula='" + data.Matricula.ToString() + "'";
            cmd.CommandText = sql;
            int i = cmd.ExecuteNonQuery();

            if (i <= 0)
            {
                return(0);
            }
            return(1);
        }
        public DataSet BusquedaLibro(object obj)
        {
            string  cadenaWhere = "";
            bool    edo         = false;
            LibroBO data        = (LibroBO)obj;

            cmd            = new SQLiteCommand();
            dsLibros       = new DataSet();
            da             = new SQLiteDataAdapter();
            con            = new Conexion();
            cmd.Connection = con.establecerConexion();
            con.abrirConexion();


            if (data.ISBN > 0)
            {
                cadenaWhere = cadenaWhere + " ISBN=" + data.ISBN + " and";
                edo         = true;
            }
            if (data.Titulo != null)
            {
                cadenaWhere = cadenaWhere + " Titulo='" + data.Titulo.Trim() + "' and";
                edo         = true;
            }
            if (data.Autor != null)
            {
                cadenaWhere = cadenaWhere + " Autor='" + data.Autor.Trim() + "' and";
                edo         = true;
            }
            if (data.Editorial != null)
            {
                cadenaWhere = cadenaWhere + " Editorial='" + data.Editorial.Trim() + "' and";
                edo         = true;
            }
            if (data.Precio > 0)
            {
                cadenaWhere = cadenaWhere + " Precio=" + data.Precio + " and";
                edo         = true;
            }
            if (data.Imagen != null)
            {
                cadenaWhere = cadenaWhere + " Imagen='" + data.Imagen.Trim() + "' and";
                edo         = true;
            }
            if (edo == true)
            {
                cadenaWhere = " WHERE " + cadenaWhere.Remove(cadenaWhere.Length - 3, 3);
            }
            sql             = " SELECT * FROM Libro " + cadenaWhere;
            cmd.CommandText = sql;
            DataSet ds = new DataSet();

            da.SelectCommand = cmd;
            da.Fill(dsLibros);
            con.cerrarConexion();
            return(dsLibros);
        }
        public int eliminaLibro(object obj)
        {
            LibroBO data = (LibroBO)obj;

            cmd            = new SQLiteCommand();
            dsLibros       = new DataSet();
            da             = new SQLiteDataAdapter();
            con            = new Conexion();
            cmd.Connection = con.establecerConexion();
            con.abrirConexion();
            sql             = "DELETE FROM Libro WHERE ISBN=" + data.ISBN.ToString();
            cmd.CommandText = sql;
            int i = cmd.ExecuteNonQuery();

            if (i <= 0)
            {
                return(0);
            }
            return(1);
        }
        public int eliminaAlumno(object obj)
        {
            AlumnoBO data = (AlumnoBO)obj;

            cmd            = new SQLiteCommand();
            dsAlumno       = new DataSet();
            da             = new SQLiteDataAdapter();
            con            = new Conexion();
            cmd.Connection = con.establecerConexion();
            con.abrirConexion();
            sql             = "DELETE FROM Alumno WHERE Matricula=" + data.Matricula.ToString();
            cmd.CommandText = sql;
            int i = cmd.ExecuteNonQuery();

            if (i <= 0)
            {
                return(0);
            }
            return(1);
        }
        public DataSet devuelveAlumno(object obj)
        {
            string   cadenaWhere = "";
            bool     edo         = false;
            AlumnoBO data        = (AlumnoBO)obj;

            cmd            = new SQLiteCommand();
            dsAlumno       = new DataSet();
            da             = new SQLiteDataAdapter();
            con            = new Conexion();
            cmd.Connection = con.establecerConexion();
            con.abrirConexion();


            if (data.Matricula > 0)
            {
                cadenaWhere = cadenaWhere + " matricula=" + data.Matricula + " and";
                edo         = true;
            }
            if (data.Nombre != null)
            {
                cadenaWhere = cadenaWhere + " Nombre='" + data.Nombre.Trim() + "' and";
                edo         = true;
            }
            if (data.Apellidopaterno != null)
            {
                cadenaWhere = cadenaWhere + " Apellidopaterno='" + data.Apellidopaterno.Trim() + "' and";
                edo         = true;
            }
            if (data.Apellidomaterno != null)
            {
                cadenaWhere = cadenaWhere + " Apellidomaterno='" + data.Apellidomaterno.Trim() + "' and";
                edo         = true;
            }
            if (data.Direccion != null)
            {
                cadenaWhere = " Direccion='" + data.Direccion.Trim() + "' and";
                edo         = true;
            }
            if (data.Telefono != null)
            {
                cadenaWhere = " Telefono='" + data.Telefono.Trim() + "' and";
                edo         = true;
            }
            if (data.Grado > 0)
            {
                cadenaWhere = cadenaWhere + " Grado=" + data.Grado + " and";
                edo         = true;
            }
            if (data.Grupo != null)
            {
                cadenaWhere = cadenaWhere + " Grupo='" + data.Grupo.Trim() + "' and";
                edo         = true;
            }

            if (edo == true)
            {
                cadenaWhere = " WHERE " + cadenaWhere.Remove(cadenaWhere.Length - 3, 3);
            }
            sql             = " SELECT * FROM Alumno " + cadenaWhere;
            cmd.CommandText = sql;
            DataSet ds = new DataSet();

            da.SelectCommand = cmd;
            da.Fill(dsAlumno);
            con.cerrarConexion();
            return(dsAlumno);
        }