Ejemplo n.º 1
0
        private void UpdateButton_Click(object sender, EventArgs e)
        {
            short videoCode;
            float rentalCost;

            // Get movie object using LINQ
            Movie m = context.Movies.OrderBy(x => x.VideoCode).Skip(currentRowIndex).FirstOrDefault();

            // TryParse VideoCode
            if (short.TryParse(VideoCodeTextBox.Text, out videoCode))
            {
                m.VideoCode = videoCode;
            }
            else
            {
                MessageBox.Show("Unable to parse Video Code, please enter a valid number.");
                return;
            }

            // TryParse RentalCost
            if (float.TryParse(RentalCostTextBox.Text, out rentalCost))
            {
                m.RentalCost = rentalCost;
            }
            else
            {
                MessageBox.Show("Unable to parse Rental Cost, please enter a valid cost.");
                return;
            }

            m.MovieTitle = MovieTitleTextBox.Text;
            m.Genre      = GenreTextBox.Text;

            context.SaveChanges();
            ShowFields(currentRowIndex);
            MessageBox.Show("Successfully updated row.");
        }
Ejemplo n.º 2
0
 private void Question4b()
 {
     context.Movies.Where(x => x.VideoCode == 5).First().RentalCost = (float?)1.8;
     context.SaveChanges();
 }