Ejemplo n.º 1
0
        private void btnConfirmBooking_Click_1(object sender, EventArgs e)
        {
            grpChangeBookingMatchingClients.Visible = false;
            grpChangeBookingActiveBookings.Visible  = false;
            grpChangeBookingActiveServices.Visible  = false;
            grpChangeBookingActiveDJs.Visible       = false;
            grpChangeBooking.Visible = false;

            string BookingID = txtBookingID.Text;

            DateTime BookingDate = dtpBookingDate.Value = DateTime.Now;

            DateTime EventDate = dtpEventDate.Value;

            string StartTime = cboStartTime.Text;

            string EndTime = cboEndTime.Text;

            string Duration = txtDuration.Text;

            string Location = txtLocation.Text;

            string Eircode = txtEircode.Text;

            string TotalCost = txtTotalCost.Text;

            string ClientID = txtClientID.Text;

            string DJID = txtDJID.Text;

            string ServiceID = txtServiceID.Text;

            string Forename = grdChangeBookingMatchingClients.SelectedRows[0].Cells[1].Value + string.Empty;

            int parsedValueInt;

            if (!ValidateData.isBlank(txtLocation.Text))
            {
                MessageBox.Show("Location must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtLocation.Focus();
                return;
            }

            else if (int.TryParse(txtLocation.Text, out parsedValueInt))
            {
                MessageBox.Show("Location cannot contain numbers only", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtLocation.Clear();
                txtLocation.Focus();
                return;
            }

            if (!ValidateData.isBlank(txtEircode.Text))
            {
                MessageBox.Show("Eircode must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEircode.Focus();
                return;
            }

            else if (!ValidateData.containsSpaces(txtEircode.Text))
            {
                MessageBox.Show("Eircode cannot contain spaces", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEircode.Clear();
                txtEircode.Focus();
                return;
            }

            else if (!ValidateData.isValidEircode(txtEircode.Text))
            {
                MessageBox.Show("Eircode must be valid", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEircode.Clear();
                txtEircode.Focus();
                return;
            }

            //Update the data in the database based on the details changed in the text boxes(if any)
            Bookings.updateBookings(Convert.ToInt32(txtBookingID.Text), dtpBookingDate.Text, cboStartTime.Text.ToUpper(), cboEndTime.Text.ToUpper(),
                                    double.Parse(txtDuration.Text), ValidateData.apostChecker(txtLocation.Text.ToUpper()), txtEircode.Text.ToUpper(), Convert.ToDecimal(txtTotalCost.Text),
                                    Convert.ToInt32(txtDJID.Text), txtServiceID.Text.ToUpper());

            txtBookingID.Clear();
            cboStartTime.SelectedIndex = -1;
            cboEndTime.SelectedIndex   = -1;
            txtDuration.Clear();
            txtLocation.Clear();
            txtEircode.Clear();
            txtTotalCost.Clear();
            txtClientID.Clear();
            txtServiceID.Clear();
            txtDJID.Clear();

            txtEnterSurname.Select();

            // I need to check if the content is valid before adding it to the form
            //this.textBox1.Items.Add(item);
            MessageBox.Show(text: "Booking details changed!" +
                            Environment.NewLine + Environment.NewLine + "Booking ID: " + BookingID.ToUpper() +
                            Environment.NewLine + Environment.NewLine + "Booking Date: " + BookingDate +
                            Environment.NewLine + Environment.NewLine + "Event Date: " + EventDate +
                            Environment.NewLine + Environment.NewLine + "Start Time: " + StartTime +
                            Environment.NewLine + Environment.NewLine + "End Time: " + EndTime +
                            Environment.NewLine + Environment.NewLine + "Duration: " + Duration +
                            Environment.NewLine + Environment.NewLine + "Location: " + Location.ToUpper() +
                            Environment.NewLine + Environment.NewLine + "Eircode: " + Eircode.ToUpper() +
                            Environment.NewLine + Environment.NewLine + "Total Cost: €" + TotalCost +
                            Environment.NewLine + Environment.NewLine + "Client ID: " + ClientID.ToUpper() +
                            Environment.NewLine + Environment.NewLine + "DJ ID: " + DJID.ToUpper() +
                            Environment.NewLine + Environment.NewLine + "Service ID: " + ServiceID.ToUpper());

            dtpEventDate.Visible   = false;
            dtpBookingDate.Visible = false;

            //Reference for being able to send emails http://karmic-development.blogspot.com/2013/10/send-email-from-aspnet-using-gmail-as.html
            //Reference to set up various security aspects to be able to send email through google mail https://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c-sharp/9572958#9572958
            //Reference on how to send an embedded link inside email
            MailMessage mail = new MailMessage();

            mail.From = new MailAddress("*****@*****.**", "Legend DJs");
            mail.To.Add("*****@*****.**");
            mail.IsBodyHtml = true;
            mail.Subject    = "Booking updated";
            //string html = "";
            mail.Body =
                "Dear " + Forename + "," +
                "<br/><br/>Your booking with Legend DJs has been updated." +
                "<br/><br/>Please check the details below to ensure that the updated booking information we have is correct. We look forward to seeing you on the day." +
                "<br/><br/><h1>Booking details updated!</h1>" +
                "<br/><br/>Booking ID: " + BookingID.ToUpper() +
                "<br/>Event Date: " + EventDate +
                "<br/>Start Time: " + StartTime +
                "<br/>End Time: " + EndTime +
                "<br/>Duration: " + Duration +
                "<br/>Location: " + Location.ToUpper() +
                "<br/>Eircode: " + Eircode.ToUpper() +
                "<br/>Total Cost: €" + TotalCost +
                "<br/>DJ ID: " + DJID.ToUpper() +
                "<br/>Service ID: " + ServiceID.ToUpper() +
                "<br/><br/><br/>Kind regards," +
                "<br/><br/>Legend DJs" +
                "<br/><br/><h1>Contact Us</h1>" +
                "<br/><br/>Legend DJs" +
                "<br/>Main Street" +
                "<br/>Tralee" +
                "<br/>Co. Kerry" +
                "<br/>087 170 1459" +
                "<br/><br/><html><body><a href=\"http://www.livinglegendcolmg.com/\" > LegendDJs.com</a></body></html>" +
                "<br/><br/><html><body><a href=\"https://www.facebook.com/colm.l.gallagher/\" > LegendDJs @ facebook</a></body></html>" +
                "<br/><br/><html><body><a href=\"https://twitter.com/LivingLegendDJ/\" > LegendDJs @ twitter</a></body></html>" +
                "<br/><br/><html><body><a href=\"https://www.instagram.com/livinglegendcolmg/?hl=en/\" > LegendDJs @ instagram</a></body></html>";

            mail.Priority = MailPriority.High;

            SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);

            smtp.UseDefaultCredentials = false;
            //smtp.UseDefaultCredentials = true;
            smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "jcxvqxkvqrfanhqj");
            smtp.EnableSsl   = true;
            //smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

            smtp.Send(mail);

            //send email to client
            MessageBox.Show(text: "Confirmation email sent to Client");
        }
Ejemplo n.º 2
0
        private void btnUpdateClient_Click_1(object sender, EventArgs e)
        {
            grpUpdateMatchingClients.Visible = false;

            String ClientID = txtClientID.Text;

            String Forename = txtForename.Text;

            String Surname = txtSurname.Text;

            DateTime Date = dtpDateOfBirth.Value;

            String Contact = txtContactNo.Text;

            String Email = txtEmail.Text;

            String Street = txtStreet.Text;

            String Town = txtTown.Text;

            String City = txtCity.Text;

            String County = cboCounty.Text;

            String Eircode = txtEircode.Text;

            int parsedValue;
            int contact;

            if (!ValidateData.isBlank(txtForename.Text))
            {
                MessageBox.Show("Forename must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtForename.Focus();
                return;
            }

            else if (!ValidateData.containsNumbers(txtForename.Text))
            {
                MessageBox.Show("Forename cannot contain numbers", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtForename.Clear();
                txtForename.Focus();
                return;
            }

            if (!ValidateData.isBlank(txtSurname.Text))
            {
                MessageBox.Show("Surname must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtSurname.Focus();
                return;
            }

            else if (!ValidateData.containsNumbers(txtSurname.Text))
            {
                MessageBox.Show("Surname cannot contain numbers", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtSurname.Clear();
                txtSurname.Focus();
                return;
            }

            if (!ValidateData.isValidDate2(dtpDateOfBirth.Value))

            {
                MessageBox.Show("Cannot be future Date", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dtpDateOfBirth.Focus();
                return;
            }

            else if (!ValidateData.isValidDate(dtpDateOfBirth.Value))

            {
                MessageBox.Show("You must be 18 or over to register", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                dtpDateOfBirth.Focus();
                return;
            }

            if (!ValidateData.isBlank(txtContactNo.Text))
            {
                MessageBox.Show("Contact number must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtContactNo.Focus();
                return;
            }

            //Reference https://stackoverflow.com/questions/24279155/how-to-validate-only-number-in-winform

            else if (!int.TryParse(txtContactNo.Text, out contact))
            {
                MessageBox.Show("Contact Number must contain numbers only", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtContactNo.Focus();
                return;
            }

            if (!ValidateData.isBlank(txtEmail.Text))
            {
                MessageBox.Show("Email must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEmail.Focus();
                return;
            }

            if (!ValidateData.isValidEmail(txtEmail.Text))
            {
                if (!Regex.IsMatch(txtEmail.Text, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase))
                {
                    //MessageBox.Show("Email must be valid format", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    txtEmail.Clear();
                    txtEmail.Focus();
                    return;
                }
            }

            if (!ValidateData.isBlank(txtStreet.Text))
            {
                MessageBox.Show("Street must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtStreet.Focus();
                return;
            }

            else if (int.TryParse(txtStreet.Text, out parsedValue))
            //else if (!ValidateData.onlyNumbers(txtStreet.Text))
            {
                MessageBox.Show("Street cannot contain numbers only", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtStreet.Clear();
                txtStreet.Focus();
                return;
            }

            if (!ValidateData.isBlank(txtTown.Text))
            {
                MessageBox.Show("Town must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtTown.Focus();
                return;
            }

            else if (int.TryParse(txtTown.Text, out parsedValue))
            //else if (!ValidateData.onlyNumbers(txtTown.Text))
            {
                MessageBox.Show("Town cannot contain numbers only", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtTown.Clear();
                txtTown.Focus();
                return;
            }

            if (int.TryParse(txtCity.Text, out parsedValue))
            //if (!ValidateData.onlyNumbers(txtCity.Text))
            {
                MessageBox.Show("City cannot contain numbers only", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtCity.Clear();
                txtCity.Focus();
                return;
            }

            if (!ValidateData.isBlank(txtEircode.Text))
            {
                MessageBox.Show("Eircode must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEircode.Focus();
                return;
            }

            else if (!ValidateData.containsSpaces(txtEircode.Text))
            {
                MessageBox.Show("Eircode cannot contain spaces", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEircode.Clear();
                txtEircode.Focus();
                return;
            }

            else if (!ValidateData.isValidEircode(txtEircode.Text))
            {
                MessageBox.Show("Eircode must be valid", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEircode.Clear();
                txtEircode.Focus();
                return;
            }

            else
            {
                //Update the data in the database based on the details changed in the text boxes(if any)
                Client.updateClient(Convert.ToInt16(txtClientID.Text), ValidateData.apostChecker(txtForename.Text.ToUpper()), ValidateData.apostChecker(txtSurname.Text.ToUpper()),
                                    dtpDateOfBirth.Text.ToUpper(), txtContactNo.Text.ToUpper(), txtEmail.Text.ToLower(), ValidateData.apostChecker(txtStreet.Text.ToUpper()),
                                    ValidateData.apostChecker(txtTown.Text.ToUpper()), ValidateData.apostChecker(txtCity.Text.ToUpper()), cboCounty.Text.ToUpper(), txtEircode.Text.ToUpper());

                txtClientID.Clear();
                txtForename.Clear();
                txtSurname.Clear();
                txtContactNo.Clear();
                txtEmail.Clear();
                txtStreet.Clear();
                txtTown.Clear();
                //reference for clearing combobox https://stackoverflow.com/questions/9321844/how-do-i-clear-a-combobox & https://stackoverflow.com/questions/9321844/how-do-i-clear-a-combobox
                cboCounty.Items.Clear();
                cboCounty.ResetText();
                txtCity.Clear();
                txtEircode.Clear();
                txtEnterSurname.Focus();


                // I need to check if the content is valid before adding it to the form
                //MessageBox item = new MessageBox(this.txtForename.Text);
                //this.textBox1.Items.Add(item);
                MessageBox.Show(text: "Client details updated!" +
                                Environment.NewLine + Environment.NewLine + "Client ID: " + ClientID.ToUpper() +
                                Environment.NewLine + Environment.NewLine + "Forename: " + Forename.ToUpper() +
                                Environment.NewLine + Environment.NewLine + "Surname: " + Surname.ToUpper() +
                                Environment.NewLine + Environment.NewLine + "Date of Birth: " + Date +
                                Environment.NewLine + Environment.NewLine + "Contact No.: " + Contact.ToUpper() +
                                Environment.NewLine + Environment.NewLine + "Email: " + Email +
                                Environment.NewLine + Environment.NewLine + "Street: " + Street.ToUpper() +
                                Environment.NewLine + Environment.NewLine + "Town: " + Town.ToUpper() +
                                Environment.NewLine + Environment.NewLine + "City: " + City.ToUpper() +
                                Environment.NewLine + Environment.NewLine + "County: " + County.ToUpper() +
                                Environment.NewLine + Environment.NewLine + "Eircode: " + Eircode.ToUpper());

                dtpDateOfBirth.Value = DateTime.Now;

                //Reference for being able to send emails http://karmic-development.blogspot.com/2013/10/send-email-from-aspnet-using-gmail-as.html
                //Reference to set up various security aspects to be able to send email through google mail https://stackoverflow.com/questions/704636/sending-email-through-gmail-smtp-server-with-c-sharp/9572958#9572958
                MailMessage mail = new MailMessage();
                mail.From = new MailAddress("*****@*****.**", "Legend DJs");
                mail.To.Add("*****@*****.**");
                mail.IsBodyHtml = true;
                mail.Subject    = "Updated Client details";
                //string html = "";
                mail.Body =
                    "Dear " + Forename + "," +
                    "<br/><br/>Thanks for updating your information details with Legend DJs." +
                    "<br/><br/>We look forward to continuing our great working relationship with you." +
                    "<br/><br/>Please check the details below to ensure that the information you updated is correct. You can update this information again, at any time, by contacting us." +
                    "<br/><br/><h1>Client details updated!</h1>" +
                    "<br/><br/>Forename: " + Forename.ToUpper() +
                    "<br/>Surname: " + Surname.ToUpper() +
                    "<br/>Date of Birth: " + Date +
                    "<br/>Contact No.: " + Contact.ToUpper() +
                    "<br/>Email: " + Email +
                    "<br/>Street: " + Street.ToUpper() +
                    "<br/>Town: " + Town.ToUpper() +
                    "<br/>City: " + City.ToUpper() +
                    "<br/>County: " + County.ToUpper() +
                    "<br/>Eircode: " + Eircode.ToUpper() +
                    "<br/><br/><br/>Kind regards," +
                    "<br/><br/>Legend DJs" +
                    "<br/><br/><h1>Contact Us</h1>" +
                    "<br/><br/>Legend DJs" +
                    "<br/>Main Street" +
                    "<br/>Tralee" +
                    "<br/>Co. Kerry" +
                    "<br/>087 170 1459" +
                    "<br/><br/><html><body><a href=\"http://www.livinglegendcolmg.com/\" > LegendDJs.com</a></body></html>" +
                    "<br/><br/><html><body><a href=\"https://www.facebook.com/colm.l.gallagher/\" > LegendDJs @ facebook</a></body></html>" +
                    "<br/><br/><html><body><a href=\"https://twitter.com/LivingLegendDJ/\" > LegendDJs @ twitter</a></body></html>" +
                    "<br/><br/><html><body><a href=\"https://www.instagram.com/livinglegendcolmg/?hl=en/\" > LegendDJs @ instagram</a></body></html>";

                mail.Priority = MailPriority.High;

                SmtpClient smtp = new SmtpClient("smtp.gmail.com", 587);
                smtp.UseDefaultCredentials = false;
                //smtp.UseDefaultCredentials = true;
                smtp.Credentials = new System.Net.NetworkCredential("*****@*****.**", "jcxvqxkvqrfanhqj");
                smtp.EnableSsl   = true;
                //smtp.DeliveryMethod = SmtpDeliveryMethod.Network;

                smtp.Send(mail);

                //send email to client
                MessageBox.Show(text: "Confirmation email sent to Client");

                grpUpdateClient.Visible = false;
            }
        }