protected void buttonSubmitClick(object sender, EventArgs e)
        {
            //int availabilityId = Convert.ToInt32(ddlDate.SelectedValue);
            //Availability availability = af.GetById(availabilityId);

            string dateDebut = ddlDate.SelectedValue; //Mercredi 12 decembre 2018

            string[]     heureMinutes = ddlHeureDebut.SelectedValue.Split(':');
            DateTime     date;
            bool         convertDate  = DateTime.TryParseExact(dateDebut, "dddd d MMMM yyyy", CultureInfo.CreateSpecificCulture("fr-FR"), System.Globalization.DateTimeStyles.None, out date);
            DateTime     dateH        = date.AddHours(Double.Parse(heureMinutes[0]));
            DateTime     dateM        = dateH.AddMinutes(Double.Parse(heureMinutes[1]));
            Availability availability = af.getByDate(dateM);
            string       temps        = ddlHeureDebut.SelectedValue;

            int heure   = Convert.ToInt32(temps.Substring(0, 2));
            int minutes = Convert.ToInt32(temps.Substring(3, 2));
            //DateTime date2 = new DateTime(dateDebutDT.Year, dateDebutDT.Month, dateDebutDT.Day, heure, minutes, 00);

            string message = txtContent.Text;

            if (message.Length > 200)
            {
                notification.Style.Add("color", "red");
                notification.InnerText = "Le nombre maximum de caractère a été atteint. Veuillez réduire la longueur de votre message.";
                return;
            }

            Regex regex = new Regex(@"\w{26,}");

            if (regex.IsMatch(message))
            {
                notification.Style.Add("color", "red");
                notification.InnerText = "Le message actuel ne peux pas être envoyer. Veuillez vérifier votre message.";
                return;
            }

            Availability        newAv = af.splitavail(availability.availabilityId, dateM);
            AppointementFactory ap    = new AppointementFactory(cnnStr);

            ap.Add(user.userId, newAv.availabilityId, message);

            //Envoyer Email
            EmailController ec   = new EmailController();
            string          body = string.Empty;

            using (StreamReader reader = new StreamReader(Server.MapPath("~/Email/PriseRDV.html")))
            {
                body = reader.ReadToEnd();
            }

            body = body.Replace("{date}", ddlDate.SelectedItem.Text);
            string minuteString;

            if (minutes == 0)
            {
                minuteString = minutes.ToString() + "0";
            }
            else
            {
                minuteString = minutes.ToString();
            }
            body = body.Replace("{heure}", heure.ToString() + "h" + minuteString);
            body = body.Replace("{prenom}", user.firstname);
            body = body.Replace("{nom}", user.lastname);
            body = body.Replace("{email}", user.email);

            ec.SendMail(emailAddress, "Rendez-vous de " + user.firstname + " " + user.lastname, body);

            // Redirection à une page de confirmation
            Response.Redirect("ConfirmationRDV.aspx?User=" + user.userId);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            // -----------Vérification le l'état du module ----------- //
            ModuleFactory moduleFactory = new ModuleFactory(cnnStr);
            Module        m             = moduleFactory.Get((int)Module.AllModules.Appointment);/* Module id 1 = Module des prises de rendez-vous */

            if (m.active == false)
            {
                ActivationValidation.Visible = true;
                PageContent.Visible          = false;
            }
            else
            {
                ActivationValidation.Visible = false;
                PageContent.Visible          = true;
            }
            // ------------------------------------------------------- //

            if (Request.QueryString["notif"] != null)
            {
                switch (Request.QueryString["notif"])
                {
                case "confirm":
                    notifWaiting.Visible   = true;
                    notifWaiting.InnerText = "Le rendez-vous sélectionné a bien été confirmé";
                    notifConfirmed.Visible = false;
                    break;

                case "refuse":
                    notifWaiting.Visible   = true;
                    notifWaiting.InnerText = "Le rendez-vous sélectionné a bien été refusé";
                    notifConfirmed.Visible = false;
                    break;

                case "cancel":
                    notifConfirmed.Visible   = true;
                    notifConfirmed.InnerText = "Le rendez-vous sélectionné a bien été annulé";
                    notifWaiting.Visible     = false;
                    break;
                }
            }
            else
            {
                notifConfirmed.Visible = false;
                notifWaiting.Visible   = false;
            }

            UserFactory         uf  = new UserFactory(cnnStr);
            AvailabilityFactory avf = new AvailabilityFactory(cnnStr);
            AppointementFactory af  = new AppointementFactory(cnnStr);

            Appointement[] unconfirmedAppointements = af.GetUnconfirmed();
            System.Diagnostics.Debug.WriteLine("TAB: " + unconfirmedAppointements.Length);
            Appointement[] confirmedAppointements = af.GetConfirmed();
            notifNoRdv.Visible = false;
            if (unconfirmedAppointements.Length > 0)
            {
                bool smth = false;
                foreach (Appointement a in unconfirmedAppointements)
                {
                    int          availabilityId = a.availabilityId;
                    Availability availability   = avf.GetById(availabilityId);
                    int          userId         = a.userId;
                    User         user           = uf.Get(userId);

                    DateTime dateTime = availability.strdt;
                    if (dateTime.CompareTo(DateTime.Now) < 0)
                    {
                        af.outdate(a.appointementId);
                    }
                    else
                    {
                        string dateToDisplay = dateTime.ToString("f", CultureInfo.CreateSpecificCulture("fr-FR"));
                        smth = true;
                        TableRow  row           = new TableRow();
                        TableCell cellDate      = new TableCell();
                        TableCell cellLastname  = new TableCell();
                        TableCell cellFirstname = new TableCell();
                        TableCell cellEmail     = new TableCell();
                        TableCell cellMessage   = new TableCell();
                        TableCell cellConfirm   = new TableCell();
                        TableCell cellRefuse    = new TableCell();
                        cellDate.Text      = dateToDisplay;
                        cellLastname.Text  = user.lastname;
                        cellFirstname.Text = user.firstname;
                        cellEmail.Text     = user.email;
                        cellMessage.Text   = a.message;
                        CheckBox cb            = new CheckBox();
                        Button   buttonConfirm = new Button();
                        buttonConfirm.Attributes.Add("class", "btn btn-success");
                        buttonConfirm.Click        += new EventHandler(Click_Confirm);
                        buttonConfirm.OnClientClick = "ConfirmerRDV()";
                        buttonConfirm.Text          = "Confirmer";
                        buttonConfirm.Attributes.Add("data-id", a.appointementId.ToString());
                        cellConfirm.Controls.Add(buttonConfirm);
                        Button buttonRefuser = new Button();
                        buttonRefuser.Attributes.Add("class", "btn btn-danger");
                        buttonRefuser.Click        += new EventHandler(Click_Refuse);
                        buttonRefuser.OnClientClick = "RefuserRDV()";
                        buttonRefuser.Text          = "Refuser";
                        buttonRefuser.Attributes.Add("data-id", a.appointementId.ToString());
                        cellRefuse.Controls.Add(buttonRefuser);


                        row.Cells.Add(cellDate);
                        row.Cells.Add(cellLastname);
                        row.Cells.Add(cellFirstname);
                        row.Cells.Add(cellEmail);
                        row.Cells.Add(cellMessage);
                        row.Cells.Add(cellConfirm);
                        row.Cells.Add(cellRefuse);
                        tabUnconfirmed.Rows.Add(row);
                    }
                }
                if (smth)
                {
                    cardUnconfirmed.Visible = true;
                }
                else
                {
                    cardUnconfirmed.Visible = false;
                }
            }
            else
            {
                cardUnconfirmed.Visible = false;
            }


            if (confirmedAppointements.Length > 0)
            {
                bool smth = false;
                foreach (Appointement a in confirmedAppointements)
                {
                    int          availabilityId = a.availabilityId;
                    Availability availability   = avf.GetById(availabilityId);
                    int          userId         = a.userId;
                    User         user           = uf.Get(userId);

                    DateTime dateTime = availability.strdt;
                    if (dateTime.CompareTo(DateTime.Now) < 0)
                    {
                        af.outdate(a.appointementId);
                    }
                    else
                    {
                        string    dateToDisplay = dateTime.ToString("f", CultureInfo.CreateSpecificCulture("fr-FR"));
                        TableRow  row           = new TableRow();
                        TableCell cellDate      = new TableCell();
                        TableCell cellLastname  = new TableCell();
                        TableCell cellFirstname = new TableCell();
                        TableCell cellEmail     = new TableCell();
                        TableCell cellMessage   = new TableCell();
                        TableCell cellRefuse    = new TableCell();
                        cellDate.Text      = dateToDisplay;
                        cellLastname.Text  = user.lastname;
                        cellFirstname.Text = user.firstname;
                        cellEmail.Text     = user.email;
                        cellMessage.Text   = a.message;
                        Button buttonRefuser = new Button();
                        buttonRefuser.Attributes.Add("class", "btn btn-danger");
                        buttonRefuser.Click        += new EventHandler(Click_Cancel);
                        buttonRefuser.OnClientClick = "AnnulerRDV()";
                        buttonRefuser.Text          = "Annuler";
                        buttonRefuser.Attributes.Add("data-id", a.appointementId.ToString());
                        cellRefuse.Controls.Add(buttonRefuser);;
                        row.Cells.Add(cellDate);
                        row.Cells.Add(cellLastname);
                        row.Cells.Add(cellFirstname);
                        row.Cells.Add(cellEmail);
                        row.Cells.Add(cellMessage);
                        row.Cells.Add(cellRefuse);
                        tabConfirmed.Rows.Add(row);
                        smth = true;
                    }
                }
                if (smth)
                {
                    cardConfirmed.Visible = true;
                }
                else
                {
                    cardConfirmed.Visible = false;
                }
            }
            else
            {
                cardConfirmed.Visible = false;
            }

            //Afficher une notif si il n'y a rien a afficher
            if (cardUnconfirmed.Visible == false && cardConfirmed.Visible == false)
            {
                notifNoRdv.Visible = true;
            }
        }