private void labelLogo_Click(object sender, EventArgs e)
        {
            this.Hide();
            var formTemp = new StoreMain();

            formTemp.Show();
        }
예제 #2
0
        private void labelLogo_Click(object sender, EventArgs e)
        {
            MessageBox.Show("Cart will be emptied");
            this.Hide();
            var formTemp = new StoreMain();

            formTemp.Show();
        }
예제 #3
0
        private void buttonCheckout_Click(object sender, EventArgs e)
        {
            // Check first name text box
            if (String.IsNullOrEmpty(textBoxFName.Text))
            {
                MessageBox.Show("Please enter the first name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check last name text box
            if (String.IsNullOrEmpty(textBoxLName.Text))
            {
                MessageBox.Show("Please enter the last name", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check email text box
            if (String.IsNullOrEmpty(textBoxEmail.Text))
            {
                MessageBox.Show("Please enter the email", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check address text box
            if (String.IsNullOrEmpty(textBoxAddress.Text))
            {
                MessageBox.Show("Please enter the address", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check credit card number text box
            if (String.IsNullOrEmpty(textBoxCCN.Text))
            {
                MessageBox.Show("Please enter the credit card number", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check ccv text box
            if (String.IsNullOrEmpty(textBoxCCV.Text))
            {
                MessageBox.Show("Please enter the ccv", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check expiration date
            if (String.IsNullOrEmpty(dateTimePicker.Text))
            {
                MessageBox.Show("Please enter the expiration date", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // Check card type combo box
            if (String.IsNullOrEmpty(comboBoxType.Text))
            {
                MessageBox.Show("Please enter the card type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Random rng      = new Random();
            int    orderNum = rng.Next(10000, 50001);

            //checks credit card length and number
            if (textBoxCCV.TextLength == 3 && textBoxCCN.TextLength == 16)
            {
                MailMessage mail       = new MailMessage();
                SmtpClient  SmtpServer = new SmtpClient("smtp.gmail.com");
                mail.From = new MailAddress("*****@*****.**");
                mail.To.Add(textBoxEmail.Text);
                mail.Subject = "Order Confirmation";
                mail.Body    = "Hello " + textBoxFName.Text + ",\n\n Super Stop 'N Buy thanks you for your purchase of $" + total.ToString($"F{2}") + "!\n\nYour Order Confirmation number is: " + orderNum + "\n\nThanks for shopping, visit us again soon!\n\n\nSuper Stop 'n Buy®\n1000 Main Street\nProvidence, RI 02860";

                SmtpServer.Port        = 587;
                SmtpServer.Credentials = new System.Net.NetworkCredential("*****@*****.**", "rhodeisland18");
                SmtpServer.EnableSsl   = true;
                SmtpServer.Send(mail);

                MessageBox.Show("Order Placed! Order Number is: " + orderNum + "\nThanks For Shopping at Super Stop 'n Buy!");
                this.Hide();
                var formTemp = new StoreMain();
                formTemp.Show();
            }
            else
            {
                if (textBoxCCV.TextLength != 3)
                {
                    MessageBox.Show("CCV Number Incorrect");
                }
                else
                {
                    MessageBox.Show("Credit Card Number Incorrect");
                }
            }
        }