Beispiel #1
0
        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);
        }