void UpdateHistorytable(DocHistoryChange change) { DocTable doc; if (change.restoreID == null) { doc = new DocTable { name = change.newDocument.Substring(change.newDocument.LastIndexOf("\\") + 1), date = change.newTime, username = System.Environment.UserName, id = -1 }; } else { doc = new DocTable { name = change.restoreID.name, date = change.newTime, username = System.Environment.UserName, id = -1 }; } history.Insert(0, doc); DocumentHistory.Items.Refresh(); }
private void RestoreButton_Click(object sender, RoutedEventArgs e) { if (DocumentHistory.SelectedIndex > 0) { if (history[DocumentHistory.SelectedIndex].id != -1) { docHistoryChanges.Add(new DocHistoryChange(history[DocumentHistory.SelectedIndex])); UpdateHistorytable(docHistoryChanges[docHistoryChanges.Count - 1]); } else { DocTable tempTable = history[DocumentHistory.SelectedIndex]; DocHistoryChange tempChange = docHistoryChanges[docHistoryChanges.Count - DocumentHistory.SelectedIndex - 1]; docHistoryChanges.Remove(tempChange); docHistoryChanges.Add(tempChange); history.RemoveAt(DocumentHistory.SelectedIndex); history.Insert(0, tempTable); DocumentHistory.Items.Refresh(); } //DatabaseHandler.RestoreDocumentHistory(history[DocumentHistory.SelectedIndex].id); SaveHistoryChange.IsEnabled = true; CancelChange.IsEnabled = true; } }