private void Btn_New_Click(object sender, RoutedEventArgs e) { if (newRecordWindow != null) { newRecordWindow.Closed -= RecordEditWindowClosed; newRecordWindow.Close(); } newRecordWindow = new NewRecord(null, GetCurMaxID()); newRecordWindow.Closed += RecordEditWindowClosed; newRecordWindow.Show(); }
private void Btn_Edit_Click(object sender, RoutedEventArgs e) { if (LVList.SelectedItem is Record rco) { Logger.v(TAG, "Editing the record of " + rco.Book.MainTitle); if (newRecordWindow != null) { newRecordWindow.Closed -= RecordEditWindowClosed; newRecordWindow.Close(); } newRecordWindow = new NewRecord(rco, GetCurMaxID()); newRecordWindow.Closed += RecordEditWindowClosed; newRecordWindow.Show(); } }
private void RecordEditWindowClosed(object?sender, EventArgs e) { if (newRecordWindow.rcoStoraged != null) { if (LVList.Items.Count > 0) { if (newRecordWindow.rcoStoraged.ID > ((Record)LVList.Items[0]).ID) { XMLManager.InsertRecord(0, newRecordWindow.rcoStoraged); LVList.Items.Insert(0, newRecordWindow.rcoStoraged); } } else { XMLManager.InsertRecord(0, newRecordWindow.rcoStoraged); LVList.Items.Insert(0, newRecordWindow.rcoStoraged); } } newRecordWindow = null; }