private void comboBoxHydroconditions_SelectionChanged_1(object sender, SelectionChangedEventArgs e) { if (comboBoxPeriods.SelectedIndex >= 0 && comboBoxHydroconditions.SelectedIndex >= 0) { Mersim mersimOne = controller.getDataForHydrocondition(idStudy, Convert.ToInt32(comboBoxYears.SelectedValue.ToString()), Convert.ToInt32(comboBoxPeriods.SelectedValue.ToString()), comboBoxHydroconditions.SelectedValue.ToString()); setData(mersimOne); } }
public Mersim getDataForHydrocondition(int idStudy, int year, int period, string hydrocondition) { Model model = new Model(); int hydroconditionId = getHydroconditionId(hydrocondition); IDataReader dataTotal = model.getScenario(idStudy, year, period, hydroconditionId); IDataReader dataThermal = model.getThermalDataForScenario(idStudy, year, period, hydroconditionId); IDataReader dataHydro = model.getHydroDataForScenario(idStudy, year, period, hydroconditionId); Mersim mersimOne = new Mersim(dataTotal, dataThermal, dataHydro); return(mersimOne); }
private void setData(Mersim mersimOne) { labelTotalCapacity.Content = mersimOne.totalCapacity[0]; labelPeakLoad.Content = mersimOne.peakLoad[0]; labelMinimumLoad.Content = mersimOne.minimumLoad[0]; lableMaintenanceSpace.Content = mersimOne.maintenanceSpace[0]; labelReserveCapacity.Content = mersimOne.reserveCapacity[0]; labelTotalGeneration.Content = mersimOne.totalGeneration[0]; labelEnergyDemand.Content = mersimOne.energyDemand[0]; labelUnservedEnergy.Content = mersimOne.unservedEnergy[0]; labelEnergyBalance.Content = mersimOne.energyBalance[0]; labelLossOfLoad.Content = mersimOne.lossOfLoadProbability[0]; labelEnergyPumped.Content = mersimOne.energyPumped[0]; dataTableThermal.ItemsSource = mersimOne.thermalData[0].DefaultView; dataTableHydro.ItemsSource = mersimOne.hydroData[0].DefaultView; }
public void addNewStudy(string name, DateTime date, Mersim mersimObj) { try { string tmpDate = date.ToString("yyyy-M-d"); string query = String.Format("insert into study (name,date) values('{0}','{1}');", name, date.ToString("yyyy-M-d")); DB.getInstance().executeNonQuery(query); IDataReader result = DB.getInstance().execute("select @@IDENTITY from study"); result.Read(); object tmp = result.GetValue(0); int identityStudy = int.Parse(tmp.ToString()); for (int i = 0; i < mersimObj.thermalData.Count; i++) { query = String.Format(@"insert into scenario (total_capacity,peak_load,minimum_load,maintenance_space,reserve_capacity,total_generation,energy_demand,unserved_energy,energy_balance,loss_of_load,energy_pumped,period,year,id_study,hydrocondition,probality) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", mersimObj.totalCapacity[i].ToString().Replace(',', '.'), mersimObj.peakLoad[i].ToString().Replace(',', '.'), mersimObj.minimumLoad[i].ToString().Replace(',', '.'), mersimObj.maintenanceSpace[i].ToString().Replace(',', '.'), mersimObj.reserveCapacity[i].ToString().Replace(',', '.'), mersimObj.totalGeneration[i].ToString().Replace(',', '.'), mersimObj.energyDemand[i].ToString().Replace(',', '.'), mersimObj.unservedEnergy[i].ToString().Replace(',', '.'), mersimObj.energyBalance[i].ToString().Replace(',', '.'), mersimObj.lossOfLoadProbability[i].ToString().Replace(',', '.'), mersimObj.energyPumped[i].ToString().Replace(',', '.'), mersimObj.period[i], mersimObj.year[i], identityStudy, mersimObj.hydrocondition[i].ToString().Replace(',', '.'), mersimObj.probality[i].ToString().Replace(',', '.')); DB.getInstance().executeNonQuery(query); result = DB.getInstance().execute("select @@IDENTITY from scenario"); result.Read(); int identityScenario = int.Parse(result.GetValue(0).ToString()); for (int j = 0; j < mersimObj.thermalData[i].Rows.Count; j++) { query = String.Format("insert into thermal_plants (id_scenario,plant_name,number_of_units,unit_base,total_capacity,plant_capacity,base_energy,peak_energy,total_energy,fuel_domestic,fuel_foreign,fuel_total,om_domestic,main_probality,for_cell,capacity_factor) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", identityScenario, mersimObj.thermalData[i].Rows[j].Field <string>(0), int.Parse(mersimObj.thermalData[i].Rows[j].Field <double>(1).ToString()), mersimObj.thermalData[i].Rows[j].Field <double>(2).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(3).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(4).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(5).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(6).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(7).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(8).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(9).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(10).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(11).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(12).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(13).ToString().Replace(',', '.'), mersimObj.thermalData[i].Rows[j].Field <double>(14).ToString().Replace(',', '.')); DB.getInstance().executeNonQuery(query); } for (int j = 0; j < mersimObj.hydroData[i].Rows.Count; j++) { query = String.Format("insert into hydro_plants (idscenario,name,number_of_units,lord_pos_pl,u,base_capacity,peak_capacity,total_capacity,base_energy,peak_energy,total_energy,peak_mineng,energy_spilled,energy_shortage,om_local,capacity_factor) values('{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}');", identityScenario, mersimObj.hydroData[i].Rows[j].Field <string>(0), mersimObj.hydroData[i].Rows[j].Field <double>(1).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(2).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(3).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(4).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(5).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(6).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(7).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(8).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(9).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(10).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(11).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(12).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(13).ToString().Replace(',', '.'), mersimObj.hydroData[i].Rows[j].Field <double>(14).ToString().Replace(',', '.')); DB.getInstance().executeNonQuery(query); } } result = DB.getInstance().execute("select count(*) from hydro_plants"); result.Read(); tmp = result.GetValue(0); return; } catch (Exception ex) { MessageBox.Show("Помилка додавання нового дослідження в базу даних!" + ex.Message); } }