WFA_psychometric_chart.Form1_main.CheckSelectedBuilding C# (CSharp) Method

CheckSelectedBuilding() public method

public CheckSelectedBuilding ( ) : void
return void
        public void CheckSelectedBuilding()
        {


            selectedBuildingList.Clear();//Reset the values first ...
            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 tbl_building_location where selection = 1 ";
                SQLiteCommand command = new SQLiteCommand(queryString, connection);
                // command.Parameters.AddWithValue("@selection_value", id);
                //SqlDataAdapter dataAdapter = new SqlDataAdapter(queryString, connection.ConnectionString); //connection.ConnectionString is the connection string

                reader = command.ExecuteReader();
                while (reader.Read())
                {
                    //Now lets add to the list 
                    selectedBuildingList.Add(new SelectedBuildingDT
                    {
                        ID = int.Parse(reader["id"].ToString()),
                        country = reader["country"].ToString(),
                        state = reader["state"].ToString(),
                        city = reader["city"].ToString(),
                        street = reader["street"].ToString(),
                       // ZIP = int.Parse(reader["ZIP"].ToString()),  //--tHIS HAS BEEN REMOVED
                        longitude = double.Parse(reader["longitude"].ToString()),
                        latitude = double.Parse(reader["latitude"].ToString()),
                        elevation = double.Parse(reader["elevation"].ToString()),
                        BuildingName = reader["BuildingName"].ToString()
                    });
                }
            }//close of using..
        }

Usage Example

示例#1
0
        /// <summary>
        /// Functions helps to load teh values that hare dissabled in the list
        /// </summary>


        public void LoadDataFromDB()
        {
            //--We need to  pass the buildingName value

            Form1_main f1 = new Form1_main();

            f1.CheckSelectedBuilding();
            string buildingName = f1.selectedBuildingList[0].BuildingName;

            // f1.CurrentSelectedBuilding;//f1.selectedBuildingList[0].BuildingName;
            buildingNameGlobal = buildingName;

            // MessageBox.Show("BuildingName = " + buildingNameGlobal);
            if (buildingNameGlobal == "")
            {
                //If no building is selected then do not go futher
                return;
            }

            PullChartList(buildingName);
            // MessageBox.Show("number of list value items =  " + chartDetailListForDissabledValue.Count);

            //--Now lets load the values in the database

            fillDataGridView();//This will load the values form db

            // }
        }
All Usage Examples Of WFA_psychometric_chart.Form1_main::CheckSelectedBuilding
Form1_main