Exemplo n.º 1
0
        private void btnCheckActiveBookings_Click(object sender, EventArgs e)
        {
            grpDJScheduleMatchingDJs.Visible = false;
            grdDJScheduleDJActiveBookings.AllowUserToAddRows = false;

            DataSet ds = new DataSet();

            //grdDJScheduleDJsActiveBookings.DataSource = DJs.GetAllBookings(ds, txtEnterName.Text.ToUpper()).Tables["Bookings"];
            ds = DJs.GetAllBookings(ds, Convert.ToInt32(txtDJID.Text));
            grdDJScheduleDJActiveBookings.DataSource = ds.Tables["searchBookings"];

            if (grdDJScheduleDJActiveBookings.Rows.Count == 0)
            {
                grdDJScheduleDJActiveBookings.Visible = false;
                grpDJScheduleDJActiveBookings.Visible = false;
                MessageBox.Show(text: "No active bookings for DJ found.");
                return;
            }

            else
            {
                grdDJScheduleDJActiveBookings.Visible = true;
            }
            grpDJScheduleDJActiveBookings.Visible            = true;
            grdDJScheduleDJActiveBookings.AllowUserToAddRows = false;
        }
        private void btnCheckActiveBookings_Click(object sender, EventArgs e)
        {
            //grpWithdrawDJsActiveBookings.Visible = true;
            grpWithdrawMatchingDJs.Visible = false;
            grdWithdrawDJActiveBookings.AllowUserToAddRows = false;

            DataSet ds = new DataSet();

            //grdWithdrawDJsActiveBookings.DataSource = DJs.GetAllBookings(ds, txtEnterName.Text.ToUpper()).Tables["Bookings"];
            ds = DJs.GetAllBookings(ds, Convert.ToInt32(txtDJID.Text));
            grdWithdrawDJActiveBookings.DataSource = ds.Tables["searchBookings"];

            if (grdWithdrawDJActiveBookings.Rows.Count == 0)
            {
                grdWithdrawDJActiveBookings.Visible        = false;
                grpWithdrawDJActiveBookings.Visible        = false;
                btnDJWithBookingsWithdrawDJ.Visible        = false;
                btnLegendDJsWithBookingsWithdrawDJ.Visible = false;
                MessageBox.Show(text: "No active bookings for DJ found.");
                btnLegendDJsNoBookingsWithdrawDJ.Visible = true;
                btnDJNoBookingsWithdrawDJ.Visible        = true;
                return;
            }

            else
            {
                grdWithdrawDJActiveBookings.Visible = true;
            }
            grpWithdrawDJActiveBookings.Visible = true;
            //grdWithdrawDJsActiveBookings.AllowUserToAddRows = false;
            btnLegendDJsNoBookingsWithdrawDJ.Visible   = false;
            btnDJNoBookingsWithdrawDJ.Visible          = false;
            btnLegendDJsWithBookingsWithdrawDJ.Visible = false;
            btnDJWithBookingsWithdrawDJ.Visible        = false;
            btnSelectAll.Visible = true;
            btnDJWithdrawDJPrintBookings.Visible = false;

            var result =
                FlexibleMessageBox.Show("Is it the choice of the DJ to withdraw? If so, click 'Yes'." +
                                        Environment.NewLine + Environment.NewLine +
                                        "If it is the ADMINS choice to withdraw the DJ, click 'No'", "DJ or Admin?", MessageBoxButtons.YesNo);

            if (result == DialogResult.No)
            {
                btnLegendDJsNoBookingsWithdrawDJ.Visible   = false;
                btnDJNoBookingsWithdrawDJ.Visible          = false;
                btnLegendDJsWithBookingsWithdrawDJ.Visible = true;
                btnDJWithBookingsWithdrawDJ.Visible        = false;
            }

            else
            {
                btnLegendDJsNoBookingsWithdrawDJ.Visible   = false;
                btnDJNoBookingsWithdrawDJ.Visible          = false;
                btnDJWithBookingsWithdrawDJ.Visible        = true;
                btnLegendDJsWithBookingsWithdrawDJ.Visible = false;
            }
        }
Exemplo n.º 3
0
        private void frmAddDJ_Load(object sender, EventArgs e)
        {
            txtDJID.Text    = DJs.nextDJID().ToString("000");
            txtDJID.Visible = true;

            //reference for eliminating duplicates https://stackoverflow.com/questions/37057116/c-sharp-how-to-eliminate-duplicate-values-from-combobox

            DataSet ds = new DataSet();

            ds = DJs.GetCounty(ds);

            for (int i = 0; i < ds.Tables["searchCounty"].Rows.Count; i++)
            {
                cboDJCounty.Items.Add(ds.Tables[0].Rows[i][0].ToString().PadLeft(3, '0'));
            }
        }
Exemplo n.º 4
0
        private void btnFindDJ_Click(object sender, EventArgs e)
        {
            if (!ValidateData.isBlank(txtEnterSurname.Text))
            {
                grpDJScheduleMatchingDJs.Visible = false;
                grdDJScheduleMatchingDJs.Visible = false;
                MessageBox.Show("Surname must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEnterSurname.Focus();
                return;
            }

            else if (!ValidateData.containsNumbers(txtEnterSurname.Text))
            {
                grpDJScheduleMatchingDJs.Visible = false;
                grdDJScheduleMatchingDJs.Visible = false;
                MessageBox.Show("Surname cannot contain numbers", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtEnterSurname.Clear();
                txtEnterSurname.Focus();
                return;
            }

            else
            {
                DataSet ds = new DataSet();
                //grdDJScheduleMatchingDJs.DataSource = DJs.GetAllActiveDJs(ds, txtEnterName.Text.ToUpper()).Tables["DJs"];
                ds = DJs.GetAllActiveDJs(ds, ValidateData.apostChecker(txtEnterSurname.Text.ToUpper()));
                grdDJScheduleMatchingDJs.DataSource = ds.Tables["searchActiveDJs"];

                if (grdDJScheduleMatchingDJs.Rows.Count == 0)
                {
                    grdDJScheduleMatchingDJs.Visible = false;
                    grpDJScheduleMatchingDJs.Visible = false;
                    MessageBox.Show("No DJ found. Please try again", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error);
                    txtEnterSurname.Clear();
                    txtEnterSurname.Focus();
                    return;
                }

                txtEnterSurname.Clear();
                grdDJScheduleMatchingDJs.Visible = true;
                grpDJScheduleMatchingDJs.Visible = true;
            }
        }
        public void UpdateAllRecords()
        {
            DataSet ds = new DataSet();

            //grdWithdrawDJsActiveBookings.DataSource = DJs.GetAllBookings(ds, txtEnterName.Text.ToUpper()).Tables["Bookings"];
            ds = DJs.GetAllBookingsOutsideNoticePeriod(ds, Convert.ToInt32(txtDJID.Text));
            grdWithdrawDJActiveBookings3.DataSource = ds.Tables["searchBookingsOutsideNotice"];

            //reference fellow student Carraig McNulty for help with foreach loop to declare array

            foreach (DataRow row in ds.Tables["searchBookingsOutsideNotice"].Rows)
            {
                StringBuilder query = new StringBuilder();
                for (int i = 0; i < grdWithdrawDJActiveBookings3.Rows.Count; i++)
                {
                    //DataGridViewRow row = grdWithdrawDJActiveBookings3.Rows[i];
                    Bookings.updateBookingsWhereDJWithdrawn(Convert.ToInt32(grdWithdrawDJActiveBookings3.Rows[i].Cells[0].Value), Convert.ToInt32(15));
                }
            }
        }
Exemplo n.º 6
0
        private void btnAddDJ_Click(object sender, EventArgs e)
        {
            string DJID = txtDJID.Text;

            string Forename = txtDJForename.Text;

            string Surname = txtDJSurname.Text;

            DateTime Date = dtpDJDateOfBirth.Value;

            string Contact = txtDJContactNo.Text;

            string Email = txtDJEmail.Text;

            string Street = txtDJStreet.Text;

            string Town = txtDJTown.Text;

            string City = txtDJCity.Text;

            string County = cboDJCounty.Text;

            string Eircode = txtDJEircode.Text;

            //https://ourcodeworld.com/articles/read/507/how-to-allow-only-numbers-inside-a-textbox-in-winforms-c-sharp
            decimal HourlyRate = Convert.ToDecimal(txtDJHourlyRate.Text);

            int     parsedValueInt;
            int     contact;
            decimal parsedValueDec;

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

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

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

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

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

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

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

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

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

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

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

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

            if (!ValidateData.isValidEmail(txtDJEmail.Text))
            {
                if (!Regex.IsMatch(txtDJEmail.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);
                    txtDJEmail.Clear();
                    txtDJEmail.Focus();
                    return;
                }
            }

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

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

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

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

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

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

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

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

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

            else if (!decimal.TryParse(txtDJHourlyRate.Text, out parsedValueDec))
            {
                MessageBox.Show("Rate must contain numeric only values.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                txtDJHourlyRate.Clear();
                txtDJHourlyRate.Focus();
                return;
            }

            DJs dj = new DJs(Convert.ToInt32(txtDJID.Text), ValidateData.apostChecker(txtDJForename.Text.ToUpper()), ValidateData.apostChecker(txtDJSurname.Text.ToUpper()), dtpDJDateOfBirth.Text.ToUpper(),
                             txtDJContactNo.Text.ToUpper(), txtDJEmail.Text.ToLower(), ValidateData.apostChecker(txtDJStreet.Text.ToUpper()), ValidateData.apostChecker(txtDJTown.Text.ToUpper()),
                             ValidateData.apostChecker(txtDJCity.Text.ToUpper()), cboDJCounty.Text.ToUpper(), txtDJEircode.Text.ToUpper(), Convert.ToDecimal(txtDJHourlyRate.Text), "A");

            dj.AddDJ();

            txtDJID.Text = DJs.nextDJID().ToString("000");
            txtDJForename.Clear();
            txtDJSurname.Clear();
            txtDJContactNo.Clear();
            txtDJEmail.Clear();
            txtDJStreet.Clear();
            txtDJTown.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
            cboDJCounty.Items.Clear();
            cboDJCounty.ResetText();
            txtDJCity.Clear();
            txtDJEircode.Clear();
            txtDJHourlyRate.Clear();
            dtpDJDateOfBirth.Value = DateTime.Now;
            txtDJForename.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 added!" +
                            Environment.NewLine + Environment.NewLine + "Client ID: " + DJID.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 + "Hourly Rate: €" + Convert.ToDecimal(HourlyRate) +
                            Environment.NewLine + Environment.NewLine + "Eircode: " + Eircode.ToUpper());

            dtpDJDateOfBirth.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
            //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    = "DJ Registration";
            //string html = "";
            mail.Body =
                "Dear " + Forename + "," +
                "<br/><br/>Welcome to the team at Legend DJs!" +
                "<br/><br/>We look forward to a long and busy working relationship with you." +
                "<br/><br/>Please check the details below to ensure that the information we have is correct. You can update this information at any time by contacting us." +
                "<br/><br/><h1>DJ details added!</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/>Hourly Rate: €" + Convert.ToDecimal(HourlyRate) +
                "<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 DJ");
        }
        private void btnWithdrawDJPrintBookings_Click(object sender, EventArgs e)
        {
            String ClientID = txtDJID.Text;
            String Forename = txtDJForename.Text;

            grpWithdrawMatchingDJs.Visible = false;
            grdWithdrawDJActiveBookings.AllowUserToAddRows  = false;
            grdWithdrawDJActiveBookings.Visible             = true;
            grpWithdrawDJActiveBookings.Visible             = true;
            grdWithdrawDJActiveBookings2.Visible            = true;
            grpWithdrawDJActiveBookings2.Visible            = true;
            grdWithdrawDJActiveBookings2.AllowUserToAddRows = false;
            btnDJWithdrawDJPrintBookings.Visible            = false;
            btnLegendDJsWithdrawDJPrintBookings.Visible     = false;
            grpWithdrawDJ.Visible = false;
            btnSelectAll.Visible  = false;
            btnLegendDJsWithBookingsWithdrawDJ.Visible      = false;
            btnDJWithBookingsWithdrawDJ.Visible             = false;
            grdWithdrawDJActiveBookings3.AllowUserToAddRows = false;
            grdWithdrawDJActiveBookings3.Visible            = true;
            grpWithdrawDJActiveBookings3.Visible            = true;

            DataSet ds = new DataSet();

            //grdWithdrawDJsActiveBookings.DataSource = DJs.GetAllBookings(ds, txtEnterName.Text.ToUpper()).Tables["Bookings"];
            ds = DJs.GetAllBookingsOutsideNoticePeriod(ds, Convert.ToInt32(txtDJID.Text));
            grdWithdrawDJActiveBookings3.DataSource = ds.Tables["searchBookingsOutsideNotice"];

            UpdateAllRecords();

            DJs.WithdrawDJ(Convert.ToInt32(txtDJID.Text));

            MessageBox.Show(text: "DJ Withdrawn");

            txtDJID.Clear();
            txtDJForename.Clear();
            txtDJSurname.Clear();
            txtDJContactNo.Clear();
            txtDJEmail.Clear();
            txtDJStreet.Clear();
            txtDJTown.Clear();
            txtDJCounty.Clear();
            txtDJCity.Clear();
            txtDJEircode.Clear();
            txtDJHourlyRate.Clear();

            //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    = "DJ Withdrawn";
            //string html = "";
            mail.Body =
                "Dear " + Forename + "," +
                "<br/><br/>In relation to your request to withdraw your services form Legend DJs' system, and in accordance with the terms and conditions of your employment, " +
                "we will be withdrawing you from our system." +
                "<br/><br/>Please find attached a list of final bookings to fulfil before you officially leave Legend DJs." +
                "<br/><br/>We would like to thank you, again, for your great service to this point." +
                "<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 DJ");

            grdWithdrawDJActiveBookings.AllowUserToAddRows  = false;
            grdWithdrawDJActiveBookings.Visible             = false;
            grpWithdrawDJActiveBookings.Visible             = false;
            grdWithdrawDJActiveBookings2.Visible            = false;
            grpWithdrawDJActiveBookings2.Visible            = false;
            grdWithdrawDJActiveBookings2.AllowUserToAddRows = false;
            btnDJWithdrawDJPrintBookings.Visible            = false;
            btnLegendDJsWithdrawDJPrintBookings.Visible     = false;
            grpWithdrawDJ.Visible = false;
            btnSelectAll.Visible  = false;
            btnLegendDJsWithBookingsWithdrawDJ.Visible      = false;
            btnDJWithBookingsWithdrawDJ.Visible             = false;
            grdWithdrawDJActiveBookings3.AllowUserToAddRows = false;
            grdWithdrawDJActiveBookings3.Visible            = false;
            grpWithdrawDJActiveBookings3.Visible            = false;

            txtEnterSurname.Select();
        }
        private void btnDJWithBookingsWithdrawDJ_Click(object sender, EventArgs e)
        {
            btnDJWithBookingsWithdrawDJ.Visible        = false;
            btnLegendDJsWithBookingsWithdrawDJ.Visible = false;

            grpWithdrawMatchingDJs.Visible = false;
            grdWithdrawDJActiveBookings.AllowUserToAddRows = false;
            btnDJWithBookingsWithdrawDJ.Visible            = false;

            DataSet ds = new DataSet();

            //grdWithdrawDJsActiveBookings.DataSource = DJs.GetAllBookings(ds, txtEnterName.Text.ToUpper()).Tables["Bookings"];
            ds = DJs.GetAllBookingsWithinNoticePeriod(ds, Convert.ToInt32(txtDJID.Text));
            grdWithdrawDJActiveBookings2.DataSource = ds.Tables["searchBookingsByNotice"];

            //reference fellow student Carraig McNulty for help with foreach loop to declare array

            string message = "";
            int    count   = 0;

            foreach (DataRow row in ds.Tables["searchBookingsByNotice"].Rows)
            {
                String tablerow = "Event Date:          " + " " + row[2].ToString() + "\n" +
                                  "Start Time:           " + " " + row[3].ToString() + "\n" +
                                  "End Time:             " + " " + row[4].ToString() + "\n" +
                                  "Location:              " + " " + row[6].ToString() + "\n" +
                                  "Eircode:                " + " " + row[7].ToString() + "\n" +
                                  "Total Cost:           " + " " + "€" + row[8].ToString() + "\n" +
                                  "Payment Status:  " + " " + row[9].ToString() + "\n\n"
                ;
                message += tablerow;
                count++;
            }

            //Reference for a flexible message box which enables the message box to scroll to see all text.  The standard message box inside Visual Studio cannot display a lot of text by default.
            //https://www.codeproject.com/Articles/601900/FlexibleMessageBox-A-Flexible-Replacement-for-the

            FlexibleMessageBox.Show(text:
                                    Environment.NewLine + Environment.NewLine +
                                    "Dear " + txtDJForename.Text + "," +
                                    Environment.NewLine + Environment.NewLine +
                                    "In relation to your request to withdraw your services form Legend DJs' system, and in accordance with the terms and conditions of your employment, we will be withdrawing you from our system." +
                                    Environment.NewLine + Environment.NewLine +
                                    "Please find below, a list of remaining bookings to be fulfilled in the remaining 28 day notice period of your contract." +
                                    Environment.NewLine + Environment.NewLine +
                                    "Any bookings after 28 days from this date will be allocated to another Legend DJs employee." +
                                    Environment.NewLine + Environment.NewLine +
                                    "We would like to sincerely thank you for giving the company such great service in the past, and hope to work with you again soon." +
                                    Environment.NewLine + Environment.NewLine +
                                    "Kind regards, " +
                                    Environment.NewLine + Environment.NewLine +
                                    "Legend DJs" +
                                    Environment.NewLine + Environment.NewLine +
                                    (message));

            grdWithdrawDJActiveBookings.Visible             = true;
            grpWithdrawDJActiveBookings.Visible             = true;
            grdWithdrawDJActiveBookings.AllowUserToAddRows  = false;
            grdWithdrawDJActiveBookings2.Visible            = true;
            grpWithdrawDJActiveBookings2.Visible            = true;
            grdWithdrawDJActiveBookings2.AllowUserToAddRows = false;
            btnLegendDJsNoBookingsWithdrawDJ.Visible        = false;
            btnDJNoBookingsWithdrawDJ.Visible           = false;
            btnLegendDJsWithBookingsWithdrawDJ.Visible  = false;
            btnDJWithBookingsWithdrawDJ.Visible         = false;
            btnDJWithdrawDJPrintBookings.Visible        = true;
            btnLegendDJsWithdrawDJPrintBookings.Visible = false;

            FlexibleMessageBox.Show("*****ADMIN - PLEASE PRESS 'PRINT BOOKINGS' TO ATTACH TO DJ CONFIRMATION EMAIL*****", "WARNING", MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }
        private void btnDJNoBookingsWithdrawDJ_Click(object sender, EventArgs e)
        {
            String Forename = txtDJForename.Text;

            DJs.WithdrawDJ(Convert.ToInt32(txtDJID.Text));
            MessageBox.Show(text: "DJ Withdrawn");
            grdWithdrawDJActiveBookings.Visible = false;
            grpWithdrawDJActiveBookings.Visible = false;
            //grdWithdrawDJsActiveBookings.AllowUserToAddRows = false;
            btnLegendDJsNoBookingsWithdrawDJ.Visible = false;
            btnDJWithdrawDJPrintBookings.Visible     = false;

            txtDJID.Clear();
            txtDJForename.Clear();
            txtDJSurname.Clear();
            txtDJContactNo.Clear();
            txtDJEmail.Clear();
            txtDJStreet.Clear();
            txtDJTown.Clear();
            txtDJCounty.Clear();
            txtDJCity.Clear();
            txtDJEircode.Clear();
            txtDJHourlyRate.Clear();

            //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    = "DJ Withdrawn";
            //string html = "";
            mail.Body =
                "Dear " + Forename + "," +
                "<br/><br/>In relation to your request to withdraw your details form Legend DJs' system, as you have no outstanding bookings, we are informing you that your contract has been terminated, " +
                "and you have now been deregistered." +
                "<br/><br/>We would like to sincerely thank you for giving the company such great service in the past, and hope to work with you again soon." +
                "<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 DJ");

            grpWithdrawDJ.Visible = false;

            txtEnterSurname.Select();
        }