private void cmbVrsta_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (b1) { Predmet pr = (Predmet)lstPredmeti.SelectedItem; if (cmbVrsta.SelectedIndex == 2) { List <Predmet> lPred = Predmet.Daj().Where(x => x.tip == -2).ToList(); cmbPodvrsta.Visibility = Visibility.Visible; cmbPodvrsta.ItemsSource = lPred; if (lPred.Count != 0) { cmbPodvrsta.SelectedIndex = 0; lista = Predmet.Daj("tip = " + lPred[0].id.ToString()); lstPredmeti.ItemsSource = lista; } } else { cmbPodvrsta.Visibility = Visibility.Hidden; lista = Predmet.Daj("tip = " + ((cmbVrsta.SelectedIndex + 1) * -1).ToString()); lstPredmeti.ItemsSource = lista; } } b1 = true; }
void ModIzbora() { g1.Visibility = Visibility.Hidden; g3.Visibility = Visibility.Visible; txtPredmet.Visibility = Visibility.Collapsed; lista = Predmet.Daj("tip < 0"); lstPredmeti.ItemsSource = lista; lstPredmeti.Focus(); lstPredmeti.SelectionMode = SelectionMode.Extended; }
// -1 - obican, -2 - tip izbornog, id - izborni public Predmeti(bool modIzbora) { InitializeComponent(); lista = Predmet.Daj("tip = -1"); lstPredmeti.Focus(); lstPredmeti.ItemsSource = lista; if (modIzbora) { ModIzbora(); } }
private void cmbPodvrsta_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { lista = Predmet.Daj("tip = " + ((Predmet)cmbPodvrsta.SelectedItem).id.ToString()); lstPredmeti.ItemsSource = lista; } catch { lista.Clear(); } }
private void btnAdd_Click(object sender, RoutedEventArgs e) { int cnt = lista.Count(); Predmet pr = new Predmet() { tip = -1 }; if (cnt != 0) { pr.id = Predmet.Daj().Last().id + 1; } else { pr.id = 1; } lista.Add(pr); lstPredmeti.SelectedIndex = cnt; EditMode(false); mode = 2; txtPredmet.Focus(); }
public static ObservableCollection <Predmet> DajPredmete(Smer sm, int razred) { ObservableCollection <Predmet> predmeti = new ObservableCollection <Predmet>(); SQLiteConnection con = new SQLiteConnection("Data Source = " + App.baza); con.Open(); ObservableCollection <Predmet> svi = Predmet.Daj(); SQLiteCommand com = new SQLiteCommand("SELECT * FROM smer_predmet WHERE id_smera=" + sm.id.ToString() + " AND razred=" + razred.ToString(), con); SQLiteDataReader read = com.ExecuteReader(); while (read.Read()) { Predmet pr = new Predmet(); var col = svi.Where(x => x.id == Convert.ToInt32(read["id_predmeta"])).ToList(); if (col.Count != 0) { pr = col[col.Count - 1]; pr.prosek = (read["prosek"].ToString() == "1"); predmeti.Add(pr); } } return(predmeti); }