public bool TestConnection()
        {
            try
            {
                DatabaseFactory.TestConnection(Connection);
                Loggable.Log(ConnectionSuccess);
                return(true);
            }
            catch (ArgumentException e)
            {
                Loggable.Log(e.Message);
            }

            return(false);
        }
        public bool SelectDatabase(string dbName)
        {
            if (Connection == null || Connection.State != ConnectionState.Open)
            {
                Loggable.Log(ConnectionNotOpenMsg);
                return(false);
            }

            if (string.IsNullOrEmpty(dbName) || !dbName.Contains(Config.DatabaseNamePrefix))
            {
                Loggable.Log(InvalidDatabase);
                return(false);
            }

            DbProperties.DatabaseName = dbName;
            Connection.Close();
            return(InitConnection(DbProperties) != null);
        }
        public List <string> GetDatabases()
        {
            if (Connection == null || Connection.State != ConnectionState.Open)
            {
                Loggable.Log(ConnectionNotOpenMsg);
                return(new List <string>());
            }

            var cmd       = new MySqlCommand("SHOW DATABASES", Connection);
            var reader    = cmd.ExecuteReader();
            var databases = new List <string>();

            while (reader.Read())
            {
                var dbName = reader["Database"].ToString();
                if (dbName.Contains(Config.DatabaseNamePrefix))
                {
                    databases.Add(dbName);
                }
            }

            reader.Close();
            return(databases);
        }
 private void grid_DataError(object sender, DataGridViewDataErrorEventArgs e)
 {
     e.Cancel = true;
     Loggable.Log(ErrorOnRow + (e.RowIndex + 1));
 }