//dohvaćanje informacija o cijenama iz baze
        protected void OnButtonPROVJERICIJENEClicked(object sender, EventArgs e)
        {
            if (comboboxNP.ActiveText == null || comboboxTermini.ActiveText == null)
            {
                RezervacijaDialog win1 = new RezervacijaDialog();
                win1.Show();
            }
            else
            {
                button1NastaviRezervaciju.Sensitive = true;
                comboboxDjeca.Sensitive             = true;
                comboboxOdrasli.Sensitive           = true;
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Cijena_djeca, Cijena_odrasli, Kapacitet FROM Termini WHERE Nacionalnipark = '{0}' AND Datum = '{1}'", comboboxNP.ActiveText, comboboxTermini.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Cijena_djeca   = (string)reader["Cijena_djeca"];
                    a.Cijena_odrasli = (string)reader["Cijena_odrasli"];
                    a.Kapacitet      = (int)reader["Kapacitet"];
                    termini.Add(a);
                }

                foreach (var i in termini)
                {
                    label18.Text = i.Cijena_djeca;
                    label19.Text = i.Cijena_odrasli;
                    label16.Text = i.Kapacitet.ToString();
                }

                c.Dispose();
                con.Close();
            }
        }
        protected void OnComboboxNPChanged(object sender, EventArgs e)
        {
            if (comboboxNP.ActiveText == "Risnjak")
            {
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int y = 0;
                int x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(y, i.Datum);

                    y++;
                }

                c.Dispose();
                con.Close();
            }
            if (comboboxNP.ActiveText == "Brijuni")
            {
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int y = 0;
                int x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(y, i.Datum);

                    y++;
                }
                c.Dispose();
                con.Close();
            }

            if (comboboxNP.ActiveText == "Mljet")
            {
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int y = 0;
                int x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(y, i.Datum);

                    y++;
                }
                c.Dispose();
                con.Close();
            }

            if (comboboxNP.ActiveText == "Krka")
            {
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int y = 0;
                int x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(y, i.Datum);

                    y++;
                }
                c.Dispose();
                con.Close();
            }

            if (comboboxNP.ActiveText == "Plitvička jezera")
            {
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int y = 0;
                int x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }

                x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(y, i.Datum);

                    y++;
                }

                c.Dispose();
                con.Close();
            }

            if (comboboxNP.ActiveText == "Sjeverni Velebit")
            {
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int y = 0;
                int x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }

                x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(y, i.Datum);

                    y++;
                }

                c.Dispose();
                con.Close();
            }

            if (comboboxNP.ActiveText == "Paklenica")
            {
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int y = 0;
                int x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(y, i.Datum);

                    y++;
                }

                c.Dispose();
                con.Close();
            }

            if (comboboxNP.ActiveText == "Kornati")
            {
                termini.Clear();
                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();
                SqliteCommand c = con.CreateCommand();
                c.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = c.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int y = 0;
                int x = 0;

                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                x = 0;
                while (x < 20)
                {
                    comboboxTermini.RemoveText(x);
                    x++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(y, i.Datum);

                    y++;
                }

                c.Dispose();
                con.Close();
            }
        }
        protected void OnButtonIzbrisiClicked(object sender, EventArgs e)
        {
            //izbrisi termin koji ima taj datum, mora biti i koji park i koji datum
            //da li termin nema rezervacije, to se provjerava pod terminCHANGED, jer je tada button i omogucen
            string           connectionString = "URI=file:bazapodataka.db";
            SqliteConnection con = new SqliteConnection(connectionString);

            con.Open();
            SqliteCommand c = con.CreateCommand();

            c.CommandText = string.Format(@"DELETE FROM Termini WHERE Nacionalnipark = '{0}' AND Datum = '{1}'", comboboxNP.ActiveText, comboboxTermini.ActiveText);
            c.ExecuteNonQuery();
            c.Dispose();
            con.Close();
            buttonIzbrisi.Sensitive = false;

            //dio za refresh
            termini.Clear();
            buttonIzbrisi.Sensitive = false;
            string           connectionStringg = "URI=file:bazapodataka.db";
            SqliteConnection conn = new SqliteConnection(connectionStringg);

            conn.Open();
            SqliteCommand cc = conn.CreateCommand();

            cc.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

            SqliteDataReader reader = cc.ExecuteReader();

            while (reader.Read())
            {
                Termin a = new Termin();
                a.Nacionalnipark = (string)reader["Nacionalnipark"];
                a.Datum          = (string)reader["Datum"];

                termini.Add(a);
            }
            int y = 0;
            int x = 0;

            while (x < 20)
            {
                comboboxTermini.RemoveText(x);
                x++;
            }
            x = 0;
            while (x < 20)
            {
                comboboxTermini.RemoveText(x);
                x++;
            }
            comboboxTermini.RemoveText(0);
            foreach (var i in termini)
            {
                comboboxTermini.InsertText(y, i.Datum);

                y++;
            }

            cc.Dispose();
            conn.Close();
            buttonIzbrisi.Sensitive = false;
            ZaVoditeljeDialog5 win2 = new ZaVoditeljeDialog5();

            win2.Show();
        }
        //spremanje novog termina
        protected void OnButton225Clicked(object sender, EventArgs e)
        {
            if (comboboxNP.ActiveText == null || spinbutton1.Text == "0" || spinbutton3.Text == "0" || spinbutton2.Text == "0")
            {
                ZaVoditeljeDialog2 win1 = new ZaVoditeljeDialog2();
                win1.Show();
            }

            else
            {
                DateTime x;
                x = calendar1.Date;
                string y;
                y = x.ToString("dd.MM.yyyy.");

                string z;
                z = comboboxNP.ActiveText;
                int u = Convert.ToInt32(spinbutton2.Text);

                string           connectionString = "URI=file:bazapodataka.db";
                SqliteConnection con = new SqliteConnection(connectionString);
                con.Open();

                SqliteCommand dbInsertCmd = con.CreateCommand();
                dbInsertCmd.CommandText = String.Format(@"INSERT INTO Termini (Nacionalnipark, Datum, Cijena_djeca, Cijena_odrasli, Kapacitet) 
						                                                        VALUES('{0}', '{1}', '{2}', '{3}', {4})"                        , comboboxNP.ActiveText, y, spinbutton1.Text, spinbutton3.Text, u);

                dbInsertCmd.ExecuteNonQuery();
                dbInsertCmd.Dispose();
                con.Close();

                ZaVoditeljeDialog3 win1 = new ZaVoditeljeDialog3();
                win1.Show();

                //dio za refresh
                termini.Clear();
                buttonIzbrisi.Sensitive = false;
                string           connectionStringg = "URI=file:bazapodataka.db";
                SqliteConnection conn = new SqliteConnection(connectionStringg);
                conn.Open();
                SqliteCommand cc = conn.CreateCommand();
                cc.CommandText = string.Format(@"SELECT Nacionalnipark, Datum FROM Termini WHERE Nacionalnipark = '{0}'", comboboxNP.ActiveText);

                SqliteDataReader reader = cc.ExecuteReader();
                while (reader.Read())
                {
                    Termin a = new Termin();
                    a.Nacionalnipark = (string)reader["Nacionalnipark"];
                    a.Datum          = (string)reader["Datum"];

                    termini.Add(a);
                }
                int b = 0;
                int q = 0;

                while (q < 20)
                {
                    comboboxTermini.RemoveText(q);
                    q++;
                }
                q = 0;
                while (q < 20)
                {
                    comboboxTermini.RemoveText(u);
                    q++;
                }
                comboboxTermini.RemoveText(0);
                foreach (var i in termini)
                {
                    comboboxTermini.InsertText(b, i.Datum);

                    b++;
                }

                cc.Dispose();
                conn.Close();
            }
        }