Exemple #1
0
        public frmConnectionManager(frmMain frmMain, ref proGEDIA.Utilities.Database database)
        {
            this.frmMain  = frmMain;
            this.database = database;

            InitializeComponent();
        }
Exemple #2
0
        private void cbServerName_SelectedIndexChanged(object sender, EventArgs e)
        {
            proGEDIA.Utilities.Database item = (proGEDIA.Utilities.Database)cbServerName.SelectedItem;

            tbServerPort.Text              = item.serverPort;
            tbServiceName.Text             = item.serviceName;
            tbDatabaseName.Text            = item.databaseName;
            tbDatabaseFile.Text            = item.databaseFile;
            cbAuthentication.SelectedIndex = item.userAuth ? 0 : 1;
            tbUserName.Text            = item.userName;
            tbUserPassword.Text        = item.userPass;
            cbRememberPassword.Checked = item.rememberPassword;
        }
        public void Add(proGEDIA.Utilities.Database set)
        {
            foreach (var item in database.Select((value, i) => new { i, value }))
            {
                if (item.value.serverType == set.serverType && item.value.serverName == set.serverName && item.value.serverPort == set.serverPort)
                {
                    database.RemoveAt(item.i);

                    break;
                }
            }

            database.Add(set);
        }
        public frmDataSelector(proGEDIA.Utilities.Database database, string db_name, ref DatabaseBackup backup_settings)
        {
            this.database        = database;
            this.db_name         = db_name;
            this.backup_settings = backup_settings;

            InitializeComponent();

            for (int i = 0; i < dgvTableList.Columns.Count; i++)
            {
                dgvTableList.Columns[i].HeaderCell.Style.Alignment = DataGridViewContentAlignment.BottomCenter;
            }
            dgvTableList.AutoSizeRowsMode      = DataGridViewAutoSizeRowsMode.None;
            dgvTableList.AllowUserToResizeRows = false;

            this.MinimumSize = this.Size;
        }
        private void loadDatabases(proGEDIA.Utilities.Database db, ComboBox cb)
        {
            cb.Items.Clear();
            switch (db.serverType.ToLower())
            {
            case "mssql":
                if (db_source.mssqlCon != null && db_source.mssqlCon.State == ConnectionState.Open)
                {
                    db_source.mssqlCon.Close();
                }

                if (db_source.mssqlCon == null)
                {
                    db_source.mssqlCon = new SqlConnection();
                }

                db_source.mssqlCon.ConnectionString = db.GetConnectionString();
                try {
                    db_source.mssqlCon.Open();
                } catch (Exception ex) {
                    MessageBox.Show("Could not connect to database.\r\n" + ex.Message);

                    return;
                }

                SqlCommand mssqlCom = db_source.mssqlCon.CreateCommand();
                mssqlCom.CommandText = "SELECT name FROM sys.databases WHERE name NOT IN('master', 'tempdb', 'model', 'msdb') ORDER BY name";
                try {
                    SqlDataReader mssqlReader = mssqlCom.ExecuteReader();
                    while (mssqlReader.Read())
                    {
                        cb.Items.Add(mssqlReader[0].ToString());
                    }
                    mssqlReader.Close();
                } catch (Exception ex) {
                    MessageBox.Show("Could not get database list.\r\n" + ex.Message);
                }
                break;

            case "mysql":
                if (db_source.mysqlCon != null && db_source.mysqlCon.State == ConnectionState.Open)
                {
                    db_source.mysqlCon.Close();
                }

                if (db_source.mysqlCon == null)
                {
                    db_source.mysqlCon = new MySqlConnection();
                }

                db_source.mysqlCon.ConnectionString = db.GetConnectionString();
                try {
                    db_source.mysqlCon.Open();
                } catch (Exception ex) {
                    MessageBox.Show("Could not connect to database.\r\n" + ex.Message);

                    return;
                }

                MySqlCommand mysqlCom = db_source.mysqlCon.CreateCommand();
                mysqlCom.CommandText = "SELECT schema_name FROM information_schema.schemata WHERE schema_name NOT LIKE '%schema' ORDER BY schema_name";
                try {
                    MySqlDataReader mysqlReader = mysqlCom.ExecuteReader();
                    while (mysqlReader.Read())
                    {
                        cb.Items.Add(mysqlReader[0].ToString());
                    }
                    mysqlReader.Close();
                } catch (Exception ex) {
                    MessageBox.Show("Could not get database list.\r\n" + ex.Message);
                }
                break;

            case "sqlite":
                if (db_source.sqliteCon != null && db_source.sqliteCon.State == ConnectionState.Open)
                {
                    db_source.sqliteCon.Close();
                }

                if (db_source.sqliteCon == null)
                {
                    db_source.sqliteCon = new SQLiteConnection();
                }

                db_source.sqliteCon.ConnectionString = db.GetConnectionString();
                try {
                    db_source.sqliteCon.Open();
                } catch (Exception ex) {
                    MessageBox.Show("Could not connect to database.\r\n" + ex.Message);

                    return;
                }

                cb.Items.Add(db_source.serverName);
                cb.SelectedIndex = 0;
                break;
            }
        }