using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SQLite;

namespace BAZA
{
    public partial class GlOkno2 : Form
    {
        private static string povNiz = @"Data Source=E:\Baze\filmi.sqlite; Version=3;";
        private SQLiteConnection povezava;
        private SQLiteDataAdapter dataAdapter;

        public GlOkno2()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            this.povezava = new SQLiteConnection(GlOkno2.povNiz);
            DataSet ds = new DataSet();
            // začetno stanje - vse
            
            SQLiteDataAdapter dataAdapter = new SQLiteDataAdapter("SELECT leto, naslov, reziser FROM Filmi", povezava);
            dataAdapter.Fill(ds);
            prikazPodatkov.DataSource = ds.Tables[0];
            

        }

        private void izbiraNaslova_TextChanged(object sender, EventArgs e)
        {
            
            DataSet ds = new DataSet(); 
            string ukaz = "SELECT leto, naslov, reziser FROM Filmi ";
            ukaz += "WHERE naslov LIKE '" + izbiraNaslova.Text + "%'";
            dataAdapter = new SQLiteDataAdapter(ukaz, povezava);
            dataAdapter.Fill(ds);
            prikazPodatkov.DataSource = ds.Tables[0];
            
        }
    }
}
