private void button1_Click(object sender, EventArgs e)
{
//When ok button is clicked the there should be plotting of the comfort zone.
//This has basically two function...
/*
* 1.insert the comfort zone info to database
* 2. Plot the comfort zone based on the value passed.
*/
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && textBox4.Text != "")
{
//chart id
string chartid = bs.chartDetailList[bs.indexOfChartSelected].chartID;
string comfortzoneid = bs.listComfortZoneDetail[comboBox1.SelectedIndex].id;
bs.InsertChartComfortzoneInfo(chartid, comfortzoneid);
//now second part call the plot function
// bs.PlotComfortZone()
double mint = double.Parse(textBox1.Text);
double maxt = double.Parse(textBox2.Text);
double minh = double.Parse(textBox3.Text);
double maxh = double.Parse(textBox4.Text);
Color c = bs.listComfortZoneDetail[comboBox1.SelectedIndex].colorValue;
string name = bs.listComfortZoneDetail[comboBox1.SelectedIndex].name;
if (bs.default_comfort_zone_of_chart.Count > 0)
{
if (bs.listchartComfortZoneInfoSingle.Count > 0)
{
//If default comfort zone is present then
//Clear previous one
//MessageBox.Show("Clear previous comfortzone");
bs.ClearComfortZone(double.Parse(bs.listchartComfortZoneInfoSingle[0].min_temp), double.Parse(bs.listchartComfortZoneInfoSingle[0].max_temp), double.Parse(bs.listchartComfortZoneInfoSingle[0].min_hum), double.Parse(bs.listchartComfortZoneInfoSingle[0].max_hum));
}
}
bs.PlotComfortZone(mint, maxt, minh, maxh, c, name);
//insert of update database value
bs.insertOrUpdateComfortChartSetting(chartid, comfortzoneid);
if (bs.dataGridView1.Rows.Count > 0) //If there is data then only do this one
{
//set parameters of your event args
var eventArgs = new DataGridViewCellEventArgs(1, bs.dataGridView1.CurrentCell.RowIndex);
// or setting the selected cells manually before executing the function
bs.dataGridView1.Rows[bs.dataGridView1.CurrentCell.RowIndex].Cells[1].Selected = true;
bs.dataGridView1_CellClick(sender, eventArgs);
}
this.Close();
}//close of if
}