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
            AquaFish fishes = new AquaFish
            {
                Date = Convert.ToDateTime(datepicker.Text),
                TankLocation = Convert.ToString(Location.SelectedItem.Text),
                Specie = Convert.ToString(species.Text),
                NumberOfFish = Convert.ToInt16(num_fish.Text),
                TankTemp = Convert.ToDouble(water_temp.Text),
                HealthOfFish = Convert.ToString(health_fish.SelectedItem.Text),
                QualityOfWater = Convert.ToString(quality_aqua.SelectedItem.Text),
                LastDateOfWaterChange = Convert.ToDateTime(water_change.Text),
                DateBufferAdded = Convert.ToDateTime(buffer.Text),
                AmountBufferAdded = Convert.ToDouble(buf_add.Text),
                DateLastFed = Convert.ToDateTime(fish_fed.Text),
                AmountFed = Convert.ToDouble(fish_food.Text),
                Notes = Notes1.Text
            };
            //Insert fw into db
            db.AquaFishes.InsertOnSubmit(fishes);
            //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();
            }

        }
    }
示例#2
0
 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
         AquaFish fishes = new AquaFish
         {
             Date                  = Convert.ToDateTime(datepicker.Text),
             TankLocation          = Convert.ToString(Location.SelectedItem.Text),
             Specie                = Convert.ToString(species.Text),
             NumberOfFish          = Convert.ToInt16(num_fish.Text),
             TankTemp              = Convert.ToDouble(water_temp.Text),
             HealthOfFish          = Convert.ToString(health_fish.SelectedItem.Text),
             QualityOfWater        = Convert.ToString(quality_aqua.SelectedItem.Text),
             LastDateOfWaterChange = Convert.ToDateTime(water_change.Text),
             DateBufferAdded       = Convert.ToDateTime(buffer.Text),
             AmountBufferAdded     = Convert.ToDouble(buf_add.Text),
             DateLastFed           = Convert.ToDateTime(fish_fed.Text),
             AmountFed             = Convert.ToDouble(fish_food.Text),
             Notes                 = Notes1.Text
         };
         //Insert fw into db
         db.AquaFishes.InsertOnSubmit(fishes);
         //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 DeleteAquaFish(AquaFish instance);
 partial void UpdateAquaFish(AquaFish instance);
 partial void InsertAquaFish(AquaFish instance);