Example #1
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            UIUtilities.ClearControls(this.groupBox1.Controls);
            UIUtilities.ClearControls(this.groupBox2.Controls);
            txtID.Text = "";

            btnAdd.Enabled    = false;
            btnUpdate.Text    = "Save";
            btnCancel.Text    = "Cancel";
            btnDelete.Enabled = false;
            NavigationState(false);
        }
Example #2
0
        private void BtnAdd_Click(object sender, EventArgs e)
        {
            UIUtilities.ClearControls(this.grpCustomerTicket.Controls);
            UIUtilities.ClearControls(this.grpPayment.Controls);

            cmbCustomers.Enabled = true;
            cmbTickets.Enabled   = true;
            NavigationState(false);
            btnAdd.Enabled    = false;
            btnDelete.Enabled = false;
            btnUpdate.Text    = "Save";
            btnCancel.Text    = "Cancel";
        }
Example #3
0
        private void BtnUpdate_Click(object sender, EventArgs e)
        {
            try
            {
                if (ValidateChildren(ValidationConstraints.Enabled))
                {
                    if (btnCancel.Text == "Cancel")
                    {
                        //Assign Business Rules 08: A Customer with 2 unpaid tickets can not book another flight.
                        if (UnpaidTickets() == 2)
                        {
                            MessageBox.Show($"{cmbCustomers.Text} can not book another flight because they have two unpaid tickets.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            UIUtilities.ClearControls(this.grpCustomerTicket.Controls);
                            UIUtilities.ClearControls(this.grpPayment.Controls);
                            return;
                        }

                        CreateBooking();
                        cmbCustomers.Enabled = false;
                        cmbTickets.Enabled   = false;
                    }
                    else
                    {
                        if (MessageBox.Show("Are you sure you want to update this booking?", "Update", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                        {
                            UpdateBooking();
                        }
                    }
                }
            }
            catch (SqlException ex)
            {
                MessageBox.Show("This booking has already been created", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                UIUtilities.ClearControls(this.grpCustomerTicket.Controls);
                UIUtilities.ClearControls(this.grpPayment.Controls);
            }
        }