private void DeleteBtn_Click(object sender, RoutedEventArgs e) { if (filesListBox.SelectedItem != null) { db.TextFiles.Remove(filesListBox.SelectedItem as TextFile); DBhandler.SaveToDB(db); } }
public MainWindow() { InitializeComponent(); db = new ApplicationContext(); DBhandler.LoadFromDB(db); mainTextBox.AutoIndent = true; }
private void SaveBtn_Click(object sender, RoutedEventArgs e) { textFile.Name = nameTextBox.Text; TextFile tempTextFile = db.TextFiles.Find(textFile.ID); if (tempTextFile != null) { db.Entry(textFile).State = System.Data.Entity.EntityState.Modified; } else { textFile.DateCreate = DateTime.Now.ToLongDateString(); db.TextFiles.Add(textFile); } DBhandler.SaveToDB(db); DialogResult = true; }