Could Youyou help me learn iswhether this this is good, and if I'm designing my class in the proper way?
So here is my current version. (Sorry if it's too big)
// Main class that i'm trying to model in such way to be a conceptual model of my real SQL Database (FootballProject Database).
public class fp_Database
{
// Virtual DB.
public static DataSet DS = new DataSet();
// Construtor.
public fp_Database()
{
DS.Tables.Add("Seassons");
DS.Tables.Add("Countries");
DS.Tables.Add("Tournaments");
DS.Tables.Add("TeamsAllowed");
DS.Tables.Add("Matches");
Tables = new fp_Tables();
}
// Public Object fp_Tables containing the fp_Database tables.
public fp_Tables Tables;
// fp_Tables Class definition.
public class fp_Tables
{
// Instantiating all the Databases tables.
public tableMatches Matches = new tableMatches();
public tableSeassons Seassons = new tableSeassons();
public tableCountries Countries = new tableCountries();
public tableTournaments Tournaments = new tableTournaments();
// Definition of all the fp_Tables Classes.
public class tableSeassons
{
public DataTable Get_Table
{
get
{
return DS.Tables["Seassons"];
}
}
public tableSeassons()
{
DatabaseInterface DBInterface = new DatabaseInterface();
SqlCommand CMD = new SqlCommand("SELECT * FROM fp.Seassons");
DBInterface.GetTable(DS.Tables["Seassons"], CMD);
}
}
public class tableCountries
{
public DataTable Get_Table
{
get
{
return DS.Tables["Countries"];
}
}
public tableCountries()
{
DatabaseInterface DBInterface = new DatabaseInterface();
SqlCommand CMD = new SqlCommand("SELECT * FROM fp.Countries");
DBInterface.GetTable(DS.Tables["Countries"], CMD);
}
}
public class tableTournaments
{
public DataTable Get_Table
{
get
{
return DS.Tables["Tournaments"];
}
}
public void Set_Filters(int Seasson, int Country)
{
DS.Tables["Tournaments"].DefaultView.RowFilter = "Seasson = " + Seasson + " AND Country = " + Country;
}
public tableTournaments()
{
DatabaseInterface DBInterface = new DatabaseInterface();
SqlCommand CMD = new SqlCommand("SELECT * FROM fp.Tournaments ORDER BY Tournament");
DBInterface.GetTable(DS.Tables["Tournaments"], CMD);
}
}
public class tableMatches
{
public DataTable Get_Table
{
get
{
return DS.Tables["Matches"];
}
}
public void Load_Table_By_Tournament(int TournamentID)
{
DatabaseInterface DBInterface = new DatabaseInterface();
SqlCommand CMD = new SqlCommand("SELECT * FROM fp.Matches WHERE Tournament = " + TournamentID);
DS.Tables["Matches"].Clear();
DBInterface.GetTable(DS.Tables["Matches"], CMD);
}
}
}
}
// DATA ACCESS LAYER. (SELECT - INSERT - UPDATE - DELETE)
class DatabaseInterface
{
// Latter i will learn how to save the connection string into app.config file and read from int too.
private SqlConnection Conn = new SqlConnection("Data Source=DESKTOP-8MGVKID\\MSSQLSERVER2016;Initial Catalog=FootballProject;Integrated Security=True");
// Select Method.
public void GetTable (DataTable Table, SqlCommand SQLCommand)
{
SqlDataAdapter DA = new SqlDataAdapter(SQLCommand.CommandText, Conn);
Conn.Open();
DA.Fill(Table);
Conn.Close();
}
// Here will be Insert Method
// Here will be Update Method.
// Here will be Delete Method
}