Beispiel #1
0
        void createNewQueryTab(string tableName)
        {
            try
            {
                this.Cursor = Cursors.WaitCursor;
                this.Update();
                TabPage newPage   = new TabPage("Query " + (++s_tabCount).ToString());
                var     queryCtrl = new QueryCtrl();
                queryCtrl.Dock = DockStyle.Fill;
                newPage.Controls.Add(queryCtrl);
                Tabs.TabPages.Add(newPage);
                Tabs.SelectedTab = newPage;

                if (tableName != null)
                {
                    string sql;
                    //sql = string.Format( "SELECT ID, [FirstName], LastName FROM [{0}]", tableName );
                    //sql = string.Format( "SELECT * FROM [{0}] ORDERBY LastName", tableName );
                    //sql = string.Format( @"SELECT ID, [FirstName], LastName FROM [{0}] WHERE firstname LIKE '\bjanet' ORDER BY LastName", tableName );
                    sql = string.Format("SELECT * FROM {0}", tableName);
                    queryCtrl.Execute(sql, true);
                }
                this.Cursor = Cursors.Default;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Beispiel #2
0
 private void Tabs_MouseClick(object sender, MouseEventArgs e)
 {
     if (e.Button == System.Windows.Forms.MouseButtons.Right)
     {
         Point pt = new Point(e.X, e.Y);
         for (int n = 0; n < Tabs.TabCount; n++)
         {
             if (Tabs.GetTabRect(n).Contains(pt))
             {
                 TabPage   tabPage   = Tabs.TabPages[n];
                 QueryCtrl queryCtrl = getQueryCtrlFromTabPage(tabPage);
                 if (queryCtrl.OkToClose())
                 {
                     Tabs.TabPages.Remove(tabPage);
                 }
             }
         }
     }
 }
Beispiel #3
0
        private void MainFrm_FormClosing(object sender, FormClosingEventArgs e)
        {
            try
            {
                foreach (TabPage tabPage in Tabs.TabPages)
                {
                    QueryCtrl queryCtrl = getQueryCtrlFromTabPage(tabPage);
                    if (!queryCtrl.OkToClose())
                    {
                        e.Cancel = true;
                        return;
                    }
                }

                DbView.CloseAll();
            }
            catch { }

            if (!e.Cancel)
            {
                Utils.Helpers.SaveFormPos(this, Path.Combine(StrFileDbRegKey, "FormSettings", "Main"));
            }

            // Keep track of last used date for licensing
            try
            {
                RegistryKey regKey = Registry.LocalMachine.OpenSubKey(MainFrm.WIN_REG_KEY, true);
                if (regKey == null)
                {
                    regKey = Registry.CurrentUser.OpenSubKey(MainFrm.WIN_REG_KEY, true);
                }
                int nDate = (int)DateTime.Now.ToOADate();
                regKey.SetValue(DMRU, nDate.ToString());
            }
            catch { }
        }