WFA_psychometric_chart.Form1_main.Form1_Load C# (CSharp) Method

Form1_Load() public method

public Form1_Load ( object sender, EventArgs e ) : void
sender object
e System.EventArgs
return void
        public void Form1_Load(object sender, EventArgs e)
        {




            //simulationMode.Text = WFA_psychometric_chart.Properties.Resources.Historical_Plot;
            lb_title_display.Text = "";
            //=====================================DATABASE OPERATION===============================//
            string dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            string databasePath1 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
            string databaseFile1 = databasePath1 + @"\db_psychrometric_project.s3db";
            if (File.Exists(databaseFile1))
            {
                //file exist so dont create the database      
            }
            else {
                MessageBox.Show("Internal database not found");
                this.Close();
                //--sqlite new databse creation
                sqlite_database_creation(); 
            }

            //first lets check for the data and then give user a message if a building is not create and selected.
            if(checkForDataInSqlite() != true)
            {
                //value is not present so say user select a building first / configure a building first then open again.
                MessageBox.Show("Please Configure the building location in T3000 first and restart the application again");
                //this.exit();
                this.Close();
                return;
            }
            //--This pulls the location info form alex db
            PullLocationInformation();//this is for loading location information

            //MessageBox.Show("ONe");

            //--This part is for checking the database and update the lat,long,elevation values in database...
            if (CheckLatLongAvailable() == true)
            {
                FillLatLongValueAutomatically();//--Fill the lat long values...
               //--MessageBox.Show("show filllat");
            }
            //--Now here lets pull the values from the database...
            /*
            This is basically for pulling altitude value for calculating the pressure value.
            */
            get_stored_data_about_building();

            //We have formula for altitude and pressure calculation
            /*
            #formula:
            P= 101325(1-2.25577*10^(-5)*h)^5.25588
            where p = air pressure in pa 
             h = altitude in meteres
            */
            // AirPressureFromDB = 

           //MessageBox.Show("Two");
            double altitue = buildingList[0].elevation;
            double P = 101325 * Math.Pow((1 - (2.25577 * Math.Pow(10, -5) * altitue)), 5.25588);

            if (P == 0 || P.ToString() == "")
            {
                //if empty or null put a default value
                AirPressureFromDB = 101325;//in terms of pa
            }
            else {
                AirPressureFromDB = P;
            }

           // AirPressureFromDB = 101325;//in terms of pa
           //=====================================END DB OPERATION=================================//

            //lets add the t and pg values
            add_t_pg();//Calling this method add the value...

            //--This is for label1 and label2
            //label1.Text = WFA_psychometric_chart.Properties.Resources.From;
            //label2.Text = WFA_psychometric_chart.Properties.Resources.To;
            //button2.Text = WFA_psychometric_chart.Properties.Resources.Show_Heat_Map;


            


            //lets plot the graph as soon as the form loads.
            plot_new_graph();

            //button1.Text = "Clear Chart"; //WFA_psychometric_chart.Properties.Resources.Refresh_Graph;
            //this is for adding values dynamically as the program loads. used by plot_on_graph_values() method 
            chart1.Series.Add(series1xx);
            //--This is added for the process diagram part...
            chart1.Series.Add(series1);
            chart1.Series.Add(series1_heat_map);
            chart1.Series.Add(seriesLineIndicator);//--This line indicator is for show temporary line for movement...
                                                   //=============================================Code from buildingSetting section ================================//  
                                                   //--ADDITIONAL PART OF CODE...

            //==========================For building infor==========//

            //  FindPathOfBuildingDB();
            FindPathOfBuildingDBNewVersion();
              //  MessageBox.Show("Test :Shows path of the building "+ BuildingSelected[0].Building_Path+",Building Name= "+ BuildingSelected[0].Building_Name);
              //==========================end of building info========//

              // MessageBox.Show("THREE");
              //--For datagridview1 editing option.
              // readOnlyModeSetUp();
              /*
              Steps :
              0.Check which DB is selected and display that value also store it in a variable...
              1.Create required DB if not present 
              2.If DB presnet then pull the values to display 
              */

              //===============================Building Selection starts=========================//
              CheckSelectedBuilding();
            string buildingNameValue = selectedBuildingList[0].BuildingName;
            lb_unit_chosen_display.Text = "Unit : " + buildingList[0].EngineeringUnits;
            lb_db_name.Text = buildingNameValue;

            //--Storing the currently selected building in a variable
            CurrentSelectedBuilding = selectedBuildingList[0].BuildingName;
           // MessageBox.Show("Current Building Selected" + CurrentSelectedBuilding);

            //--This is where the table creation is done
            CreateRequireTableIfNotPresent(buildingNameValue);

            DataGridView_Show_Data();
            dataGridView1.Rows.Add();
            //loading the comfortzone when set             
            //This to prevent anonomous plotting
            chart1.Enabled = false;
            //==============================end of building selection starts==================//

            //=======================================End of building Setting section.=======================================//

            // public List<chartDetailDT> chartDetailList = new List<chartDetailDT>();//This is used for storing the chart detail ids

            if (dataGridView1.Rows.Count > 0)  //If there is data then only do this one
            {
                //set parameters of your event args
                var eventArgs = new DataGridViewCellEventArgs(1, 0);
               // or setting the selected cells manually before executing the function
                dataGridView1.Rows[0].Cells[1].Selected = true;
                dataGridView1_CellClick(sender, eventArgs);
            }


            //--Assing the location path to alex database 
            //goind one step above to the porject
            string path = databasePath1 ;
            //string path = @"C:\Folder1\Folder2\Folder3\Folder4";
            string newPath = Path.GetFullPath(Path.Combine(path, @"..\"));
            string againNewPath = newPath+@"Database\Buildings\"+ buildingNameValue +@"\"+buildingNameValue+".db";  //psychopath+ database\Buildings\"BuildingName"\"BuildingName.db" 
            PathToT3000BuildingDB = againNewPath;
            //MessageBox.Show(againNewPath);
            
        }  //Close of the laod function
Form1_main