Esempio n. 1
0
        private IQueryForm DoConnect()
        {
            ConnectForm cf = new ConnectForm();

            cf.ApplyServerList(serverList);
            if (cf.ShowDialog(this) == DialogResult.OK)
            {
                int settingIndex = serverList.IndexOf(cf.DbClient.ConSettings.Key);
                if (settingIndex >= 0)
                {
                    serverList.Items[settingIndex] = (cf.DbClient.ConSettings);
                }
                else
                {
                    serverList.Add(cf.DbClient.ConSettings);
                }
                SaveServerList();
                QueryForm qf = new QueryForm(cf.DbClient, false); //, cf.Browser, cf.LowBandwidth);
                qf.MdiParent = this;
                // This is so that we can update the toolbar and menu as the state of the QueryForm changes.
                qf.PropertyChanged += new EventHandler <EventArgs>(qf_PropertyChanged);
                qf.MRUFileAdded    += new EventHandler <MRUFileAddedEventArgs>(qf_MRUFileAdded);
                qf.WindowState      = FormWindowState.Maximized;
                qf.Show();
                return(qf);
            }
            return(null);
        }
Esempio n. 2
0
        private IQueryForm DoConnect(ConnectionSettings conSettings)
        {
            DbClient client    = DbClientFactory.GetDBClient(conSettings);
            Cursor   oldCursor = Cursor;

            Cursor = Cursors.WaitCursor;

            ConnectingForm c = new ConnectingForm();

            c.Show();
            c.Refresh();

            bool success = client.Connect();

            c.Close();
            Cursor = oldCursor;

            if (!success)
            {
                MessageBox.Show("Unable to connect: " + client.ErrorMessage, "Query Express", MessageBoxButtons.OK, MessageBoxIcon.Error);
                client.Dispose();
                return(null);
            }
            int settingIndex = serverList.IndexOf(client.ConSettings.Key);

            if (settingIndex >= 0)
            {
                serverList.Items[settingIndex] = (client.ConSettings);
            }
            else
            {
                serverList.Add(client.ConSettings);
            }
            SaveServerList();
            QueryForm qf = new QueryForm(client, false); //, cf.Browser, cf.LowBandwidth);

            qf.MdiParent   = this;
            qf.WindowState = FormWindowState.Maximized;
            // This is so that we can update the toolbar and menu as the state of the QueryForm changes.
            qf.PropertyChanged += new EventHandler <EventArgs>(qf_PropertyChanged);
            qf.MRUFileAdded    += new EventHandler <MRUFileAddedEventArgs>(qf_MRUFileAdded);
            qf.Show();

            return(qf);
        }