using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MySql.Data.MySqlClient;

namespace sport_invent_modul_14._05
{
    internal class DB
    {
        private static DB instance = null;
        MySqlConnection connection = new MySqlConnection("server = 85.239.57.125; port = 3306; username = Primakov_Natalya; password = Primakov_Natalya; database=Primakov_Natalya_modul; uid=Primakov_Natalya; pwd=TempPass123!");
        static public MySqlDataAdapter adapter;
        static MySqlConnection myconnect;
        static public MySqlCommand command;


        public DB() { }
        public static DB getInstance()
        {
            if (instance != null)
                return instance;
            else
            {
                instance = new DB();
                instance.OpenConnection();
                return instance;
            }
        }

        public void OpenConnection()
        {
            if (connection.State == System.Data.ConnectionState.Closed) connection.Open();
        }
        public void CloseConnection()
        {
            if (connection.State != System.Data.ConnectionState.Open) connection.Close();
        }
        public MySqlConnection getConnection()
        {
            return connection;
        }
    }
}
