//Muestra la lista de genero public IEnumerable <CatGenero> ListaGeneros() { List <CatGenero> listGenero = new List <CatGenero>(); comando.Connection = conn.AbrirConexion(); comando.CommandText = "Listar_Genero"; comando.CommandType = CommandType.StoredProcedure; leer = comando.ExecuteReader(); while (leer.Read()) { CatGenero generos = new CatGenero() { IdGender = Convert.ToInt32(leer["ID_GENDER"]), Genero = leer["GENERO"].ToString(), GeneroCode = leer["GENERO_CODE"].ToString() }; listGenero.Add(generos); } leer.Close(); conn.CerrarConexion(); return(listGenero); }
public IEnumerable <CatGenero> ListarTallasPorGenero(string genero) { List <CatGenero> listGenero = new List <CatGenero>(); comando.Connection = conn.AbrirConexion(); comando.CommandText = "Listar_Tallas_Por_Genero"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@Genero", genero); leer = comando.ExecuteReader(); while (leer.Read()) { CatGenero generos = new CatGenero() { IdGender = Convert.ToInt32(leer["ID_GENDER"]), Genero = leer["GENERO"].ToString() }; CatTallaItem catTalla = new CatTallaItem() { Id = Convert.ToInt32(leer["ID"]), Talla = leer["TALLA"].ToString() }; generos.CatTallaItem = catTalla; listGenero.Add(generos); } leer.Close(); conn.CerrarConexion(); return(listGenero); }
//Permite consultar los detalles de un genero public CatGenero ConsultarListaGenero(int?id) { CatGenero generos = new CatGenero(); Conexion conn = new Conexion(); try { SqlCommand comando = new SqlCommand(); SqlDataReader leerG = null; comando.Connection = conn.AbrirConexion(); comando.CommandText = "Listar_Genero_Por_Id"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@Id", id); leerG = comando.ExecuteReader(); while (leerG.Read()) { generos.IdGender = Convert.ToInt32(leerG["ID_GENDER"]); generos.Genero = leerG["GENERO"].ToString(); generos.GeneroCode = leerG["GENERO_CODE"].ToString(); } //leerF.Close(); } finally { conn.CerrarConexion(); conn.Dispose(); } return(generos); }
//Permite crear nuevo genero public void AgregarGenero(CatGenero generos) { comando.Connection = conn.AbrirConexion(); comando.CommandText = "AgregarGeneros"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@Genero", generos.Genero); comando.Parameters.AddWithValue("@Codigo", generos.GeneroCode); comando.ExecuteNonQuery(); conn.CerrarConexion(); }
//Permite consultar los detalles de un genero public CatGenero ConsultarListaGenero(int?id) { CatGenero generos = new CatGenero(); comando.Connection = conn.AbrirConexion(); comando.CommandText = "Listar_Genero_Por_Id"; comando.CommandType = CommandType.StoredProcedure; comando.Parameters.AddWithValue("@Id", id); leer = comando.ExecuteReader(); while (leer.Read()) { generos.IdGender = Convert.ToInt32(leer["ID_GENDER"]); generos.Genero = leer["GENERO"].ToString(); generos.GeneroCode = leer["GENERO_CODE"].ToString(); } return(generos); }
//Permite crear nuevo genero public void AgregarGenero(CatGenero generos) { Conexion conex = new Conexion(); try { SqlCommand com = new SqlCommand(); com.Connection = conex.AbrirConexion(); com.CommandText = "AgregarGeneros"; com.CommandType = CommandType.StoredProcedure; com.Parameters.AddWithValue("@Genero", generos.Genero); com.Parameters.AddWithValue("@Codigo", generos.GeneroCode); com.ExecuteNonQuery(); } finally { conex.CerrarConexion(); conex.Dispose(); } }
public IEnumerable <CatGenero> ListarTallasPorGenero(string genero) { List <CatGenero> listGenero = new List <CatGenero>(); Conexion conne = new Conexion(); try { SqlCommand comand = new SqlCommand(); SqlDataReader leerTG = null; comand.Connection = conne.AbrirConexion(); comand.CommandText = "Listar_Tallas_Por_Genero"; comand.CommandType = CommandType.StoredProcedure; comand.Parameters.AddWithValue("@Genero", genero); leerTG = comand.ExecuteReader(); while (leerTG.Read()) { CatGenero generos = new CatGenero() { IdGender = Convert.ToInt32(leerTG["ID_GENDER"]), Genero = leerTG["GENERO"].ToString() }; CatTallaItem catTalla = new CatTallaItem() { Id = Convert.ToInt32(leerTG["ID"]), Talla = leerTG["TALLA"].ToString() }; generos.CatTallaItem = catTalla; listGenero.Add(generos); } leerTG.Close(); } finally { conne.CerrarConexion(); conne.Dispose(); } return(listGenero); }