Esempio n. 1
0
        private void rentBtn_Click_1(object sender, EventArgs e)
        {
            bool requiredFieldsFilled = false;



            while (requiredFieldsFilled == false)
            {
                if (movie_IDTextBox.Text.Equals("") || customer_IDTextBox.Text.Equals(""))
                {
                    MessageBox.Show("You have stated the movie is being checked out. Either the Customer ID or" +
                                    "Date Rented fields are blank. Please fill in both fields to continue.");

                    requiredFieldsFilled = false;
                    return;
                }
                else
                {
                    requiredFieldsFilled = true;
                }
            }

            int  convertedRentalID = rentalController.convertedText(movie_IDTextBox.Text);
            int  convertedClientID = rentalController.convertedText(customer_IDTextBox.Text);
            bool ischecked         = false;

            if (rentedChkBx.Checked)
            {
                ischecked = true;
            }

            RentMovie rentMovie = new RentMovie()
            {
                customerID = convertedClientID,
                movieID    = convertedRentalID,
                movieTitle = movieTitleTextBx.Text,
                dateRented = newdateRentedTxtBx.Text,
                rented     = ischecked
            };

            bool canRent = false;

            canRent = rentalController.testToRent(rentMovie);
            if (canRent == false)
            {
                MessageBox.Show("The movie is already rented or the customer " +
                                "already has 3 movies rented. They cannot rent this title.");
            }
            else
            {
                rentalController.RentMovie(rentMovie);
                rentedChkBx.Checked = true;
            }
            this.mOVIE_INFOTableAdapter.Fill(this.mOVIESDataSet1.MOVIE_INFO);
            // TODO: This line of code loads data into the 'mOVIESDataSet.MOVIE_INFO' table. You can move, or remove it, as needed.
            this.mOVIE_INFOTableAdapter.Fill(this.mOVIESDataSet.MOVIE_INFO);
            // TODO: This line of code loads data into the 'mOVIESDataSet.RENTAL' table. You can move, or remove it, as needed.
            this.rENTALTableAdapter.Fill(this.mOVIESDataSet.RENTAL);

            //clearAll();
        }