Пример #1
0
        private bool EditMovie()
        {
            if ((MessageBox.Show("Add new Movie with current information?", "Confirm",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                 MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes))
            {
                try
                {
                    String title    = TitleBox.Text;
                    String genre    = GenreComboBox.Text;
                    int    copies   = int.Parse(CopyAmountBox.Text);
                    float  fees     = float.Parse(FeesBox.Text);
                    Movie  newMovie = new Movie(title, genre, fees, copies, copies, 0);
                    newMovie.Id = movie.Id;
                    DBEnvironment.Edit(newMovie);

                    Starred starred = new Starred(this.movieActors.ToArray(), deletedActors.ToArray(), newMovie);
                    DBEnvironment.Edit(starred);
                }
                catch (Exception e)
                {
                }
            }

            return(true);
        }
Пример #2
0
        private bool EditMovie()
        {
            Movie edittedMovie = movie;

            if (TitleBox.Text != movie.Name)
            {
                Console.WriteLine("CHANGE TITLE");
                edittedMovie.Name = TitleBox.Text;
            }
            if (GenreBox.Text != movie.Genre)
            {
                edittedMovie.Genre = GenreBox.Text;
            }
            if (float.Parse(FeesBox.Text) != movie.Fees)
            {
                edittedMovie.Fees = (float.Parse(FeesBox.Text));
            }
            if (int.Parse(CopyAmountBox.Text) != movie.Num_copies)
            {
                edittedMovie.Num_copies = int.Parse(CopyAmountBox.Text);
            }
            if (DBEnvironment.Edit(edittedMovie))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #3
0
        private bool InsertMovie()
        {
            if ((MessageBox.Show("Add new Movie with current information?", "Confirm",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                 MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes))
            {
                try
                {
                    String title    = TitleBox.Text;
                    String genre    = GenreComboBox.Text;
                    int    copies   = int.Parse(CopyAmountBox.Text);
                    float  fees     = float.Parse(FeesBox.Text);
                    Movie  newMovie = new Movie(title, genre, fees, copies, copies, 0);
                    newMovie.Id = -1;
                    DBEnvironment.Add(newMovie);
                    movie = newMovie;

                    return(true);
                }
                catch (Exception Ex)
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #4
0
        private bool InsertUser()
        {
            if ((MessageBox.Show("Add new Customer with current information?", "Confirm",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                 MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes))
            {
                try
                {
                    Customer newCustomer = CreateCustomer();
                    DBEnvironment.Add(newCustomer);
                    MessageBox.Show("Customer successfully added!");
                    parent.Refresh();

                    return(true);
                }
                catch (Exception Ex)
                {
                    HandleException(Ex);
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        public MovieViewForm(Movie selectedMovie, Customer CurrentUser, bool canRate, CustomerForm parent)

        {
            this.parent  = parent;
            this.canRate = canRate;
            movie        = selectedMovie;
            user         = CurrentUser;
            InitializeComponent();
            NameLabel.Text   = movie.Name;
            GenreLabel.Text  = movie.Genre;
            RatingLabel.Text = movie.Rating.ToString();
            CopyLabel.Text   = movie.Num_copies.ToString();
            BindingList <Actor> actors  = DBEnvironment.RetrieveActors();
            Starred             starred = new Starred(actors.ToArray(), null, movie);

            actorsInMovie       = DBEnvironment.GetStarred(movie);
            MovieCastLabel.Text = CreateStarredText();
            RatingSlider.Hide();
            RatingButton.Hide();
            if (!canRate)
            {
                return;
            }
            RatingSlider.Show();
            RatingButton.Show();
            RentButton.Hide();
        }
Пример #6
0
 public void Reload()
 {
     DBEnvironment.SetActors();
     actors = DBEnvironment.GetActors();
     ActorList.DataSource = actors;
     this.Refresh();
 }
Пример #7
0
        public AddMovieForm(ManagerForm manager, Movie selectedMovie)
        {
            parent = manager;
            InitializeComponent();
            DBEnvironment.SetActors();
            actors                                        = DBEnvironment.GetActors();
            movieActors                                   = new BindingList <Actor>();
            deletedActors                                 = new BindingList <Actor>();
            movie                                         = selectedMovie;
            ActorList.DataSource                          = actors;
            MovieActorList.DataSource                     = movieActors;
            ActorList.AutoGenerateColumns                 = true;
            MovieActorList.Columns["Id"].Visible          = false;
            MovieActorList.Columns["Sex"].Visible         = false;
            MovieActorList.Columns["DateOfBirth"].Visible = false;
            MovieActorList.Columns["Age"].Visible         = false;
            MovieActorList.Columns["Rating"].Visible      = false;

            if (selectedMovie == null)
            {
                return;
            }
            movieActors = DBEnvironment.GetActors(selectedMovie);
            MovieActorList.DataSource = movieActors;


            fillForm();
        }
Пример #8
0
        static void Main()
        {
            DBEnvironment.ConnectToDB();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.Run(new LoginForm());
        }
Пример #9
0
 private void FufillOrderButton_Click(object sender, EventArgs e)
 {
     if (DBEnvironment.FulfillOrder(order.Id, parent.User.Id))
     {
         // update parent table
         parent.FillTable();
     }
     Close();
 }
Пример #10
0
        private void myMoviesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ChangeFormType();
            userQueue = DBEnvironment.RetrieveCustomerQueue(user);
            fillMovies();
            currentType = CustomerFormType.myMovies;
            Console.WriteLine("Showing Movies");

            myMoviesPanel.Visible = true;
        }
Пример #11
0
        public void fillMovies()
        {
            DBEnvironment.SetMovies();

            movies            = DBEnvironment.GetMovies();
            userQueue         = DBEnvironment.RetrieveCustomerQueue(user);
            pending           = DBEnvironment.RetrieveCustomerPending(user);
            currentlyRented   = DBEnvironment.GetCurrentlyRentedMovies(user);
            pastRented        = DBEnvironment.GetRentedInPast(user);
            recommendedMovies = DBEnvironment.GetRecommendedMovies(user);

            MovieGridView.DataSource                   = movies;
            MoviesQueuedGridView.DataSource            = userQueue;
            RentedMoviesGridView.DataSource            = currentlyRented;
            MoviesRentedThisMonth.DataSource           = pastRented;
            MoviesPendingDataGridView.DataSource       = pending;
            personalSuggestionsDataGridView.DataSource = recommendedMovies;

            personalSuggestionsDataGridView.Columns["Id"].Visible               = false;
            personalSuggestionsDataGridView.Columns["Num_copies"].Visible       = false;
            personalSuggestionsDataGridView.Columns["Copies_available"].Visible = false;
            personalSuggestionsDataGridView.Columns["customerRating"].Visible   = false;
            personalSuggestionsDataGridView.Columns["Fees"].Visible             = false;

            MovieGridView.Columns["Id"].Visible               = false;
            MovieGridView.Columns["Num_copies"].Visible       = false;
            MovieGridView.Columns["Copies_available"].Visible = false;
            MovieGridView.Columns["CustomerRating"].Visible   = false;
            MovieGridView.Columns["Fees"].Visible             = false;

            MoviesQueuedGridView.Columns["Id"].Visible               = false;
            MoviesQueuedGridView.Columns["Num_copies"].Visible       = false;
            MoviesQueuedGridView.Columns["Copies_available"].Visible = false;
            MoviesQueuedGridView.Columns["CustomerRating"].Visible   = false;
            MoviesQueuedGridView.Columns["Fees"].Visible             = false;

            RentedMoviesGridView.Columns["Id"].Visible               = false;
            RentedMoviesGridView.Columns["Num_copies"].Visible       = false;
            RentedMoviesGridView.Columns["Copies_available"].Visible = false;
            RentedMoviesGridView.Columns["CustomerRating"].Visible   = false;
            RentedMoviesGridView.Columns["Fees"].Visible             = false;

            MoviesRentedThisMonth.Columns["Id"].Visible                = false;
            MoviesRentedThisMonth.Columns["Num_copies"].Visible        = false;
            MoviesRentedThisMonth.Columns["Copies_available"].Visible  = false;
            MoviesRentedThisMonth.Columns["CustomerRating"].HeaderText = "Your Rating";
            MoviesRentedThisMonth.Columns["Fees"].Visible              = false;

            MoviesPendingDataGridView.Columns["Id"].Visible               = false;
            MoviesPendingDataGridView.Columns["Num_copies"].Visible       = false;
            MoviesPendingDataGridView.Columns["Copies_available"].Visible = false;
            MoviesPendingDataGridView.Columns["CustomerRating"].Visible   = false;
            MoviesPendingDataGridView.Columns["Fees"].Visible             = false;
        }
Пример #12
0
        private bool InsertActors(Movie movie)
        {
            Starred s = new Starred(movieActors.ToArray(), null, movie);

            if (!DBEnvironment.Add(s))
            {
                return(false);
            }

            return(true);
        }
Пример #13
0
        public void FillUserInfo()

        {
            user               = DBEnvironment.GetCustomerByID(user.Id);
            NameLabel.Text     = "Name:" + user.Name.FirstName + " " + user.Name.LastName;
            AddressLabel.Text  = "Address: " + user.Address.HouseNumber + " " + user.Address.StreetNumber;
            PhoneLabel.Text    = "Phone number: " + user.ContactInformation.CleanNumberForOutput();
            CityLabel.Text     = "City: " + user.Address.City;
            ProvinceLabel.Text = "Province: " + user.Address.Province;
            EmailLabel.Text    = "Email: " + user.ContactInformation.Email;
            NumberLabel.Text   = "Number: " + user.CreditCard;
        }
Пример #14
0
        private bool ValidUsernamePassword()
        {
            if (UsernameTextBox.Text == "" || PasswordTextBox.Text == "")
            {
                return(false);
            }

            if (!DBEnvironment.EmployeeUsernameAvailablility(UsernameTextBox.Text))
            {
                return(false);
            }

            return(true);
        }
Пример #15
0
 private void RatingButton_Click(object sender, EventArgs e)
 {
     if (DBEnvironment.AddMovieRating(movie, user, int.Parse(RatingLabel.Text)))
     {
         Debug.Print("Adding movie rating!");
         parent.fillMovies();
     }
     else
     {
         Debug.Print("Updating movie rating");
         DBEnvironment.EditMovieRating(movie, user, int.Parse(RatingLabel.Text));
         parent.fillMovies();
     }
     Close();
 }
Пример #16
0
        public bool MovieInQueue()
        {
            BindingList <Movie> userQueue;

            userQueue = DBEnvironment.RetrieveCustomerQueue(user);

            foreach (Movie queueMovie in userQueue)
            {
                if (queueMovie.Id == movie.Id)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #17
0
        private Employee ValidateEmployee()
        {
            string   name = NameTextBox.Text;
            string   pass = PasswordTextBox.Text;
            Employee employee;

            if (name == "admin" && pass == "pass")
            {
                employee = DBEnvironment.ValidateEmployee(name, pass);
                return(employee);
            }

            employee = DBEnvironment.ValidateEmployee(name, DBEnvironment.HashPassword(pass));

            return(employee);
        }
Пример #18
0
        private Employee ValidateManager()
        {
            string   name = NameTextBox.Text;
            string   pass = PasswordTextBox.Text;
            Employee manager;

            if (name == "admin" && pass == "pass")
            {
                manager = DBEnvironment.ValidateManager(name, pass);
                return(manager);
            }

            manager = DBEnvironment.ValidateManager(name, DBEnvironment.HashPassword(pass));

            return(manager);
        }
Пример #19
0
        private void DeleteActor_Click(object sender, EventArgs e)
        {
            if (selectedActor == null)
            {
                return;
            }


            if ((MessageBox.Show("are you sure you want to delete" + selectedActor.Name.FirstName + "?", "Confirm",
                                 MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                                 MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes))
            {
                DBEnvironment.Delete(selectedActor);
                this.Reload();
            }
        }
Пример #20
0
        private Customer ValidateCustomer()
        {
            string   name = NameTextBox.Text;
            string   pass = PasswordTextBox.Text;
            Customer customer;

            if (name == "admin" && pass == "pass")
            {
                customer = DBEnvironment.ValidateCustomer(name, pass);
                return(customer);
            }

            customer = DBEnvironment.ValidateCustomer(name, DBEnvironment.HashPassword(pass));

            return(customer);
        }
Пример #21
0
 public SearchMovieForm(CustomerForm manager)
 {
     parent = manager;
     InitializeComponent();
     DBEnvironment.SetActors();
     actors                                        = DBEnvironment.GetActors();
     movieActors                                   = new BindingList <Actor>();
     deletedActors                                 = new BindingList <Actor>();
     ActorList.DataSource                          = actors;
     MovieActorList.DataSource                     = movieActors;
     ActorList.AutoGenerateColumns                 = true;
     MovieActorList.Columns["Id"].Visible          = false;
     MovieActorList.Columns["Sex"].Visible         = false;
     MovieActorList.Columns["DateOfBirth"].Visible = false;
     MovieActorList.Columns["Age"].Visible         = false;
     MovieActorList.Columns["Rating"].Visible      = false;
 }
Пример #22
0
        private void FillForm()
        {
            Customer customer = DBEnvironment.GetCustomerByID(order.CustomerID);

            // get customer
            CustomerNameLabel.Text  = "Name: " + customer.FirstName + " " + customer.LastName;
            StreetAddressLabel.Text = "Street Address: " + customer.StreetNumber;
            CityLabel.Text          = "City: " + customer.City;
            ProvenceLabel.Text      = "Province: " + customer.Province;
            PostalCodeLabel.Text    = "Postal Code: " + customer.PostalCode;
            PhoneLabel.Text         = "Phone Number: " + customer.ContactInformation.PhoneNumber;
            EmailLabel.Text         = "Email: " + customer.ContactInformation.Email;

            Movie movie = DBEnvironment.GetMovieByID(order.MovieID);

            // get movie
            MovieTitleLabel.Text = "Title: " + movie.Name;
            MovieIDLabel.Text    = "Movie ID: " + movie.Id;
        }
Пример #23
0
        private void SearchButton_Click(object sender, EventArgs e)
        {
            FormInputHandler inputcleaner = new FormInputHandler();

            List <String> queryList = new List <String>();

            if (!inputcleaner.doesNotContainSemiColonOrSingleQuote(TitleBox.Text))
            {
                return;
            }

            String q = "Select * from movie where [name] like '%" + TitleBox.Text + "%' ";

            if (!inputcleaner.doesNotContainSemiColonOrSingleQuote(GenreComboBox.Text))
            {
                return;
            }

            if (GenreComboBox.Text != "")
            {
                queryList.Add("genre like '" + GenreComboBox.Text + "'");
            }


            if (movieActors.Count != 0)
            {
                string actors = "";
                foreach (Actor actor in movieActors)
                {
                    actors += actor.Id.ToString() + ", ";
                }
                //remove the last 2 characters
                actors = actors.Remove(actors.Length - 2);
                queryList.Add("mid in (select mid from starred where aid in (" + actors + "))");
            }

            foreach (string s in queryList)
            {
                q += "and " + s;
            }
            parent.fillSearch(DBEnvironment.searchForMovies(q));
        }
Пример #24
0
        private void RentButton_Click(object sender, EventArgs e)
        {
            AddToQueue adder = new AddToQueue(movie, user);

            if (adder.MovieInQueue())
            {
                MessageBox.Show("Movie is already in your queue");
                this.Close();
                return;
            }
            if (DBEnvironment.AddToQueue(adder))
            {
                MessageBox.Show("Movie has been added to your queue!");
            }
            else
            {
                MessageBox.Show("Movie could not be added");
            }
            this.Close();
        }
Пример #25
0
        private void ReturnMovieButton_Click(object sender, EventArgs e)
        {
            if (indexCurrentlyRented >= currentlyRented.Count)
            {
                return;
            }

            Movie movie = currentlyRented[indexCurrentlyRented];

            if (DBEnvironment.ReturnMovie(movie, user))
            {
                //if not in past update past
                if (pastRented.SingleOrDefault(_ => _.Id == movie.Id) == null)
                {
                    pastRented = DBEnvironment.GetRentedInPast(user);
                    MoviesRentedThisMonth.DataSource = pastRented;
                }
                currentlyRented.RemoveAt(indexCurrentlyRented);
            }
        }
Пример #26
0
 private bool InsertUser()
 {
     if ((MessageBox.Show("Add new Employee with current information?", "Confirm",
                          MessageBoxButtons.YesNo, MessageBoxIcon.Question,
                          MessageBoxDefaultButton.Button1) == System.Windows.Forms.DialogResult.Yes))
     {
         try
         {
             Employee newEmployee = CreateEmployee();
             DBEnvironment.Add(newEmployee);
             MessageBox.Show("Customer successfully added!");
             return(true);
         }
         catch (Exception Ex)
         {
             return(false);
         }
     }
     return(false);
 }
Пример #27
0
        public static BindingList <Actor> GetStarred(Movie movie)
        {
            int mid = movie.Id;
            BindingList <Actor> actors    = new BindingList <Actor>();
            BindingList <Actor> allActors = DBEnvironment.GetActors();

            String         query   = "SELECT aid FROM starred WHERE mid = " + mid;
            SqlDataAdapter adapter = new SqlDataAdapter(query, con);
            DataTable      table   = new DataTable();

            adapter.Fill(table);


            foreach (DataRow actorID in table.Rows)
            {
                int   aid        = int.Parse(actorID["aid"].ToString());
                Actor movieActor = DBEnvironment.RetreiveActorByID(aid);
                Debug.WriteLine("ACTOR " + movieActor.Name.FirstName + " " + movieActor.Name.LastName);
                actors.Add(movieActor);
            }

            return(actors);
        }
Пример #28
0
        private void AddEdit_Click(object sender, EventArgs e)
        {
            if (!Validate())
            {
                return;
            }

            UserName name = new UserName(this.FirstNameBox.Text, this.LastNameBox.Text);
            Actor    newActor;

            if (FemaleRadio.Checked)
            {
                //Need to fix on database, reinit constraint from G to F
                newActor = new Actor(name, "F", validator.getDBReadyDate(DateOfBirthBox.Text), "", "", "");
            }
            else if (MaleRadio.Checked)
            {
                newActor = new Actor(name, "M", validator.getDBReadyDate(DateOfBirthBox.Text), "", "", "");
            }
            else
            {
                return;
            }

            if (actor == null)
            {
                DBEnvironment.Add(newActor);
            }
            else
            {
                newActor.Id = actor.Id;
                DBEnvironment.Edit(newActor);
            }

            parent.Reload();
            this.Close();
        }
Пример #29
0
        private bool InputsValid()
        {
            string msg = "";

            if (FirstNameBox.Text == "")
            {
                msg += "First name cannot be blank.\n";
            }

            if (LastNameBox.Text == "")
            {
                msg += "Last name cannot be blank.\n";
            }

            if (UsernameTextBox.Text == "")
            {
                msg += "Username cannot be blank.\n";
            }
            else if (!DBEnvironment.CustomerUsernameAvailablility(UsernameTextBox.Text))
            {
                msg += "Username unavailable.\n";
            }

            if (PasswordTextBox.Text == "")
            {
                msg += "Password cannot be blank.\n";
            }

            if (msg != "")
            {
                MessageBox.Show(msg);
                return(false);
            }

            return(true);
        }
Пример #30
0
        private void EditUser()
        {
            Customer updatedCustomer = customer;

            if (customer.Name.FirstName != FirstNameBox.Text)
            {
                updatedCustomer.Name.FirstName = FirstNameBox.Text;
            }
            if (customer.Name.LastName != LastNameBox.Text)
            {
                updatedCustomer.Name.LastName = LastNameBox.Text;
            }
            if (customer.Address.City != CityBox.Text)
            {
                updatedCustomer.Address.City = CityBox.Text;
            }
            if (customer.Address.HouseNumber != HouseBox.Text)
            {
                updatedCustomer.Address.HouseNumber = HouseBox.Text;
            }
            if (customer.Address.PostalCode != PostalBox.Text)
            {
                if (PostalBox.Text == "")
                {
                    updatedCustomer.Address.PostalCode = "";
                }
                else
                {
                    updatedCustomer.Address.PostalCode = PostalBox.Text;
                }
            }
            if (customer.Address.Province != ProvinceBox.Text)
            {
                updatedCustomer.Address.Province = ProvinceBox.Text;
            }
            if (customer.Address.StreetNumber != StreetBox.Text)
            {
                updatedCustomer.Address.StreetNumber = StreetBox.Text;
            }
            if (customer.Address.SuiteNumber != SuiteBox.Text)
            {
                updatedCustomer.Address.SuiteNumber = SuiteBox.Text;
            }
            if (customer.ContactInformation.Email != EmailBox.Text)
            {
                if (EmailBox.Text == "")
                {
                    updatedCustomer.ContactInformation.Email = "";
                }
                else
                {
                    updatedCustomer.ContactInformation.Email = EmailBox.Text;
                }
            }
            if (customer.ContactInformation.PhoneNumber != PhoneBox.Text)
            {
                if (PhoneBox.Text == "")
                {
                    updatedCustomer.ContactInformation.PhoneNumber = "";
                }
                else
                {
                    updatedCustomer.ContactInformation.PhoneNumber = PhoneBox.Text;
                }
            }
            if (customer.Type.ToString() != TypeBox.SelectedItem.ToString())
            {
                updatedCustomer.Type = GetAccountType();
            }

            DBEnvironment.Edit(updatedCustomer);
            MessageBox.Show("Customer edit complete!");
        }