Example #1
0
        private void sqlDictionaryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Form childForm = new SqlDictionaryForm
            {
                MdiParent = this
            };

            childForm.Show();
        }
Example #2
0
        private void OpenFile(object sender, EventArgs e)
        {
            string filePath = string.Empty;

            using (var openFileDialog = new OpenFileDialog())
            {
                openFileDialog.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
                openFileDialog.Filter           = string.Format("{0} (*.{1})|*.{1}|All Files (*.*)|*.*",
                                                                "xml files", "xml");
                if (openFileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    filePath = openFileDialog.FileName;
                }
            }

            if (filePath.IsNullOrWhiteSpace())
            {
                return;
            }

            foreach (var child in MdiChildren)
            {
                if (child is IStandardActionForm && ((IStandardActionForm)child).CurrentFilePath.Trim().ToLower()
                    == filePath.Trim().ToLower())
                {
                    child.Activate();
                    return;
                }
            }

            Form childForm = null;

            try
            {
                var result = new ApplicationRoleSchemaList();
                result.LoadXmlFile(filePath);
                childForm = new ApplicationRoleSchemaListForm(result, filePath);
            }
            catch (Exception) { }

            if (childForm == null)
            {
                try
                {
                    var result = new DbSchema();
                    result.LoadXmlFile(filePath);
                    childForm = new DbSchemaForm(filePath, result);
                }
                catch (Exception) { }
            }

            if (childForm == null)
            {
                try
                {
                    var result = new SqlRepository();
                    result.LoadFile(filePath);
                    childForm = new SqlDictionaryForm(result, filePath);
                }
                catch (Exception) { }
            }

            if (childForm == null)
            {
                MessageBox.Show("File is not recognized as any Apskaita5 cofig file.", "",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                return;
            }

            childForm.MdiParent = this;
            childForm.Show();
        }