using System.Data.SqlClient;

namespace Baza_Reklam
{
    internal class ConnString
    {
        private string value;

        public string Value
        {
            get { return value; }
            set { this.value = value; }
        }

        private static ConnString connectionString;

        private ConnString()
        {
        }

        public static ConnString getConnString()
        {
            if (connectionString == null)
            {
                connectionString = new ConnString();
            }
            return connectionString;
        }

        public static string GetDataBaseInfo()
        {
            SqlConnection sqlConnection = null;
            try
            {
                sqlConnection = new SqlConnection(getConnString().Value);
                return sqlConnection.DataSource + "/" + sqlConnection.Database;
            }
            catch
            {
                return string.Empty;
            }
            finally
            {
                if (sqlConnection != null) sqlConnection.Dispose();
            }
        }

        public static string GetDataSource()
        {
            SqlConnection sqlConnection = null;
            try
            {
                sqlConnection = new SqlConnection(getConnString().Value);
                return sqlConnection.DataSource;
            }
            catch
            {
                return string.Empty;
            }
            finally
            {
                if (sqlConnection != null) sqlConnection.Dispose();
            }
        }
    }
}