private void resetDBObject() { if (_db != null) { _db.SaveChanges(); _db.Database.Connection.Close(); var file = Properties.Settings.Default.FileLocation; _db = null; _db = new NurseryAssignerEntities(file); } }
private bool setDBConnectionAndLoad() { var file = Properties.Settings.Default.FileLocation; if (string.IsNullOrWhiteSpace(file)) { if (!openDatabaseFile()) { return(false); } } if (_db != null) { _db.Database.Connection.Close(); } _db = new NurseryAssignerEntities(file); this.Text = "Nursery Assigner - " + System.IO.Path.GetFileName(file); loadByRange(); return(true); }