コード例 #1
0
        private void calculateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (titleInput.Text == "" || (buttonBD.Checked == false && buttonDVD.Checked == false))
            {
                MessageBox.Show("Please enter a valid input", "Error");
            }
            else
            {
                //Is customer created yet?
                if (customer == null)
                {
                    customer    = new Customer(checkMember.Checked);
                    rentalOrder = new RentalOrder(customer);
                }

                //Create rental item
                string title      = titleInput.Text;
                bool   isBD       = false;
                bool   newRelease = false;
                if (checkNew.Checked == true)
                {
                    newRelease = true;
                }
                if (buttonBD.Checked == true)
                {
                    isBD = true;
                }
                Rental rental = new Rental(title, isBD, newRelease);

                //Pass rental item to calculate function
                rentalOrder.calculate(rental);
                checkMember.Enabled = false;
                totalOutput.Text    = rentalOrder.subTotal.ToString("C");
            }
        }
コード例 #2
0
        private void resetForm(bool newOrder)
        {
            //clears textbox and buttons
            titleInput.Clear();
            checkMember.Checked = false;
            checkNew.Checked    = false;
            buttonBD.Checked    = false;
            buttonDVD.Checked   = false;

            if (newOrder == true)
            {
                customer            = null;
                rentalOrder         = null;
                checkMember.Enabled = true;
                totalOutput.Clear();
            }
        }