//private HelpForm helpForm;

        public MDI_ParentForm(Login lgnForm, int loginId)
        {
            InitializeComponent();
            objects = new ObjectHolder();
            currentUser = objects.GetPersonnelById(loginId);
                      
            if (currentUser.IsAdmin)
            {
                isAdmin = true;
                lblUserName.Text = currentUser.FirstName + " " + currentUser.LastName + "  \n(Administrator)";
            }  
            else
            {
                lblUserName.Text = currentUser.FirstName + " " + currentUser.LastName + "  \n(User)";
            }
            this.loginForm = lgnForm;

            
            SetupTreeView();
        }
        private void restoreToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog.Reset();
            openFileDialog.AddExtension = true;
            openFileDialog.DefaultExt = ".sqlite";
            openFileDialog.Filter = "SQLite files (*.sqlite) | *.sqlite";
            openFileDialog.Title = "Select backup";
            DialogResult result = openFileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                string path = openFileDialog.FileName;
                if (!DbSetupManager.EvaluateExternalDB(path))
                {
                    // problem with selected database
                    MessageBox.Show(
                        "Cannot restore from the file you selected.\n" +
                        "Only restore from backups created by KeyManager\n" +
                        "usually name 'KEYMANAGER_BACKUP_###.sqlite'\n" +
                        "with some number in place of the '###'.",
                        "Restore Cancelled"
                    );
                }
                else
                {
                    // looks good
                    result = MessageBox.Show(
                        "Are you sure you want to restore from backup?\n" +
                        "All current data will be overwritten.",
                        "Confirm Restore from Backup",
                        MessageBoxButtons.OKCancel
                    );
                    if (result == DialogResult.OK)
                    {
                        string dbpath = DbSetupManager.GetDBPath();
                        File.Delete(dbpath);
                        File.Copy(path, dbpath);

                        // reset it all!
                        objects = new ObjectHolder();
                        currentUser = objects.GetPersonnelById(1);
                        isAdmin = true;
                        SetupTreeView();

                        MessageBox.Show("Restore complete.");
                    }
                }
            }
        }
        private void importFromCSVToolStripMenuItem_Click(object sender, EventArgs e)
        {
            openFileDialog.Reset();
            openFileDialog.AddExtension = true;
            openFileDialog.DefaultExt = "csv";
            openFileDialog.Filter = "CSV | *.csv";
            openFileDialog.Title = "Import from CSV";
            DialogResult result = openFileDialog.ShowDialog();
            if (result == DialogResult.OK)
            {
                result = MessageBox.Show("Are you sure you wish to import? All current data will be overwritten", "Confirm Import", MessageBoxButtons.OKCancel);
                if (result == DialogResult.OK)
                {
                    string status = (new CSV()).InsertCSV(openFileDialog.FileName);
                    if (status == "refuse")
                    {
                        MessageBox.Show("Import Cancelled. Can only import from a CSV created using KeyManager.", "Import Cancelled");
                    }
                    else if (status == "error")
                    {
                        MessageBox.Show("Encountered an Error while importing");
                    }
                    else
                    {
                        MessageBox.Show("Import Complete");

                        // reset it all!
                        objects = new ObjectHolder();
                        currentUser = objects.GetPersonnelById(1);
                        isAdmin = true;
                        SetupTreeView();
                    }
                }
            }
            
        }