示例#1
0
        private void btnRent_Click(object sender, EventArgs e)
        {
            try
            {
                Rental rental = new Rental();
                rental.movie_number        = movie.movie_number;
                rental.member_number       = memberNum;
                rental.media_checkout_date = DateTime.Now.ToString();
                rental.media_return_date   = null;

                RentalDB.AddRental(rental);
                MessageBox.Show("Success!");
            }
            catch (Exception)
            {
                MessageBox.Show("Error in rental process", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
示例#2
0
        private void btn_Rent1_Click(object sender, EventArgs e)
        {
            Rental newRental = new Rental();

            newRental.movie_number  = MovieList[ScrollPosition].id;
            newRental.member_number = ActiveMember.id;
            Rental existingRental = RentalDB.GetRental(newRental.movie_number, newRental.member_number);

            if (existingRental is null)
            {
                //the member is NOT currently renting that movie
                newRental.media_checkout_date = DateTime.Now.ToString();
                newRental.media_return_date   = DateTime.Now.AddDays(30).ToString();
                RentalDB.AddRental(newRental);
                MessageBox.Show("You have rented " + lbl_Title1.Text + ", and it is due back by " + newRental.media_return_date + ". Thank you, please come again.");
            }
            else
            {
                //the member IS currently renting that movie
                MessageBox.Show("You are already renting " + lbl_Title1.Text + ". It was checked out at "
                                + existingRental.media_checkout_date + "and it is due back by " + existingRental.media_return_date +
                                ". You may not rent multiple copies of the same movie.");
            }
        }