コード例 #1
0
        public BindingList <CategoriaProd> devolverLista()
        {
            BindingList <CategoriaProd> categorias = new BindingList <CategoriaProd>();

            ConexionBD cadConexion = new ConexionBD();

            SqlConnection conexion  = new SqlConnection(cadConexion.CadenaConexion);
            SqlCommand    sentencia = conexion.CreateCommand();

            sentencia.CommandText = "dbo.buscarCategoria";
            sentencia.CommandType = System.Data.CommandType.StoredProcedure;

            conexion.Open();
            SqlDataReader reader = sentencia.ExecuteReader();


            while (reader.Read())
            {
                CategoriaProd cat = new CategoriaProd(Int32.Parse(reader["Id"].ToString()), reader["Nombre"].ToString());
                categorias.Add(cat);
            }

            conexion.Close();

            return(categorias);
        }
コード例 #2
0
ファイル: ProductoDA.cs プロジェクト: DChaps13/LP2-Project
        public BindingList <Producto> devolverLista(string nombre, string categoria, string proveedor)
        {
            BindingList <Producto> productos = new BindingList <Producto>();

            ConexionBD    cadConexion = new ConexionBD();
            SqlConnection conexion    = new SqlConnection(cadConexion.CadenaConexion);
            SqlCommand    sentencia   = conexion.CreateCommand();

            sentencia.CommandText = "dbo.buscarProducto";
            sentencia.CommandType = System.Data.CommandType.StoredProcedure;
            sentencia.Parameters.Add("@_nombre", SqlDbType.VarChar).Value    = nombre;
            sentencia.Parameters.Add("@_categoria", SqlDbType.VarChar).Value = categoria;
            sentencia.Parameters.Add("@_proveedor", SqlDbType.VarChar).Value = proveedor;

            try
            {
                conexion.Open();
                SqlDataReader reader = sentencia.ExecuteReader();


                while (reader.Read())
                {
                    CategoriaProd   cat  = new CategoriaProd(Int32.Parse(reader["Id_Categoria"].ToString()), reader["Nombre_Categoria"].ToString());
                    PersonaJuridica prov = new PersonaJuridica(Int32.Parse(reader["Id_Proveedor"].ToString()), reader["RazonSocial"].ToString());
                    Producto        prod = new Producto(Int32.Parse(reader["Id"].ToString()), reader["Nombre"].ToString(), Int32.Parse(reader["Cantidad"].ToString()), Double.Parse(reader["Precio"].ToString()), reader["Estado"].ToString(), cat, prov);
                    productos.Add(prod);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Mensaje de error");
                return(productos);
            }


            conexion.Close();
            return(productos);
        }
コード例 #3
0
 public bool registrarCategoria(CategoriaProd c)
 {
     return(true);
 }
コード例 #4
0
 public bool registrarCategoria(CategoriaProd c)
 {
     return(catDA.registrarCategoria(c));
 }