Ejemplo n.º 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                GaleriaDAL gDAL = new GaleriaDAL();

                switch (Request.QueryString["act"])
                {
                case "exc":
                    Galeria g = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));
                    gDAL.Excluir(g);
                    Response.Write("<script language='JavaScript'>alert('Galeria excluída com sucesso');location='ListarGalerias.aspx';</script>");
                    break;

                default:
                    break;
                }

                // LISTA AS GALERIAS //
                rptGalerias.DataSource = gDAL.Listar();
                rptGalerias.DataBind();
                // FIM //
            }
            catch (Exception)
            { throw; }
        }
Ejemplo n.º 2
0
        protected void Cadastrar(object sender, EventArgs e)
        {
            try
            {
                Galeria g = new Galeria();

                g.DSGaleria = Util.formataTexto(txtDescricao.Text, false);

                if (radAtiva_N.Checked)
                {
                    g.BTAtiva = false;
                }
                else
                {
                    g.BTAtiva = true;
                }

                GaleriaDAL gDAL = new GaleriaDAL();
                gDAL.Cadastrar(g);

                Response.Write("<script language='JavaScript'>alert('Galeria cadastrada com sucesso');window.parent.location='ListarGalerias.aspx';</script>");
            }
            catch (Exception)
            { throw; }
        }
Ejemplo n.º 3
0
        protected void Alterar(object sender, EventArgs e)
        {
            try
            {
                GaleriaDAL gDAL = new GaleriaDAL();
                Galeria    g    = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));

                g.DSGaleria = Util.formataTexto(txtDescricao.Text, false);

                if (radAtiva_N.Checked)
                {
                    g.BTAtiva = false;
                }
                else
                {
                    g.BTAtiva = true;
                }

                gDAL.Alterar(g);

                Response.Write("<script language='JavaScript'>alert('Galeria alterada com sucesso');window.parent.location='ListarGalerias.aspx';</script>");
            }
            catch (Exception)
            { throw; }
        }
Ejemplo n.º 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    GaleriaDAL gDAL = new GaleriaDAL();
                    Galeria    g    = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));

                    txtDescricao.Text = g.DSGaleria;

                    if (g.BTAtiva == true)
                    {
                        radAtiva_N.Checked = false;
                        radAtiva_S.Checked = true;
                    }
                    else
                    {
                        radAtiva_N.Checked = true;
                        radAtiva_S.Checked = false;
                    }
                }
            }
            catch (Exception)
            { throw; }
        }
Ejemplo n.º 5
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         // LISTA AS GALERIAS //
         GaleriaDAL gDAL = new GaleriaDAL();
         rptGalerias.DataSource = gDAL.Listar().Cast <Galeria>().OrderByDescending(i => i.IDGaleria);
         rptGalerias.DataBind();
         // FIM //
     }
     catch (Exception)
     { throw; }
 }
Ejemplo n.º 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    GaleriaDAL gDAL = new GaleriaDAL();
                    Galeria    g    = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));

                    litDescricao.Text = g.DSGaleria;

                    // LISTA AS FOTOS DA GALERIA //
                    FotoGaleriaDAL fgDAL = new FotoGaleriaDAL();
                    rptFotosGaleria.DataSource = fgDAL.Listar().Cast <FotoGaleria>().Where(gl => gl.Galeria.IDGaleria == g.IDGaleria);
                    rptFotosGaleria.DataBind();
                    // FIM //
                }
            }
            catch (Exception)
            { throw; }
        }
Ejemplo n.º 7
0
        protected void Cadastrar(object sender, EventArgs e)
        {
            try
            {
                FotoGaleriaDAL fgDAL = new FotoGaleriaDAL();
                GaleriaDAL     gDAL  = new GaleriaDAL();

                #region FOTO 1
                if (txtFoto1.HasFile)
                {
                    switch (txtFoto1.FileName.Substring(txtFoto1.FileName.Length - 4))
                    {
                    case ".jpg":

                        FotoGaleria fg_1 = new FotoGaleria();
                        fg_1.Galeria       = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));
                        fg_1.DSArquivoFoto = "-";

                        fgDAL.Cadastrar(fg_1);

                        FotoGaleria fgUltimo = fgDAL.ObterDadosUltimoCadastrado();

                        string strNome;

                        strNome = fgUltimo.IDFotoGaleria + txtFoto1.FileName.Substring(txtFoto1.FileName.Length - 4);
                        fgUltimo.DSArquivoFoto = strNome;

                        txtFoto1.SaveAs(ConfigurationManager.AppSettings["path"] + @"\Galerias\" + strNome);

                        fgDAL.Alterar(fgUltimo);

                        break;

                    default:
                        break;
                    }
                }
                #endregion

                #region FOTO 2
                if (txtFoto2.HasFile)
                {
                    switch (txtFoto2.FileName.Substring(txtFoto2.FileName.Length - 4))
                    {
                    case ".jpg":

                        FotoGaleria fg_2 = new FotoGaleria();
                        fg_2.Galeria       = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));
                        fg_2.DSArquivoFoto = "-";

                        fgDAL.Cadastrar(fg_2);

                        FotoGaleria fgUltimo = fgDAL.ObterDadosUltimoCadastrado();

                        string strNome;

                        strNome = fgUltimo.IDFotoGaleria + txtFoto2.FileName.Substring(txtFoto2.FileName.Length - 4);
                        fgUltimo.DSArquivoFoto = strNome;

                        txtFoto2.SaveAs(ConfigurationManager.AppSettings["path"] + @"\Galerias\" + strNome);

                        fgDAL.Alterar(fgUltimo);

                        break;

                    default:
                        break;
                    }
                }
                #endregion

                #region FOTO 3
                if (txtFoto3.HasFile)
                {
                    switch (txtFoto3.FileName.Substring(txtFoto3.FileName.Length - 4))
                    {
                    case ".jpg":

                        FotoGaleria fg_3 = new FotoGaleria();
                        fg_3.Galeria       = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));
                        fg_3.DSArquivoFoto = "-";

                        fgDAL.Cadastrar(fg_3);

                        FotoGaleria fgUltimo = fgDAL.ObterDadosUltimoCadastrado();

                        string strNome;

                        strNome = fgUltimo.IDFotoGaleria + txtFoto3.FileName.Substring(txtFoto3.FileName.Length - 4);
                        fgUltimo.DSArquivoFoto = strNome;

                        txtFoto3.SaveAs(ConfigurationManager.AppSettings["path"] + @"\Galerias\" + strNome);

                        fgDAL.Alterar(fgUltimo);

                        break;

                    default:
                        break;
                    }
                }
                #endregion

                #region FOTO 4
                if (txtFoto4.HasFile)
                {
                    switch (txtFoto4.FileName.Substring(txtFoto4.FileName.Length - 4))
                    {
                    case ".jpg":

                        FotoGaleria fg_3 = new FotoGaleria();
                        fg_3.Galeria       = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));
                        fg_3.DSArquivoFoto = "-";

                        fgDAL.Cadastrar(fg_3);

                        FotoGaleria fgUltimo = fgDAL.ObterDadosUltimoCadastrado();

                        string strNome;

                        strNome = fgUltimo.IDFotoGaleria + txtFoto4.FileName.Substring(txtFoto4.FileName.Length - 4);
                        fgUltimo.DSArquivoFoto = strNome;

                        txtFoto4.SaveAs(ConfigurationManager.AppSettings["path"] + @"\Galerias\" + strNome);

                        fgDAL.Alterar(fgUltimo);

                        break;

                    default:
                        break;
                    }
                }
                #endregion

                #region FOTO 5
                if (txtFoto5.HasFile)
                {
                    switch (txtFoto5.FileName.Substring(txtFoto5.FileName.Length - 4))
                    {
                    case ".jpg":

                        FotoGaleria fg_3 = new FotoGaleria();
                        fg_3.Galeria       = gDAL.ObterDadosPorId(Convert.ToInt32(Request.QueryString["idGlr"]));
                        fg_3.DSArquivoFoto = "-";

                        fgDAL.Cadastrar(fg_3);

                        FotoGaleria fgUltimo = fgDAL.ObterDadosUltimoCadastrado();

                        string strNome;

                        strNome = fgUltimo.IDFotoGaleria + txtFoto5.FileName.Substring(txtFoto5.FileName.Length - 4);
                        fgUltimo.DSArquivoFoto = strNome;

                        txtFoto5.SaveAs(ConfigurationManager.AppSettings["path"] + @"\Galerias\" + strNome);

                        fgDAL.Alterar(fgUltimo);

                        break;

                    default:
                        break;
                    }
                }
                #endregion

                Response.Write("<script language='JavaScript'>alert('Foto(s) da Galeria cadastrada(s) com sucesso');window.location='FotosGaleria.aspx?idGlr=" + Request.QueryString["idGlr"] + "';</script>");
            }
            catch (Exception)
            { throw; }
        }