/// <summary> /// Creates a new technology with a couple of emission factors for different years, then inserts that mix in the database /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void buttonNewTechnology_Click(object sender, EventArgs e) { //Hardcoded crude oil resource ID, could be fetched from the IData class instead int CRUDE_RES_ID = 23; //Creating new instance of a technology ITechnology technology = _dataHelper.CreateNewTechnology("Example4 Technology"); //Sets the resource being combusted/used by that technology bool success = _dataHelper.TechnologySetResource(technology, CRUDE_RES_ID); //Adds a couple of yers for the emissions that will be created success &= _dataHelper.TechnologyAddYear(technology, 2010); success &= _dataHelper.TechnologyAddYear(technology, 2014); //Adds a couple of emission factors for different gases IGas gas = _controller.CurrentProject.Data.Gases.AllValues.First(); IGas gas2 = _controller.CurrentProject.Data.Gases.AllValues.Last(); success &= _dataHelper.TechnologyAddEmission(technology, gas); success &= _dataHelper.TechnologyAddEmission(technology, gas2); //Retrieves an emission factor to observe it's value IParameter ef = _dataHelper.TechnologyGetEF(technology, 2014, gas.Id); //Sets the emission factor for a specific year and pollutant success &= _dataHelper.TechnologySetEF(technology, 2014, gas.Id, ef.UnitGroupName, 1); //Adds the technology to the database success &= _dataHelper.DataInsertOrUpdateTechnology(technology); if (success) { MessageBox.Show("Technology named : '" + technology.Name + "' inserted in dataset"); } else { MessageBox.Show("Failure"); } }