protected void eliminarBtn_Click(object sender, EventArgs e)
        {
            Resultado resultado = new Resultado();

            try
            {
                LinkButton link = new LinkButton();
                link = (LinkButton)sender;

                img.Tag    = "ELIMINAR";
                img.Codigo = Convert.ToInt32(link.CommandName);
                resultado  = new ImagenLogica().Acciones(img);
                if (resultado.TipoResultado == "OK")
                {
                    ListarRegistro();
                    string script = "swal('Excelente', 'La imagen se borró con éxito', 'success'); ";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, true);
                }
            }
            catch (Exception ex)
            {
                string script = "swal('Error', '" + ex + "', 'error'); ";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, true);
            }
        }
        private void ListarPertenencia()
        {
            Resultado resultado = new Resultado();

            try
            {
                List <string> lista1 = new List <string>();
                List <string> lista2 = new List <string>();
                List <object> lista3 = new List <object>();
                resultado = new ImagenLogica().ObtenerPertenencia();
                if (resultado.TipoResultado == "OK")
                {
                    lista3 = (List <object>)resultado.ObjetoResultado;
                    lista1 = (List <string>)lista3[0];
                    lista2 = (List <string>)lista3[1];

                    foreach (string item in lista1)
                    {
                        pertenece.Items.Add(item);
                    }

                    foreach (string item in lista2)
                    {
                        duenos.Items.Add(item);
                    }
                }
            }
            catch (Exception ex)
            {
                string script = "swal('Error', '" + ex + "', 'error'); ";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, true);
            }
        }
Пример #3
0
        private void ListarRegistro()
        {
            Resultado     resultado = new Resultado();
            Imagen        img       = new Imagen();
            List <Imagen> lista     = new List <Imagen>();

            try
            {
                img.Tag       = "LISTADOESPECIFICO";
                img.Pertenece = "Pagina Principal";
                resultado     = new ImagenLogica().Acciones(img);
                if (resultado.TipoResultado == "OK")
                {
                    lista = new List <Imagen>();
                    lista = (List <Imagen>)resultado.ObjetoResultado;
                    galeria.DataSource = lista;
                    galeria.DataBind();


                    //imagenesList.DataSource = lista;
                    //imagenesList.DataBind();
                }
            }
            catch (Exception ex)
            {
                string script = "swal('Error', '" + ex + "', 'error'); ";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, true);
            }
        }
        private void MostrarBaner()
        {
            Resultado     resultado = new Resultado();
            Imagen        img       = new Imagen();
            List <Imagen> lista     = new List <Imagen>();

            try
            {
                img.Tag       = "LISTADOESCUELA";
                img.Pertenece = "Baner Escuela";
                img.Dueño     = nombreEscuela;

                resultado = new ImagenLogica().Acciones(img);
                if (resultado.TipoResultado == "OK")
                {
                    lista = (List <Imagen>)resultado.ObjetoResultado;
                    banerImg.DataSource = lista;
                    banerImg.DataBind();
                }
            }
            catch (Exception ex)
            {
                string script = "swal('Error', '" + ex + "', 'error'); ";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, true);
            }
        }
        private void Guardar()
        {
            Resultado resultado = new Resultado();

            try
            {
                img.Tag       = "INSERTAR";
                img.Aprobado  = true;
                img.Titulo    = txtTitulo.Text;
                img.Leyenda   = txtLeyenda.Text;
                img.Pertenece = pertenece.SelectedValue;
                img.Dueño     = duenos.SelectedValue.ToUpper();

                string base64ImageRepresentation = Convert.ToBase64String(FileUpload.FileBytes);
                img.Imgs = base64ImageRepresentation;

                resultado = new ImagenLogica().Acciones(img);

                if (resultado.TipoResultado == "OK")
                {
                    ListarRegistro();
                    string script = "swal('Excelente', 'Éxito en la insersión', 'success'); ";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, true);
                }
                else
                {
                    string script = "swal('Lo sentimos, ha ocurrido un error', '" + resultado.Mensaje + "', 'error'); ";
                    ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, true);
                }
            }
            catch (Exception ex)
            {
                string script = "swal('Error', '" + ex + "', 'error'); ";
                ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, true);
            }
        }