public ReservationType generation() { String sd = monthCalendar1.SelectionStart.ToString("yyyyMMdd"); String cusID; randomGeneration ran = new randomGeneration(); cusID = ran.getCustID(); ReservationType reservation = new ReservationType(hotelID(), sd, getDateDifference(), cusID, hotelRoom()); if (r.ReserveRoom(reservation)) { String year = reservation.startDate.Substring(0, 4); String month = reservation.startDate.Substring(4, 2); String day = reservation.startDate.Substring(6, 2); MessageBox.Show("The reservation was: " + reservation.result + ".Customer " + reservation.customerId + " RESERVERD " + reservation.roomType + " ROOM for " + reservation.numDays + " days Starting " + month + "/" + day + "/" + year + " - $" + reservation.cost); String email = EmailBox.Text; Console.WriteLine(email); MailMessage message = new MailMessage(); SmtpClient client = new SmtpClient(); client.Host = "smtp.gmail.com"; client.Port = 587; client.EnableSsl = true; client.Credentials = new NetworkCredential("*****@*****.**", "danielandmaria"); String boo = "Hello " + nameBox.Text + "!!!\n You just reserved a room in " + HotelFactory.GetHotelName(reservation.hotelId) + "\n " + "Your reservation starts: " + month + "/" + day + "/" + year + " for " + reservation.numDays + " nights " + ". The total cost of your reservation is $" + reservation.cost + ".\nTo keep track of your reservation: " + reservation.reservationId + "\n We hope you have an amazing time and thanks for choosing us!!."; try { MailMessage mail = new MailMessage(); mail.From = new MailAddress("*****@*****.**"); mail.To.Add(email); mail.Subject = "Information from your reservation!!"; mail.Body = boo; client.Send(mail); } catch (Exception ex) { MessageBox.Show("Cannot email the reservation"); //MessageBox.Show(ex.ToString()); } } else { MessageBox.Show("Cannot reserve because: " + reservation.result); } return(reservation); }
public void RunningReservations() { progressBar1.Maximum = list.Count; foreach (ReservationType reserve in list) { progressBar1.PerformStep(); //This will take the last ID on the XML form and increase it by one, so if you run the simulator twice it wont generate 1 as the first id even // if we had 30 reservations already reserve.customerId = random.getCustID(); if (!f.ReserveRoom(reserve)) { //If the reservation wansnt completed added to the main method listBox1.Items.Add("Customer " + reserve.customerId + " Tried to RESERVERD " + reserve.roomType + " at Hotel " + reserve.hotelId + " Starting " + reserve.startDate); } this.Refresh(); Thread.Sleep(300); } }