Esempio n. 1
0
        private void btnViewBookings_Click(object sender, EventArgs e)
        {
            ViewBookings viewBookings = new ViewBookings(); //opens a form called Menu

            this.Hide();                                    //hides the previous form
            viewBookings.ShowDialog();                      //opens the form
            this.Close();                                   //closes the form
        }
Esempio n. 2
0
        private void icnEditSave_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtBoxEditName.Text.Trim()) || string.IsNullOrEmpty(txtBoxEditBookingEmail.Text.Trim()))
            {
                const string RequiredFieldsError = "Fields can not be empty";
                const string caption             = "Empty Fields";

                var result = MessageBox.Show(RequiredFieldsError, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                if (comboBoxEditUnder4.SelectedIndex != 0 || comboBoxEditChild.SelectedIndex != 0 || comboBoxEditTeen.SelectedIndex != 0 ||
                    comboBoxEditAdult.SelectedIndex != 0 || comboBoxEditSenior.SelectedIndex != 0)
                {
                    if (editTotal > total || editTotal == total)
                    {
                        if (txtBoxEditPaymentType.Text == "Credit Card")
                        {
                            string UpdatePayment = "Original Price: £" + total.ToString("F") + Environment.NewLine + "New Payment: £" + (editTotal + editTotal * CreditCardFee).ToString("F")
                                                   + Environment.NewLine + Environment.NewLine + "Remaining Cost to be paid: £" + ((editTotal + editTotal * CreditCardFee) - total).ToString("F")
                                                   + Environment.NewLine + Environment.NewLine + "Confirm?";
                            string captionUpdatePayment = "Payment";

                            var resultUpdatePayment = MessageBox.Show(UpdatePayment, captionUpdatePayment, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                            if (resultUpdatePayment == DialogResult.Yes)
                            {
                                con.Open();                                           // Opens the connection
                                cmd = new SqlCommand("UPDATE dbo.Bookings SET Name=@Name, BookingEmail=@BookingEmail, Movie=@Movie, MovieTime=@MovieTime, TicketPrice=@TicketPrice, PaymentType=@PaymentType, Email=@Email, Under4Tickets=@Under4Tickets, ChildTickets=@ChildTickets, TeenTickets=@TeenTickets, AdultTickets=@AdultTickets, SeniorTickets=@SeniorTickets WHERE BookingID=@BookingID", con);
                                cmd.Parameters.AddWithValue("@BookingID", BookingID); // Stores the ID collected from the command to the @ID variable
                                cmd.Parameters.AddWithValue("@Name", txtBoxEditName.Text);
                                cmd.Parameters.AddWithValue("@BookingEmail", txtBoxEditBookingEmail.Text);
                                cmd.Parameters.AddWithValue("@Movie", comboBoxEditMovieNames.SelectedItem); // Stores the Password collected from the command to the @Password variable
                                cmd.Parameters.AddWithValue("@MovieTime", comboBoxEditMovieTimes.SelectedItem);
                                cmd.Parameters.AddWithValue("@TicketPrice", lblEditFinalPrice.Text);
                                cmd.Parameters.AddWithValue("@PaymentType", txtBoxEditPaymentType.Text);
                                cmd.Parameters.AddWithValue("@Email", Login.Email);
                                cmd.Parameters.AddWithValue("@Under4Tickets", comboBoxEditUnder4.SelectedItem);
                                cmd.Parameters.AddWithValue("@ChildTickets", comboBoxEditChild.SelectedItem);
                                cmd.Parameters.AddWithValue("@TeenTickets", comboBoxEditTeen.SelectedItem);
                                cmd.Parameters.AddWithValue("@AdultTickets", comboBoxEditAdult.SelectedItem);
                                cmd.Parameters.AddWithValue("@SeniorTickets", comboBoxEditSenior.SelectedItem);

                                cmd.ExecuteNonQuery(); // Executes the query (Non query is for UPDATE, INSERT AND DELETE statements)
                                MessageBox.Show("Booking Updated Successfully");
                                con.Close();

                                const string LogoutConfirmation = "Would you like to return to the View Booking page to view your Booking?";
                                const string caption            = "View Booking?";

                                var result = MessageBox.Show(LogoutConfirmation, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                if (result == DialogResult.Yes)
                                {
                                    ViewBookings viewBookings = new ViewBookings(); //opens a form called Menu
                                    this.Hide();                                    //hides the previous form
                                    viewBookings.ShowDialog();                      //opens the form
                                    this.Close();                                   //closes the form
                                }
                                else
                                {
                                    Menu menu = new Menu(); //opens a form called Menu
                                    this.Hide();            //hides the previous form
                                    menu.ShowDialog();      //opens the form
                                    this.Close();           //closes the form
                                }
                            }
                        }
                        else
                        {
                            string UpdatePayment = "Original Price: £" + total.ToString("F") + Environment.NewLine + "New Payment: £" + (editTotal + editTotal * PaypalFee).ToString("F")
                                                   + Environment.NewLine + Environment.NewLine + "Remaining Cost to be paid: £" + ((editTotal + editTotal * PaypalFee) - total).ToString("F")
                                                   + Environment.NewLine + Environment.NewLine + "Confirm?";
                            string captionUpdatePayment = "Payment";

                            var resultUpdatePayment = MessageBox.Show(UpdatePayment, captionUpdatePayment, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                            if (resultUpdatePayment == DialogResult.Yes)
                            {
                                con.Open();                                           // Opens the connection
                                cmd = new SqlCommand("UPDATE dbo.Bookings SET Name=@Name, BookingEmail=@BookingEmail, Movie=@Movie, MovieTime=@MovieTime, TicketPrice=@TicketPrice, PaymentType=@PaymentType, Email=@Email, Under4Tickets=@Under4Tickets, ChildTickets=@ChildTickets, TeenTickets=@TeenTickets, AdultTickets=@AdultTickets, SeniorTickets=@SeniorTickets WHERE BookingID=@BookingID", con);
                                cmd.Parameters.AddWithValue("@BookingID", BookingID); // Stores the ID collected from the command to the @ID variable
                                cmd.Parameters.AddWithValue("@Name", txtBoxEditName.Text);
                                cmd.Parameters.AddWithValue("@BookingEmail", txtBoxEditBookingEmail.Text);
                                cmd.Parameters.AddWithValue("@Movie", comboBoxEditMovieNames.SelectedItem); // Stores the Password collected from the command to the @Password variable
                                cmd.Parameters.AddWithValue("@MovieTime", comboBoxEditMovieTimes.SelectedItem);
                                cmd.Parameters.AddWithValue("@TicketPrice", lblEditFinalPrice.Text);
                                cmd.Parameters.AddWithValue("@PaymentType", txtBoxEditPaymentType.Text);
                                cmd.Parameters.AddWithValue("@Email", Login.Email);
                                cmd.Parameters.AddWithValue("@Under4Tickets", comboBoxEditUnder4.SelectedItem);
                                cmd.Parameters.AddWithValue("@ChildTickets", comboBoxEditChild.SelectedItem);
                                cmd.Parameters.AddWithValue("@TeenTickets", comboBoxEditTeen.SelectedItem);
                                cmd.Parameters.AddWithValue("@AdultTickets", comboBoxEditAdult.SelectedItem);
                                cmd.Parameters.AddWithValue("@SeniorTickets", comboBoxEditSenior.SelectedItem);

                                cmd.ExecuteNonQuery(); // Executes the query (Non query is for UPDATE, INSERT AND DELETE statements)

                                MessageBox.Show("Booking Updated Successfully");
                                con.Close();

                                const string LogoutConfirmation = "Would you like to return to the View Booking page to view your Booking?";
                                const string caption            = "View Booking?";

                                var result = MessageBox.Show(LogoutConfirmation, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                if (result == DialogResult.Yes)
                                {
                                    ViewBookings viewBookings = new ViewBookings(); //opens a form called Menu
                                    this.Hide();                                    //hides the previous form
                                    viewBookings.ShowDialog();                      //opens the form
                                    this.Close();                                   //closes the form
                                }
                                else
                                {
                                    Menu menu = new Menu(); //opens a form called Menu
                                    this.Hide();            //hides the previous form
                                    menu.ShowDialog();      //opens the form
                                    this.Close();           //closes the form
                                }
                            }
                        }
                    }
                    if (total > editTotal)
                    {
                        if (txtBoxEditPaymentType.Text == "Credit Card")
                        {
                            string UpdatePaymentplus = "Original Price: £" + total.ToString("F") + Environment.NewLine + "New Payment: £" + (editTotal + editTotal * CreditCardFee).ToString("F")
                                                       + Environment.NewLine + Environment.NewLine + "You will be refunded: £" + (total - (editTotal + editTotal * CreditCardFee)).ToString("F")
                                                       + Environment.NewLine + Environment.NewLine + "Confirm?";
                            string captionUpdatePaymentplus = "Confirm?";

                            var resultUpdatePaymentplus = MessageBox.Show(UpdatePaymentplus, captionUpdatePaymentplus, MessageBoxButtons.YesNo, MessageBoxIcon.Question);


                            if (resultUpdatePaymentplus == DialogResult.Yes)
                            {
                                con.Open();                                           // Opens the connection
                                cmd = new SqlCommand("UPDATE dbo.Bookings SET Name=@Name, BookingEmail=@BookingEmail, Movie=@Movie, MovieTime=@MovieTime, TicketPrice=@TicketPrice, PaymentType=@PaymentType, Email=@Email, Under4Tickets=@Under4Tickets, ChildTickets=@ChildTickets, TeenTickets=@TeenTickets, AdultTickets=@AdultTickets, SeniorTickets=@SeniorTickets WHERE BookingID=@BookingID", con);
                                cmd.Parameters.AddWithValue("@BookingID", BookingID); // Stores the ID collected from the command to the @ID variable
                                cmd.Parameters.AddWithValue("@Name", txtBoxEditName.Text);
                                cmd.Parameters.AddWithValue("@BookingEmail", txtBoxEditBookingEmail.Text);
                                cmd.Parameters.AddWithValue("@Movie", comboBoxEditMovieNames.SelectedItem); // Stores the Password collected from the command to the @Password variable
                                cmd.Parameters.AddWithValue("@MovieTime", comboBoxEditMovieTimes.SelectedItem);
                                cmd.Parameters.AddWithValue("@TicketPrice", lblEditFinalPrice.Text);
                                cmd.Parameters.AddWithValue("@PaymentType", txtBoxEditPaymentType.Text);
                                cmd.Parameters.AddWithValue("@Email", Login.Email);
                                cmd.Parameters.AddWithValue("@Under4Tickets", comboBoxEditUnder4.SelectedItem);
                                cmd.Parameters.AddWithValue("@ChildTickets", comboBoxEditChild.SelectedItem);
                                cmd.Parameters.AddWithValue("@TeenTickets", comboBoxEditTeen.SelectedItem);
                                cmd.Parameters.AddWithValue("@AdultTickets", comboBoxEditAdult.SelectedItem);
                                cmd.Parameters.AddWithValue("@SeniorTickets", comboBoxEditSenior.SelectedItem);

                                cmd.ExecuteNonQuery(); // Executes the query (Non query is for UPDATE, INSERT AND DELETE statements)
                                MessageBox.Show("Record Updated Successfully");
                                con.Close();

                                const string LogoutConfirmation = "Would you like to return to the View Booking page to view your Booking?";
                                const string caption            = "View Booking?";

                                var result = MessageBox.Show(LogoutConfirmation, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                if (result == DialogResult.Yes)
                                {
                                    ViewBookings viewBookings = new ViewBookings(); //opens a form called Menu
                                    this.Hide();                                    //hides the previous form
                                    viewBookings.ShowDialog();                      //opens the form
                                    this.Close();                                   //closes the form
                                }
                                else
                                {
                                    Menu menu = new Menu(); //opens a form called Menu
                                    this.Hide();            //hides the previous form
                                    menu.ShowDialog();      //opens the form
                                    this.Close();           //closes the form
                                }
                            }
                            else
                            {
                                const string LogoutConfirmation = "Payment Cancelled, you have not been charged";
                                const string caption            = "Payment";

                                var result = MessageBox.Show(LogoutConfirmation, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                        else
                        {
                            string UpdatePaymentplus = "Original Price: £" + total.ToString("F") + Environment.NewLine + "New Payment: £" + (editTotal + editTotal * PaypalFee).ToString("F")
                                                       + Environment.NewLine + Environment.NewLine + "You will be refunded: £" + (total - (editTotal + editTotal * PaypalFee)).ToString("F")
                                                       + Environment.NewLine + Environment.NewLine + "Confirm?";
                            string captionUpdatePaymentplus = "Confirm?";

                            var resultUpdatePaymentplus = MessageBox.Show(UpdatePaymentplus, captionUpdatePaymentplus, MessageBoxButtons.YesNo, MessageBoxIcon.Question);


                            if (resultUpdatePaymentplus == DialogResult.Yes)
                            {
                                con.Open();                                           // Opens the connection
                                cmd = new SqlCommand("UPDATE dbo.Bookings SET Name=@Name, BookingEmail=@BookingEmail, Movie=@Movie, MovieTime=@MovieTime, TicketPrice=@TicketPrice, PaymentType=@PaymentType, Email=@Email, Under4Tickets=@Under4Tickets, ChildTickets=@ChildTickets, TeenTickets=@TeenTickets, AdultTickets=@AdultTickets, SeniorTickets=@SeniorTickets WHERE BookingID=@BookingID", con);
                                cmd.Parameters.AddWithValue("@BookingID", BookingID); // Stores the ID collected from the command to the @ID variable
                                cmd.Parameters.AddWithValue("@Name", txtBoxEditName.Text);
                                cmd.Parameters.AddWithValue("@BookingEmail", txtBoxEditBookingEmail.Text);
                                cmd.Parameters.AddWithValue("@Movie", comboBoxEditMovieNames.SelectedItem); // Stores the Password collected from the command to the @Password variable
                                cmd.Parameters.AddWithValue("@MovieTime", comboBoxEditMovieTimes.SelectedItem);
                                cmd.Parameters.AddWithValue("@TicketPrice", lblEditFinalPrice.Text);
                                cmd.Parameters.AddWithValue("@PaymentType", txtBoxEditPaymentType.Text);
                                cmd.Parameters.AddWithValue("@Email", Login.Email);
                                cmd.Parameters.AddWithValue("@Under4Tickets", comboBoxEditUnder4.SelectedItem);
                                cmd.Parameters.AddWithValue("@ChildTickets", comboBoxEditChild.SelectedItem);
                                cmd.Parameters.AddWithValue("@TeenTickets", comboBoxEditTeen.SelectedItem);
                                cmd.Parameters.AddWithValue("@AdultTickets", comboBoxEditAdult.SelectedItem);
                                cmd.Parameters.AddWithValue("@SeniorTickets", comboBoxEditSenior.SelectedItem);

                                cmd.ExecuteNonQuery(); // Executes the query (Non query is for UPDATE, INSERT AND DELETE statements)
                                MessageBox.Show("Record Updated Successfully");
                                con.Close();

                                const string LogoutConfirmation = "Would you like to return to the View Booking page to view your Booking?";
                                const string caption            = "View Booking?";

                                var result = MessageBox.Show(LogoutConfirmation, caption, MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                                if (result == DialogResult.Yes)
                                {
                                    ViewBookings viewBookings = new ViewBookings(); //opens a form called Menu
                                    this.Hide();                                    //hides the previous form
                                    viewBookings.ShowDialog();                      //opens the form
                                    this.Close();                                   //closes the form
                                }
                                else
                                {
                                    Menu menu = new Menu(); //opens a form called Menu
                                    this.Hide();            //hides the previous form
                                    menu.ShowDialog();      //opens the form
                                    this.Close();           //closes the form
                                }
                            }
                            else
                            {
                                const string LogoutConfirmation = "Payment Cancelled, you have not been charged";
                                const string caption            = "Payment";

                                var result = MessageBox.Show(LogoutConfirmation, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            }
                        }
                    }
                }
                else
                {
                    const string NoTickets = "No tickets selected, please select at least 1 ticket to continue";
                    const string caption   = "No ticket";

                    var result = MessageBox.Show(NoTickets, caption, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }