private void dodaj_przedmiot() { DataClasses1DataContext context = new DataClasses1DataContext(); Guid idWykladowcy = Wykladowca.FindWykladowcaIdByName(_selectedWykladowca); Guid idTyp = Typ_Zajec.FindZajeciasIdByName(_selectedTyp); Guid PrzedmiotNazwaId = Przedmiot.FindPrzedmiotNazwaIdByNazwa(_selectedPrzedmiot); Przedmiot przedmiotExist = Przedmiot.CheckPrzedmiotExist(idTyp, idWykladowcy, PrzedmiotNazwaId); if (przedmiotExist == null) { var newPrzedmiot = new Przedmiot { Id_PrzedmiotNazwa = PrzedmiotNazwaId, Id_Typ_Zajec = idTyp, PunktyETCS = Convert.ToInt32(_punktyETCS), Godziny = Convert.ToInt32(_liczbaGodzin), Id_Wykladowcy = idWykladowcy }; przedmiotExist = newPrzedmiot; context.Przedmiots.InsertOnSubmit(przedmiotExist); context.SubmitChanges(); } if (!Semestr.CheckPrzedmiotExistInSemester(_idSemestr, _idGrupa, przedmiotExist.Id_Przedmiot)) { var grupaPrzedmiotSemestr = new GrupaSemestrPrzedmiot { Id_Grupa = _idGrupa, Id_Semestr = _idSemestr, Id_Przedmiot = przedmiotExist.Id_Przedmiot }; context.GrupaSemestrPrzedmiots.InsertOnSubmit(grupaPrzedmiotSemestr); context.SubmitChanges(); } else { MessageBox.Show("Przedmiot jest już na liście","Uwaga", MessageBoxButton.OK, MessageBoxImage.Error); } }
private void detach_Przedmiots(Przedmiot entity) { this.SendPropertyChanging(); entity.Wykladowca = null; }
private void AddPrzedmiotCommand(object parameter) { DataClasses1DataContext context = new DataClasses1DataContext(); Guid idTyp = Typ_Zajec.FindZajeciasIdByName(_selectedTyp); Guid idPrzedmiotNazwa = Przedmiot.FindPrzedmiotNazwaIdByNazwa(_selectedPrzedmiot); Guid idWykladowca = Wykladowca.FindWykladowcaIdByName(_selectedWykladowca); var przedmiot = new Przedmiot { Id_PrzedmiotNazwa = idPrzedmiotNazwa, Id_Typ_Zajec = idTyp, Godziny = Convert.ToInt32(_liczbaGodzin), PunktyETCS = Convert.ToInt32(_punktyETCS), Id_Wykladowcy = idWykladowca }; context.Przedmiots.InsertOnSubmit(przedmiot); context.SubmitChanges(); Window frm = (Window)parameter; frm.Close(); }
partial void DeletePrzedmiot(Przedmiot instance);
partial void UpdatePrzedmiot(Przedmiot instance);
partial void InsertPrzedmiot(Przedmiot instance);
private void detach_Przedmiots(Przedmiot entity) { this.SendPropertyChanging(); entity.Typ_Zajec = null; }
private void detach_Przedmiots(Przedmiot entity) { this.SendPropertyChanging(); entity.PrzedmiotNazwa = null; }