Пример #1
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);
        }
Пример #2
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();
            }
        }
Пример #3
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();
            }
        }
Пример #4
0
        private void removeCustomer1Btn_Click(object sender, EventArgs e)
        {
            string customerId = removeCustomer1Txt.Text.Trim(' ');

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

            try
            {
                if (!CustomersTable.hasCustomer(Int32.Parse(customerId)))
                {
                    Prompt.notInDB("customer", customerId);
                    return;
                }
                if (RentalsTable.customerIsRenting(Int32.Parse(customerId)))
                {
                    Prompt.removalDependency("customer", "rental");
                    return;
                }

                CustomersTable.setDeleted(true, Int32.Parse(customerId));

                clearTextBoxes(removeCustomerPnl);
                //exit to admin panel
                setCurrentMainPanel(adminPnl);
            }catch
            {
                CustomersTable.adapter.Dispose();
                RentalsTable.adapter.Dispose();
                Prompt.dbError();
            }
        }
Пример #5
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();
            }
        }