//this is the function that plotes the values form the graph.. public void plot_on_first_graph() { if (first_enable == 1 && second_enable == 1) { if (checkedListBox1.CheckedItems.Count > 0) { //string t = null; //lets check if the hour was changed or not... foreach (object item in checkedListBox1.CheckedItems)//this is done like this because the items checked has discarded in 0. { int index = checkedListBox1.Items.IndexOf(item); if (index != 0) { new_checked_item_index.Add(index); //t += index + ",\t"; } } //then only do the changes else we dont have to do it. //MessageBox.Show("it works\n "+t); //lets do the plotting part here.. if (dtp2.Value > dtp1.Value) { //-----------resetting to newly plotted graph---------// form1.plot_new_graph();//this is doen because we need to plot on new graph every time the values are pulled. //---------------resetting ends here-----------------// // string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); // string connString1 = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + dir + @"\T3000.mdb;Persist Security Info=True"; //sql connection string is this.. // string connString1 = @"Data Source=GREENBIRD;Initial Catalog=db_psychrometric_project;Integrated Security=True"; //--changing all the database to the sqlite database... string databasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string databaseFile = databasePath + @"\db_psychrometric_project.s3db"; string connString1 = @"Data Source=" + databaseFile + ";Version=3;"; using (SQLiteConnection connection1 = new SQLiteConnection(connString1)) { connection1.Open(); //string sql_query = "Select * from tbl_data_stored_temp_hum_one_year WHERE date_current = " + day_list[i] + " , hour_current = " + hour_al[h] + " AND station_name = "+ station_name +" ; "; //lets pass this string to a query which does the pulling part. SQLiteDataReader reader1 = null; SQLiteCommand command1 = new SQLiteCommand("Select * from tbl_historical_data WHERE date_current BETWEEN @date_first AND @date_second AND ID=@id_value", connection1); command1.Parameters.AddWithValue("@date_first", dtp1.Value); command1.Parameters.AddWithValue("@date_second", dtp2.Value); command1.Parameters.AddWithValue("@id_value", index_selected); //command1.Parameters.AddWithValue("@station_name", station_name); reader1 = command1.ExecuteReader(); while (reader1.Read()) { //station_name = reader["station_name"].ToString(); hist_temp_hum_list.Add( new data_type_hum_temp { temp = double.Parse(reader1["temperature"].ToString()), hum = double.Parse(reader1["humidity"].ToString()), date = reader1["date_current"].ToString(), hour = int.Parse(reader1["hour_current"].ToString()) }); } //close of while loop // connection1.Close(); } //close of database using statement //lets display the data //string test = null; //for (int i = 0; i < hist_temp_hum_list.Count; i++) //{ // test += hist_temp_hum_list[i].temp+" , hum= "+ hist_temp_hum_list[i].hum +",date="+hist_temp_hum_list[i].date+",hour="+hist_temp_hum_list[i].hour+"\n"; //} //MessageBox.Show("value = \n"+test); //since we have the data now we can start plotting it in the form.. for (int i = 0; i < new_checked_item_index.Count; i++) { for (int y = 0; y < hist_temp_hum_list.Count; y++) { //here we compare the desired outcome... if (new_checked_item_index[i].ToString() == hist_temp_hum_list[y].hour.ToString()) { //then push it into the new list.. temp_hist_temp_hum_list.Add(hist_temp_hum_list[y]); hist_temp_hum_list.RemoveAt(y); } } }//close of for.. //--Testing... //string test = null; //for (int i = 0; i < temp_hist_temp_hum_list.Count; i++) //{ // test += "Temp = "+temp_hist_temp_hum_list[i].temp + " , hum= " + temp_hist_temp_hum_list[i].hum + ",date=" + temp_hist_temp_hum_list[i].date + ",hour=" + temp_hist_temp_hum_list[i].hour + "\n"; //} // MessageBox.Show(WFA_psychometric_chart.Properties.Resources.after_filtering_the_values_of_ + test); //now lets plot it in the graph for (int x = 0; x < temp_hist_temp_hum_list.Count; x++) { //this plots the value form1.plot_by_DBT_HR((double)temp_hist_temp_hum_list[x].temp, (double)(temp_hist_temp_hum_list[x].hum / 100)); } //now lets reset all the values.. temp_hist_temp_hum_list.Clear(); hist_temp_hum_list.Clear(); new_checked_item_index.Clear(); form1.lb_title_display.Text = "Historical Plot"; //if plotted then we need to dissable the insert node fxn // insertNodeToolStripMenuItem.Enabled = false; }//close of comparision if else { MessageBox.Show(WFA_psychometric_chart.Properties.Resources.Please_enter_a_valid_dates_Dat); } }//close of if checkedItem>0 else { MessageBox.Show(WFA_psychometric_chart.Properties.Resources.Please_Select_one_or_more_hour); } } //close of if } //close of the main function .
}//close of class.my lsit private void button1_Click(object sender, EventArgs e) { //this part let the user plot the value on the graph.. /*Lets do follwing steps form now. * check the value are empty or not if empty message error... * check for the values are correct or not... * push the data in array list and pass the value to the form1. */ if (tb_ref_temp_ten.Text == "" || tb_ref_temp_twentyfive.Text == "" || tb_ref_temp_fourty.Text == "") { MessageBox.Show("Enter a valid refrence temperature value in degree celcius"); } else { //do some operation. if (tb_ref_hum_twentyfive.Text == "" || tb_ref_hum_fifty.Text == "" || tb_ref_hum_seventyfive.Text == "") { MessageBox.Show("Enter a valid refrence humidity value in %"); } else { //do something... //check for input boxex. if (tb_one.Text == "" || tb_two.Text == "" || tb_three.Text == "" || tb_four.Text == "" || tb_five.Text == "" || tb_six.Text == "" || tb_seven.Text == "" || tb_eight.Text == "" || tb_nine.Text == "") { MessageBox.Show("Enter a valid temperature value in the input boxex in degree celcius"); } else { //do something... try { //refrence temp and humidity double temp_ref1 = double.Parse(tb_ref_temp_ten.Text); double temp_ref2 = double.Parse(tb_ref_temp_twentyfive.Text); double temp_ref3 = double.Parse(tb_ref_temp_fourty.Text); double hum_ref1 = double.Parse(tb_ref_hum_twentyfive.Text); double hum_ref2 = double.Parse(tb_ref_hum_fifty.Text); double hum_ref3 = double.Parse(tb_ref_hum_seventyfive.Text); //the actual input temperature... double temp_one = double.Parse(tb_one.Text); double temp_two = double.Parse(tb_two.Text); double temp_three = double.Parse(tb_three.Text); double temp_four = double.Parse(tb_four.Text); double temp_five = double.Parse(tb_five.Text); double temp_six = double.Parse(tb_six.Text); double temp_seven = double.Parse(tb_seven.Text); double temp_eight = double.Parse(tb_eight.Text); double temp_nine = double.Parse(tb_nine.Text); //now lets throw this value in an array list and pass it to the other form using dynamic datatype.... //lets put this values in an list.. List <list_class> list_temp = new List <list_class>(); //lets add to this list.. list_temp.Add(new list_class { value1 = temp_ref1, value2 = hum_ref1 }); list_temp.Add(new list_class { value1 = temp_ref2, value2 = hum_ref2 }); list_temp.Add(new list_class { value1 = temp_ref3, value2 = hum_ref3 }); //lets add the nine values as well.. list_temp.Add(new list_class { value1 = temp_ref1, value2 = temp_one }); list_temp.Add(new list_class { value1 = temp_ref2, value2 = temp_two }); list_temp.Add(new list_class { value1 = temp_ref3, value2 = temp_three }); list_temp.Add(new list_class { value1 = temp_ref1, value2 = temp_four }); list_temp.Add(new list_class { value1 = temp_ref2, value2 = temp_five }); list_temp.Add(new list_class { value1 = temp_ref3, value2 = temp_six }); list_temp.Add(new list_class { value1 = temp_ref1, value2 = temp_seven }); list_temp.Add(new list_class { value1 = temp_ref2, value2 = temp_eight }); list_temp.Add(new list_class { value1 = temp_ref3, value2 = temp_nine }); form1.plot_new_graph(); //this one is working.. //now lets call the appropriate function to plot this values.. for (int i = 0; i < list_temp.Count; i++) { //form1.plot_by_DBT_HR((double)list_temp[i].value1, (double)list_temp[i].value2); form1.plot_by_DBT_HR((double)list_temp[i].value1, (double)(list_temp[i].value2 / 100)); //MessageBox.Show("temp =" + (double)list_temp[i].value1 + " , hum= " + (double)list_temp[i].value2); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } } } MessageBox.Show("success"); }