Exemple #1
0
        protected void _btnHyreMovie_Click(object sender, EventArgs e)
        {
            //Get UserName And Id Movie to Hyre
            string userName = Session["User"].ToString();

            var custThatWillHire = ctxCustomer.GetCustomerByName(userName);


            Button btn           = (Button)sender;
            string IdMovieToHyre = btn.Attributes["Value"];
            int    idmovie;

            Int32.TryParse(IdMovieToHyre, out idmovie);
            ///////////////
            //Check if movie available:
            bool isRented = ctxRented.GetAllMovieIfINRentedList(idmovie);


            if (isRented == false)
            {
                var rentedMovie = ctxRented.HireMovieNewEntry(idmovie, custThatWillHire.CustomerID);
                Response.Redirect("~/Pages/UserRentedMovies");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Movie not available, please choose another one");
            }
        }
Exemple #2
0
        protected void _btnCreateRentedMovie_Click(object sender, EventArgs e)
        {
            //Get Date From TextBox
            //DateTime date = new DateTime();
            //DateTime.TryParse(_txtBoxRentedTo.Text, out date);

            //Get Customer From DropDown
            int customerID;

            Int32.TryParse(_dropDownCustomers.SelectedValue, out customerID);
            //Get MovieID
            int movieID;

            Int32.TryParse(_dropDownMovies.SelectedValue, out movieID);

            bool isRent = context.GetAllMovieIfINRentedList(movieID);

            if (isRent == false)
            {
                var rentedMovie = context.HireMovieNewEntry(movieID, customerID);
                Response.Redirect("~/Pages/Rented");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Movie not available, please choose another one");
            }



            //var rentedMovie = context.HireMovie(movieID, customerID);
            //Response.Redirect("~/Pages/Rented.aspx");


            //int genre;
            //Int32.TryParse(_dropDownGender.SelectedValue, out genre);
            //DateTime releasedYear;
            //DateTime.TryParse(_txtBoxReleaseYear.Text, out releasedYear);
            //context.CreateMovie(new Movie(_txtBoxMovieName.Text, _txtBoxDirector.Text, releasedYear, genre));
            //Response.Redirect("~/Pages/Movies.aspx");
        }
Exemple #3
0
        protected void _btnUpdateRentedMovie_Click(object sender, EventArgs e)
        {
            //Get Rented Entry to compare
            int    rentedID;
            string rentedIDString = Session["RentedToUpdate"].ToString();

            Int32.TryParse(rentedIDString, out rentedID);
            var rentedMovie = context.GetRentedMovie(rentedID);

            //Get Customer From DropDown
            int customerID;

            Int32.TryParse(_dropDownCustomers.SelectedValue, out customerID);

            //Get MovieID
            int movieID;

            Int32.TryParse(_dropDownMovies.SelectedValue, out movieID);


            if (movieID != rentedMovie.MovieID)
            {
                //Check if movie available for rent
                bool isRent = context.GetAllMovieIfINRentedList(movieID);

                //Ckect date limit
                DateTime limit = DateTime.Now.AddDays(7);
                DateTime inputDate;
                DateTime.TryParse(_txtBoxRentedTo.Text, out inputDate);
                if (inputDate > limit)
                {
                    System.Windows.Forms.MessageBox.Show("Max rent days: 7");
                }
                else if (inputDate < DateTime.Now)
                {
                    System.Windows.Forms.MessageBox.Show("Please enter a present or future date (max 7 days)");
                }
                else
                {
                    if (isRent == false)
                    {
                        isRent = context.HireMovieUpdateEntry(new RentedMovies(rentedID, customerID, movieID, inputDate));
                        Response.Redirect("~/Pages/Rented");
                    }
                    else
                    {
                        System.Windows.Forms.MessageBox.Show("Movie not available, please choose another one");
                    }
                }
            }
            else
            {
                DateTime limit = DateTime.Now.AddDays(7);
                DateTime inputDate;
                DateTime.TryParse(_txtBoxRentedTo.Text, out inputDate);
                if (inputDate > limit)
                {
                    System.Windows.Forms.MessageBox.Show("Max rent days: 7");
                }
                else if (inputDate < DateTime.Now)
                {
                    System.Windows.Forms.MessageBox.Show("Please enter a present or future date (max 7 days)");
                }
                else
                {
                    bool isRent = context.HireMovieUpdateEntry(new RentedMovies(rentedID, customerID, movieID, inputDate));
                    Response.Redirect("~/Pages/Rented");
                }
            }
        }