Exemple #1
0
        public string Insertar_ave(string nombreComun, string nombreCientifico, string descripcion, int tipo, int clase_dieta, int dieta, int comportamiento, int habitat, int reproduccion, int origen, int especie, int color_plumaje, int tamaño_ave)
        {
            tbl_Ave                tblAv   = new tbl_Ave();
            tbl_Tipo_ave           tblTp   = new tbl_Tipo_ave();
            tbl_Clase_dieta        tblCld  = new tbl_Clase_dieta();
            tbl_Dieta              tbldt   = new tbl_Dieta();
            tbl_Comportamiento_ave tblComp = new tbl_Comportamiento_ave();
            tbl_Habitat_ave        tblHab  = new tbl_Habitat_ave();
            tbl_Reproduccion_ave   tblRp   = new tbl_Reproduccion_ave();
            tbl_Origen_ave         tblOv   = new tbl_Origen_ave();
            tbl_Especie_ave        tblEsp  = new tbl_Especie_ave();
            tbl_Estado_ave         tblEst  = new tbl_Estado_ave();
            tbl_Tamaño_ave         tblTm   = new tbl_Tamaño_ave();
            tbl_Color_plumaje      tblCp   = new tbl_Color_plumaje();

            tblAv.Nombre_cientifico       = nombreCientifico;
            tblAv.Nombre_comun            = nombreComun;
            tblAv.Descripcion             = descripcion;
            tblTp.id_Tipo_ave             = tipo;
            tblCld.id_Clase_dieta         = clase_dieta;
            tbldt.id_Dieta                = dieta;
            tblComp.id_Comportamiento_ave = comportamiento;
            tblHab.id_Habitat_ave         = habitat;
            tblRp.id_Reproduccion_ave     = reproduccion;
            tblOv.id_Origen_ave           = origen;
            tblEsp.id_Especie_ave         = especie;
            tblTm.id_Tamaño_ave           = tamaño_ave;
            tblCp.id_Color_plumaje        = color_plumaje;
            tblEst.id_Estado_ave          = new tbl_Estado_aveCAD().Buscar_Estado_ave("Espera");
            return(new tbl_AveCAD().insertar_ave(tblAv, tblEst, tblEsp, tblOv, tblTp, tblCld, tbldt, tblComp, tblHab, tblRp, tblCp, tblTm));
        }
Exemple #2
0
        public string Insertar_imagen_ave(string imagen, string nombreCientifico, string nombreComun, int especie)
        {
            tbl_Ave tblAv = new tbl_Ave();

            tblAv.Nombre_cientifico = nombreCientifico;
            tblAv.Nombre_comun      = nombreComun;
            tblAv.id_Especie_ave    = especie;
            tbl_Fotos_aves tblfA = new tbl_Fotos_aves();

            tblfA.id_Aves    = new tbl_AveCAD().Buscar_id_ave(tblAv);
            tblfA.Fotos_aves = nombreCientifico + ".txt";

            string       fil  = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Ave/" + nombreCientifico + ".txt");
            StreamWriter file = new StreamWriter(fil);

            file.WriteLine(imagen);
            file.Close();
            Boolean foto    = System.IO.File.Exists(fil);
            string  mensaje = "";

            if (foto)
            {
                mensaje = new tbl_Foto_avesCAD().insert_foto_aves(tblfA);
            }
            StreamReader sr = new StreamReader(fil);

            return(mensaje);
        }
Exemple #3
0
        public int Buscar_id_ave(tbl_Ave tblAv)
        {
            int id = 0;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = con;
                cmd.CommandText = "prc_Buscar_id_ave";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@a", tblAv.Nombre_comun);
                cmd.Parameters.AddWithValue("@nombreCi", tblAv.Nombre_cientifico);
                cmd.Parameters.AddWithValue("@id_especie", tblAv.id_Especie_ave);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                foreach (var item in dr)
                {
                    id = int.Parse(dr["id_ave"].ToString());
                }
                con.Close();
            }
            catch (Exception)
            {
                throw;
            }
            return(id);
        }
Exemple #4
0
        public List <tbl_Fotos_aves> Buscar_fotos_aves(tbl_Ave av)
        {
            List <tbl_Fotos_aves> list = new List <tbl_Fotos_aves>();

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = con;
                cmd.CommandText = "prc_Buscar_tbl_Fotos_aves_con_id_ave";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@id", av.id_Ave);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                foreach (var item in dr)
                {
                    tbl_Fotos_aves fa = new tbl_Fotos_aves();
                    fa.id_Fotos_aves = int.Parse(dr["id_foto_ave"].ToString());
                    fa.Fotos_aves    = dr["foto_ave"].ToString();
                    list.Add(fa);
                }
                con.Close();
            }
            catch (Exception)
            {
                throw;
            }
            return(list);
        }
Exemple #5
0
        public bool buscar_Ave_con_nombreCientifico(tbl_Ave tblAv)
        {
            bool existe = false;

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = con;
                cmd.CommandText = "prc_Buscar_ave_nombreCient";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@nombreCient", tblAv.Nombre_cientifico);
                con.Open();
                SqlDataReader dr = cmd.ExecuteReader();
                int           id = 0;
                foreach (var item in dr)
                {
                    id = int.Parse(dr["id_ave"].ToString());
                }
                if (id != 0)
                {
                    existe = true;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(existe);
        }
Exemple #6
0
        public List <tbl_Fotos_aves> Llamar_fotos_aves(String idAve)
        {
            tbl_Ave ar = new tbl_Ave();

            ar.id_Ave = int.Parse(idAve);
            List <tbl_Fotos_aves> listaFo = new List <tbl_Fotos_aves>();
            List <tbl_Fotos_aves> listaF  = new tbl_Foto_avesCAD().Buscar_fotos_aves(ar);

            foreach (var item in listaF)
            {
                String fil    = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Ave/" + item.Fotos_aves);
                bool   existe = File.Exists(fil);
                if (existe)
                {
                    tbl_Fotos_aves fa         = new tbl_Fotos_aves();
                    StreamReader   img        = new StreamReader(fil);
                    string         imagenes   = img.ReadLine();
                    String[]       arregloimg = imagenes.Split('~');
                    for (int i = 0; i < arregloimg.Length - 1; i++)
                    {
                        fa.Fotos_aves    = arregloimg[i];
                        fa.id_Fotos_aves = item.id_Fotos_aves;
                        listaFo.Add(fa);
                    }
                }
            }
            return(listaFo);
        }
Exemple #7
0
        public string[] Cargar_ave(string NombreCientifico)
        {
            tbl_Ave ave = new tbl_Ave();

            ave.Nombre_cientifico = NombreCientifico;
            HttpContext.Current.Session["ave"] = NombreCientifico;
            return(new tbl_AveCAD().Buscar_ave_nombre_cientifico(ave));
        }
Exemple #8
0
        public string Eliminar_favoritos(String nombreCientifico)
        {
            tbl_Usuario us    = new tbl_Usuario();
            tbl_Ave     tblAv = new tbl_Ave();

            tblAv.Nombre_cientifico = nombreCientifico;
            us.id_usuario           = new tbl_UsuarioCAD().Buscar_id_usu(HttpContext.Current.Session["Correo"].ToString());
            int ave = new tbl_AveCAD().Buscar_id_ave_cient(tblAv);

            return(new tbl_Favoritos_aveCAD().Eliminar_ave(ave, us.id_usuario));
        }
Exemple #9
0
        public string Agregar_favoritos(string nombreCientifico)
        {
            tbl_Ave tblAv = new tbl_Ave();

            tblAv.Nombre_cientifico = nombreCientifico;
            tblAv.id_Ave            = new tbl_AveCAD().Buscar_id_ave_cient(tblAv);
            int idusu = new tbl_UsuarioCAD().Buscar_id_usu(HttpContext.Current.Session["Correo"].ToString());
            int idAve = new tbl_AveCAD().Buscar_id_ave_cient(tblAv);

            return(new tbl_Favoritos_aveCAD().agregar_ave(idAve, idusu));
        }
Exemple #10
0
        public String Buscar_ave_con_nombreCientifico(string nombreCientifico)
        {
            tbl_Ave tblAv = new tbl_Ave();

            tblAv.Nombre_cientifico = nombreCientifico;
            string mensaje;
            bool   existe = new tbl_AveCAD().buscar_Ave_con_nombreCientifico(tblAv);

            if (existe)
            {
                mensaje = "El ave ya esta guardado, por favor valida la información.";
            }
            else
            {
                mensaje = "Correcto";
            }
            return(mensaje);
        }
Exemple #11
0
 public String[] Buscar_ave_nombre_cientifico(tbl_Ave av)
 {
     String[] Save = new String[22];
     try
     {
         SqlCommand cmd = new SqlCommand();
         cmd.Connection  = con;
         cmd.CommandText = "prc_Buscar_tbl_Ave_nombreCient";
         cmd.CommandType = System.Data.CommandType.StoredProcedure;
         cmd.Parameters.AddWithValue("@nombreCient", av.Nombre_cientifico);
         con.Open();
         SqlDataReader dr = cmd.ExecuteReader();
         foreach (var item in dr)
         {
             Save[0]  = dr["id_ave"].ToString();
             Save[1]  = dr["nom_cient_ave"].ToString();
             Save[2]  = dr["nom_com_ave"].ToString();
             Save[3]  = dr["desc_ave"].ToString();
             Save[4]  = dr["id_estado_ave"].ToString();
             Save[5]  = dr["id_dominio_ave"].ToString();
             Save[6]  = dr["id_reino_ave"].ToString();
             Save[7]  = dr["id_filum_ave"].ToString();
             Save[8]  = dr["id_dieta_ave"].ToString();
             Save[9]  = dr["id_orden_ave"].ToString();
             Save[10] = dr["id_familia_ave"].ToString();
             Save[11] = dr["id_genero_ave"].ToString();
             Save[12] = dr["id_especie_ave"].ToString();
             Save[13] = dr["id_origen_ave"].ToString();
             Save[14] = dr["id_tipo_ave"].ToString();
             Save[15] = dr["id_comportamiento_ave"].ToString();
             Save[16] = dr["id_habitat_ave"].ToString();
             Save[17] = dr["id_reproduccion_ave"].ToString();
             Save[18] = dr["id_color_plumaje"].ToString();
             Save[19] = dr["id_tamaño_ave"].ToString();
             Save[20] = dr["id_clase_dieta"].ToString();
             Save[21] = dr["id_clase_ave"].ToString();
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(Save);
 }
Exemple #12
0
        public String Modificar_ave(tbl_Ave tblAv, tbl_Estado_ave tblEst, tbl_Especie_ave tblEpa, tbl_Origen_ave tblOra, tbl_Tipo_ave tblTa, tbl_Clase_dieta tblCld, tbl_Dieta tblD, tbl_Comportamiento_ave tblComp, tbl_Habitat_ave tblHbt, tbl_Reproduccion_ave tblRp, tbl_Color_plumaje tblCpl, tbl_Tamaño_ave tblTma)
        {
            String mensaje = "Error al modificar, porfavor intenta de nuevo";

            try
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection  = con;
                cmd.CommandText = "prc_UPDATE_tbl_Ave";
                cmd.CommandType = System.Data.CommandType.StoredProcedure;
                cmd.Parameters.AddWithValue("@idAve", tblAv.id_Ave);
                cmd.Parameters.AddWithValue("@nombre_cientifico", tblAv.Nombre_cientifico);
                cmd.Parameters.AddWithValue("@nombre_comun", tblAv.Nombre_comun);
                cmd.Parameters.AddWithValue("@descripcion", tblAv.Descripcion);
                cmd.Parameters.AddWithValue("@idTipo", tblTa.id_Tipo_ave);
                cmd.Parameters.AddWithValue("@idDieta", tblD.id_Dieta);
                cmd.Parameters.AddWithValue("@idComportamiento", tblComp.id_Comportamiento_ave);
                cmd.Parameters.AddWithValue("@idHabitat", tblHbt.id_Habitat_ave);
                cmd.Parameters.AddWithValue("@idReproduccion", tblRp.id_Reproduccion_ave);
                cmd.Parameters.AddWithValue("@idEstado", tblEst.id_Estado_ave);
                cmd.Parameters.AddWithValue("@idOrigen", tblOra.id_Origen_ave);
                cmd.Parameters.AddWithValue("@idEspecie", tblEpa.id_Especie_ave);
                cmd.Parameters.AddWithValue("@idTamaño", tblTma.id_Tamaño_ave);
                cmd.Parameters.AddWithValue("@idColor", tblCpl.id_Color_plumaje);
                con.Open();
                int rows = cmd.ExecuteNonQuery();
                con.Close();
                if (rows != 0)
                {
                    mensaje = "Modificado correctamente";
                }
            }
            catch (Exception e)
            {
                mensaje = e.Message;
            }
            return(mensaje);
        }
Exemple #13
0
        public string Modificar_foto_ave(String imagen)
        {
            tbl_Ave tblAv = new tbl_Ave();

            tblAv.Nombre_cientifico = HttpContext.Current.Session["ave"].ToString();
            tbl_Fotos_aves tblfA = new tbl_Fotos_aves();
            Random         rn    = new Random();

            tblfA.id_Aves    = new tbl_AveCAD().Buscar_id_ave_cient(tblAv);
            tblfA.Fotos_aves = tblAv.Nombre_cientifico + rn.Next(1, 9999) + ".txt";
            string       fil  = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Ave/" + tblfA.Fotos_aves);
            StreamWriter file = new StreamWriter(fil);

            file.WriteLine(imagen);
            file.Close();
            Boolean foto    = System.IO.File.Exists(fil);
            string  mensaje = "";

            if (foto)
            {
                mensaje = new tbl_Foto_avesCAD().Modificar_foto_aves(tblfA);
            }
            return(mensaje);
        }