Example #1
0
        /// <summary>
        /// Try to add pregnancy. Asks user any questions he has to be asked.
        /// </summary>
        /// <param name="date">The clicked day.</param>
        /// <returns>True if added. Otherwise false.</returns>
        public bool AddConceptionDay(DateTime date)
        {
            if (!this.Conceptions.IsPregnancyDay(date))
            {
                if (date > DateTime.Today)
                {
                    if (!MsgBox.YesNo(
                            TEXT.Get["Future_pregnancy_day"] + TEXT.Get["Are_you_sure_capital"],
                            TEXT.Get["What_a_situation"]))
                    {
                        return(false);
                    }
                }

                ConceptionPeriod concPeriod = this.Conceptions.GetConceptionAfterDate(date);
                if (concPeriod != null && (concPeriod.StartDay - date).Days <= ConceptionPeriod.StandardLength)
                {
                    MsgBox.YesNo(
                        TEXT.Get.Format("Already_pregnant_after", (concPeriod.StartDay - date).Days.ToString()),
                        TEXT.Get["No_no_no"]);
                    return(false);
                }

                MenstruationPeriod nextMenses = this.Menstruations.GetClosestPeriodAfterDay(date);
                if (nextMenses != null)
                {
                    if (!MsgBox.YesNo(
                            TEXT.Get["Have_menses_after_pregn"] + TEXT.Get["Are_you_sure_capital"],
                            TEXT.Get["What_a_situation"]))
                    {
                        return(false);
                    }
                }

                MenstruationPeriod prevMenses = this.Menstruations.GetPeriodByDate(date);
                if (prevMenses != null)
                {
                    if (!MsgBox.YesNo(
                            TEXT.Get["Pregn_on_menses"] + TEXT.Get["Are_you_sure_capital"],
                            TEXT.Get["What_a_situation"]))
                    {
                        return(false);
                    }
                }
                else
                {
                    prevMenses = this.Menstruations.GetClosestPeriodBeforeDay(date);
                }

                if (prevMenses != null && Math.Abs((date - prevMenses.LastDay).Days) <= this.ManualPeriodLength)
                { // The pregnancy must start from last cycle start.
                  // Also we must be sure is was not so long time ago since last cycle.
                    prevMenses.HasPregnancy = true;
                    return(this.Conceptions.Add(prevMenses.StartDay));
                }
                else
                {
                    return(this.Conceptions.Add(date));
                }
            }

            return(false);
        }
Example #2
0
        /// <summary>
        /// Check if the baby is carried by woman that day.
        /// </summary>
        /// <param name="date">Date to check.</param>
        /// <returns>True if the baby is in the woman's stomak at the day.</returns>
        public bool IsPregnancyDay(DateTime date)
        {
            ConceptionPeriod period = this.Conceptions.GetConceptionByDate(date);

            return(period != null);
        }