private void btnDodaj_Click(object sender, EventArgs e) { try { int ocjena = int.Parse(cmbOcjena.SelectedItem.ToString()); Predmet p = cmbPredmeti.SelectedItem as Predmet; string datum = dateTimePolaganje.Value.ToShortDateString(); if (!s.JelPolozen(p)) { StudentPredmet sp = new StudentPredmet(); sp.Ocjena = ocjena; sp.Datum = datum; sp.Predmet = p; s.Uspjeh.Add(sp); DLWMS.Bazza.SaveChanges(); MessageBox.Show("Uspjesno dodan."); chbPolozeni.Checked = false; UcitajPolozene(); } else { MessageBox.Show("Vec polozen."); } } catch (Exception ex) { MessageBox.Show(ex.Message + ex.InnerException?.Message); } }
void Dodaj100Predmeta(Predmet p, int ocj, string datum) { for (int i = 0; i < 500; i++) { StudentPredmet sp = new StudentPredmet(); sp.Predmet = p; sp.Ocjena = ocj; sp.Datum = datum; s.Uspjeh.Add(sp); } DLWMS.Bazza.SaveChanges(); }