Ejemplo n.º 1
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (CheckAll())
            {
                Rental objRental;

                objRental = new Rental();
                objRental.movie_number        = (int)cmbMovieNumber.SelectedValue;
                objRental.member_number       = (int)cmbMemberNumber.SelectedValue;
                objRental.media_checkout_date = dtpMediaCheckoutDate.Value;
                objRental.media_return_date   = dtpMediaReturnDate.Value;            //TODO only add if not blank
                try
                {
                    bool status = Rentals.AddRental(objRental);
                    if (status)
                    {
                        MessageBox.Show(MsgBoxHelper.Inserted("Rental"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        rentalList = Rentals.GetRentals();
                        rentalDataGridView.DataSource = rentalList;    //TODO movie and member not -1?
                    }
                    else
                    {
                        MessageBox.Show(MsgBoxHelper.Inserted("Rental not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 2
0
        private void frmRental_Load(object sender, EventArgs e)
        {
            try
            {
                rentalList = Rentals.GetRentals();
                rentalDataGridView.DataSource = rentalList;

                List <Movie> movieList = Movies.GetMovies();
                cmbMovieNumber.DataSource    = movieList;
                cmbMovieNumber.DisplayMember = Movies.extra;
                cmbMovieNumber.ValueMember   = Movies.key;
                cmbMovieNumber.SelectedIndex = -1;

                List <Member> memberList = Members.GetMembers();
                cmbMemberNumber.DataSource    = memberList;
                cmbMemberNumber.DisplayMember = Members.extra3;
                cmbMemberNumber.ValueMember   = Members.key;
                cmbMemberNumber.SelectedIndex = -1;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            ToolTip toolTip = new ToolTip();

            toolTip.SetToolTip(btnAdd, "Add Movie, Member, Checkout and Return");
            toolTip.SetToolTip(btnBrowse, "Browse by Movie, Member and Checkout");
            toolTip.SetToolTip(btnUpdate, "Update Movie, Member, Checkout and Return");
            toolTip.SetToolTip(btnDelete, "Delete Movie, Member and Checkout");
            toolTip.SetToolTip(btnClear, "Clear all Rental fields");

            toolTip.SetToolTip(cmbMovieNumber, Rental.movie_numberTip);
            toolTip.SetToolTip(lblMovieNumber, Rental.movie_numberTip);

            toolTip.SetToolTip(cmbMemberNumber, Rental.member_numberTip);
            toolTip.SetToolTip(lblMemberNumber, Rental.member_numberTip);

            toolTip.SetToolTip(dtpMediaCheckoutDate, Rental.media_checkout_dateTip);
            toolTip.SetToolTip(lblMediaCheckoutDate, Rental.media_checkout_dateTip);

            toolTip.SetToolTip(dtpMediaReturnDate, Rental.media_return_dateTip);
            toolTip.SetToolTip(lblMediaReturnDate, Rental.media_return_dateTip);

            rentalDataGridView.Width  = 43 + 3 * 100 + 17;
            rentalDataGridView.Height = 23 + 3 * 22 + 17;
        }
Ejemplo n.º 3
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            if ((cmbMovieNumber.SelectedIndex == -1) && (cmbMemberNumber.SelectedIndex == -1) && dtpMediaCheckoutDate.Value == new DateTime(1753, 1, 1, 0, 0, 0))
            {
                MessageBox.Show(lblMovieNumber.Text + " and " + lblMemberNumber.Text + " and " + lblMediaCheckoutDate.Text + " must not all be blank.",
                                "Invalid " + lblMovieNumber.Text + " and/or " + lblMemberNumber.Text + " and/or " + lblMediaCheckoutDate.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                int first,
                    second;

                if (cmbMovieNumber.SelectedIndex == -1)
                {
                    first = -1;
                }
                else
                {
                    first = (int)cmbMovieNumber.SelectedValue;
                }
                if (cmbMemberNumber.SelectedIndex == -1)
                {
                    second = -1;
                }
                else
                {
                    second = (int)cmbMemberNumber.SelectedValue;
                }

                Rental objRental;

                try
                {
                    objRental = Rentals.GetRental(first, second, dtpMediaCheckoutDate.Value);                                        //TODO
                    if (!BadKey(objRental, first, second))
                    {
                        dtpMediaReturnDate.Value = objRental.media_return_date;
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 4
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            if ((cmbMovieNumber.SelectedIndex == -1) && (cmbMemberNumber.SelectedIndex == -1) && dtpMediaCheckoutDate.Value == new DateTime(1753, 1, 1, 0, 0, 0))
            {
                MessageBox.Show(lblMovieNumber.Text + " and " + lblMemberNumber.Text + " and " + lblMediaCheckoutDate.Text + " must not all be blank.",
                                "Invalid " + lblMovieNumber.Text + " and/or " + lblMemberNumber.Text + " and/or " + lblMediaCheckoutDate.Text,
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
            else
            {
                int first,
                    second;

                if (cmbMovieNumber.SelectedIndex == -1)
                {
                    first = -1;
                }
                else
                {
                    first = (int)cmbMovieNumber.SelectedValue;
                }
                if (cmbMemberNumber.SelectedIndex == -1)
                {
                    second = -1;
                }
                else
                {
                    second = (int)cmbMemberNumber.SelectedValue;
                }

                Rental objRental = new Rental();

                objRental.movie_number        = first;
                objRental.member_number       = second;
                objRental.media_checkout_date = dtpMediaCheckoutDate.Value;

                try
                {
                    bool status = Rentals.DeleteRental(ref objRental);
                    if (!BadKey(objRental, first, second))
                    {
                        dtpMediaReturnDate.Value = objRental.media_return_date;

                        if (status)
                        {
                            MessageBox.Show(MsgBoxHelper.Deleted("Rental"), "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            rentalList = Rentals.GetRentals();
                            rentalDataGridView.DataSource = rentalList;            //movie and member not -1?
                        }
                        else
                        {
                            MessageBox.Show(MsgBoxHelper.Deleted("Rental not"), "Failure", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message, "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }