private void BtnOperationEdit_Click(object sender, RoutedEventArgs e) { SaverDefaultValue valSaver = new SaverDefaultValue(); if (cbOperation.SelectedItem == null) { return; } OperationName operationName = cbOperation.SelectedItem as OperationName; EditValue wnd = new EditValue(); wnd.Value = operationName.Name; wnd.ShowDialog(); if (wnd.Value == null) { return; } if (wnd.DialogResult == true) { using (DataModelContainer db = new DataModelContainer()) { OperationName val = db.OperationNameSet.FirstOrDefault(a => a.Id == operationName.Id); val.Name = wnd.Value; db.SaveChanges(); cbOperation.ItemsSource = db.OperationNameSet.ToList(); cbOperation.SelectedItem = val; if (wnd.Default) { valSaver.dic["operation"] = val.Id; valSaver.Save(); } } } }
private void BtnOperationAdd_Click(object sender, RoutedEventArgs e) { SaverDefaultValue valSaver = new SaverDefaultValue(); EditValue wnd = new EditValue(); wnd.ShowDialog(); if (wnd.Value == null) { return; } if (wnd.DialogResult == true) { using (DataModelContainer db = new DataModelContainer()) { OperationName val = new OperationName() { Name = wnd.Value }; db.OperationNameSet.Add(val); db.SaveChanges(); cbOperation.ItemsSource = db.OperationNameSet.ToList(); cbOperation.SelectedItem = val; if (wnd.Default) { valSaver.dic["operation"] = db.OperationNameSet.FirstOrDefault(p => p.Name == wnd.Value).Id; valSaver.Save(); } } } }