/// <summary> /// Відкриття файлу БД /// </summary> private void OpenFile() { // block other menu BlockMenu(true); if (openFileD.ShowDialog() == DialogResult.OK) { this.path = Path.GetDirectoryName(openFileD.FileName); this.filename = Path.GetFileNameWithoutExtension(openFileD.FileName); db?.Dispose(); //using (db = new LesApp0Context(path, filename)) //{ db = new LesApp0Context(path, filename); db.Audiences.Load(); // load data LoadDBOnForm(db); //} } // finish statusLabel.Text = "Finish loading"; Cursor = Cursors.Default; // unblock BlockMenu(false); }
/// <summary> /// Створення файла БД /// </summary> private void CreateFile() { // block other menu BlockMenu(true); #if false if (folderBrowser.ShowDialog() == DialogResult.OK) { this.path = folderBrowser.SelectedPath; // choose directory and save data there AppDomain.CurrentDomain.SetData("DataDirectory", path); db.Dispose(); db = new LesApp0Context(); //using (db = new LesApp0Context()) //{ db.Audiences.Load(); db.SaveChanges(); // load data LoadDBOnForm(db); //} } #endif if (saveFileD.ShowDialog() == DialogResult.OK) { this.path = Path.GetDirectoryName(saveFileD.FileName); this.filename = Path.GetFileNameWithoutExtension(saveFileD.FileName); db?.Dispose(); db = new LesApp0Context(path, filename); db.Audiences.Load(); db.SaveChanges(); LoadDBOnForm(db); } // finish statusLabel.Text = "Finish creating"; Cursor = Cursors.Default; // unblock BlockMenu(false); }