예제 #1
0
 //"Tools -> Merge -> Merge Databases" menu item
 private void menu_ToolsMergeMergeDBMenuItem_Click(object sender, EventArgs e)
 {
     MergeDialog mdialog = new MergeDialog(GuiPrefs.DefaultDBDir, Mydb);
     mdialog.StartPosition = FormStartPosition.CenterParent;
     if (mdialog.ShowDialog() == DialogResult.OK)
     {
         if (!Mydb.IsOpen())
         {
             Mydb.OpenDB(Mydb.MyPath);
         }
         UpdateAfterOpenDB();
     }
 }
예제 #2
0
        /// <summary>
        /// Click event for the File->Restore menu item
        /// </summary>
        private void menu_FileRestoreMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.InitialDirectory = GuiPrefs.DefaultBackupDir;
            ofd.Filter = "Second Sight Database Files (*.ssd, *.ssb)|*.ssd;*.ssb|All files (*.*)|*.*";
            ofd.Title = "Restore the current database from a backup.";
            ofd.Multiselect = false;
            ofd.CheckFileExists = true;
            ofd.CheckPathExists = true;

            if (!Mydb.IsOpen())
            {
                MessageBox.Show("No database is currently loaded.  Please load a database " +
                                "before attempting to restore a database from a backup.",
                                "No Loaded Database", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            { //If no database is loaded
                if (ofd.ShowDialog() == DialogResult.OK)
                {
                    if (MessageBox.Show("The current database will be permanently replaced with the backup you selected.  Are you sure you want to continue?",
                        "Confirm Restore", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.Yes)
                    {
                        string currentdbpath = GuiPrefs.OpenDBPath;
                        try
                        {

                            Mydb.CloseDB();
                            File.Copy(ofd.FileName, currentdbpath, true);
                            Mydb.OpenDB(currentdbpath);
                            MessageBox.Show("The database was successfully restored.",
                                "Restore Successful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch
                        {
                            MessageBox.Show("The database could not be restored.  Make sure you have permission to write to the destination folder.",
                                "Restore Unsuccessful", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        finally
                        {
                            Mydb.OpenDB(currentdbpath);
                            UpdateAfterOpenDB();
                        }
                    }
                }
            }
        }
예제 #3
0
        //"File -> Open Database" Menu item.
        private void menu_FileOpenMenuItem_Click(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.InitialDirectory = GuiPrefs.DefaultDBDir;
            ofd.Filter = "Second Sight Database Files (*.ssd, *.ssp)|*.ssd;*.ssp|All files (*.*)|*.*";
            ofd.Title = "Load Existing Second Sight Database";

            if (ofd.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Mydb.OpenDB(ofd.FileName);
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Could not open database.", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                    return;
                }

                UpdateAfterOpenDB(); //Update the controls and variables
            }
        }