Exemplo n.º 1
0
        public FotoGaleria ObterDadosPorId(int _IdFotoGaleria)
        {
            using (OleDbConnection objConn = new OleDbConnection(ConfigurationManager.ConnectionStrings["DBASANM"].ConnectionString))
            {
                try
                {
                    objConn.Open();

                    FotoGaleria fg = new FotoGaleria();

                    OleDbCommand cmd = new OleDbCommand("SELECT IDFotoGaleria,IDGaleria,DSArquivoFoto FROM TB_FotoGaleria WHERE IDFotoGaleria = @IDFotoGaleria", objConn);
                    cmd.Parameters.Add("@IDFotoGaleria", OleDbType.Integer).Value = _IdFotoGaleria;
                    OleDbDataReader dr = cmd.ExecuteReader();

                    GaleriaDAL gDAL = new GaleriaDAL();

                    if (dr.Read())
                    {
                        fg.IDFotoGaleria = Convert.ToInt32(dr["IDFotoGaleria"]);
                        fg.Galeria       = gDAL.ObterDadosPorId(Convert.ToInt32(dr["IDGaleria"]));
                        fg.DSArquivoFoto = dr["DSArquivoFoto"].ToString();
                    }

                    return(fg);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    objConn.Close();
                }
            }
        }
Exemplo n.º 2
0
        public Noticia ObterDadosUltimoCadastrado()
        {
            using (OleDbConnection objConn = new OleDbConnection(ConfigurationManager.ConnectionStrings["DBASANM"].ConnectionString))
            {
                try
                {
                    objConn.Open();

                    Noticia n = new Noticia();

                    OleDbCommand    cmd1 = new OleDbCommand("SELECT MAX(IDNoticia) AS IDNoticia FROM TB_Noticia", objConn);
                    OleDbDataReader dr1  = cmd1.ExecuteReader();

                    if (dr1.Read())
                    {
                        OleDbCommand    cmd2 = new OleDbCommand("SELECT IDNoticia,DSTitulo,DSCorpo,DSArquivoImagem,BTAtiva FROM TB_Noticia WHERE IDNoticia = " + dr1["IDNoticia"], objConn);
                        OleDbDataReader dr2  = cmd2.ExecuteReader();

                        GaleriaDAL gDAL = new GaleriaDAL();

                        if (dr2.Read())
                        {
                            n.IDNoticia       = Convert.ToInt32(dr2["IDNoticia"]);
                            n.DSTitulo        = dr2["DSTitulo"].ToString();
                            n.DSCorpo         = dr2["DSCorpo"].ToString();
                            n.DSArquivoImagem = dr2["DSArquivoImagem"].ToString();
                            n.BTAtiva         = Convert.ToBoolean(dr2["BTAtiva"]);
                        }
                    }

                    return(n);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    objConn.Close();
                }
            }
        }
Exemplo n.º 3
0
        public FotoGaleria ObterDadosUltimoCadastrado()
        {
            using (OleDbConnection objConn = new OleDbConnection(ConfigurationManager.ConnectionStrings["DBASANM"].ConnectionString))
            {
                try
                {
                    objConn.Open();

                    FotoGaleria fg = new FotoGaleria();

                    OleDbCommand    cmd1 = new OleDbCommand("SELECT MAX(IDFotoGaleria) AS IDFotoGaleria FROM TB_FotoGaleria", objConn);
                    OleDbDataReader dr1  = cmd1.ExecuteReader();

                    if (dr1.Read())
                    {
                        OleDbCommand    cmd2 = new OleDbCommand("SELECT IDFotoGaleria,IDGaleria,DSArquivoFoto FROM TB_FotoGaleria WHERE IDFotoGaleria = " + dr1["IDFotoGaleria"], objConn);
                        OleDbDataReader dr2  = cmd2.ExecuteReader();

                        GaleriaDAL gDAL = new GaleriaDAL();

                        if (dr2.Read())
                        {
                            fg.IDFotoGaleria = Convert.ToInt32(dr2["IDFotoGaleria"]);
                            fg.Galeria       = gDAL.ObterDadosPorId(Convert.ToInt32(dr2["IDGaleria"]));
                            fg.DSArquivoFoto = dr2["DSArquivoFoto"].ToString();
                        }
                    }

                    return(fg);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    objConn.Close();
                }
            }
        }
Exemplo n.º 4
0
        public IList Listar()
        {
            using (OleDbConnection objConn = new OleDbConnection(ConfigurationManager.ConnectionStrings["DBASANM"].ConnectionString))
            {
                try
                {
                    objConn.Open();

                    List <FotoGaleria> lst = new List <FotoGaleria>();

                    OleDbCommand    cmd = new OleDbCommand("SELECT IDFotoGaleria,IDGaleria,DSArquivoFoto FROM TB_FotoGaleria", objConn);
                    OleDbDataReader dr  = cmd.ExecuteReader();

                    GaleriaDAL gDAL = new GaleriaDAL();

                    while (dr.Read())
                    {
                        lst.Add(
                            new FotoGaleria()
                        {
                            IDFotoGaleria = Convert.ToInt32(dr["IDFotoGaleria"]),
                            Galeria       = gDAL.ObterDadosPorId(Convert.ToInt32(dr["IDGaleria"])),
                            DSArquivoFoto = dr["DSArquivoFoto"].ToString()
                        }
                            );
                    }

                    return(lst);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    objConn.Close();
                }
            }
        }