Ejemplo n.º 1
0
        private void btVerify_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;
            try
            {
                if (db.Verify(tbFileName.Text, tbPassword.Text.Trim()))
                {
                    GlobalText.ShowInfo("VerifyDone");
                }
                else if (db.LastError == "")
                {
                    GlobalText.ShowError("VerifyFault");
                }
                else
                {
                    GlobalText.ShowError("VerifyError", db.LastError);
                }
            }
            catch (Exception ex)
            {
                GlobalText.ShowError("VerifyError", ex.Message);
            }
            db.Close();
            this.Cursor = Cursors.Default;

            LoadDatabase(tbFileName.Text, tbPassword.Text.Trim());
        }
Ejemplo n.º 2
0
        private void btUpgrade_Click(object sender, EventArgs e)
        {
            if (!CreateBackup())
            {
                return;
            }

            bool ok = false;

            this.Cursor = Cursors.WaitCursor;
            try
            {
                ok = db.Upgrade(tbFileName.Text, openPassword, tbPassword.Text.Trim(), (Version)cbUpgradeTo.SelectedItem);
                if (ok)
                {
                    GlobalText.ShowInfo("UpgradeDone");
                }
                else
                {
                    GlobalText.ShowError("UpgradeError", db.LastError);
                }
            }
            catch (Exception ex)
            {
                GlobalText.ShowError("UpgradeError", ex.Message);
            }
            this.Cursor = Cursors.Default;

            if (ok)
            {
                LoadDatabase(tbFileName.Text, tbPassword.Text.Trim());
            }
            SetActiveButtons();
        }
Ejemplo n.º 3
0
        private void btShrink_Click(object sender, EventArgs e)
        {
            if (!CreateBackup())
            {
                return;
            }

            bool ok = false;

            Cursor = Cursors.WaitCursor;
            try
            {
                ok = db.Shrink(tbFileName.Text, openPassword, tbPassword.Text.Trim());
                if (ok)
                {
                    GlobalText.ShowInfo("ShrinkDone");
                }
                else
                {
                    GlobalText.ShowError("ShrinkError", db.LastError);
                }
            }
            catch (Exception ex)
            {
                GlobalText.ShowError("ShrinkError", ex.Message);
            }
            Cursor = Cursors.Default;

            if (ok)
            {
                LoadDatabase(tbFileName.Text, tbPassword.Text.Trim());
            }
            SetActiveButtons();
        }
Ejemplo n.º 4
0
        private void btCreate_Click(object sender, EventArgs e)
        {
            bool ok = false;

            Cursor = Cursors.WaitCursor;
            try
            {
                ok = db.CreateDatabase(tbFileName.Text, tbPassword.Text.Trim(), (Version)cbVersion.SelectedItem);
                if (ok)
                {
                    GlobalText.ShowInfo("CreateDone");
                }
                else
                {
                    GlobalText.ShowError("CreateError", db.LastError);
                }
            }
            catch (Exception ex)
            {
                GlobalText.ShowError("CreateError", ex.Message);
            }
            Cursor = Cursors.Default;

            if (ok)
            {
                LoadDatabase(tbFileName.Text, tbPassword.Text.Trim());
            }
            SetActiveButtons();
        }
Ejemplo n.º 5
0
        private void btnImport_Click(object sender, EventArgs e)
        {
            bool anyTableExists  = false;
            bool allTablesExists = true;

            foreach (TreeNode node in treeDb.Nodes)
            {
                if (node.Checked)
                {
                    bool exists = db.TableNames.Contains(node.Text, StringComparer.InvariantCultureIgnoreCase);
                    if (exists)
                    {
                        anyTableExists = true;
                    }
                    else
                    {
                        allTablesExists = false;
                    }
                }
            }

            if (cbSchema.Checked && anyTableExists)
            {
                GlobalText.ShowError("ErrorImportingTablesSchema");
                DialogResult = DialogResult.Abort;
                return;
            }

            if (cbData.Checked && !cbSchema.Checked && !allTablesExists)
            {
                GlobalText.ShowError("ErrorImportingTablesData");
                DialogResult = DialogResult.Abort;
                return;
            }

            FilterDdl();

            toolStripProgressBar1.Value   = 0;
            toolStripProgressBar1.Maximum = ddl.Count;
            DbCommand cmd = db.Connection.CreateCommand();

            cmd.CommandType = CommandType.Text;

            try
            {
                foreach (string sql in ddl)
                {
                    toolStripProgressBar1.Increment(1);
                    cmd.CommandText = sql;
                    cmd.ExecuteNonQuery();
                }
                GlobalText.ShowInfo("ImportOk");
                DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                string sql = cmd.CommandText.Length <= 500 ? cmd.CommandText : $"{cmd.CommandText.Remove(500)}...";
                GlobalText.ShowError("ImportError", ex.Message + Environment.NewLine + Environment.NewLine + sql);
                DialogResult = DialogResult.Abort;
            }
        }