Exemple #1
0
        private void update_list()
        {
            kraji.Clear();

            krajilistbox.Items.Clear();

            using (NpgsqlConnection con = new NpgsqlConnection("Server=rogue.db.elephantsql.com; User Id=clhpojwc;" + "Password=wm7N_asXtodPaLSASbaFBEAcB1MtcKMU; Database=clhpojwc;"))
            {
                con.Open();
                NpgsqlCommand    com    = new NpgsqlCommand("SELECT id_k, ime_k, posta_k FROM vsikrajiinposta()", con);
                NpgsqlDataReader reader = com.ExecuteReader();
                while (reader.Read())
                {
                    krajilistbox.Items.Add(reader.GetString(1) + " " + reader.GetString(2));

                    kraj a = new kraj(reader.GetInt32(0), reader.GetString(1), reader.GetString(2));

                    kraji.Add(a);
                }
                con.Close();
            }

            gore.Clear();
            gorelistbox.Items.Clear();

            using (NpgsqlConnection con = new NpgsqlConnection("Server=rogue.db.elephantsql.com; User Id=clhpojwc;" + "Password=wm7N_asXtodPaLSASbaFBEAcB1MtcKMU; Database=clhpojwc;"))
            {
                con.Open();
                NpgsqlCommand    com    = new NpgsqlCommand("SELECT * FROM vsegore()", con);
                NpgsqlDataReader reader = com.ExecuteReader();
                while (reader.Read())
                {
                    gora a = new gora(reader.GetInt32(0), reader.GetString(1), reader.GetString(2), reader.GetInt32(3));

                    gorelistbox.Items.Add(a.ime);

                    gore.Add(a);
                }
                con.Close();
            }

            foreach (kraj a in kraji)
            {
                kraj_combo.Items.Add(a.ime);
            }
        }
        public SpremeniUserForm()
        {
            InitializeComponent();

            using (NpgsqlConnection con = new NpgsqlConnection("Server=rogue.db.elephantsql.com; User Id=clhpojwc;" + "Password=wm7N_asXtodPaLSASbaFBEAcB1MtcKMU; Database=clhpojwc;"))
            {
                con.Open();
                NpgsqlCommand    com    = new NpgsqlCommand("SELECT id_k, ime_k, posta_k FROM vsikrajiinposta()", con);
                NpgsqlDataReader reader = com.ExecuteReader();
                while (reader.Read())
                {
                    comboBox1.Items.Add(reader.GetString(1) + " " + reader.GetString(2));

                    kraj a = new kraj(reader.GetInt32(0), reader.GetString(1), reader.GetString(2));

                    kraji.Add(a);
                }
                con.Close();
            }
        }