public ReadNodeInfoToDelete ( string chartNodeID ) : void | ||
chartNodeID | string | |
Résultat | void |
public void ReadNodeInfoToDelete(string chartNodeID)
{
deleteNodeDetailList.Clear();
string tableName = "tbl_" + selectedBuildingList[0].BuildingName + "_node_value";// "tbl_" ++"_node_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();
SQLiteDataReader reader = null;
string queryString = "SELECT * from " + tableName + " where chart_respective_nodeID = @id_value";
SQLiteCommand command = new SQLiteCommand(queryString, connection);
command.Parameters.AddWithValue("@id_value", chartNodeID);
//SqlDataAdapter dataAdapter = new SqlDataAdapter(queryString, connection.ConnectionString); //connection.ConnectionString is the connection string
reader = command.ExecuteReader();
while (reader.Read())
{
deleteNodeDetailList.Add(new TempDataType
{
//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(),
//nodeSize = int.Parse(reader["nodeSize"].ToString())
id = reader["nodeID"].ToString(), //This is just changed code : bbk305
xVal = double.Parse(reader["xValue"].ToString()),
yVal = double.Parse(reader["yValue"].ToString()),
temperature_source = reader["temperature_source"].ToString(),
humidity_source = reader["humidity_source"].ToString(),
name = reader["name"].ToString(),
// label = reader["label"].ToString(),
colorValue = ColorTranslator.FromHtml(reader["colorValue"].ToString()),
// showItemText = reader["showTextItem"].ToString(),
marker_Size = int.Parse(reader["nodeSize"].ToString()),
airFlow = int.Parse(reader["airFlow"].ToString()),
lastUpdatedDate = reader["lastUpdatedDate"].ToString()
});
}
}//Close of using
}
public void deleteChartAndItsContent(string chartID1, string chart_resp_nodeid, string chart_resp_lineID) { //if (dataGridView1.CurrentCell.RowIndex > -1 && dataGridView1.CurrentCell.RowIndex < f1.chartDetailList.Count)//Header is selected.. if (chartID1 != "" && chart_resp_nodeid != "" && chart_resp_lineID != "")//Header is selected.. { //int selectedItemIndex = index;//dataGridView1.CurrentCell.RowIndex; //int.Parse(dataGridView1.Rows[indexSelectedForDeletion].Cells[0].Value.ToString()); //we need to find the corresponding tables for deletion. //int id = selectedItemIndex; string chartID = chartID1; //f1.chartDetailList[selectedItemIndex].chartID; string chart_respective_node_ID = chart_resp_nodeid; //f1.chartDetailList[selectedItemIndex].chart_respective_nodeID; string chart_respective_line_ID = chart_resp_lineID; //f1.chartDetailList[selectedItemIndex].chart_respective_lineID; //First read the node values for particular chart f1.ReadNodeInfoToDelete(chart_respective_node_ID); //For all node delete the device list if (f1.deleteNodeDetailList.Count > 0) { //if there is data then delete the device infor foreach (var item in f1.deleteNodeDetailList) { if ((item.temperature_source == "Device") || (item.humidity_source == "Device")) { f1.DeleteNodeDeviceInfo(item.id); } } } //After this deletion lets delete the line info f1.DeleteLine(chart_respective_line_ID);//This deletes the line //now delete comfort zone.. f1.DeleteComfortZoneSettingForChart(chartID); //now delete the node value f1.DeleteNode(chart_respective_node_ID); //Delete the mix node info f1.DeleteMixNodeInfo(chartID); //Now delete the chart itself f1.DeleteChart(chartID); }//Close of if }