Created Model Base Class
Created the base class for all models and started on attributes
This commit is contained in:
44
Articulate/DBConnection.cs
Normal file
44
Articulate/DBConnection.cs
Normal file
@ -0,0 +1,44 @@
|
||||
using MySql.Data.MySqlClient;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace Articulate
|
||||
{
|
||||
public class DBConnection
|
||||
{
|
||||
public string Server { get; set; }
|
||||
public string DatabaseName { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string Password { get; set; }
|
||||
|
||||
private MySqlConnection Connection { get; set; }
|
||||
|
||||
private static DBConnection _instance = null;
|
||||
public static DBConnection Instance()
|
||||
{
|
||||
if (_instance == null)
|
||||
_instance = new DBConnection();
|
||||
return _instance;
|
||||
}
|
||||
|
||||
public bool IsConnect()
|
||||
{
|
||||
if (Connection == null)
|
||||
{
|
||||
if (String.IsNullOrEmpty(DatabaseName))
|
||||
return false;
|
||||
string connstring = string.Format("Server={0}; database={1}; UID={2}; password={3}", Server, DatabaseName, UserName, Password);
|
||||
Connection = new MySqlConnection(connstring);
|
||||
Connection.Open();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Close()
|
||||
{
|
||||
Connection.Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user