WFA_psychometric_chart.Form1_main.DeleteNode C# (CSharp) Method

DeleteNode() public method

public DeleteNode ( string nodeID ) : void
nodeID string
return void
        public void DeleteNode(string nodeID)
        {
            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 = "delete   from  " + tableName + "  where chart_respective_nodeID = @id_value";
                SQLiteCommand command = new SQLiteCommand(queryString, connection);
                command.Parameters.AddWithValue("@id_value", nodeID);
                //SqlDataAdapter dataAdapter = new SqlDataAdapter(queryString, connection.ConnectionString); //connection.ConnectionString is the connection string
                reader = command.ExecuteReader();


            }//Close of using 
        }

Usage Example

Example #1
0
        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
        }
Form1_main