void ExecuteRecAdd(object sender, ExecutedRoutedEventArgs e) { var data = listDB.SelectedItem as DBData; if (data == null) { return; } var win = new NewRecordWindow { Owner = this }; if (win.ShowDialog() != true || string.IsNullOrEmpty(win.FinalValue)) { return; } var rec = new DataRecord { Value = win.FinalValue, Name = win.FinalName, Description = win.FinalDescription }; var eMessage = ""; if (!SQLManager.TryAddRecord(data.Id, rec, currentSessionPassword, out eMessage)) { MessageBox.Show(eMessage, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Stop); return; } data.Records.Add(rec); listRecords.SelectedItem = rec; }
void ExecuteRecEdit(object sender, ExecutedRoutedEventArgs e) { var rec = listRecords.SelectedItem as DataRecord; if (rec == null) { return; } var win = new NewRecordWindow { Owner = this, FinalName = rec.Name, FinalValue = rec.Value, FinalDescription = rec.Description }; if (win.ShowDialog() != true || string.IsNullOrEmpty(win.FinalValue)) { return; } var tmp = new DataRecord { Name = win.FinalName, Value = win.FinalValue, Description = win.FinalDescription, }; var eMessage = ""; if (!SQLManager.TrUpdateRecord(tmp, currentSessionPassword, out eMessage)) { MessageBox.Show(eMessage, "Ошибка", MessageBoxButton.OK, MessageBoxImage.Stop); return; } rec.Name = tmp.Name; rec.Value = tmp.Value; rec.Description = tmp.Description; }