private void ExportToBriefcaseFile()
        {
            SaveFileDialog sfdlg = new SaveFileDialog();

            sfdlg.Filter = "(briefcase files *.sdf)|*.sdf";
            if (DialogResult.OK == sfdlg.ShowDialog())
            {
                if (this.dataGridViewVIQRegistry.SelectedRows.Count > 0)
                {
                    try
                    {
                        Portable.SaveSchema(sfdlg.FileName, ApplicationInfo.bfpassword);
                    }
                    catch (Exception e2)
                    {
                        MessageBox.Show("Metadata failed to be exported :" + e2.Message);
                        return;
                    }

                    if (!Questionnaire.TransferRegistryInfoToBriefcase(MyConnection.GetConnection(), sfdlg.FileName, ApplicationInfo.bfpassword))
                    {
                        MessageBox.Show("Registry data failed to be transfered.");

                        return;
                    }
                    foreach (DataGridViewRow dgv in this.dataGridViewVIQRegistry.SelectedRows)
                    {
                        var drv = (DataRowView)dgv.DataBoundItem;
                        int qid = (int)drv["Qid"];
                        try
                        {
                            if ((byte)drv["finalized"] != 1)
                            {
                                throw new Exception("not finalized");
                            }
                        }
                        catch (Exception e3)
                        {
                            MessageBox.Show(drv["Qid"].ToString() + " skipped :not finalized");
                            continue;
                        }


                        try
                        {
                            Portable.TransferQuestionnaireTemplate(MyConnection.GetConnection(), qid, sfdlg.FileName, ApplicationInfo.bfpassword);
                        }
                        catch (Exception e2)
                        {
                            MessageBox.Show("Questionnaire export failed :" + e2.Message);
                        }
                    }
                    MessageBox.Show(string.Format("Briefcase file {0} created.", sfdlg.FileName));
                }
            }
        }