public void ReadNodeAndLineDetails(string chart_respective_node_id, string chart_respective_line_id, string buildingName)
{
nodeList.Clear();//resetting the node value
lineList.Clear();//Resetting the line value
string tableForNode = "tbl_" + buildingName + "_node_value";
string tableForLine = "tbl_" + buildingName + "_line_value";
string databasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string databaseFile = databasePath + @"\db_psychrometric_project.s3db";
string connString = @"Data Source=" + databaseFile + ";Version=3;";
using (SQLiteConnection connection = new SQLiteConnection(connString))
{
connection.Open();
//--We also need to create table for particular data added..
//This is done because for each different building we need different
// tables and also we need to all the chart of single building in a s single table .
string sql = "select * from " + tableForNode + " where chart_respective_nodeID = " + chart_respective_node_id;
SQLiteCommand command = new SQLiteCommand(sql, connection);
SQLiteDataReader reader = command.ExecuteReader();
while (reader.Read())
{
//This is the reading part of the data...
nodeList.Add(new nodeDataType
{
count = int.Parse(reader["count"].ToString()),
chart_respective_nodeID = reader["chart_respective_nodeID"].ToString(),
nodeID = reader["nodeID"].ToString(),
xValue = double.Parse(reader["xValue"].ToString()),
yValue = double.Parse(reader["yValue"].ToString()),
source = reader["source"].ToString(),
name = reader["name"].ToString(),
label = reader["label"].ToString(),
colorValue = reader["colorValue"].ToString(),
showTextItem = reader["showTextItem"].ToString()
});
}
//This is for the line
string sql1 = "select * from " + tableForLine + " where chart_respective_nodeID = " + chart_respective_line_id;
SQLiteCommand command1 = new SQLiteCommand(sql1, connection);
SQLiteDataReader reader1 = command1.ExecuteReader();
while (reader1.Read())
{
//This is the reading part of the data...
lineList.Add(new lineDataType
{
count = int.Parse(reader1["count"].ToString()),
chart_respective_lineID = reader1["chart_respective_lineID"].ToString(),
lineID = reader1["lineID"].ToString(),
prevNodeID = reader1["prevNodeID"].ToString(),
nextNodeID = reader1["nextNodeID"].ToString(),
lineColorValue = reader1["lineColorValue"].ToString(),
lineSeriesID = reader1["lineSeriesID"].ToString(),
thickness = reader1["thickness"].ToString()
});
}
}
}