Пример #1
0
 public static int GetDailyPrintNumber(Date date, int refNumber, Date refDate, SpecialDay noPrintDays, Dictionary<int, int> noPrintDates, Dictionary<int, int> noPrintNumbers)
 {
     int no = refNumber;
     Date date2 = refDate;
     while (date > date2)
     {
         date2 = date2.AddDays(1);
         if (!noPrintDates.ContainsKey(date2.AbsoluteDay) && !SpecialDayTools.IsSpecialDay(noPrintDays, date2))
         {
             do
             {
                 no++;
             } while (noPrintNumbers.ContainsKey(no));
         }
     }
     while (date < date2)
     {
         if (!noPrintDates.ContainsKey(date2.AbsoluteDay) && !SpecialDayTools.IsSpecialDay(noPrintDays, date2))
         {
             do
             {
                 no--;
             } while (noPrintNumbers.ContainsKey(no));
         }
         date2 = date2.AddDays(-1);
     }
     return no;
 }
Пример #2
0
        public ActionResult SpecialDays(SpecialDay model)
        {
            var values       = ViewData.ModelState.Values;
            var errorMessage = _validationService.CheckModelHasErrorMessage(values);

            if (string.IsNullOrEmpty(errorMessage))
            {
                var result = _specialDayRepository.AddSpecialDay(model);
                if (result)
                {
                    ViewData["Success"] = WarningMessages.AddSpecialDaySuccess;
                    ModelState.Clear();
                }
                else
                {
                    ViewData["Error"] = WarningMessages.AddSpecialDayFail;
                }
            }
            else
            {
                ViewData["Error"] = errorMessage;
            }
            ViewBag.specialDays = _specialDayRepository.GetSpecialDays();
            var countries = _countryRepository.GetCountry();

            ViewBag.countryDropDownItems = ReturnCountriesASelectListItems(countries);
            return(View());
        }
Пример #3
0
 private void ClearProperties()
 {
     SDStackPanelVis = false;
     TheSpecialDay   = new SpecialDay();
     TheMonth        = new TimePeriod();
     TheDayType      = new DayType();
 }
Пример #4
0
        public TimeOfDay GetZman(DailyZmanim dz)
        {
            var hm = TimeOfDay.NoValue;

            switch (this.ZmanIndex)
            {
            case 0: hm = (dz.NetzMishor - 90); break;                                 //Alos Hashachar - 90

            case 1: hm = (dz.NetzMishor - 72); break;                                 //Alos Hashachar - 72

            case 2: hm = dz.NetzAtElevation; break;                                   //Sunrise

            case 3: hm = dz.NetzMishor; break;                                        //Sunrise - sea level

            case 4: hm = dz.GetZman(ZmanType.KShmMga); break;                         //Shma - MG\A

            case 5: hm = dz.GetZman(ZmanType.KshmGra); break;                         //Shma - GR\A

            case 6: hm = dz.GetZman(ZmanType.TflMga); break;                          //Tefilla - MG\A

            case 7: hm = dz.GetZman(ZmanType.TflGra); break;                          //Tefilla - GR\A

            case 8: hm = dz.Chatzos; break;                                           //Midday and Midnight

            case 9: hm = dz.GetZman(ZmanType.MinchaG); break;                         //Mincha Gedolah

            case 10: hm = dz.GetZman(ZmanType.MinchaK); break;                        //Mincha Ketana

            case 11: hm = dz.GetZman(ZmanType.MinchaPlg); break;                      //Plag HaMincha

            case 12: hm = dz.ShkiaAtElevation; break;                                 //Sunset

            case 13: hm = dz.ShkiaMishor; break;                                      //Sunset - sea level

            case 14: hm = dz.ShkiaAtElevation + 45; break;                            //Night - 45

            case 15: hm = dz.ShkiaAtElevation + 72; break;                            //Night - Rabbeinu Tam

            case 16: hm = dz.ShkiaAtElevation + (int)(dz.ShaaZmanisMga * 1.2); break; //Night - 72 Zmaniyos
            }
            var isYomTov        = SpecialDay.IsShabbosOrYomTov(dz.JewishDate, dz.Location);
            var hasYomTovOffset = !this.DaysOfWeek.Contains(7);
            var showYomTov      = isYomTov && hasYomTovOffset;

            if (this.Offset != 0 &&
                (this.DaysOfWeek == null ||
                 this.DaysOfWeek.Contains((int)dz.SecularDate.DayOfWeek)) && (!showYomTov))
            {
                hm += this.Offset;
            }
            else if (this.AlternateOffset != 0 &&
                     this.DaysOfWeek != null &&
                     ((!this.DaysOfWeek.Contains((int)dz.SecularDate.DayOfWeek)) ||
                      showYomTov))
            {
                hm += this.AlternateOffset;
            }
            return(hm);
        }
Пример #5
0
        private string GetDayOfWeekString(JewishDate jd, Location location)
        {
            string dow = "";

            if (this.rbDOWJewishNum.Checked)
            {
                dow = (jd.DayInWeek + 1).ToNumberHeb();
            }
            else if (this.rbDowNum.Checked)
            {
                dow = (jd.DayInWeek + 1).ToString();
            }
            else if (this.rbDayOfWeekFull.Checked)
            {
                if (jd.DayOfWeek == DayOfWeek.Saturday)
                {
                    dow = "ש\"ק";
                    if (!SpecialDay.IsMajorYomTov(jd, location))
                    {
                        dow += " " + string.Join(" - ",
                                                 Sedra.GetSedra(jd, location.IsInIsrael)
                                                 .Select(i => i.nameHebrew));
                    }
                }
                else
                {
                    dow = Utils.JewishDOWNamesShort[jd.DayInWeek];
                }
            }
            else if (this.rbDOWEnglish.Checked)
            {
                if (jd.DayOfWeek == DayOfWeek.Saturday)
                {
                    dow = "Shabbos";
                    if (!SpecialDay.IsMajorYomTov(jd, location))
                    {
                        dow += " " + string.Join(" - ",
                                                 Sedra.GetSedra(jd, location.IsInIsrael)
                                                 .Select(i => i.nameEng));
                    }
                }
                else
                {
                    dow = jd.DayOfWeek.ToString().Substring(0, 3);
                }
            }
            if (this.choiceDayDetails.ChoiceOneSelected)
            {
                string holidayText = Zmanim.GetHolidaysText(
                    Zmanim.GetHolidays(jd, location.IsInIsrael), " - ",
                    !this.rbDOWEnglish.Checked);

                if (!string.IsNullOrWhiteSpace(holidayText))
                {
                    dow += " - " + holidayText;
                }
            }
            return(dow);
        }
Пример #6
0
 private void SetAddingProperties()
 {
     TheMonth        = new TimePeriod();
     TheSpecialDay   = new SpecialDay();
     TheDayType      = new DayType();
     SDStackPanelVis = true;
     UpdateSDVis     = false;
 }
 public bool AddSpecialDay(SpecialDay specialDay)
 {
     using (var db = new DbContext())
     {
         db.SpecialDays.Add(specialDay);
         var result = db.SaveChanges();
         return(result > 0);
     }
 }
Пример #8
0
 public SpecialDayViewModel()
 {
     _specLogic           = new SpecialDayLogic();
     TheSpecialDay        = new SpecialDay();
     TheMonth             = new TimePeriod();
     TheDayType           = new DayType();
     SpecialDayCollection = new ObservableCollection <SpecialDay>(_specLogic.GetSP());
     DayTypeCollection    = new ObservableCollection <DayType>(_specLogic.GetDT());
     PeriodCollection     = new ObservableCollection <TimePeriod>(_specLogic.GetPC());
 }
Пример #9
0
        public static SpecialDay GetSpecialDays(string[] text)
        {
            SpecialDay sd = 0;

            foreach (string t in text)
            {
                sd |= GetSpecialDay(t);
            }
            return(sd);
        }
Пример #10
0
        //protected RegexValues _normalizedFilename = null;
        //protected RegexValues _normalizedSpecialFilename = null;

        public Print1(string name, string title, PrintFrequency frequency, DayOfWeek?weekday, string directory, Date refPrintDate, int refPrintNumber, SpecialDay noPrintDays)
        {
            _name           = name;
            _title          = title;
            _frequency      = frequency;
            _weekday        = weekday;
            _directory      = directory;
            _refPrintDate   = refPrintDate;
            _refPrintNumber = refPrintNumber;
            _noPrintDays    = noPrintDays;
        }
Пример #11
0
        //protected RegexValues _normalizedFilename = null;
        //protected RegexValues _normalizedSpecialFilename = null;

        public Print1(string name, string title, PrintFrequency frequency, DayOfWeek? weekday, string directory, Date refPrintDate, int refPrintNumber, SpecialDay noPrintDays)
        {
            _name = name;
            _title = title;
            _frequency = frequency;
            _weekday = weekday;
            _directory = directory;
            _refPrintDate = refPrintDate;
            _refPrintNumber = refPrintNumber;
            _noPrintDays = noPrintDays;
        }
Пример #12
0
 public Task <int> SaveSpecialDay(SpecialDay specialDay)
 {
     try
     {
         _context.SpecialDays.AddOrUpdate(specialDay);
         return(_context.SaveChangesAsync());
     }
     catch (Exception exception)
     {
         throw exception;
     }
 }
Пример #13
0
        public int SaveSpecialDaysDA(SpecialDay specialDay)
        {
            DataSet ds = new DataSet();

            string query = "exec spI_SpecialDays @DelegationId= " + specialDay.DelegationId +
                           ", @Date =" + specialDay.Date +
                           ",@IsNonWorking =" + specialDay.IsNonWorking +
                           ", @IsOverrided=" + specialDay.IsOverrided;

            ds = con.ObtenerConsulta(query);

            return(Convert.ToInt32(ds.Tables[0].Rows[0].ItemArray[0].ToString()));
        }
 public bool DeleteSpecialDay(int specialDayId)
 {
     using (var db = new DbContext())
     {
         var specialDay = new SpecialDay {
             Id = specialDayId
         };
         db.SpecialDays.Attach(specialDay);
         db.SpecialDays.Remove(specialDay);
         var result = db.SaveChanges();
         return(result > 0);
     }
 }
Пример #15
0
 private void GetNoPrintDates(string[] noPrintDates)
 {
     _noPrintDays   = SpecialDay.NoDay;
     _noPrintMonths = Month.NoMonth;
     _noPrintDates  = new Dictionary <int, int>();
     foreach (string noPrintDate in noPrintDates)
     {
         Date date;
         if (Date.TryParseExact(noPrintDate, "yyyy-MM-dd", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out date))
         {
             int d = date.AbsoluteDay;
             if (!_noPrintDates.ContainsKey(d))
             {
                 _noPrintDates.Add(d, d);
             }
         }
         else if (Date.TryParseExact(noPrintDate, "yyyy-MM", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out date))
         {
             int d = date.AbsoluteDay;
             if (!_noPrintDates.ContainsKey(d))
             {
                 _noPrintDates.Add(d, d);
             }
         }
         else
         {
             SpecialDay day = SpecialDayTools.GetSpecialDay(noPrintDate);
             if (day != SpecialDay.NoDay)
             {
                 _noPrintDays |= SpecialDayTools.GetSpecialDay(noPrintDate);
             }
             else
             {
                 Month month = zdate.GetMonth(noPrintDate);
                 if (month != Month.NoMonth)
                 {
                     _noPrintMonths |= zdate.GetMonth(noPrintDate);
                 }
                 else
                 {
                     throw new PBException("unknow NoPrintDate value \"{0}\"", noPrintDate);
                 }
             }
         }
     }
 }
Пример #16
0
 internal void Add(SpecialDay sd)
 {
     if (CheckValidation(sd) == true)
     {
         using (SalDbContext _db = new SalDbContext())
         {
             try
             {
                 _db.SpecialDays.Add(sd);
                 _db.SaveChanges();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.ToString());
             }
         }
         MessageBox.Show("Успішно");
     }
 }
        public EveryNthMonthOnFrequencySpecialDayStrategy(Frequency frequency = Frequency.First, SpecialDay specialDay = SpecialDay.WeekDay, int n = 1)
        {
            if (!Enum.IsDefined(typeof(Frequency), frequency))
            {
                throw new ArgumentException("frequency is not a valid Frequency");
            }
            if (!Enum.IsDefined(typeof(SpecialDay), specialDay))
            {
                throw new ArgumentException("specialDay is not a valid SpecialDay");
            }
            if (n < 1)
            {
                throw new ArgumentOutOfRangeException("n must be a positive integer");
            }

            _frequency  = frequency;
            _specialDay = specialDay;
            _n          = n;
        }
Пример #18
0
 internal void Update(SpecialDay sd)
 {
     using (SalDbContext _db = new SalDbContext())
     {
         var newsd = _db.SpecialDays.FirstOrDefault(p => p.SpecialDayID == sd.SpecialDayID);
         newsd.SpecialDayYear = sd.SpecialDayYear;
         newsd.PeriodId       = newsd.PeriodId;
         newsd.DayTypeId      = sd.DayTypeId;
         try
         {
             _db.SaveChanges();
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
     MessageBox.Show("Об'єкт був вдало оновленим");
 }
Пример #19
0
 //private void GetNoPrintDays(string[] noPrintDays)
 private void GetNoPrintDays(IEnumerable <string> noPrintDays)
 {
     _noPrintDays  = 0;
     _noPrintDates = new Dictionary <int, int>();
     foreach (string noPrintDay in noPrintDays)
     {
         Date date;
         if (Date.TryParseExact(noPrintDay, "yyyy-MM-dd", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out date))
         {
             int d = date.AbsoluteDay;
             if (!_noPrintDates.ContainsKey(d))
             {
                 _noPrintDates.Add(d, d);
             }
         }
         else
         {
             _noPrintDays |= SpecialDayTools.GetSpecialDay(noPrintDay);
         }
     }
 }
Пример #20
0
        public List <SpecialDay> GetSpecialDaysDA(int DelegationId)
        {
            DataSet           ds    = new DataSet();
            List <SpecialDay> listA = new List <SpecialDay>();

            string query = "exec spS_SpecialDayByDelegation @DelegationId=" + DelegationId;

            ds = con.ObtenerConsulta(query);

            foreach (DataRow DR in ds.Tables[0].Rows)
            {
                SpecialDay sd = new SpecialDay();

                sd.DelegationId = Convert.ToInt32(DR["DelegationId"].ToString());
                sd.Date         = Convert.ToDateTime(DR["Date"].ToString());
                sd.IsNonWorking = Convert.ToBoolean(DR["IsNonWorking"].ToString());
                sd.IsOverrided  = Convert.ToBoolean(DR["IsOverrided"].ToString());

                listA.Add(sd);
            }

            return(listA);
        }
Пример #21
0
        private bool CheckValidation(SpecialDay sd)
        {
            string MessageError = null;

            using (SalDbContext _db = new SalDbContext())
            {
                var newsd = _db.SpecialDays.FirstOrDefault(p => p.SpecialDayYear == sd.SpecialDayYear &&
                                                           p.DayTypeId == sd.DayTypeId && p.PeriodId == sd.PeriodId);
                if (newsd != null)
                {
                    MessageBox.Show("Елемент вже введений в  базу"); return(false);
                }
                else
                {
                    if (!string.IsNullOrWhiteSpace(sd.SpecialDayYear.ToString()) &&
                        (!Regex.IsMatch(sd.SpecialDayYear.ToString(), @"\A[0-9]{4}\z")))
                    {
                        MessageError += "Всі полі мають бути введені";
                    }
                    if (string.IsNullOrWhiteSpace(sd.DayValue.ToString()) &&
                        (!Regex.IsMatch(sd.DayValue.ToString(), @"\A[0-9]{2}\z")))
                    {
                        MessageError += "Всі полі мають бути введені";
                    }

                    if (string.IsNullOrEmpty(MessageError))
                    {
                        return(true);
                    }
                    else
                    {
                        MessageBox.Show(MessageError.ToString(), "Mistake {0}");
                        return(false);
                    }
                }
            }
        }
Пример #22
0
        public EveryNthYearOnFrequencySpecialDayOfMonthStrategy(Frequency frequency = Frequency.First, SpecialDay specialDay = SpecialDay.WeekDay, int month = 1, int n = 1)
        {
            if (!Enum.IsDefined(typeof(Frequency), frequency))
            {
                throw new ArgumentException("frequency is not a valid Frequency");
            }
            if (!Enum.IsDefined(typeof(SpecialDay), specialDay))
            {
                throw new ArgumentException("specialDay is not a valid SpecialDay");
            }
            if (month < 1 || month > 12)
            {
                throw new ArgumentOutOfRangeException("month is outside the valid range");
            }
            if (n < 1)
            {
                throw new ArgumentOutOfRangeException("n must be a positive integer");
            }

            _frequency  = frequency;
            _specialDay = specialDay;
            _month      = month;
            _n          = n;
        }
Пример #23
0
        //private static ITrace _tr = Trace.CurrentTrace;

        public static int GetDailyPrintNumber(Date date, int refNumber, Date refDate, SpecialDay noPrintDays, Dictionary <int, int> noPrintDates, Dictionary <int, int> noPrintNumbers)
        {
            int  no    = refNumber;
            Date date2 = refDate;

            while (date > date2)
            {
                date2 = date2.AddDays(1);
                if (!noPrintDates.ContainsKey(date2.AbsoluteDay) && !SpecialDayTools.IsSpecialDay(noPrintDays, date2))
                {
                    do
                    {
                        no++;
                    } while (noPrintNumbers.ContainsKey(no));
                }
            }
            while (date < date2)
            {
                if (!noPrintDates.ContainsKey(date2.AbsoluteDay) && !SpecialDayTools.IsSpecialDay(noPrintDays, date2))
                {
                    do
                    {
                        no--;
                    } while (noPrintNumbers.ContainsKey(no));
                }
                date2 = date2.AddDays(-1);
            }
            return(no);
        }
Пример #24
0
 public LeParisien(string name, string title, PrintFrequency frequency, DayOfWeek? weekday, string directory, Date refPrintDate, int refPrintNumber, SpecialDay noPrintDays)
     : base(name, title, frequency, weekday, directory, refPrintDate, refPrintNumber, noPrintDays)
 {
 }
Пример #25
0
 public static bool IsSpecialDay(SpecialDay specialDay, Date date)
 {
     if ((specialDay & SpecialDay.Monday) == SpecialDay.Monday && date.DayOfWeek == DayOfWeek.Monday)
         return true;
     if ((specialDay & SpecialDay.Tuesday) == SpecialDay.Tuesday && date.DayOfWeek == DayOfWeek.Tuesday)
         return true;
     if ((specialDay & SpecialDay.Wednesday) == SpecialDay.Wednesday && date.DayOfWeek == DayOfWeek.Wednesday)
         return true;
     if ((specialDay & SpecialDay.Thursday) == SpecialDay.Thursday && date.DayOfWeek == DayOfWeek.Thursday)
         return true;
     if ((specialDay & SpecialDay.Friday) == SpecialDay.Friday && date.DayOfWeek == DayOfWeek.Friday)
         return true;
     if ((specialDay & SpecialDay.Saturday) == SpecialDay.Saturday && date.DayOfWeek == DayOfWeek.Saturday)
         return true;
     if ((specialDay & SpecialDay.Sunday) == SpecialDay.Sunday && date.DayOfWeek == DayOfWeek.Sunday)
         return true;
     if ((specialDay & SpecialDay.NewYearDay) == SpecialDay.NewYearDay && date == GetNewYearDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.MayFirst) == SpecialDay.MayFirst && date == GetMayFirstDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.VictoryInEuropeDay) == SpecialDay.VictoryInEuropeDay && date == GetVictoryInEuropeDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.MardiGras) == SpecialDay.MardiGras && date == GetMardiGrasDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.PalmSunday) == SpecialDay.PalmSunday && date == GetPalmSundayDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.EasterSunday) == SpecialDay.EasterSunday && date == GetEasterSundayDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.EasterMonday) == SpecialDay.EasterMonday && date == GetEasterMondayDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.AscensionThursday) == SpecialDay.AscensionThursday && date == GetAscensionThursdayDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.PentecostSunday) == SpecialDay.PentecostSunday && date == GetPentecostSundayDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.PentecostMonday) == SpecialDay.PentecostMonday && date == GetPentecostMondayDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.FrenchRevolutionDay) == SpecialDay.FrenchRevolutionDay && date == GetFrenchRevolutionDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.AssumptionDay) == SpecialDay.AssumptionDay && date == GetAssumptionDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.AllSaintsDay) == SpecialDay.AllSaintsDay && date == GetAllSaintsDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.ArmisticeDay) == SpecialDay.ArmisticeDay && date == GetArmisticeDate(date.Year))
         return true;
     if ((specialDay & SpecialDay.ChristmasDay) == SpecialDay.ChristmasDay && date == GetChristmasDate(date.Year))
         return true;
     return false;
 }
Пример #26
0
        private string GetHtml()
        {
            Location            location      = (Location)this.cmbLocations.SelectedItem;
            int                 month         = this.GetSelectedMonth();
            int                 year          = this.GetSelectedYear();
            StringBuilder       sbHeaderCells = new StringBuilder();
            StringBuilder       sbRows        = new StringBuilder();
            bool                showMonth     = this.choiceSwitcherDateType.ChoiceOneSelected;
            JewishDate          jd            = showMonth ? new JewishDate(year, month, 1) : this.jdpFrom.Value;
            DailyZmanim         dz            = new DailyZmanim(jd.GregorianDate, location);
            string              startSMonth   = dz.SecularDate.ToString("MM yyyy");
            SelectedZmanColumns columns       = this.GetSelectedColumns();
            bool                showSeconds   = this.choiceSeconds.ChoiceOneSelected;

            //Once "Generate" is clicked, we save the columns selected.
            Properties.Settings.Default.SelectedZmanColumns = columns;
            Properties.Settings.Default.ArmyTime            = this.choiceArmy.ChoiceOneSelected;
            Properties.Settings.Default.AmPm            = this.choiceAmPm.ChoiceOneSelected;
            Properties.Settings.Default.Width100        = (bool)this.choiceWidth100.SelectedValue;
            Properties.Settings.Default.DirectionRight  = (bool)this.choiceDirection.SelectedValue;
            Properties.Settings.Default.DateChooseMonth = this.choiceSwitcherDateType.ChoiceOneSelected;
            Properties.Settings.Default.ShowSeconds     = this.choiceSeconds.ChoiceOneSelected;
            Properties.Settings.Default.ShowDayDetails  = this.choiceDayDetails.ChoiceOneSelected;
            this.SaveDayOfWeek();

            var columnsSorted = from c in columns orderby c.ZmanIndex, c.Offset select c;

            foreach (var zmanColumn in columnsSorted)
            {
                sbHeaderCells.AppendFormat("<th>{0}</th>", zmanColumn.Header);
            }
            while (true)
            {
                sbRows.AppendFormat("<tr{0}>",
                                    (jd.DayOfWeek == DayOfWeek.Saturday ||
                                     SpecialDay.IsMajorYomTov(jd, location) ? " class='special'" :
                                     SpecialDay.IsMinorYomTovOrFast(jd, location) ? " class='special2'" : ""));

                if (Properties.Settings.Default.DOWFormat != DayOfWeekFormat.None)
                {
                    sbRows.AppendFormat("<td class=\"dow {0}\">{1}</td>",
                                        this.rbDOWEnglish.Checked ? "left" : "right",
                                        this.GetDayOfWeekString(jd, location));
                }

                sbRows.AppendFormat(
                    "<td style=\"direction:rtl;\">{0}</td><td>{1}</td>",
                    Utils.ToNumberHeb(jd.Day),
                    dz.SecularDate.Day);


                foreach (var zmanColumn in columnsSorted)
                {
                    string    zmanTime = null;
                    TimeOfDay zman     = TimeOfDay.NoValue;
                    if (zmanColumn.ZmanIndex == 17)
                    {
                        zmanTime = DafYomi.GetDafYomi(jd).ToStringHeb();
                    }
                    else if (zmanColumn.DaysOfWeek == null /* All days */ ||
                             zmanColumn.DaysOfWeek.Contains(jd.DayInWeek) ||
                             zmanColumn.AlternateOffset != 0)
                    {
                        zman = zmanColumn.GetZman(dz);
                        //For netz, if we are not showing seconds, we show the end of the minute
                        if (!showSeconds && zmanColumn.ZmanIndex.In(2, 3) && zman.Seconds > 0)
                        {
                            zman += 1;
                        }
                        zmanTime = zman.ToString(
                            Properties.Settings.Default.ArmyTime,
                            Properties.Settings.Default.AmPm);
                    }
                    if (!string.IsNullOrEmpty(zmanTime))
                    {
                        if (zmanColumn.Bold)
                        {
                            zmanTime = "<strong>" + zmanTime + "</strong>";
                        }
                        if (zman != TimeOfDay.NoValue && Properties.Settings.Default.ShowSeconds)
                        {
                            zmanTime += "<sub>:" +
                                        (zman.Seconds < 10 ? "0" : "") +
                                        zman.Seconds.ToString() + "</sub>";
                        }
                    }
                    sbRows.AppendFormat("<td>{0}</td>", zmanTime);
                }

                jd = jd + 1;
                if (showMonth ? jd.Month == month : jd <= this.jdpTo.Value)
                {
                    dz.SecularDate = jd.GregorianDate;
                }
                else
                {
                    sbRows.Append("</tr>");
                    break;
                }
            }
            string endSMonth   = dz.SecularDate.ToString("MM yyyy");
            string monthHeader = showMonth ?
                                 Utils.JewishMonthNamesHebrew[month] + " " + Utils.ToNumberHeb(year % 1000) :
                                 this.getFromToHeaderText();
            int inBuiltColsCount = Properties.Settings.Default.DOWFormat == DayOfWeekFormat.None ? 2 : 3;

            return(Properties.Resources.template
                   .Replace("#--DIRECTION--#", (Properties.Settings.Default.DirectionRight ? "direction:rtl;" : ""))
                   .Replace("#--TOTAL_CELLS--#", (columns.Count + inBuiltColsCount).ToString())
                   .Replace("#--LOCATION--#", location.NameHebrew)
                   .Replace("#--TABLE_WIDTH--#", Properties.Settings.Default.Width100 ? "width: 100%;" : "")
                   .Replace("#--MONTH--#", "<strong>" + monthHeader + "</strong> (" +
                            startSMonth +
                            (startSMonth != endSMonth ? " - " + endSMonth : "") + ")")
                   .Replace("#--HEADER_CELLS--#", sbHeaderCells.ToString())
                   .Replace("#--LOCATION_COL_SPAN--#", inBuiltColsCount.ToString())
                   .Replace("#--VALUE_ROWS--#", sbRows.ToString()));
        }
Пример #27
0
 public int SaveSpecialDays(SpecialDay specialDay)
 {
     return(calDA.SaveSpecialDaysDA(specialDay));
 }
Пример #28
0
 public LeVifExpress(string name, string title, PrintFrequency frequency, DayOfWeek?weekday, string directory, Date refPrintDate, int refPrintNumber, SpecialDay noPrintDays)
     : base(name, title, frequency, weekday, directory, refPrintDate, refPrintNumber, noPrintDays)
 {
 }
Пример #29
0
 private static Boolean KawigiEdit_RunTest(int testNum, string p0, int p1, string p2, int p3, Boolean hasAnswer, int p4)
 {
     Console.Write("Test " + testNum + ": [" + "\"" + p0 + "\"" + "," + p1 + "," + "\"" + p2 + "\"" + "," + p3);
     Console.WriteLine("]");
     SpecialDay obj;
     int answer;
     obj = new SpecialDay();
     DateTime startTime = DateTime.Now;
     answer = obj.howMany(p0, p1, p2, p3);
     DateTime endTime = DateTime.Now;
     Boolean res;
     res = true;
     Console.WriteLine("Time: " + (endTime - startTime).TotalSeconds + " seconds");
     if (hasAnswer) {
         Console.WriteLine("Desired answer:");
         Console.WriteLine("\t" + p4);
     }
     Console.WriteLine("Your answer:");
     Console.WriteLine("\t" + answer);
     if (hasAnswer) {
         res = answer == p4;
     }
     if (!res) {
         Console.WriteLine("DOESN'T MATCH!!!!");
     } else if ((endTime - startTime).TotalSeconds >= 2) {
         Console.WriteLine("FAIL the timeout");
         res = false;
     } else if (hasAnswer) {
         Console.WriteLine("Match :-)");
     } else {
         Console.WriteLine("OK, but is it right?");
     }
     Console.WriteLine("");
     return res;
 }
Пример #30
0
        static void Main(string[] args)
        {
            using (SalDbContext db = new SalDbContext())
            {
                db.Database.CreateIfNotExists();

                Person per1 = new Person
                {
                    Surname          = "Petrov",
                    FirstName        = "Max",
                    MidleName        = "Petrovich",
                    IndentificalCode = "7895231456",
                    PasportCode      = "AT54782",
                    BirthDay         = new DateTime(1987, 02, 05),
                    gender           = Person.Gender.Male,
                    // PersonID = 1
                };

                Position pos1 = new Position()
                {
                    PositionName = "Director",
                    //PositionId = 1
                };
                Position pos2 = new Position()
                {
                    PositionName = "Acountant",
                    // PositionId = 2
                };

                Employee emp1 = new Employee
                {
                    EmployeeID = per1.PersonID,
                    StartDate  = new DateTime(2008, 05, 02),
                    EndDate    = new DateTime(2018, 05, 02),
                    position   = pos1
                };
                Tax tax1 = new Tax
                {
                    //  TaxID = 1,
                    TaxName       = "Військовий збір",
                    TaxPresentage = 18
                };
                DayType daytype1 = new DayType
                {
                    //  DayTypeID = 1,
                    NameDayType = "Каледнарні дні"
                };
                TimePeriod tp1 = new TimePeriod
                {
                    PeriodID   = 1,
                    PeriodName = "Січень"
                };
                SpecialDay specday1 = new SpecialDay
                {
                    //  SpecialDayID = 1,
                    daytype        = daytype1,
                    SpecialDayYear = 2017,
                    DayValue       = 20,
                    PeriodId       = tp1.PeriodID,
                    DayTypeId      = daytype1.DayTypeID,
                    timeperiod     = tp1
                };
                LivingWageMin wagemin1 = new LivingWageMin()
                {
                    //   WageID = 1,
                    WageYear   = 2017,
                    WageValue  = 1600,
                    PeriodId   = tp1.PeriodID,
                    timeperiod = tp1
                };
                Company comp1 = new Company
                {
                    //   CompanyID = 1,
                    CompanyName        = "ІП Симоненко",
                    ErdpoyCode         = "8745632179985",
                    CompanyAdress      = "Леніна 24",
                    InformationCode    = "АП 87512",
                    RegistrationDate   = "5/07/2014",
                    RegistrationAdress = "Вінницьке Рувд "
                };
                SalaryCalculation salcal1 = new SalaryCalculation
                {
                    SalaryCalculationID = 1,
                    Advance             = 234.5m,
                    EmployeeID          = emp1.EmployeeID,
                    TimePeriodID        = tp1.PeriodID,
                    timeperiod          = tp1,
                };
                db.Companys.Add(comp1);
                db.LivingWageMins.Add(wagemin1);
                db.DayTypes.Add(daytype1);
                db.SpecialDays.Add(specday1);
                db.Taxes.Add(tax1);
                //db.SaveChanges();
                db.Employees.Add(emp1);
                db.Positions.Add(pos1);
                db.Positions.Add(pos2);
                db.TimePeriods.Add(tp1);
                db.Persons.Add(per1);
                db.SalaryCalculations.Add(salcal1);
                try
                {
                    //db.SaveChanges();
                }
                catch (DbUpdateException e)
                {
                    Console.WriteLine("\n\n*** {0}\n\n", e.InnerException);
                }
                Console.WriteLine("Success");
            }
            Console.ReadKey(true);
        }
Пример #31
0
        public void Calendar_CRUD_Positive()
        {
            // create
            var random = Guid.NewGuid().ToString().Split('-').First();

            var newCalendar = new NewCalendar {
                Name = $"EN {random}"
            };
            Calendar    calendar      = null;
            Func <Task> asyncFunction = async() => calendar = await Client.CreateCalendar(newCalendar);

            asyncFunction.ShouldNotThrow();
            calendar.Should().NotBeNull();
            calendar.Name.Should().Be(newCalendar.Name);

            // read list
            IEnumerable <Calendar> calendars = null;

            asyncFunction = async() => calendars = await Client.ReadCalendars();

            asyncFunction.ShouldNotThrow();
            calendars.Should().NotBeNullOrEmpty();
            calendars.Any(x => x.Id == calendar.Id).Should().BeTrue();

            // update
            var update = new NewCalendar(calendar)
            {
                Name = calendar.Name + " Updated",
            };

            asyncFunction = async() => calendar = await Client.UpdateCalendar(calendar.Id, update);

            asyncFunction.ShouldNotThrow();
            calendar.Should().NotBeNull();
            calendar.Name.Should().Be(update.Name);


            // create special day
            var newDay = new NewSpecialDay {
                Name = $"EN {random}", Day = DateTime.Today, IsRecurrent = true
            };
            SpecialDay day = null;

            asyncFunction = async() => day = await Client.CreateSpecialDay(calendar.Id, newDay);

            asyncFunction.ShouldNotThrow();
            day.Should().NotBeNull();
            day.Name.Should().Be(newDay.Name);
            day.Day.Should().Be(newDay.Day);
            day.IsRecurrent.Should().Be(newDay.IsRecurrent);

            // update special day
            var updateDay = new NewSpecialDay(day)
            {
                Name = day.Name + " Updated"
            };

            asyncFunction = async() => await Client.UpdateSpecialDay(calendar.Id, day.Id, updateDay);

            asyncFunction.ShouldNotThrow();

            // delete special day
            asyncFunction = async() => await Client.DeleteSpecialDay(calendar.Id, day.Id);

            asyncFunction.ShouldNotThrow();


            // create season
            var newSeason = new NewSeason {
                Name = $"EN {random}", StartDate = DateTime.Today
            };
            Season season = null;

            asyncFunction = async() => season = await Client.CreateSeason(calendar.Id, newSeason);

            asyncFunction.ShouldNotThrow();
            season.Should().NotBeNull();
            season.Name.Should().Be(newSeason.Name);
            season.StartDate.Should().Be(newSeason.StartDate);

            // read seasons list
            IEnumerable <Season> seasons = null;

            asyncFunction = async() => seasons = await Client.ReadSeasons(calendar.Id);

            asyncFunction.ShouldNotThrow();
            seasons.Should().NotBeNullOrEmpty();
            seasons.Any(x => x.Id == season.Id).Should().BeTrue();

            // update season
            var updateSeason = new NewSeason(season)
            {
                Name = season.Name + " Updated"
            };

            asyncFunction = async() => season = await Client.UpdateSeason(calendar.Id, season.Id, updateSeason);

            asyncFunction.ShouldNotThrow();
            season.Should().NotBeNull();
            season.Name.Should().Be(updateSeason.Name);
            season.StartDate.Should().Be(updateSeason.StartDate);


            // create period
            var newPeriod = new NewPeriod
            {
                Name      = $"EN {random}",
                StartTime = new TimeSpan(06, 00, 00),
                EndTime   = new TimeSpan(18, 00, 00),
                Monday    = true,
                Tuesday   = true,
                Wednesday = true,
                Thursday  = true
            };
            Period period = null;

            asyncFunction = async() => period = await Client.CreatePeriod(calendar.Id, season.Id, newPeriod);

            asyncFunction.ShouldNotThrow();
            period.Should().NotBeNull();
            period.Name.Should().Be(newPeriod.Name);
            period.StartTime.Should().Be(newPeriod.StartTime);
            period.EndTime.Should().Be(newPeriod.EndTime);
            period.Monday.Should().Be(newPeriod.Monday);
            period.Tuesday.Should().Be(newPeriod.Tuesday);
            period.Wednesday.Should().Be(newPeriod.Wednesday);
            period.Thursday.Should().Be(newPeriod.Thursday);
            period.Friday.Should().Be(newPeriod.Friday);
            period.Saturday.Should().Be(newPeriod.Saturday);
            period.Sunday.Should().Be(newPeriod.Sunday);
            period.Special.Should().Be(newPeriod.Special);

            // read periods
            IEnumerable <Period> periods = null;

            asyncFunction = async() => periods = await Client.ReadPeriods(calendar.Id, season.Id);

            asyncFunction.ShouldNotThrow();
            periods.Should().NotBeNullOrEmpty();
            periods.Any(x => x.Id == period.Id).Should().BeTrue();

            // update period
            var updatePeriod = new NewPeriod(period)
            {
                Name = period.Name + " Name", EndTime = period.EndTime.Add(TimeSpan.FromHours(3)), Friday = true
            };

            asyncFunction = async() => period = await Client.UpdatePeriod(calendar.Id, season.Id, period.Id, updatePeriod);

            asyncFunction.ShouldNotThrow();
            period.Should().NotBeNull();
            period.Name.Should().Be(updatePeriod.Name);
            period.StartTime.Should().Be(updatePeriod.StartTime);
            period.EndTime.Should().Be(updatePeriod.EndTime);
            period.Monday.Should().Be(updatePeriod.Monday);
            period.Tuesday.Should().Be(updatePeriod.Tuesday);
            period.Wednesday.Should().Be(updatePeriod.Wednesday);
            period.Thursday.Should().Be(updatePeriod.Thursday);
            period.Friday.Should().Be(updatePeriod.Friday);
            period.Saturday.Should().Be(updatePeriod.Saturday);
            period.Sunday.Should().Be(updatePeriod.Sunday);
            period.Special.Should().Be(updatePeriod.Special);

            // delete period
            periods.ToList().ForEach(x =>
            {
                asyncFunction = async() => await Client.DeletePeriod(calendar.Id, season.Id, x.Id);
                asyncFunction.ShouldNotThrow();
            });

            // delete seasons
            seasons.ToList().ForEach(x =>
            {
                asyncFunction = async() => await Client.DeleteSeason(calendar.Id, x.Id);
                asyncFunction.ShouldNotThrow();
            });

            // delete
            calendars.ToList().ForEach(x =>
            {
                asyncFunction = async() => await Client.DeleteCalendar(x.Id);
                asyncFunction.ShouldNotThrow();
            });
        }
Пример #32
0
 public static bool IsSpecialDay(SpecialDay specialDay, Date date)
 {
     if ((specialDay & SpecialDay.Monday) == SpecialDay.Monday && date.DayOfWeek == DayOfWeek.Monday)
     {
         return(true);
     }
     if ((specialDay & SpecialDay.Tuesday) == SpecialDay.Tuesday && date.DayOfWeek == DayOfWeek.Tuesday)
     {
         return(true);
     }
     if ((specialDay & SpecialDay.Wednesday) == SpecialDay.Wednesday && date.DayOfWeek == DayOfWeek.Wednesday)
     {
         return(true);
     }
     if ((specialDay & SpecialDay.Thursday) == SpecialDay.Thursday && date.DayOfWeek == DayOfWeek.Thursday)
     {
         return(true);
     }
     if ((specialDay & SpecialDay.Friday) == SpecialDay.Friday && date.DayOfWeek == DayOfWeek.Friday)
     {
         return(true);
     }
     if ((specialDay & SpecialDay.Saturday) == SpecialDay.Saturday && date.DayOfWeek == DayOfWeek.Saturday)
     {
         return(true);
     }
     if ((specialDay & SpecialDay.Sunday) == SpecialDay.Sunday && date.DayOfWeek == DayOfWeek.Sunday)
     {
         return(true);
     }
     if ((specialDay & SpecialDay.NewYearDay) == SpecialDay.NewYearDay && date == GetNewYearDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.MayFirst) == SpecialDay.MayFirst && date == GetMayFirstDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.VictoryInEuropeDay) == SpecialDay.VictoryInEuropeDay && date == GetVictoryInEuropeDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.MardiGras) == SpecialDay.MardiGras && date == GetMardiGrasDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.PalmSunday) == SpecialDay.PalmSunday && date == GetPalmSundayDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.EasterSunday) == SpecialDay.EasterSunday && date == GetEasterSundayDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.EasterMonday) == SpecialDay.EasterMonday && date == GetEasterMondayDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.AscensionThursday) == SpecialDay.AscensionThursday && date == GetAscensionThursdayDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.PentecostSunday) == SpecialDay.PentecostSunday && date == GetPentecostSundayDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.PentecostMonday) == SpecialDay.PentecostMonday && date == GetPentecostMondayDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.FrenchRevolutionDay) == SpecialDay.FrenchRevolutionDay && date == GetFrenchRevolutionDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.AssumptionDay) == SpecialDay.AssumptionDay && date == GetAssumptionDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.AllSaintsDay) == SpecialDay.AllSaintsDay && date == GetAllSaintsDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.ArmisticeDay) == SpecialDay.ArmisticeDay && date == GetArmisticeDate(date.Year))
     {
         return(true);
     }
     if ((specialDay & SpecialDay.ChristmasDay) == SpecialDay.ChristmasDay && date == GetChristmasDate(date.Year))
     {
         return(true);
     }
     return(false);
 }
Пример #33
0
 //private void GetNoPrintDays(string[] noPrintDays)
 private void GetNoPrintDays(IEnumerable<string> noPrintDays)
 {
     _noPrintDays = 0;
     _noPrintDates = new Dictionary<int, int>();
     foreach (string noPrintDay in noPrintDays)
     {
         Date date;
         if (Date.TryParseExact(noPrintDay, "yyyy-MM-dd", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out date))
         {
             int d = date.AbsoluteDay;
             if (!_noPrintDates.ContainsKey(d))
                 _noPrintDates.Add(d, d);
         }
         else
             _noPrintDays |= SpecialDayTools.GetSpecialDay(noPrintDay);
     }
 }
Пример #34
0
 private void GetNoPrintDates(string[] noPrintDates)
 {
     _noPrintDays = SpecialDay.NoDay;
     _noPrintMonths = Month.NoMonth;
     _noPrintDates = new Dictionary<int, int>();
     foreach (string noPrintDate in noPrintDates)
     {
         Date date;
         if (Date.TryParseExact(noPrintDate, "yyyy-MM-dd", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out date))
         {
             int d = date.AbsoluteDay;
             if (!_noPrintDates.ContainsKey(d))
                 _noPrintDates.Add(d, d);
         }
         else if (Date.TryParseExact(noPrintDate, "yyyy-MM", CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out date))
         {
             int d = date.AbsoluteDay;
             if (!_noPrintDates.ContainsKey(d))
                 _noPrintDates.Add(d, d);
         }
         else
         {
             SpecialDay day = SpecialDayTools.GetSpecialDay(noPrintDate);
             if (day != SpecialDay.NoDay)
                 _noPrintDays |= SpecialDayTools.GetSpecialDay(noPrintDate);
             else
             {
                 Month month = zdate.GetMonth(noPrintDate);
                 if (month != Month.NoMonth)
                     _noPrintMonths |= zdate.GetMonth(noPrintDate);
                 else
                     throw new PBException("unknow NoPrintDate value \"{0}\"", noPrintDate);
             }
         }
     }
 }