Exemplo n.º 1
0
 private void SetCultureTexts()
 {
     Text          = GlobalText.GetValue("Password");
     label1.Text   = GlobalText.GetValue("PasswordNote");
     btOK.Text     = GlobalText.GetValue("Ok");
     btCancel.Text = GlobalText.GetValue("Cancel");
 }
Exemplo n.º 2
0
        private DataTable DatabaseInfoLocale(DataTable table)
        {
            if (table.Columns.Count != 2)
            {
                return(table);
            }

            table.Columns[0].ColumnName = GlobalText.GetValue("Property");
            table.Columns[1].ColumnName = GlobalText.GetValue("Value");

            foreach (DataRow row in table.Rows)
            {
                string key = row[0].ToString().Replace(" ", string.Empty);
                string s   = GlobalText.GetValue(key);
                if (!string.IsNullOrEmpty(s))
                {
                    row[0] = s;
                }
                if (key == "CaseSensitive")
                {
                    s = GlobalText.GetValue(row[1].ToString());
                    if (!string.IsNullOrEmpty(s))
                    {
                        row[1] = s;
                    }
                }
            }
            return(table);
        }
Exemplo n.º 3
0
 private void SetCultureTexts()
 {
     this.Text      = GlobalText.GetValue("Tools");
     groupBox1.Text = GlobalText.GetValue("Database");
     label1.Text    = GlobalText.GetValue("FileName") + ":";
     label2.Text    = GlobalText.GetValue("Password") + ":";
     label4.Text    = GlobalText.GetValue("Version") + ":";
     toolTip2.SetToolTip(tbFileName, GlobalText.GetValue("FileNameTip"));
     toolTip2.SetToolTip(tbPassword, GlobalText.GetValue("PasswordTip"));
     toolTip2.SetToolTip(btSelect, GlobalText.GetValue("SelectTip"));
     label5.Text    = GlobalText.GetValue("UpgradeToVersion") + ":";
     groupBox2.Text = GlobalText.GetValue("Action");
     btCreate.Text  = GlobalText.GetValue("Create");
     btCompact.Text = GlobalText.GetValue("Compact");
     btRepair.Text  = GlobalText.GetValue("Repair");
     btShrink.Text  = GlobalText.GetValue("Shrink");
     btUpgrade.Text = GlobalText.GetValue("Upgrade");
     btVerify.Text  = GlobalText.GetValue("Verify");
     toolTip1.SetToolTip(btCreate, GlobalText.GetValue("CreateTip"));
     toolTip1.SetToolTip(btCompact, GlobalText.GetValue("CompactTip"));
     toolTip1.SetToolTip(btRepair, GlobalText.GetValue("RepairTip"));
     toolTip1.SetToolTip(btShrink, GlobalText.GetValue("ShrinkTip"));
     toolTip1.SetToolTip(btUpgrade, GlobalText.GetValue("UpgradeTip"));
     toolTip1.SetToolTip(btVerify, GlobalText.GetValue("VerifyTip"));
     label3.Text  = GlobalText.GetValue("ToolsNote");
     btClose.Text = GlobalText.GetValue("Close");
 }
Exemplo n.º 4
0
 private void SetCultureTexts()
 {
     Text           = GlobalText.GetValue("Import");
     btnImport.Text = GlobalText.GetValue("Import");
     cbSchema.Text  = GlobalText.GetValue("Schema");
     cbData.Text    = GlobalText.GetValue("Data");
 }
Exemplo n.º 5
0
        private void treeDb_BeforeCheck(object sender, TreeViewCancelEventArgs e)
        {
            if (e.Node.Parent == null || !e.Node.Checked)
            {
                return;
            }
            TreeNode[] nodes = treeDb.Nodes.Find(e.Node.Parent.Text + "@" + e.Node.Text, true);
            if (nodes.Length <= 0 || nodes[0].Parent == null)
            {
                return;
            }

            bool used = false;

            for (int i = 0; i < nodes.Length; i++)
            {
                if (nodes[i].Checked)
                {
                    used = true;
                }
            }
            if (!used)
            {
                return;
            }

            string txt = string.Format("[{0}]-[{1}] {2}{3}[{4}]-[{5}].",
                                       e.Node.Parent.Text, e.Node.Text, GlobalText.GetValue("UsedAsAForeignKey"), Environment.NewLine, nodes[0].Parent.Text, nodes[0].Text);

            GlobalText.ShowWarning(txt);
        }
Exemplo n.º 6
0
        private void treeDb_BeforeCheck(object sender, TreeViewCancelEventArgs e)
        {
            if (e.Node.Parent == null || !e.Node.Checked)
            {
                return;
            }
            TreeNode[] nodes = treeDb.Nodes.Find($"{e.Node.Parent.Text}@{e.Node.Text}", true);
            if (nodes.Length <= 0 || nodes[0].Parent == null)
            {
                return;
            }

            bool used = false;

            for (int i = 0; i < nodes.Length; i++)
            {
                if (nodes[i].Checked)
                {
                    used = true;
                }
            }
            if (!used)
            {
                return;
            }

            string txt = $"[{e.Node.Parent.Text}]-[{e.Node.Text}] {GlobalText.GetValue("UsedAsAForeignKey")}{Environment.NewLine}[{nodes[0].Parent.Text}]-[{nodes[0].Text}].";

            GlobalText.ShowWarning(txt);
        }
Exemplo n.º 7
0
 private void SetCultureTexts()
 {
     this.Text      = GlobalText.GetValue("Export");
     btnExport.Text = GlobalText.GetValue("Export");
     rbAll.Text     = GlobalText.GetValue("All");
     rbSchema.Text  = GlobalText.GetValue("OnlySchema");
     rbData.Text    = GlobalText.GetValue("OnlyData");
 }
Exemplo n.º 8
0
        private void btnExecute_Click(object sender, EventArgs e)
        {
            if (rtbQuery.Text.Trim().Length == 0)
            {
                return;
            }
            bool partial = rtbQuery.SelectedText.Trim().Length > 0;

            if (partial)
            {
                DialogResult result = MessageBox.Show(GlobalText.GetValue("SelectedTextQuery"), GlobalText.GetValue("Confirm"),
                                                      MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1);
                if (result == DialogResult.Cancel)
                {
                    return;
                }
                partial = result == DialogResult.Yes;
            }
            string sql = partial ? rtbQuery.SelectedText.Trim() : rtbQuery.Text.Trim();

            dataGrid.DataSource = null;

            // Initial time
            DateTime initTime = DateTime.Now;

            object resultSet = db.ExecuteSql(sql, false);

            long ms = (long)(DateTime.Now - initTime).TotalMilliseconds;

            dataGrid.DataSource = resultSet;

            if (resultSet != null || string.IsNullOrEmpty(db.LastError))
            {
                lbResult.ForeColor = Color.Black;
                lbResult.Text      = string.Format("{0} {1}, {2} {3}, {4} {5}", db.QueryCount, GlobalText.GetValue("Querys"), dataGrid.RowCount,
                                                   GlobalText.GetValue("Rows"), ms, GlobalText.GetValue("Milliseconds"));
                if (resultSet == null && regexCreateAlterDrop.IsMatch(regexDropQuotesAndBrackets.Replace(rtbQuery.Text, "")))
                {
                    db.ResetDdl();  // Update DDL
                    UpdateTreeDb();
                }
                else
                {
                    tabControl1.SelectedIndex = 0;
                    if (resultSet == null && regexInsertUpdateDelete.IsMatch(regexDropQuotesAndBrackets.Replace(rtbQuery.Text, "")))
                    {
                        TreeNode node = treeDb.SelectedNode;  // Update data view
                        treeDb.SelectedNode = null;
                        treeDb.SelectedNode = node;
                    }
                }
            }
            else
            {
                lbResult.ForeColor = Color.Red;
                lbResult.Text      = db.LastError;
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Load database with password
        /// </summary>
        /// <param name="fileName">Database file name</param>
        /// <param name="password">Database password</param>
        private void LoadDatabase(string fileName, string password)
        {
            Reset();

            try
            {
                if (!File.Exists(fileName))
                {
                    throw new Exception($"{GlobalText.GetValue("FileNotFound")}: '{fileName}'");
                }

                Cursor = Cursors.WaitCursor;

                if (db.Open(fileName, password))
                {
                    Text = string.Concat(formText, " - ", db.FileName);

                    // Fill tree with database name and table names
                    treeDb.BeginUpdate();
                    treeDb.Nodes.Clear();
                    TreeNode main = treeDb.Nodes.Add("Database", Path.GetFileNameWithoutExtension(fileName), 0, 0);
                    foreach (string tableName in db.TableNames)
                    {
                        main.Nodes.Add(tableName, tableName, 1, 1);
                    }
                    main.Expand();
                    treeDb.EndUpdate();
                    treeDb.SelectedNode = treeDb.Nodes[0];
                    settings.AddToRecentFiles(fileName);
                    UpdateRecentFilesMenu();
                }
                else
                {
                    bool badPassword = db.BadPassword;
                    Reset();
                    if (badPassword)
                    {
                        var form = new GetPassForm();
                        if (form.ShowDialog() == DialogResult.OK)
                        {
                            LoadDatabase(fileName, form.edPass.Text.Trim());
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                GlobalText.ShowError("UnableToOpen", ex.Message);
                btnQuery.Enabled = btnExecute.Enabled = btnClear.Enabled = false;
                settings.RemoveFromRecentFiles(fileName);
                UpdateRecentFilesMenu();
            }
            Cursor = Cursors.Default;

            UpdateStatus();
        }
Exemplo n.º 10
0
 private void SetCultureTexts()
 {
     btnOpen.Text                       = GlobalText.GetValue("OpenDatabase");
     cbReadOnly.Items[0]                = GlobalText.GetValue("ReadOnly");
     cbReadOnly.Items[1]                = GlobalText.GetValue("AllowEditing");
     btnQuery.Text                      = GlobalText.GetValue("Query");
     btnExecute.Text                    = GlobalText.GetValue("Execute");
     btnClear.Text                      = GlobalText.GetValue("Clear");
     btnCut.Text                        = GlobalText.GetValue("Cut");
     btnCopy.Text                       = GlobalText.GetValue("Copy");
     btnPaste.Text                      = GlobalText.GetValue("Paste");
     tabControl1.TabPages[0].Text       = GlobalText.GetValue("Data");
     tabControl1.TabPages[1].Text       = GlobalText.GetValue("SqlSchema");
     lbResult.Text                      = GlobalText.GetValue("QueryNote");
     cutToolStripMenuItem.Text          = GlobalText.GetValue("Cut");
     copyToolStripMenuItem.Text         = GlobalText.GetValue("Copy");
     pasteToolStripMenuItem.Text        = GlobalText.GetValue("Paste");
     loadFromFileToolStripMenuItem.Text = $"{GlobalText.GetValue("LoadFromFile")}...";
     saveToFileToolStripMenuItem.Text   = $"{GlobalText.GetValue("SaveToFile")}...";
     printToolStripMenuItem.Text        = $"{GlobalText.GetValue("Print")}...";
     fileMenuItem.Text                  = GlobalText.GetValue("File");
     openDatabaseMenuItem.Text          = $"{GlobalText.GetValue("OpenDatabase")}...";
     recentFilesMenuItem.Text           = GlobalText.GetValue("RecentFiles");
     allowEditingMenuItem.Text          = GlobalText.GetValue("AllowEditing");
     importMenuItem.Text                = $"{GlobalText.GetValue("Import")}...";
     exportMenuItem.Text                = $"{GlobalText.GetValue("Export")}...";
     exitMenuItem.Text                  = GlobalText.GetValue("Exit");
     editMenuItem.Text                  = GlobalText.GetValue("Edit");
     cutMenuItem.Text                   = GlobalText.GetValue("Cut");
     copyMenuItem.Text                  = GlobalText.GetValue("Copy");
     pasteMenuItem.Text                 = GlobalText.GetValue("Paste");
     deleteMenuItem.Text                = GlobalText.GetValue("Delete");
     queryMenuItem.Text                 = GlobalText.GetValue("Query");
     showEditorMenuItem.Text            = GlobalText.GetValue("ShowEditor");
     executeMenuItem.Text               = GlobalText.GetValue("Execute");
     clearMenuItem.Text                 = GlobalText.GetValue("Clear");
     toolsMenuItem.Text                 = GlobalText.GetValue("Tools");
     databaseToolsMenuItem.Text         = $"{GlobalText.GetValue("DatabaseTools")}...";
     optionsMenuItem.Text               = $"{GlobalText.GetValue("Options")}...";
     helpMenuItem.Text                  = GlobalText.GetValue("Help");
     aboutCompactViewMenuItem.Text      = $"{GlobalText.GetValue("About")} CompactView";
     loadSqlMenuItem.Text               = $"{GlobalText.GetValue("LoadSqlQuery")}...";
     saveSqlMenuItem.Text               = $"{GlobalText.GetValue("SaveSqlQuery")}...";
     saveSchemaMenuItem.Text            = $"{GlobalText.GetValue("SaveSqlSchema")}...";
     closeDatabaseMenuItem.Text         = GlobalText.GetValue("CloseDatabase");
     printMenuItem.Text                 = $"{GlobalText.GetValue("Print")}...";
     previewMenuItem.Text               = GlobalText.GetValue("Preview");
 }
Exemplo n.º 11
0
 private void SetCultureTexts()
 {
     this.Text      = GlobalText.GetValue("Options");
     groupBox1.Text = GlobalText.GetValue("Colors");
     label6.Text    = GlobalText.GetValue("FontColor");
     label5.Text    = GlobalText.GetValue("BackgroundColor");
     label1.Text    = GlobalText.GetValue("Line") + " 1";
     label2.Text    = GlobalText.GetValue("Line") + " 2";
     label3.Text    = GlobalText.GetValue("Line") + " 3";
     label4.Text    = GlobalText.GetValue("Line") + " 4";
     label7.Text    = GlobalText.GetValue("ColorSet") + ":";
     cbColorSet.Items[cbColorSet.Items.Count - 1] = GlobalText.GetValue("UserDefined");
     groupBox2.Text = GlobalText.GetValue("UserDefined");
     btnOk.Text     = GlobalText.GetValue("Ok");
     btnCancel.Text = GlobalText.GetValue("Cancel");
 }
Exemplo n.º 12
0
        public object ExecuteSql(string sql, bool updatable)
        {
            if (Connection == null)
            {
                return(null);
            }

            if (Connection.State == ConnectionState.Closed)
            {
                Connection.Open();
            }

            LastError = string.Empty;

            object           command  = assembly.CreateInstance("System.Data.SqlServerCe.SqlCeCommand", false, BindingFlags.CreateInstance, null, new object[] { null, Connection }, null, null);
            var              enumType = assembly.GetType("System.Data.SqlServerCe.ResultSetOptions");
            ResultSetOptions options  = updatable ? ResultSetOptions.Scrollable | ResultSetOptions.Updatable : ResultSetOptions.Scrollable;

            object result = null;

            QueryCount = 0;

            for (Match m = regexSemicolon.Match(sql); m.Success; m = m.NextMatch())
            {
                if (!string.IsNullOrWhiteSpace(m.Value))
                {
                    QueryCount++;
                    try
                    {
                        command.GetType().InvokeMember("CommandText", BindingFlags.SetProperty, null, command, new object[] { m.Value.Trim() });
                        object resultset  = command.GetType().GetMethod("ExecuteResultSet", new Type[] { enumType }, null).Invoke(command, new object[] { options });
                        bool   scrollable = (bool)resultset.GetType().InvokeMember("Scrollable", BindingFlags.GetProperty, null, resultset, null);
                        if (scrollable)
                        {
                            result = resultset;
                        }
                    }
                    catch (Exception e)
                    {
                        LastError = $"{GlobalText.GetValue("Query")} {QueryCount}: {(e.InnerException == null ? e.Message : e.InnerException.Message)}";
                        return(null);
                    }
                }
            }

            return(result);
        }
Exemplo n.º 13
0
        public AboutBox1()
        {
            InitializeComponent();
            this.Text               = String.Format("{0} {1}", GlobalText.GetValue("About"), AssemblyTitle);
            labelProductName.Text   = AssemblyProduct;
            labelVersion.Text       = String.Format("{0} {1}", GlobalText.GetValue("Version"), AssemblyVersion);
            labelCopyright.Text     = AssemblyCopyright;
            textBoxDescription.Text = GlobalText.GetValue("AboutDescription");
            okButton.Text           = GlobalText.GetValue("Ok");
            labelLanguage.Text      = Thread.CurrentThread.CurrentUICulture.Name;
            string s = GlobalText.GetValue("TranslationInfo");

            labelTranslationInfo.Text = s + ".";
            if (s == "English translation by Iván Costales Suárez (CompactView)")
            {
                tableLayoutPanel.RowStyles[5].Height = 0;
            }
        }
Exemplo n.º 14
0
 public static void ShowWarning(string warningMsg)
 {
     MessageBox.Show(warningMsg, GlobalText.GetValue("Warning"), MessageBoxButtons.OK, MessageBoxIcon.Warning);
 }
Exemplo n.º 15
0
 public static void ShowInfo(string key)
 {
     MessageBox.Show(GlobalText.GetValue(key), GlobalText.GetValue("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information);
 }
Exemplo n.º 16
0
        public static void ShowError(string key, string additionalMsg)
        {
            string errorText = string.IsNullOrEmpty(additionalMsg) ? GlobalText.GetValue(key) : GlobalText.GetValue(key) + ":\r\n\r\n" + additionalMsg;

            MessageBox.Show(errorText, GlobalText.GetValue("Error"), MessageBoxButtons.OK, MessageBoxIcon.Error);
        }