public DataTable getAllProductos(string nombre)
        {
            dbConection conn  = new dbConection();
            string      query = @"SELECT * from productos where nombre = @nombre";
            SqlCommand  cmd   = new SqlCommand();
            DataTable   dt    = new DataTable();

            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@nombre", nombre);
            dt = conn.queryCmd(cmd);
            return(dt);
        }
        public DataTable productosPorCat(int cat_id)
        {
            dbConection conn  = new dbConection();
            string      query = @"SELECT * from productos where categoria_id = @cat_id";
            SqlCommand  cmd   = new SqlCommand();
            DataTable   dt    = new DataTable();

            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@cat_id", cat_id);
            dt = conn.queryCmd(cmd);
            return(dt);
        }
Esempio n. 3
0
        public int getId(string nombre)
        {
            dbConection function = new dbConection();
            int         id;
            string      query = @"select * from productos where nombre = @proNombre";
            SqlCommand  cmd   = new SqlCommand();
            DataTable   dt    = new DataTable();

            cmd.CommandText = query;
            cmd.Parameters.AddWithValue("@proNombre", nombre);
            dt = function.queryCmd(cmd);
            id = Int32.Parse(dt.Rows[0]["id"].ToString());
            return((int)id);
        }