Ejemplo n.º 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);
        }
Ejemplo n.º 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";
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 4
0
        private void LoadTickets()
        {
            DataTable dt = DataAccess.GetData("SELECT TicketID, DepartureAirport + ' - ' + ArrivalAirport + ' (' + CONVERT(VARCHAR(MAX), DepartureTime) + ')'AS TicketInfo FROM Ticket");

            UIUtilities.FillListControl(cmbTickets, "TicketInfo", "TicketID", dt, true, "--- Choose a ticket ---");
        }
Ejemplo n.º 5
0
        private void LoadCustomers()
        {
            DataTable dtCustomers = DataAccess.GetData("SELECT CustomerID,FirstName + ' ' + LastName AS CustomerName FROM Customer");

            UIUtilities.FillListControl(cmbCustomers, "CustomerName", "CustomerID", dtCustomers, true, "");
        }