//When the submit button is commeted should do the following
    protected void buttonSubmit_Click(object sender, EventArgs e)
    {
        //Ensure the page is valid before you submit to the database
        if (Page.IsValid)
        {
            //Create instance of compost db and load values to go into the db
            EnergyProduction ep = new EnergyProduction
            {
                EnergyProducer = Convert.ToString(producer.SelectedItem.Text),
                Date = Convert.ToDateTime(datepicker.Text),
                AmountEnergyCreated = Convert.ToDouble(energy_pro.Text),
                PercentageOfEnergyProduced = Convert.ToDouble(Percent_Energy.Text),
                Notes = Convert.ToString(Notes1.Text)
                
            };
            //Insert fw into db
            db.EnergyProductions.InsertOnSubmit(ep);
            //Submit the changes and go home page
            //NOTE: Will not go to home page runnign in VS due to the way master pages work.
            try
            {
                db.SubmitChanges();
            }
            //If not throw error
            catch
            {
                Console.WriteLine(e);
                db.SubmitChanges();
            }

        }
    }
Beispiel #2
0
 //When the submit button is commeted should do the following
 protected void buttonSubmit_Click(object sender, EventArgs e)
 {
     //Ensure the page is valid before you submit to the database
     if (Page.IsValid)
     {
         //Create instance of compost db and load values to go into the db
         EnergyProduction ep = new EnergyProduction
         {
             EnergyProducer             = Convert.ToString(producer.SelectedItem.Text),
             Date                       = Convert.ToDateTime(datepicker.Text),
             AmountEnergyCreated        = Convert.ToDouble(energy_pro.Text),
             PercentageOfEnergyProduced = Convert.ToDouble(Percent_Energy.Text),
             Notes                      = Convert.ToString(Notes1.Text)
         };
         //Insert fw into db
         db.EnergyProductions.InsertOnSubmit(ep);
         //Submit the changes and go home page
         //NOTE: Will not go to home page runnign in VS due to the way master pages work.
         try
         {
             db.SubmitChanges();
         }
         //If not throw error
         catch
         {
             Console.WriteLine(e);
             db.SubmitChanges();
         }
     }
 }
 partial void DeleteEnergyProduction(EnergyProduction instance);
 partial void UpdateEnergyProduction(EnergyProduction instance);
 partial void InsertEnergyProduction(EnergyProduction instance);