public List <tbl_Fotos_arboles> Llamar_fotos_arboles(String idArbol) { tbl_Arbol ar = new tbl_Arbol(); ar.id_arbol = int.Parse(idArbol); List <tbl_Fotos_arboles> listaFo = new List <tbl_Fotos_arboles>(); List <tbl_Fotos_arboles> listaF = new tbl_Foto_arbolesCAD().Buscar_fotos(ar); foreach (var item in listaF) { String fil = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Arbol/" + item.foto_arbol); bool existe = File.Exists(fil); if (existe) { tbl_Fotos_arboles fa = new tbl_Fotos_arboles(); StreamReader img = new StreamReader(fil); string imagenes = img.ReadLine(); String[] arregloimg = imagenes.Split('~'); for (int i = 0; i < arregloimg.Length - 1; i++) { fa.foto_arbol = arregloimg[i]; listaFo.Add(fa); } } } return(listaFo); }
public int Buscar_id_arbol(tbl_Arbol tblAr) { int id = 0; try { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; //cmd.CommandText = "SELECT * FROM tbl_Arbol WHERE nom_cient_arbol=" + tblAr.nom_cient_arbol + " AND nom_com_arbol=" + tblAr.nom_com_arbol + " AND id_especie_arbol =" + tblAr.id_especie_arbol + ";"; //cmd.CommandType = System.Data.CommandType.Text; cmd.CommandText = "prc_Buscar_id_arbol"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@a", tblAr.nom_com_arbol); cmd.Parameters.AddWithValue("@nombreCi", tblAr.nom_cient_arbol); cmd.Parameters.AddWithValue("@id_especie", tblAr.id_especie_arbol); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); foreach (var item in dr) { id = int.Parse(dr["id_arbol"].ToString()); } con.Close(); } catch (Exception) { throw; } return(id); }
public bool buscar_Arbol_con_nombreCientifico(tbl_Arbol tblAr) { bool existe = false; try { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "prc_Buscar_arbol_nombreCient"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@nombreCient", tblAr.nom_cient_arbol); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); int id = 0; foreach (var item in dr) { id = int.Parse(dr["id_arbol"].ToString()); } if (id != 0) { existe = true; } } catch (Exception) { throw; } return(existe); }
public List <tbl_Fotos_arboles> Buscar_fotos(tbl_Arbol ar) { List <tbl_Fotos_arboles> lista = new List <tbl_Fotos_arboles>(); try { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "prc_Buscar_tbl_Fotos_arboles_con_id_arbol"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@id", ar.id_arbol); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); foreach (var item in dr) { tbl_Fotos_arboles fa = new tbl_Fotos_arboles(); fa.foto_arbol = dr["foto_arbol"].ToString(); fa.id_arbol = int.Parse(dr["id_foto_arbol"].ToString()); lista.Add(fa); } con.Close(); } catch (Exception) { throw; } return(lista); }
public string Insertar_imagen_arbol(string imagen, string nombreCientifico, string nombreComun, int especie) { tbl_Arbol tblAr = new tbl_Arbol(); tblAr.nom_cient_arbol = nombreCientifico; tblAr.nom_com_arbol = nombreComun; tblAr.id_especie_arbol = especie; tbl_Fotos_arboles tblfA = new tbl_Fotos_arboles(); tblfA.id_arbol = new tbl_ArbolCAD().Buscar_id_arbol(tblAr); tblfA.foto_arbol = nombreCientifico + ".txt"; string fil = HttpContext.Current.Server.MapPath(@"~/images/Fotos_Arbol/" + nombreCientifico + ".txt"); System.IO.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_arbolesCAD().insert_foto_arboles(tblfA); } StreamReader sr = new StreamReader(fil); return(mensaje); //return new tbl_Foto_arbolesCAD().insert_foto_arboles(tblfA); }
public string Agregar_favoritos(string nombreCientifico) { tbl_Arbol tblAr = new tbl_Arbol(); tblAr.nom_cient_arbol = nombreCientifico; int idusu = new tbl_UsuarioCAD().Buscar_id_usu(HttpContext.Current.Session["Correo"].ToString()); int idAr = new tbl_ArbolCAD().Buscar_id_arbol_cient(tblAr); return(new tbl_Favoritos_arbolCAD().agregar_arbol(idAr, idusu)); }
public string Eliminar_favoritos(string nombreCientifico) { tbl_Usuario us = new tbl_Usuario(); tbl_Arbol tblAr = new tbl_Arbol(); tblAr.nom_cient_arbol = nombreCientifico; us.id_usuario = new tbl_UsuarioCAD().Buscar_id_usu(HttpContext.Current.Session["Correo"].ToString()); int arbol = new tbl_ArbolCAD().Buscar_id_arbol_cient(tblAr); return(new tbl_Favoritos_arbolCAD().Eliminar_arbol(arbol, us.id_usuario)); }
public String[] Buscar_arbol_nombre_cientifico(tbl_Arbol av) { String[] Save = new String[28]; try { SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "prc_SELECT_tbl_Arbol_nombre_cient"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@nombrecient", av.nom_cient_arbol); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); foreach (var item in dr) { Save[0] = dr["id_arbol"].ToString(); //0 Save[1] = dr["nom_cient_arbol"].ToString(); //1 Save[2] = dr["nom_com_arbol"].ToString(); //2 Save[3] = dr["desc_arbol"].ToString(); //3 Save[4] = dr["id_dominio_arbol"].ToString(); //4 Save[5] = dr["id_reino_arbol"].ToString(); //5 Save[6] = dr["id_division_arbol"].ToString(); //6 Save[7] = dr["id_clase_arbol"].ToString(); //7 Save[8] = dr["id_orden_arbol"].ToString(); //8 Save[9] = dr["id_familia_arbol"].ToString(); //9 Save[10] = dr["id_genero_arbol"].ToString(); //10 Save[11] = dr["id_especie_arbol"].ToString(); //11 Save[12] = dr["id_tipo_arbol"].ToString(); //12 Save[13] = dr["id_crecimiento"].ToString(); //13 Save[14] = dr["id_altura_arbol"].ToString(); //14 Save[15] = dr["id_diametro_arbol"].ToString(); //15 Save[16] = dr["id_amplitud_copa"].ToString(); //16 Save[17] = dr["id_forma_copa"].ToString(); //17 Save[18] = dr["id_persistencia_hoja"].ToString(); //18 Save[19] = dr["id_color_flor"].ToString(); //19 Save[20] = dr["id_color_hoja"].ToString(); //20 Save[21] = dr["id_estacion_de_floracion"].ToString(); //21 Save[22] = dr["id_limitaciones_arbol"].ToString(); //22 Save[23] = dr["id_limitaciones_fruto"].ToString(); //23 Save[24] = dr["id_longevidad_arbol"].ToString(); //24 Save[25] = dr["id_piso_termico"].ToString(); //25 Save[26] = dr["id_luminocidad_arbol"].ToString(); //26 Save[27] = dr["id_funcion_arbol"].ToString(); //27 } } catch (Exception) { throw; } return(Save); }
public string Buscar_arbol(string nombreCientifico) { tbl_Arbol tblAr = new tbl_Arbol(); tblAr.nom_cient_arbol = nombreCientifico; string mensaje; bool existe = new tbl_ArbolCAD().buscar_Arbol_con_nombreCientifico(tblAr); if (existe) { mensaje = "El árbol ya esta guardado, por favor valida la información."; } else { mensaje = "Correcto"; } return(mensaje); }
public int a(tbl_Arbol tblA) { int a = 0; SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "prc_Buscar_id_arbol"; cmd.CommandType = System.Data.CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@a", tblA.nom_com_arbol); cmd.Parameters.AddWithValue("@nombreCi", tblA.nom_cient_arbol); cmd.Parameters.AddWithValue("@id_especie", tblA.id_especie_arbol); con.Open(); SqlDataReader dr = cmd.ExecuteReader(); foreach (var item in dr) { a = int.Parse(dr["id_arbol"].ToString()); } return(a); }