Exemplo n.º 1
0
        //get new values from Dialog controls
        private void GetNewConnectionValues(ConnectionWindow win, out string NewConnString, out string newConnName)
        {
            ConnectionBase new_conn_base = new ConnectionBase();

            new_conn_base.Database = win.tbBD.Text.ToString().Trim();
            new_conn_base.Host     = win.tbHost.Text.ToString().Trim();
            new_conn_base.Port     = win.tbPort.Text.ToString().Trim();
            new_conn_base.Username = win.tbUsername.Text.ToString().Trim();
            new_conn_base.ConnName = win.tbNewConnectionName.Text.ToString().Trim();

            NewConnString = new_conn_base.BuildConnectionString();
            newConnName   = new_conn_base.ConnName;
        }
Exemplo n.º 2
0
        // OK button
        protected void BtnOk_Click(object sender, RoutedEventArgs e)
        {
            //check selected connection iin combobox
            if (cb_Connections.SelectedIndex < 0)
            {
                //MessageBox.Show("Выберите подключение");
                Ext.UIHelper.ShowToolTip("Выберите подключение", cb_Connections, 2);
                return;
            }
            //check empty password
            if (tbPassword.Password.ToString().Length < 1)
            {
                //tbPassword.Background = Brushes.MistyRose;
                Ext.UIHelper.ShowToolTip("Введите пароль", tbPassword, 3);
                tbPassword.Focus();
                return;
            }
            ConnectionBase connBase = new ConnectionBase();

            connBase.Database        = tbBD.Text;
            connBase.Host            = tbHost.Text;
            connBase.Port            = tbPort.Text;
            connBase.Username        = tbUsername.Text;
            connBase.Password        = tbPassword.Password.ToString();
            connBase.ApplicationName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + " " + versionNumberString;
            //create ConnectionString from ConnectionBase object
            _conn_string = connBase.BuildConnectionString();
            //Test connection. If OK - show MainWondow
            Exception access_accept = connBase.TestConnectionAccess(_conn_string);

            if (access_accept == null)
            {
                this.Hide();
                string conn_stringTitle = String.Format("{4} [{0}:{1}, {2}, {3}]", connBase.Host, connBase.Port, connBase.Database, connBase.Username, connBase.ApplicationName);
                Common.ConnectionStrings.ConnectionString = _conn_string;
                //Views.MainWindow mainWindow = new Views.MainWindow();
                //mainWindow.Title = conn_stringTitle;
                //mainWindow.Show();
                ShowMainWindow(conn_stringTitle);
            }
            else
            {
                MessageBox.Show(access_accept.Message);
            }
        }