public void EditExecute(object param) { var v = new BearbeitePositionCTL(); var vm = new BearbeiteAddVMODELPosition(); vm.Pos = SelectedPosition; vm.IsInEditMode = true; v.DataContext = vm; v.ShowDialog(); if (v.DialogResult == true) { using (SnackEmDBEntities db = new SnackEmDBEntities()) { db.Entry(vm.Pos).State = EntityState.Modified; db.SaveChanges(); PropertyChanged(this, new PropertyChangedEventArgs("AllePositionen")); } } }
public void NewExecute(object param) { if (SelectedPosition != null) { var v = new BearbeitePositionCTL(); var vm = new BearbeiteAddVMODELPosition(); vm.Pos = new POSITION(); vm.IsInEditMode = false; v.DataContext = vm; v.ShowDialog(); if (v.DialogResult == true) { using (SnackEmDBEntities db = new SnackEmDBEntities()) { db.POSITIONs.Add(vm.Pos); db.SaveChanges(); PropertyChanged(this, new PropertyChangedEventArgs("AllePositionen")); } } } }
public void NewExecutePos(object param) { // New Button was pressed if (SelectedAutomat != null) { var v = new BearbeitePositionCTL(); var vm = new BearbeiteAddVMODELPosition(); vm.Pos = new POSITION { POS_A_ID = SelectedAutomat.A_ID }; vm.IsInEditMode = false; v.DataContext = vm; // view.DataContext = ViewModel v.ShowDialog(); if (v.DialogResult == true) // speichern { using (SnackEmDBEntities db = new SnackEmDBEntities()) { // die stunden Instanz in den OR Mapper db.POSITIONs.Add(vm.Pos); db.SaveChanges(); PropertyChanged(this, new PropertyChangedEventArgs("AutomatPositions")); } } } }