private void grdChangeBookingActiveBookings_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { //this is checking if the amount of rows in the grdChangeBookingActiveDJs is greater than 0 if (grdChangeBookingActiveBookings.SelectedRows.Count > 0) { string DJID = grdChangeBookingActiveBookings.SelectedRows[0].Cells[3].Value + string.Empty; string ServiceID = grdChangeBookingActiveBookings.SelectedRows[0].Cells[4].Value + string.Empty; string EventDate = grdChangeBookingActiveBookings.SelectedRows[0].Cells[0].Value + string.Empty; string BookingID = grdChangeBookingActiveBookings.SelectedRows[0].Cells[2].Value + string.Empty; string Location = grdChangeBookingActiveBookings.SelectedRows[0].Cells[8].Value + string.Empty; string Eircode = grdChangeBookingActiveBookings.SelectedRows[0].Cells[9].Value + string.Empty; dtpEventDate.Text = EventDate; txtDJID.Text = DJID; txtServiceID.Text = ServiceID; txtBookingID.Text = BookingID; if (!ValidateData.isValidDate28(dtpEventDate.Value)) { //Reference for message box options https://www.functionx.com/vb/functions/msgbox.htm DialogResult dialog = MessageBox.Show("Sorry, booking cannot be changed less than 28 days before the event date. \n\nWould you like to choose another booking?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (dialog == DialogResult.No) { // parent.Show(); // this.Dispose() parent.Show(); this.Dispose(); } else { grdChangeBookingActiveBookings.Select(); } return; } grdChangeBookingActiveServices.Visible = true; grpChangeBookingActiveServices.Visible = true; grdChangeBookingActiveServices.AllowUserToAddRows = false; DataSet ds = new DataSet(); string Service_ID = null; //grChangeBookingActiveServices.DataSource = Bookings.GetAllActiveServices(ds, txtEnterName.Text.ToUpper()).Tables["Services"]; ds = Bookings.GetAllActiveServices(ds, Service_ID); grdChangeBookingActiveServices.DataSource = ds.Tables["searchActiveServices"]; txtServiceID.Select(); } }
private void btnCheckAvailibility_Click(object sender, EventArgs e) { if (!ValidateData.isValidDate3(dtpEventDate.Value)) { MessageBox.Show("Cannot be previous Date", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); dtpEventDate.Focus(); return; } if (!Bookings.isDJAvailable(dtpEventDate.Text, Convert.ToInt32(txtDJID.Text))) { //Reference for message box options https://www.functionx.com/vb/functions/msgbox.htm DialogResult dialog = MessageBox.Show("This DJ selected is not available on this date. Would you like to choose another DJ?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Error); if (dialog == DialogResult.No) { // parent.Show(); // this.Dispose() parent.Show(); this.Dispose(); } else { grdMakeBookingActiveDJs.Select(); } } else { //Reference for message box options https://www.functionx.com/vb/functions/msgbox.htm DialogResult dialog = MessageBox.Show("Great! The DJ selected is available on this date. Would you like to complete booking form?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialog == DialogResult.No) { // parent.Show(); // this.Dispose() parent.Show(); this.Dispose(); } else { //reference to lock cells from being edited once inputted data is made https://social.msdn.microsoft.com/Forums/en-US/00b513aa-6fc2-4e70-a951-752aa12dd0c6/datagridview-get-selected-value-on-mouseclick-then-click-edit-button?forum=csharplanguage grdMakeBookingMatchingClients.Enabled = false; grdMakeBookingActiveServices.Enabled = false; grdMakeBookingActiveDJs.Enabled = false; btnCheckAvailibility.Visible = false; pnlMakeBooking.Visible = true; grpMakeBooking.Select(); cboStartTime.Focus(); } } }
private void btnConfirmCancellation_Click(object sender, EventArgs e) { //Update the data in the database based on the details changed in the text boxes(if any) Bookings.cancelBookings(Convert.ToInt32(txtBookingID.Text), Convert.ToDecimal(txtTotalCost.Text), "R", Convert.ToInt32(txtRefundPercentage.Text), Convert.ToDecimal(txtRefundDue.Text), "C", Convert.ToInt32(15)); grpCancelBooking.Visible = false; pnlCancelBooking.Visible = false; pnlCancelBooking2.Visible = false; MessageBox.Show(text: Environment.NewLine + Environment.NewLine + "Booking cancellation confirmed!" + Environment.NewLine + Environment.NewLine + "Please click on 'Print Invoice' below to send comfirmation email to client."); btnCancelBookingClientPrintInvoice.Visible = true; }
private void btnFindClient_Click(object sender, EventArgs e) { if (!ValidateData.isBlank(txtEnterSurname.Text)) { grpChangeBookingMatchingClients.Visible = false; grdChangeBookingMatchingClients.Visible = false; MessageBox.Show("Surname must be entered", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEnterSurname.Focus(); return; } else if (!ValidateData.containsNumbers(txtEnterSurname.Text)) { grpChangeBookingMatchingClients.Visible = false; grdChangeBookingMatchingClients.Visible = false; MessageBox.Show("Surname cannot contain numbers", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); txtEnterSurname.Clear(); txtEnterSurname.Focus(); return; } else { DataSet ds = new DataSet(); //grdChangeBookingMatchingClients.DataSource = Bookings.GetAllActiveBookings(ds, txtEnterName.Text.ToUpper()).Tables["Bookings"]; ds = Bookings.GetAllActiveClients(ds, ValidateData.apostChecker(txtEnterSurname.Text.ToUpper())); grdChangeBookingMatchingClients.DataSource = ds.Tables["searchActiveClient"]; if (grdChangeBookingMatchingClients.Rows.Count == 0) { grdChangeBookingMatchingClients.Visible = false; grpChangeBookingMatchingClients.Visible = false; MessageBox.Show("No clients found. Please try again", "Error", MessageBoxButtons.OKCancel, MessageBoxIcon.Error); txtEnterSurname.Clear(); txtEnterSurname.Focus(); return; } txtEnterSurname.Clear(); grdChangeBookingMatchingClients.Visible = true; grpChangeBookingMatchingClients.Visible = true; grdChangeBookingActiveBookings.AllowUserToAddRows = false; } }
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)); } } }
private void frmMakeBooking_Load(object sender, EventArgs e) { txtBookingID.Text = Bookings.nextBookingID().ToString("00000"); txtBookingID.Visible = true; txtEnterSurname.Select(); //reference for autocomplete textbox http://www.simplylearnprogramming.com/autocomplete-textbox-from-database-using-csharp/51 cmd = new OracleCommand("SELECT Surname FROM Client", myConn); myConn.Open(); dr = cmd.ExecuteReader(); AutoCompleteStringCollection Collection = new AutoCompleteStringCollection(); while (dr.Read()) { Collection.Add(dr.GetString(0)); } txtEnterSurname.AutoCompleteCustomSource = Collection; dr.Close(); myConn.Close(); }
private void grdMakeBookingActiveServices_CellDoubleClick(object sender, DataGridViewCellEventArgs e) { grdMakeBookingActiveServices.Visible = true; //this is checking if the amount of rows in the grdMakeBookingActiveServices is greater than 0 if (grdMakeBookingActiveServices.SelectedRows.Count > 0) { string ServiceID = grdMakeBookingActiveServices.SelectedRows[0].Cells[0].Value + string.Empty; txtServiceID.Text = ServiceID; DataSet ds = new DataSet(); string DJ_ID = null; //grdMakeBookingActiveDJs.DataSource = Bookings.GetAllActiveDJs(ds, txtEnterName.Text.ToUpper()).Tables["DJs"]; ds = Bookings.GetAllActiveDJs(ds, DJ_ID); grdMakeBookingActiveDJs.DataSource = ds.Tables["searchActiveDJs"]; grdMakeBookingActiveDJs.Visible = true; grpMakeBookingActiveDJs.Visible = true; } }
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"); }