public static TituloLibreriaView GetTitulo(int idTitulo)
    {
        var data = HttpContext.Current.Session;

        TituloLibreriaView titulo = null;

        try
        {
            LibreriaController controller = new LibreriaController();
            if (AutenticacionSitio.IsUsuarioAutenticado())
            {
                titulo = controller.CargarPorId(idTitulo);
            }
            else
            {
                HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.Unauthorized;
            }
        }
        catch (Exception ex)
        {
            titulo = null;
            HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
        }
        return(titulo);
    }
Ejemplo n.º 2
0
    public static TituloLibreriaView CargaTitulo(int idTitulo)
    {
        TituloLibreriaView titulo = null;

        try
        {
            LibreriaController controller = new LibreriaController();
            titulo = controller.CargarPorId(idTitulo);
        }
        catch (Exception ex)
        {
            titulo = null;
            HttpContext.Current.Response.StatusCode = (int)HttpStatusCode.InternalServerError;
        }
        return(titulo);
    }
Ejemplo n.º 3
0
    protected void GridViewResultado_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            //if (e.Row.RowType == DataControlRowType.Header)
            //{
            //    GridView grid = sender as GridView;
            //    var row = e.Row;
            //    string sortedExpression = (ViewState["currentSort"] != null ? ViewState["currentSort"].ToString() : string.Empty);
            //    int indexColumn = 0;
            //    switch (sortedExpression)
            //    {
            //        case "tituloOriginal":
            //            indexColumn = 4;
            //            break;
            //        case "titulo":
            //            indexColumn = 5;
            //            break;
            //        case "autor":
            //            indexColumn = 6;
            //            break;
            //        case "año":
            //            indexColumn = 10;
            //            break;
            //        default:
            //            indexColumn = 0;
            //            break;
            //    }
            //    if (indexColumn > 0)
            //    {
            //        bool isdescending = (ViewState["isSortDescending"] != null ? (bool)ViewState["isSortDescending"] : false);
            //        string sort = (isdescending ? "desc" : "asc");
            //        e.Row.Cells[indexColumn].Attributes.Add("data-column-sorted", sort);
            //    }
            //}


            if (e.Row.RowType == DataControlRowType.Pager)
            {
                LinkButton cmdAnterior      = e.Row.FindControl("cmdAnterior") as LinkButton;
                LinkButton cmdInicio        = e.Row.FindControl("cmdInicio") as LinkButton;
                LinkButton cmdFinal         = e.Row.FindControl("cmdFinal") as LinkButton;
                LinkButton cmdSiguiente     = e.Row.FindControl("cmdSiguiente") as LinkButton;
                TextBox    textPaginaActual = e.Row.FindControl("TextBoxPaginaActual") as TextBox;
                if (textPaginaActual != null)
                {
                    textPaginaActual.Attributes.Add("onkeyup", "javascript: return autoPostbackPaginador(this,event);");
                }

                if (_Paginacion.PaginaActual == 1)
                {
                    cmdAnterior.Enabled  = false;
                    cmdInicio.Enabled    = false;
                    cmdFinal.Enabled     = true;
                    cmdSiguiente.Enabled = true;
                }
                else if (_Paginacion.PaginaActual > 1 && _Paginacion.PaginaActual < _Paginacion.PaginasTotales)
                {
                    cmdAnterior.Enabled  = true;
                    cmdInicio.Enabled    = true;
                    cmdFinal.Enabled     = true;
                    cmdSiguiente.Enabled = true;
                }
                else if (_Paginacion.PaginaActual == _Paginacion.PaginasTotales)
                {
                    cmdAnterior.Enabled  = true;
                    cmdInicio.Enabled    = true;
                    cmdFinal.Enabled     = false;
                    cmdSiguiente.Enabled = false;
                }
                else
                {
                    cmdAnterior.Enabled  = false;
                    cmdInicio.Enabled    = false;
                    cmdFinal.Enabled     = false;
                    cmdSiguiente.Enabled = false;
                }
            }


            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                TituloLibreriaView fila = e.Row.DataItem as TituloLibreriaView;
                if (fila != null)
                {
                    Label label = e.Row.FindControl("LabelAutor") as Label;
                    if (label != null)
                    {
                        string nombre = fila.Autor.NombreEspanol;
                        //if (!string.IsNullOrEmpty(fila.Autor.NombreLatin))
                        //{
                        //    nombre = nombre + "(" + fila.Autor.NombreLatin + ")";
                        //}
                        //else if (!string.IsNullOrEmpty(fila.Autor.NombreGriego))
                        //{
                        //    nombre = nombre + "(" + fila.Autor.NombreGriego + ")";
                        //}
                        label.Text = nombre;
                    }
                    Image imgPdf     = e.Row.FindControl("ImagenPdf") as Image;
                    Image imgVirtual = e.Row.FindControl("ImageVirtual") as Image;
                    Image imgOnline  = e.Row.FindControl("ImageOnline") as Image;
                    if (imgPdf != null)
                    {
                        imgPdf.Visible = !string.IsNullOrEmpty(fila.UrlPdf);
                        imgPdf.Attributes.Add("data-url", fila.UrlPdf);
                        imgPdf.Attributes.Add("onclick", "onSelectedResource('pdf','" + fila.UrlPdf + "')");
                    }
                    if (imgVirtual != null)
                    {
                        imgVirtual.Visible = !string.IsNullOrEmpty(fila.UrlVirtual);
                        imgVirtual.Attributes.Add("data-url", fila.UrlVirtual);
                        imgVirtual.Attributes.Add("onclick", "onSelectedResource('virtual','" + fila.UrlVirtual + "')");
                    }
                    if (imgOnline != null)
                    {
                        imgOnline.Visible = !string.IsNullOrEmpty(fila.UrlOnline);
                        imgOnline.Attributes.Add("data-url", fila.UrlOnline);
                        imgOnline.Attributes.Add("onclick", "onSelectedResource('online','" + fila.UrlOnline + "')");
                    }

                    Label labelTrad = e.Row.FindControl("LabelTraductor") as Label;
                    if (labelTrad != null)
                    {
                        if (fila.DetalleResponsables != null && fila.DetalleResponsables.Count > 0)
                        {
                            if (fila.DetalleResponsables[0] != null && fila.DetalleResponsables[0].Responsables != null)
                            {
                                if (fila.DetalleResponsables[0].Responsables.Count > 0)
                                {
                                    var traductores = (from q in fila.DetalleResponsables[0].Responsables
                                                       where q.TipoFuncion.ToLower().Contains("traductor") || q.TipoFuncion.ToLower().Contains("traducción")
                                                       select q).ToList();
                                    if (traductores != null && traductores.Count > 0)
                                    {
                                        if (traductores.Count > 1)
                                        {
                                            labelTrad.Text = traductores[0].NombreCompletoResponsable + " ...";
                                        }
                                        else
                                        {
                                            labelTrad.Text = traductores[0].NombreCompletoResponsable;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        catch (System.Exception ex)
        {
            throw ex;
        }
    }
Ejemplo n.º 4
0
    protected void GridViewResultado_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        try
        {
            if (e.Row.RowType == DataControlRowType.Header)
            {
                GridView grid             = sender as GridView;
                var      row              = e.Row;
                string   sortedExpression = (ViewState["currentSort"] != null ? ViewState["currentSort"].ToString() : string.Empty);
                int      indexColumn      = 0;
                switch (sortedExpression)
                {
                case "tituloOriginal":
                    indexColumn = 3;
                    break;

                case "titulo":
                    indexColumn = 4;
                    break;

                case "autor":
                    indexColumn = 5;
                    break;

                case "año":
                    indexColumn = 9;
                    break;

                default:
                    indexColumn = 0;
                    break;
                }
                if (indexColumn > 0)
                {
                    bool   isdescending = (ViewState["isSortDescending"] != null ? (bool)ViewState["isSortDescending"] : false);
                    string sort         = (isdescending ? "desc" : "asc");
                    e.Row.Cells[indexColumn].Attributes.Add("data-column-sorted", sort);
                }
            }

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                TituloLibreriaView fila = e.Row.DataItem as TituloLibreriaView;
                if (fila != null)
                {
                    Label label = e.Row.FindControl("LabelAutor") as Label;
                    if (label != null)
                    {
                        string nombre = fila.Autor.NombreEspanol;
                        //if (!string.IsNullOrEmpty(fila.Autor.NombreLatin))
                        //{
                        //    nombre = nombre + "(" + fila.Autor.NombreLatin + ")";
                        //}
                        //else if (!string.IsNullOrEmpty(fila.Autor.NombreGriego))
                        //{
                        //    nombre = nombre + "(" + fila.Autor.NombreGriego + ")";
                        //}
                        label.Text = nombre;
                    }
                    Image imgPdf     = e.Row.FindControl("ImagenPdf") as Image;
                    Image imgVirtual = e.Row.FindControl("ImageVirtual") as Image;
                    Image imgOnline  = e.Row.FindControl("ImageOnline") as Image;
                    if (imgPdf != null)
                    {
                        imgPdf.Visible = !string.IsNullOrEmpty(fila.UrlPdf);
                        imgPdf.Attributes.Add("data-url", fila.UrlPdf);
                    }
                    if (imgVirtual != null)
                    {
                        imgVirtual.Visible = !string.IsNullOrEmpty(fila.UrlVirtual);
                        imgVirtual.Attributes.Add("data-url", fila.UrlVirtual);
                    }
                    if (imgOnline != null)
                    {
                        imgOnline.Visible = !string.IsNullOrEmpty(fila.UrlOnline);
                        imgOnline.Attributes.Add("data-url", fila.UrlOnline);
                    }

                    Label labelTrad = e.Row.FindControl("LabelTraductor") as Label;
                    if (labelTrad != null)
                    {
                        if (fila.DetalleResponsables != null && fila.DetalleResponsables.Count > 0)
                        {
                            if (fila.DetalleResponsables[0] != null && fila.DetalleResponsables[0].Responsables != null)
                            {
                                if (fila.DetalleResponsables[0].Responsables.Count > 0)
                                {
                                    var traductores = (from q in fila.DetalleResponsables[0].Responsables
                                                       where q.TipoFuncion.ToLower().Contains("traductor") || q.TipoFuncion.ToLower().Contains("traducción")
                                                       select q).ToList();
                                    if (traductores != null && traductores.Count > 0)
                                    {
                                        if (traductores.Count > 1)
                                        {
                                            labelTrad.Text = traductores[0].NombreCompletoResponsable + " ...";
                                        }
                                        else
                                        {
                                            labelTrad.Text = traductores[0].NombreCompletoResponsable;
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        catch (System.Exception ex)
        {
            throw ex;
        }
    }
    private void CargarTitulo(int idTitulo)
    {
        LibreriaController titulosBD   = new LibreriaController();
        TituloLibreriaView titulo      = titulosBD.CargarPorId(idTitulo);
        string             stringDummy = string.Empty;

        if (titulo != null)
        {
            this.Title                 = titulo.Titulo;
            this.HiddenId.Value        = titulo.IdTitulo.ToString();
            this.ImagenTitulo.ImageUrl = titulo.RutaArchivo;
            this.LabelTitulo.Text      = string.Format("{0} (<i>{1}</i>) , {2}", titulo.Titulo, titulo.TituloOriginal, titulo.AnioPublicacion);
            if (titulo.Autor != null)
            {
                stringDummy = (!string.IsNullOrEmpty(titulo.Autor.NombreLatin)) ? titulo.Autor.NombreLatin : titulo.Autor.NombreGriego;
                //this.LabelAutor.Text = string.Format("{0} ({1})", titulo.Autor.NombreEspanol, stringDummy);
                this.LabelAutor.Text = string.Format("{0}", titulo.Autor.NombreEspanol);
                this.bAutor.Visible  = (!string.IsNullOrEmpty(titulo.Autor.NombreEspanol));
            }
            else
            {
                this.LabelAutor.Text = "";
                this.bAutor.Visible  = false;
            }

            if (titulo.Editor != null)
            {
                this.LabelEditor.Text = string.Format("{0} ", titulo.Editor.Nombre);
                this.bEditor.Visible  = (!string.IsNullOrEmpty(titulo.Editor.Nombre));
            }
            else
            {
                this.bEditor.Visible = false;
            }

            //this.LabelPaginas.Text = string.Format(" Paginas: {0}  {1}", titulo.Paginas, titulo.Medidas);
            this.LabelTema.Text          = titulo.Tema;
            this.bTema.Visible           = (!string.IsNullOrEmpty(titulo.Tema));
            this.LabelContenido.Text     = titulo.Contenido;
            this.bContenido.Visible      = (!string.IsNullOrEmpty(titulo.Contenido));
            this.LabelColofon.Text       = titulo.Colofon;
            this.bColofon.Visible        = (!string.IsNullOrEmpty(titulo.Colofon));
            this.LabelObservaciones.Text = titulo.Observaciones;
            this.bObservaciones.Visible  = (!string.IsNullOrEmpty(titulo.Observaciones));
            this.LabelCiudad.Text        = (titulo.Ciudad != null) ? titulo.Ciudad.Descripcion : string.Empty;
            this.bCiudad.Visible         = (!string.IsNullOrEmpty((titulo.Ciudad != null) ? (titulo.Ciudad.Descripcion) : string.Empty));
            this.LabelCualidades.Text    = titulo.Cualidades;
            this.bCualidades.Visible     = (!string.IsNullOrEmpty(titulo.Cualidades));

            if (titulo.NumeroEdicion > 0)
            {
                this.LabelEdicion.Text = string.Format("<b>Edición:</b> {0} <sup><u>a</u></sup>.", titulo.NumeroEdicion);
                this.bEdicion.Visible  = true;
            }
            else
            {
                this.LabelEdicion.Text = " - ";
                this.bEdicion.Visible  = false;
            }

            //this.LabelEdicion.Text = string.Format("{0}{1}{2}", LibreriaController.ObtenerNumeroEdicion(titulo.NumeroEdicion), (titulo.NumeroReimpresion > 0 ? ",":string.Empty), LibreriaController.ObtenerNumeroReimpresion(titulo.NumeroReimpresion));
            this.Label_UffYL.Text      = titulo.UffYL;
            this.bUFFYL.Visible        = (!string.IsNullOrEmpty(titulo.UffYL));
            this.Label_UiiFL.Text      = titulo.UiiFL;
            this.bUIIFL.Visible        = (!string.IsNullOrEmpty(titulo.UiiFL));
            this.bFlagLatin.Visible    = (titulo.IsLatin | titulo.IsGriego);
            this.RadioIsLatin.Checked  = titulo.IsLatin;
            this.RadioIsGriego.Checked = titulo.IsGriego;

            if (titulo.DetalleIsbn != null && titulo.DetalleIsbn.Count > 0)
            {
                foreach (Isbn item in titulo.DetalleIsbn)
                {
                    string edicion   = (item.Edicion > 0) ? ", " + item.Edicion + "<sup><u>a</u></sup>" + " ed." : "";
                    string reedicion = (item.Reedicion > 0) ? ", " + item.Reedicion + "<sup><u>a</u></sup>" + " reed." : "";
                    string reimp     = (item.Reimpresion > 0) ? ", " + item.Reimpresion + "<sup><u>a</u></sup>" + " reimpr." : "";
                    string ediciones = edicion + reedicion + reimp;

                    if (item.IdDescripcion > 0)
                    {
                        this.LabelIsbn.Text += item.ClaveIsbn + " (" + item.DescripcionVersion + ediciones + ")" + "<br/>";
                    }
                    else
                    {
                        this.LabelIsbn.Text += item.ClaveIsbn + (ediciones.Length > 0 ? "(" + ediciones + ")": "") + "<br/>";
                    }
                }
                this.LabelIsbn.Visible = true;
            }
            else
            {
                this.LabelIsbn.Text    = string.Empty;
                this.LabelIsbn.Visible = false;
            }

            if (titulo.DetalleResponsables != null && titulo.DetalleResponsables.Count > 0)
            {
                ResponsableTituloView resp = titulo.DetalleResponsables[0];
                foreach (ResponsableTituloDetail item in resp.Responsables)
                {
                    this.LabelResponsables.Text += string.Format("{0}  ({1}) {2}", item.NombreCompletoResponsable, item.TipoFuncion, "<br/>");
                }
                this.LabelResponsables.Visible = true;
            }
            else
            {
                this.LabelResponsables.Text    = string.Empty;
                this.LabelResponsables.Visible = false;
            }

            if (!string.IsNullOrEmpty(titulo.UrlPdf))
            {
                this.ImagenPdf.Visible = true;
                this.ImagenPdf.Attributes.Add("data-url", titulo.UrlPdf);
                this.ImagenPdf.Attributes.Add("onclick", "onSelectedResource('pdf','" + titulo.UrlPdf + "')");
            }
            if (!string.IsNullOrEmpty(titulo.UrlVirtual))
            {
                this.ImageVirtual.Visible = true;
                this.ImageVirtual.Attributes.Add("data-url", titulo.UrlVirtual);
                this.ImageVirtual.Attributes.Add("onclick", "onSelectedResource('virtual','" + titulo.UrlVirtual + "')");
            }
            if (!string.IsNullOrEmpty(titulo.UrlOnline))
            {
                this.ImageOnline.Visible = true;
                this.ImageOnline.Attributes.Add("data-url", titulo.UrlOnline);
                this.ImageOnline.Attributes.Add("onclick", "onSelectedResource('online','" + titulo.UrlOnline + "')");
            }
        }
        else
        {
            this.ImagenTitulo.Visible = false;
            this.ImagenPdf.Visible    = false;
            this.ImageVirtual.Visible = false;
            this.ImageOnline.Visible  = false;
        }
    }