Пример #1
0
        /*
         * When submit button is clicked, the mandatory fields are checked if they are filled.
         * If all the mandatory fields are selected, then we check for all the optional fields
         * and make the queries as per the condition.
         */
        private void submitButton_Click(object sender, EventArgs e)
        {
            resultLabel.Visible = true;

            String customerID = customerIDTextBox.Text.TrimEnd(); // Value in textbox

            if (customerID == "")                                 // If the text field is empty
            {
                resultLabel.Text      = "Please enter something";
                resultLabel.ForeColor = Color.FromArgb(192, 0, 0); //dark red
            }
            else
            {
                // Changing the result label
                resultLabel.Text      = "Running the query . . . ";
                resultLabel.ForeColor = Color.FromArgb(0, 192, 0); //dark green

                // Creating the query
                String query = $"select CUSTOMER_ID, First_Name, Membership_Status, Card_Type, Card_Number from Customer where CUSTOMER_ID = '{customerID}'";
                // Runs query and updates table
                DataTable table = Database.getDataTableAfterRunningQuery(query);

                Customer user;

                user            = new Customer();
                user.ID         = Int32.Parse(table.Rows[0][0].ToString());
                user.FirstName  = table.Rows[0][1].ToString();
                user.Status     = table.Rows[0][2].ToString();
                user.cardType   = table.Rows[0][3].ToString();
                user.cardNumber = table.Rows[0][4].ToString();

                StartReservation startreservation = new StartReservation(user);
                startreservation.ShowDialog();
            }
        }
Пример #2
0
        private void reserveButton_Click(object sender, EventArgs e)
        {
            StartReservation startreservation = new StartReservation(this.User);

            this.Opacity = 0.0;
            startreservation.ShowDialog();
            this.Opacity = 100.0;
        }
Пример #3
0
        private void existingCxButton_Click(object sender, EventArgs e)
        {
            string email = inputEmail.Text;

            if (!Login.IsValidEmail(email))
            {
                MessageBox.Show("Error: Email address provided is invalid", "Error");
                return;
            }
            string pass = inputPassword.Text;

            if (Login.CustomerAuth(email, pass))
            {
                this.DialogResult = DialogResult.OK;

                // Load user details from database
                string    query = String.Format("SELECT CUSTOMER_ID, First_Name, Membership_Status, Card_Type, Card_Number FROM Customer WHERE Email = '{0}';", email);
                DataTable table = Database.SqlQuery(query);
                this.User            = new Customer();
                this.User.ID         = Int32.Parse(table.Rows[0][0].ToString());
                this.User.FirstName  = table.Rows[0][1].ToString();
                this.User.Status     = table.Rows[0][2].ToString();
                this.User.cardType   = table.Rows[0][3].ToString();
                this.User.cardNumber = table.Rows[0][4].ToString();

                Console.WriteLine("" +
                                  "ID = {0}, " +
                                  "FirstName = {1}, " +
                                  "Status = {2}, " +
                                  "Card Type = {3}, " +
                                  "Card Number = {4}",
                                  this.User.ID,
                                  this.User.FirstName,
                                  this.User.Status,
                                  this.User.cardType,
                                  this.User.cardNumber);

                this.Close();

                StartReservation startreservation = new StartReservation(this.User);
                this.Opacity = 0.0;
                startreservation.ShowDialog();
                this.Opacity = 100.0;
            }
        }
Пример #4
0
        private void newCxButton_Click(object sender, EventArgs e)
        {
            Customer cx = new Customer();

            string email = EmailBox.Text.Trim();

            if (!Login.IsValidEmail(email))
            {
                MessageBox.Show("Error: Email address provided is invalid", "Password Error");
                return;
            }
            if (passwordBox.Text != confirmBox.Text)
            {
                MessageBox.Show("Error: Passwords do not match", "Password Error");
                return;
            }

            Match match = Regex.Match(cardNoBox.Text, @"[0-9]{16}");

            if (!match.Success)
            {
                MessageBox.Show("Error: Card number should be 16 numeric digits", "Invalid Card");
                return;
            }

            if (cardTypeCombo.SelectedIndex == -1)
            {
                MessageBox.Show("Please select a credit card type", "Error");
                return;
            }

            // Use try-catch in case the values are not going to be compatible (ie. letters entered in Age)
            try
            {
                cx.FirstName    = fNameBox.Text.Trim();
                cx.LastName     = lNameBox.Text.Trim();
                cx.BDay         = BDay.Value.ToShortDateString();
                cx.Insurance    = insuranceBox.Text.Trim();
                cx.Drivers      = driversBox.Text.Trim();
                cx.PhoneNumber  = Decimal.Parse(phoneBox.Text);
                cx.EmailAddress = email;
                cx.Password     = Login.HashPassword(confirmBox.Text.Trim());
                cx.Address      = addressBox.Text.Trim();
                cx.City         = cityBox.Text.Trim();
                cx.Province     = provinceBox.Text.Trim();
                cx.Country      = countryBox.Text.Trim();
                cx.CardNumber   = cardNoBox.Text;
                cx.CardType     = cardTypeCombo.GetItemText(cardTypeCombo.SelectedItem);
                cx.Status       = "Basic";
                if (Login.insertCustomer(cx))
                {
                    MessageBox.Show("Successfully Registered as a new Customer", "Success");
                    this.DialogResult = DialogResult.OK;
                    this.User         = cx;
                    this.Close();

                    StartReservation startreservation = new StartReservation(this.User);
                    this.Opacity = 0.0;
                    startreservation.ShowDialog();
                    this.Opacity = 100.0;
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Error");
            }
        }