Esempio n. 1
0
        private void rent1Btn_Click(object sender, EventArgs e)
        {
            string upc = checkout1Txt.Text.Trim(' ');

            if (!Check.isUPC(upc))
            {
                Prompt.enterUPC();
                return;
            }

            if (!CopiesTable.hasCopy(upc))
            {
                Prompt.notInDB("dvd", "UPC");
                return;
            }
            if (!CopiesTable.isAvailable(upc))
            {
                Prompt.copyUnavailable();
                return;
            }

            string movie = MoviesTable.getMovieName(upc);

            currentDVD = new DVD(movie, upc);

            clearTextBoxes(rentPnl);
            setCurrentMainPanel(rent2Pnl);
        }
Esempio n. 2
0
        public void setupAdminPnl()
        {
            //fill the data tables with info
            if (isFirstSetup)
            {
                try
                {
                    admin1Data.DataSource = EmployeesTable.getAll();
                    admin1Data.Columns["password"].Visible = false;
                    admin1Data.Columns["deleted"].Visible  = false;

                    admin2Data.DataSource = CustomersTable.getAll();
                    admin2Data.Columns["deleted"].Visible = false;

                    admin3Data.DataSource = MoviesTable.getAll();
                    admin3Data.Columns["deleted"].Visible = false;
                    sortBy(admin3Data, 1, true);

                    admin4Data.DataSource = CopiesTable.getAll();
                    admin4Data.Columns["deleted"].Visible = false;
                    sortBy(admin4Data, 0, true);
                }catch
                {
                    EmployeesTable.adapter.Dispose();
                    CustomersTable.adapter.Dispose();
                    MoviesTable.adapter.Dispose();
                    CopiesTable.adapter.Dispose();
                    Prompt.dbError();
                }
            }

            Reposition.setControl(adminTitleLbl, .4, .7, 0, .1);

            Reposition.setControl(adminTab, .1, .9, .1, .9);

            Reposition.setNestedControlPosition(admin1Data, .05, .95, 0, .8);
            Reposition.setNestedControlPosition(admin2Data, .05, .95, 0, .8);
            Reposition.setNestedControlPosition(admin3Data, .05, .95, 0, .8);
            Reposition.setNestedControlPosition(admin4Data, .05, .95, 0, .8);

            //user Buttons
            Reposition.setNestedControlLocation(admin1Btn, .1, .85);
            Reposition.setNestedControlLocation(adminPasswordBtn, .4, .85);
            Reposition.setNestedControlLocation(admin2Btn, .7, .85);

            //customer buttons
            Reposition.setNestedControlLocation(admin3Btn, .3, .85);
            Reposition.setNestedControlLocation(admin4Btn, .6, .85);

            //movie buttons
            Reposition.setNestedControlLocation(admin5Btn, .3, .85);
            Reposition.setNestedControlLocation(admin6Btn, .6, .85);

            //upc buttons
            Reposition.setNestedControlLocation(admin7Btn, .3, .85);
            Reposition.setNestedControlLocation(admin8Btn, .6, .85);
        }
Esempio n. 3
0
        private void addCopy1Btn_Click(object sender, EventArgs e)
        {
            string movieId = addCopy1Txt.Text.Trim(' ');
            string upc     = addCopy2Txt.Text.Trim(' ');

            if (!Check.areValidInputs(movieId, upc))
            {
                Prompt.enterValidInput();
                return;
            }
            //enter int MovieId
            if (!Check.isNumeric(movieId))
            {
                Prompt.enterNumeric("movie ID");
                return;
            }
            //incorrect UPC format
            if (!Check.isUPC(upc))
            {
                Prompt.enterUPC();
                return;
            }

            try
            {
                //specified movie is not in DB
                if (!MoviesTable.hasMovieById(Int32.Parse(movieId)))
                {
                    Prompt.notInDB("movie", "movie ID");
                    return;
                }

                if (CopiesTable.hasAnyCopyByInfo(upc, Int32.Parse(movieId)))
                {
                    CopiesTable.unDelete(upc);
                    addCopy2Txt.Clear();
                    return;
                }

                if (CopiesTable.hasAnyCopy(upc))
                {
                    Prompt.alreadyInDB("UPC");
                    return;
                }

                CopiesTable.add(upc, Int32.Parse(movieId));
                addCopy2Txt.Clear();
            }
            catch
            {
                MoviesTable.adapter.Dispose();
                CopiesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Esempio n. 4
0
        private void addMovie1Btn_Click(object sender, EventArgs e)
        {
            string name   = addMovie1Txt.Text.Trim(' ');
            string studio = addMovie2Txt.Text.Trim(' ');
            string year   = addMovie3Txt.Text.Trim(' ');

            if (!Check.areValidInputs(name, studio, year))
            {
                Prompt.enterValidInput();
                return;
            }
            if (!Check.isYear(year))
            {
                Prompt.enterYear();
                return;
            }

            try
            {
                //Movie is already in DB
                if (MoviesTable.hasMovieByInfo(name, studio, Int32.Parse(year)))
                {
                    int movieId = MoviesTable.getMovieId(name, studio, Int32.Parse(year));
                    Prompt.alreadyInDB("movie");
                }
                else if (MoviesTable.hasAnyMovieByInfo(name, studio, Int32.Parse(year)))
                {
                    int movieId = MoviesTable.getAllMovieId(name, studio, Int32.Parse(year));
                    //since the movie is already in the Db, just deleted
                    //undelete the movie and associated upc values
                    MoviesTable.unDelete(movieId);
                    CopiesTable.unDeleteById(movieId);
                }
                else
                {
                    //Add to DB
                    MoviesTable.add(name, Int32.Parse(year), studio);
                }

                //cleanup
                clearRadioButtons(addMoviePnl);
                clearTextBoxes(addMoviePnl);

                //transition to add DVDs for the movie
                addCopy1Txt.Text = MoviesTable.getMovieId(name, studio, Int32.Parse(year)).ToString();
                setCurrentMainPanel(addCopyPnl);
            }catch
            {
                MoviesTable.adapter.Dispose();
                CopiesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Esempio n. 5
0
        public void setupReportsPnl()
        {
            if (isFirstSetup)
            {
                try
                {
                    reports1Data.DataSource = MoviesTable.getAll();
                    reports1Data.Columns["deleted"].Visible = false;
                    sortBy(reports1Data, 5, false);

                    reports2Data.DataSource = CustomersTable.getAll();
                    reports2Data.Columns["deleted"].Visible = false;
                    sortBy(reports2Data, 7, false);

                    reports3Data.DataSource = MoviesTable.getAll();
                    reports3Data.Columns["deleted"].Visible = false;
                    sortBy(reports3Data, 1, true);

                    reports4Data.DataSource = RentalsTable.getNotReturned();
                    reports4Data.Columns["returned"].Visible = false;
                    sortBy(reports4Data, 4, true);

                    reports5Data.DataSource = RentalsTable.getLateMovies();
                    reports5Data.Columns["returned"].Visible = false;
                    sortBy(reports5Data, 4, true);

                    reports6Data.DataSource = CopiesTable.getAll();
                    reports6Data.Columns["deleted"].Visible = false;
                    sortBy(reports6Data, 0, true);
                }catch
                {
                    CustomersTable.adapter.Dispose();
                    MoviesTable.adapter.Dispose();
                    RentalsTable.adapter.Dispose();
                    CopiesTable.adapter.Dispose();
                    Prompt.dbError();
                }
            }

            Reposition.setControl(reportsTitleLbl, .4, .7, 0, .1);

            Reposition.setControl(reportsTab, .1, .9, .1, .9);

            Reposition.setNestedControlPosition(reports1Data, .05, .95, 0, 1);
            Reposition.setNestedControlPosition(reports2Data, .05, .95, 0, 1);
            Reposition.setNestedControlPosition(reports3Data, .05, .95, 0, 1);
            Reposition.setNestedControlPosition(reports4Data, .05, .95, 0, 1);
            Reposition.setNestedControlPosition(reports5Data, .05, .95, 0, 1);
            Reposition.setNestedControlPosition(reports6Data, .05, .95, 0, 1);
        }
Esempio n. 6
0
        private void rent2Btn_Click(object sender, EventArgs e)
        {
            string firstName = rent2Txt.Text.Trim(' ');
            string lastName  = rent3Txt.Text.Trim(' ');
            string phone     = rent4Txt.Text.Trim(' ');
            int    customerId;

            if (!Check.areValidInputs(firstName, lastName, phone))
            {
                Prompt.enterValidInput();
                return;
            }

            if (!Check.isPhone(phone))
            {
                Prompt.enterPhone();
                return;
            }
            try
            {
                if (!CustomersTable.hasCustomer(firstName, lastName, phone))
                {
                    Prompt.notACustomer();
                    return;
                }

                customerId = CustomersTable.getCustomerId(firstName, lastName, phone);

                currentCustomer = new Customer(customerId, firstName, lastName);

                CopiesTable.makeUnavailable(currentDVD.getUpc());

                RentalsTable.add(currentDVD.getUpc(), currentCustomer.getCustomerId(), currentUser.getUserName(), Date.dateAfter(7));
                CustomersTable.incrementTimesRented(currentCustomer.getCustomerId());
                MoviesTable.incrementTimesRented(currentDVD.getUpc());
                clearTextBoxes(rent2Pnl);
                setCurrentMainPanel(rentPnl);
            }catch
            {
                CustomersTable.adapter.Dispose();
                RentalsTable.adapter.Dispose();
                MoviesTable.adapter.Dispose();
                CopiesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Esempio n. 7
0
        /*
         * ----------------------------------------------------------------------------------------------
         * Part 7: Submit Button Events
         * ----------------------------------------------------------------------------------------------
         */

        private void removeMovie1Btn_Click(object sender, EventArgs e)
        {
            string movieId = removeMovie1Txt.Text.Trim(' ');

            if (!Check.areValidInputs(movieId))
            {
                Prompt.enterValidInput();
                return;
            }
            if (!Check.isNumeric(movieId))
            {
                Prompt.enterNumeric("Movie Id");
                return;
            }

            try
            {
                if (!MoviesTable.hasMovieById(Int32.Parse(movieId)))
                {
                    Prompt.notInDB("movie", "movie ID");
                    return;
                }
                if (MoviesTable.hasRentedCopyById(Int32.Parse(movieId)))
                {
                    Prompt.removalDependency("movie", "rental");
                    return;
                }

                MoviesTable.delete(Int32.Parse(movieId));
                CopiesTable.deleteById(Int32.Parse(movieId));

                clearTextBoxes(removeMoviePnl);

                setCurrentMainPanel(adminPnl);
            }catch
            {
                MoviesTable.adapter.Dispose();
                CopiesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Esempio n. 8
0
        private void removeCopy1Btn_Click(object sender, EventArgs e)
        {
            string upc = removeCopy1Txt.Text.Trim(' ');

            if (!Check.areValidInputs(upc))
            {
                Prompt.enterValidInput();
                return;
            }
            if (!Check.isUPC(upc))
            {
                Prompt.enterUPC();
                return;
            }

            try
            {
                if (!CopiesTable.hasCopy(upc))
                {
                    Prompt.notInDB("dvd", "upc");
                    return;
                }
                if (RentalsTable.upcIsRenting(upc))
                {
                    Prompt.removalDependency("upc", "rental");
                    return;
                }

                CopiesTable.delete(upc);

                clearTextBoxes(removeCopyPnl);
                //exit to admin panel
                setCurrentMainPanel(adminPnl);
            }
            catch
            {
                RentalsTable.adapter.Dispose();
                CopiesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Esempio n. 9
0
        private void return1Btn_Click(object sender, EventArgs e)
        {
            string upc = return1Txt.Text.Trim(' ');

            if (!Check.areValidInputs(upc))
            {
                Prompt.enterValidInput();
                return;
            }
            if (!Check.isUPC(upc))
            {
                Prompt.enterUPC();
                return;
            }

            try
            {
                if (!CopiesTable.hasCopy(upc))
                {
                    Prompt.notInDB("dvd", "UPC");
                    return;
                }
                if (CopiesTable.isAvailable(upc))
                {
                    Prompt.cantReturn();
                    return;
                }


                RentalsTable.returnMovie(upc);
                CopiesTable.makeAvailable(upc);

                clearTextBoxes(returnPnl);
            }catch
            {
                RentalsTable.adapter.Dispose();
                CopiesTable.adapter.Dispose();
                Prompt.dbError();
            }
        }