/// <summary>
        /// Obtient les informations pour les emails d'annulation à envoyer.
        /// </summary>
        /// <param name="_avaibilityID">ID de la diponibilité</param>
        /// <returns>List : Réussite -> Informations de l'email. Echec -> Valeur null</returns>
        private static List <string> AbortEmailInformations(string _avaibilityID)
        {
            string avaibilityID         = _avaibilityID;
            string temporaryID          = InterimDatabase.GetAvaibilityTemporaryID(avaibilityID);
            bool   isCorrectTemporaryID = (!string.IsNullOrEmpty(temporaryID));

            // Vérifie le contenu de l'ID de l'intérimaire.
            if (isCorrectTemporaryID)
            {
                string temporaryTitle       = InterimDatabase.GetTemporaryTitle(temporaryID);
                string temporaryName        = InterimDatabase.GetTemporaryName(temporaryID);
                string temporaryEmailAdress = InterimDatabase.GetTemporaryEmailAdress(temporaryID);
                string date = InterimDatabase.GetTemporaryDate(avaibilityID);
                bool   isCorrectTemporaryTitle = (!string.IsNullOrEmpty(temporaryTitle));
                bool   isCorrectTemporaryName  = (!string.IsNullOrEmpty(temporaryName));
                bool   isCorrectEmailAdress    = (!string.IsNullOrEmpty(temporaryEmailAdress));
                bool   isCorrectDate           = (!string.IsNullOrEmpty(date));

                // Vérifie le contenu des informations de l'intérimaire.
                if (isCorrectTemporaryTitle && isCorrectTemporaryName && isCorrectEmailAdress && isCorrectDate)
                {
                    string dayName                     = DayName(date);
                    string dayNumber                   = DayNumber(date);
                    string month                       = MonthName(date);
                    string workTimetableStart          = InterimDatabase.GetTemporaryWorkTimetableStart(avaibilityID);
                    string workTimetableEnd            = InterimDatabase.GetTemporaryWorkTimetableEnd(avaibilityID);
                    string serviceName                 = InterimDatabase.GetTemporaryService(avaibilityID);
                    string sendDate                    = InterimDatabase.GetTemporarySendDate(avaibilityID);
                    bool   isCorrectWorkTimetableStart = (!string.IsNullOrEmpty(workTimetableStart));
                    bool   isCorrectWorkTimetableEnd   = (!string.IsNullOrEmpty(workTimetableEnd));
                    bool   isCorrectServiceName        = (!string.IsNullOrEmpty(serviceName));
                    bool   isCorrectSendDate           = (!string.IsNullOrEmpty(sendDate));

                    // Vérifie le contenu des informations de la mission.
                    if (isCorrectWorkTimetableStart && isCorrectWorkTimetableEnd && isCorrectServiceName && isCorrectSendDate)
                    {
                        List <string> emailInformations = new List <string>();

                        emailInformations.Add(avaibilityID);
                        emailInformations.Add(temporaryEmailAdress);
                        emailInformations.Add(temporaryTitle);
                        emailInformations.Add(temporaryName);
                        emailInformations.Add(dayName);
                        emailInformations.Add(dayNumber);
                        emailInformations.Add(month);
                        emailInformations.Add(workTimetableStart);
                        emailInformations.Add(workTimetableEnd);
                        emailInformations.Add(serviceName);
                        emailInformations.Add(sendDate);

                        return(emailInformations);
                    }
                    else
                    {
                        // Affiche un message d'erreur.
                        MessageBox.Show(SentOffer_Val.Default.NullAvaibilityInformations, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(null);
                    }
                }
                else
                {
                    // Affiche un message d'erreur.
                    MessageBox.Show(SentOffer_Val.Default.NullInformations, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }
            }
            else
            {
                // Affiche un message d'erreur.
                MessageBox.Show(SentOffer_Val.Default.NullTemporaryID, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }
示例#2
0
        /// <summary>
        /// Ajoute les contrôles pour les propositions de missions envoyées.
        /// </summary>
        /// <param name="_stp_dynamicsBase">StackPanel de base</param>
        internal static void AddSentOfferControls(StackPanel _stp_dynamicsBase)
        {
            List <string>   avaibilityDate = InterimDatabase.GetAvaibilityDate();
            bool            isCorrectAvaibilityDateList = IsCorrectList(avaibilityDate);
            List <TimeSpan> workTimetableList           = new List <TimeSpan>();
            bool            isCorrecyWorkTimetableList  = false;

            List <string> avaibilityStartTime = new List <string>();
            List <string> avaibilityEndTime   = new List <string>();
            string        workTimetable       = string.Empty;

            List <string> avaibilityIDAll                = new List <string>();
            string        avaibilityTemporaryID          = string.Empty;
            bool          isCorrectAvaibilityTemporaryID = false;

            string temporaryName          = string.Empty;
            bool   isCorrectTemporaryName = false;

            string temporaryTitle     = string.Empty;
            string temporaryFirstName = string.Empty;
            string temporaryService   = string.Empty;
            string tamporarySendDate  = string.Empty;

            // Vérifie le contenu de la liste de données.
            if (isCorrectAvaibilityDateList)
            {
                for (int indexDate = 0; indexDate < avaibilityDate.Count; indexDate++)
                {
                    StackPanel stp_DateData = StackPanelBaseBuild(_stp_dynamicsBase);
                    Sections(stp_DateData, avaibilityDate[indexDate]);

                    workTimetableList          = InterimDatabase.GetAvaibilityWorkTimetable(avaibilityDate[indexDate]);
                    isCorrecyWorkTimetableList = (workTimetableList != null);

                    // Vérifie le contenu des horaires de travail.
                    if (isCorrecyWorkTimetableList)
                    {
                        // Sépare les horaires de travail en début et fin.
                        for (int index = 0; index < workTimetableList.Count; index += 2)
                        {
                            avaibilityStartTime.Add(workTimetableList[index].ToString().Substring(0, 5));
                            avaibilityEndTime.Add(workTimetableList[index + 1].ToString().Substring(0, 5));
                        }

                        for (int indexWorkTimetable = 0; indexWorkTimetable < avaibilityStartTime.Count; indexWorkTimetable++)
                        {
                            // Assigne à un stackPanel de contrôles, pour les données de chaque horaires de travail.
                            workTimetable = avaibilityStartTime[indexWorkTimetable] + SentOffer_Val.Default.BetweenTime + avaibilityEndTime[indexWorkTimetable];

                            StackPanel stp_WorkTimetableData = DayWorkTimetable(workTimetable, _stp_dynamicsBase);

                            avaibilityIDAll = InterimDatabase.GetAvaibilityIDAll(avaibilityDate[indexDate], avaibilityStartTime[indexWorkTimetable], avaibilityEndTime[indexWorkTimetable]);

                            // Vérifie le contenu des ID des disponibilités.
                            if (IsCorrectList(avaibilityIDAll))
                            {
                                foreach (string avaibilityID in avaibilityIDAll)
                                {
                                    avaibilityTemporaryID          = InterimDatabase.GetAvaibilityTemporaryID(avaibilityID);
                                    isCorrectAvaibilityTemporaryID = (!string.IsNullOrEmpty(avaibilityTemporaryID));

                                    // Vérifie le contenu de l'ID de l'intérimaire.
                                    if (isCorrectAvaibilityTemporaryID)
                                    {
                                        // Assigne à des chaînes de caractères, les informations de chaque intérimaires ayant reçu une propositions de missions.
                                        temporaryName          = InterimDatabase.GetTemporaryName(avaibilityTemporaryID);
                                        isCorrectTemporaryName = (!string.IsNullOrEmpty(temporaryName));

                                        // Vérifie le contenu du nom de l'intérimaire.
                                        if (isCorrectTemporaryName)
                                        {
                                            temporaryTitle     = InterimDatabase.GetTemporaryTitle(avaibilityTemporaryID);
                                            temporaryFirstName = InterimDatabase.GetTemporaryFirstName(avaibilityTemporaryID);
                                            temporaryService   = InterimDatabase.GetTemporaryService(avaibilityID);
                                            tamporarySendDate  = InterimDatabase.GetTemporarySendDate(avaibilityID);

                                            // Assigne à un stackPanel de contrôles, pour les données de chaque intérimaires.
                                            StackPanel stp_TemporaryData = StackPanelBaseBuild(_stp_dynamicsBase, Orientation.Horizontal);

                                            // Assigne à une étiquette des propriétés graphiques.
                                            stp_TemporaryData.Margin = new Thickness(40, 10, 0, 10);

                                            // Assigne le titre de civilité de l'intérimaire.
                                            TemporaryTitle(stp_TemporaryData, temporaryTitle);

                                            // Assigne le nom de l'intérimaire.
                                            TemporaryName(stp_TemporaryData, temporaryName);

                                            // Assigne le prénom de l'intérimaire.
                                            TemporaryFirstName(stp_TemporaryData, temporaryFirstName);

                                            // Assigne le service de l'intérimaire.
                                            TemporaryService(stp_TemporaryData, temporaryService);

                                            // Assigne la date d'envoi de la proposition de mission de l'intérimaire.
                                            TemporarySendDate(stp_TemporaryData, tamporarySendDate);

                                            // Assigne les étiquettes de l'état de l'acceptation de proposition de mission.
                                            TemporaryStateMission(stp_TemporaryData, avaibilityID);
                                        }
                                    }
                                }
                            }
                        }

                        avaibilityStartTime.Clear();
                        avaibilityEndTime.Clear();
                    }
                }
            }
        }
        /// <summary>
        /// Obtient les informations pour l'email à envoyer.
        /// </summary>
        /// <param name="_avaibilityIDAndMessage">ID de la disponibilité et message à afficher</param>
        /// <returns>List : Réussite -> Informations de l'email. Echec -> Valeur null</returns>
        private static List <string> EmailInformations(List <string> _avaibilityIDAndMessage)
        {
            List <string> avaibilityIDAndMessage = _avaibilityIDAndMessage;
            string        temporaryID            = InterimDatabase.GetAvaibilityTemporaryID(avaibilityIDAndMessage[0]);
            bool          isCorrectTemporaryID   = (!string.IsNullOrEmpty(temporaryID));

            // Vérifie le contenu de l'ID de l'intérimaire.
            if (isCorrectTemporaryID)
            {
                string temporaryTitle          = InterimDatabase.GetTemporaryTitle(temporaryID);
                string temporaryName           = InterimDatabase.GetTemporaryName(temporaryID);
                bool   isCorrectTemporaryTitle = (!string.IsNullOrEmpty(temporaryTitle));
                bool   isCorrectTemporaryName  = (!string.IsNullOrEmpty(temporaryName));

                // Vérifie le contenu des informations de l'intérimaire.
                if (isCorrectTemporaryTitle && isCorrectTemporaryName)
                {
                    string messageBox = avaibilityIDAndMessage[1] + temporaryTitle + " " + temporaryName + SentOffer_Val.Default.Ask;

                    // Message de confirmation.
                    DialogResult dialogResult = MessageBox.Show(messageBox, avaibilityIDAndMessage[2], MessageBoxButtons.YesNo, MessageBoxIcon.Question);

                    // Vérifie la réponse au message de confirmation.
                    if (dialogResult == DialogResult.Yes)
                    {
                        string temporaryEmailAdress = InterimDatabase.GetTemporaryEmailAdress(temporaryID);
                        string date = InterimDatabase.GetTemporaryDate(avaibilityIDAndMessage[0]);
                        bool   isCorrectEmailAdress = (!string.IsNullOrEmpty(temporaryEmailAdress));
                        bool   isCorrectDate        = (!string.IsNullOrEmpty(date));

                        // Vérifie le contenu de l'adresse email.
                        if (isCorrectEmailAdress && isCorrectDate)
                        {
                            string dayName                     = DayName(date);
                            string dayNumber                   = DayNumber(date);
                            string month                       = MonthName(date);
                            string workTimetableStart          = InterimDatabase.GetTemporaryWorkTimetableStart(avaibilityIDAndMessage[0]);
                            string workTimetableEnd            = InterimDatabase.GetTemporaryWorkTimetableEnd(avaibilityIDAndMessage[0]);
                            string serviceName                 = InterimDatabase.GetTemporaryService(avaibilityIDAndMessage[0]);
                            string sendDate                    = InterimDatabase.GetTemporarySendDate(avaibilityIDAndMessage[0]);
                            bool   isCorrectWorkTimetableStart = (!string.IsNullOrEmpty(workTimetableStart));
                            bool   isCorrectWorkTimetableEnd   = (!string.IsNullOrEmpty(workTimetableEnd));
                            bool   isCorrectServiceName        = (!string.IsNullOrEmpty(serviceName));
                            bool   isCorrectSendDate           = (!string.IsNullOrEmpty(sendDate));

                            // Vérifie le contenu des informations de la mission.
                            if (isCorrectWorkTimetableStart && isCorrectWorkTimetableEnd && isCorrectServiceName && isCorrectSendDate)
                            {
                                List <string> emailInformations = new List <string>();

                                emailInformations.Add(avaibilityIDAndMessage[0]);
                                emailInformations.Add(temporaryEmailAdress);
                                emailInformations.Add(temporaryTitle);
                                emailInformations.Add(temporaryName);
                                emailInformations.Add(dayName);
                                emailInformations.Add(dayNumber);
                                emailInformations.Add(month);
                                emailInformations.Add(workTimetableStart);
                                emailInformations.Add(workTimetableEnd);
                                emailInformations.Add(serviceName);
                                emailInformations.Add(sendDate);

                                return(emailInformations);
                            }
                            else
                            {
                                // Affiche un message d'erreur.
                                MessageBox.Show(SentOffer_Val.Default.NullAvaibilityInformations, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return(null);
                            }
                        }
                        else
                        {
                            // Affiche un message d'erreur.
                            MessageBox.Show(SentOffer_Val.Default.NullEmailAdressOrDate, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(null);
                        }
                    }

                    return(null);
                }
                else
                {
                    // Affiche un message d'erreur.
                    MessageBox.Show(SentOffer_Val.Default.NullInformations, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return(null);
                }
            }
            else
            {
                // Affiche un message d'erreur.
                MessageBox.Show(SentOffer_Val.Default.NullTemporaryID, SentOffer_Err.Default.ErrorTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
        }