Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            try
            {
                racun();
                baza.OtvoriKonekciju();
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection  = baza.Connection;
                cmd.CommandText = "select * from grupa";
                OleDbDataReader reader = cmd.ExecuteReader();
                grupe.Clear();
                while (reader.Read())
                {
                    Grupa g = new Grupa();
                    g.Id_grupa = int.Parse(reader["id_grupa"].ToString());
                    g.Naziv    = reader["naziv"].ToString();
                    grupe.Add(g);
                }
            }
            catch (Exception ex)
            { MessageBox.Show("Greska je " + ex); }
            finally
            {
                baza.ZatvoriKonekciju();
            }



            for (int i = 0; i < grupe.Count(); i++)
            {
                Button button = new Button();
                button.Width  = 92;
                button.Height = 62;
                button.Text   = grupe[i].Naziv;
                button.Name   = grupe[i].Id_grupa.ToString();
                button.Click += new EventHandler(otvoriArtikle);
                flowLayoutPanel1.Controls.Add(button);
                //dodao ih i postavio im ime da bih mogao da u sledecoj formi
                //povucem ime i izvucem iz baze odredjene prozivode
            }
        }
Ejemplo n.º 2
0
        private void DodavanjeProizvoda_Load(object sender, EventArgs e)
        {
            // TODO: This line of code loads data into the 'prodavnicaDataSet.artikal' table. You can move, or remove it, as needed.
            this.artikalTableAdapter.Fill(this.prodavnicaDataSet.artikal);
            try
            {
                baza.OtvoriKonekciju();
                OleDbCommand cmd = new OleDbCommand();
                cmd.Connection  = baza.Connection;
                cmd.CommandText = "select * from grupa";
                OleDbDataReader reader = cmd.ExecuteReader();
                grupe.Clear();
                while (reader.Read())
                {
                    Grupa g = new Grupa();
                    g.Id_grupa = int.Parse(reader["id_grupa"].ToString());
                    g.Naziv    = reader["naziv"].ToString();
                    grupe.Add(g);
                }

                if (comboBox1.Items.Count > 0)
                {
                    comboBox1.DataSource = null;
                    comboBox1.Items.Clear();
                }
                comboBox1.DataSource    = grupe;
                comboBox1.DisplayMember = "naziv";
                comboBox1.ValueMember   = "id_grupa";
            }
            catch (Exception ex)
            { MessageBox.Show("Greska je " + ex); }
            finally
            {
                baza.ZatvoriKonekciju();
            }
        }