private void iscitajGrupe() { grupe.Clear(); try { baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = baza.Conn; cmd.CommandText = "SELECT id_grupa, naziv FROM Grupa" + Environment.NewLine + "GROUP BY naziv, id_grupa ORDER BY id_grupa"; OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { idjevi_artikala.Clear(); 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(ex.Message); } finally { baza.ZatvoriKonekciju(); } }
private void cbxGrupeIzmena_SelectedValueChanged(object sender, EventArgs e) { if (cbxGrupeIzmena.SelectedIndex != 0 && cbxGrupeIzmena.SelectedItem != null) { selektovanaGrupaZaIzmenu = (Grupa)cbxGrupeIzmena.SelectedItem; } }
private List <Grupa> ucitajCeleGrupe(int id_grupa) { List <Grupa> celeGrupe = new List <Grupa>(); try { celeGrupe.Clear(); baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = baza.Conn; cmd.CommandText = "SELECT * FROM Grupa WHERE id_grupa = " + id_grupa; OleDbDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { Grupa g = new Grupa(); g.Id_grupa = int.Parse(reader["id_grupa"].ToString()); g.Naziv = reader["naziv"].ToString(); g.Id_artikla = int.Parse(reader["id_artikla"].ToString()); celeGrupe.Add(g); } } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { baza.ZatvoriKonekciju(); } return(celeGrupe); }
private void iscitajGrupe() { cbxGrupe.DataSource = null; cbxGrupe.Items.Clear(); cbxGrupeIzmena.DataSource = null; cbxGrupeIzmena.Items.Clear(); if (grupe.Count > 0) { grupe.Clear(); } try { baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = baza.Conn; cmd.CommandText = "SELECT id_grupa, naziv FROM Grupa" + Environment.NewLine + "GROUP BY naziv, id_grupa ORDER BY id_grupa"; OleDbDataReader reader = cmd.ExecuteReader(); 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(ex.Message); } finally { baza.ZatvoriKonekciju(); } cbxGrupe.DataSource = grupe; cbxGrupeIzmena.BindingContext = new BindingContext(); cbxGrupeIzmena.DataSource = grupe; if (selektovanaGrupaZaIzmenu != null) { selektujGrupuZaIzmenu(); } }
private void obrisiGrupu(Grupa grupa) { try { baza.OtvoriKonekciju(); OleDbCommand cmd = new OleDbCommand(); cmd.Connection = baza.Conn; cmd.CommandText = "DELETE *" + Environment.NewLine + "FROM Grupa" + Environment.NewLine + "WHERE id_grupa = " + grupa.Id_grupa; OleDbDataReader reader = cmd.ExecuteReader(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { baza.ZatvoriKonekciju(); } }