void BindDdlDays(List <Day> days)
        {
            rdoDays.DataSource     = days;
            rdoDays.DataTextField  = "DayTitle";
            rdoDays.DataValueField = "DayNumber";
            rdoDays.DataBind();

            foreach (ListItem item in rdoDays.Items)
            {
                item.Attributes.Add("class", "mealDay" + item.Value);
            }

            hccCartItemCalendar cartCal = hccCartItemCalendar.GetBy(CurrentCartItem.CartItemID, CurrentCalendarId);

            CurrentDaysWithAllergens(cartCal.CartCalendarID).ForEach(delegate(int a)
            {
                ListItem item = rdoDays.Items.FindByValue(a.ToString());
                if (item != null)
                {
                    item.Attributes["class"] += " redFont";
                }
            });

            if (CurrentDay != 0)
            {
                rdoDays.SelectedValue = CurrentDay.ToString();
            }
            else
            {
                rdoDays.SelectedIndex = 0;
                CurrentDay            = int.Parse(rdoDays.SelectedValue);
            }
            //ddlDays_SelectedIndexChanged(this, new EventArgs());
        }
Esempio n. 2
0
 /// <summary>
 /// Palauttaa päivästä, seasonista ja vuodesta display stringin.
 /// </summary>
 /// <returns></returns>
 public string GetDateDisplayString()
 {
     return(string.Format("D:{0} - Y:{1} - DOW:{2}",
                          CurrentDayOfMonth,
                          CurrentYear,
                          CurrentDay.ToString().Substring(0, 3)));
 }
Esempio n. 3
0
 void UpdateRangeInfoText()
 {
     LblRangeInfo.Text = String.Format("{0} {1}, {2}", CurrentDay.ToString("MMMM", CultureInfo.CurrentCulture), CurrentDay.Day.ToString(), CurrentDay.Year.ToString());
     if (_btnGroupTab.CurrentIndex == 0 && null != ViewModel.WeeklyHistoryRangeModel)
     {
         LblRangeInfo.Text = ViewModel.WeeklyHistoryRangeModel.RangeInfo;
     }
 }
Esempio n. 4
0
 private string GenerateLogFileName(string fileNamePrefix)
 {
     return
         (fileNamePrefix
          + LogFileSuffix
          + DateTime.UtcNow.Month.ToString()
          + CurrentDay.ToString()
          + ".txt");
 }
Esempio n. 5
0
        // %t - minutes
        // %h - hours
        // %d - current day
        // %D - current day name
        // %m - current month index
        // %M - current month name
        // %y - year
        public string GetTimeAsString(string format)
        {
            string ret = format;

            ret = ret.Replace("%t", CurrentMinutes.ToString());
            ret = ret.Replace("%h", CurrentHours.ToString());
            ret = ret.Replace("%d", CurrentDay.ToString());
            ret = ret.Replace("%D", Days[CurrentDayIndex]);
            ret = ret.Replace("%m", CurrentMonthIndex.ToString());
            ret = ret.Replace("%M", Months.ElementAt(CurrentMonthIndex).Key);
            ret = ret.Replace("%y", CurrentYear.ToString());

            return(ret);
        }
Esempio n. 6
0
 private void _updateDayHeader()
 {
     lblDayNumber.Text = CurrentDay.ToString("MMM d").ToUpper();
     if (!InCurrentMonth)
     {
         pnlDayLabel.BackColor  = Theme.OutOfMonthDayBG;
         lblDayNumber.ForeColor = Theme.OutOfMonthDayFG;
     }
     else if (DateTime.Now.ToString("MMM d").ToUpper() == lblDayNumber.Text)
     {
         pnlDayLabel.BackColor  = Theme.TodayBG;
         lblDayNumber.ForeColor = Theme.TodayFG;
     }
     else
     {
         pnlDayLabel.BackColor  = Theme.InMonthDayBG;
         lblDayNumber.ForeColor = Theme.InMonthDayFG;
     }
 }
Esempio n. 7
0
        public virtual void CalcCurrentMonthDays()
        {
            DayOfWeek firstDayOfWeekOfCurrentCulture = Culture.DateTimeFormat.FirstDayOfWeek;

            List <DayOfWeekInfo> daysOfWeek = Enum.GetValues(typeof(DayOfWeek))
                                              .Cast <DayOfWeek>()
                                              .OrderBy(d => (d - firstDayOfWeekOfCurrentCulture + 7) % 7)
                                              .Select((d, i) => new DayOfWeekInfo
            {
                DayOfWeekNumber = i + 1,
                IsoDayOfWeek    = (IsoDayOfWeek)Enum.Parse(typeof(IsoDayOfWeek), d.ToString()),
                DayOfWeekName   = Culture.DateTimeFormat.GetAbbreviatedDayName(d)
            })
                                              .ToList();

            DaysOfWeekNames = daysOfWeek.Select(d => d.DayOfWeekName).ToArray();

            if (CalendarSystem != CalendarSystemProperty.DefaultValue)
            {
                CurrentDay = CurrentDay.WithCalendar(CalendarSystem);
            }

            CalendarTitle = CurrentDay.ToString(Culture.DateTimeFormat.YearMonthPattern, Culture);

            int thisMonthDaysCount = CurrentDay.Calendar.GetDaysInMonth(CurrentDay.Year, CurrentDay.Month);

            LocalDate firstDayOfMonth = CurrentDay;

            while (firstDayOfMonth.Day != 1)
            {
                firstDayOfMonth = LocalDate.Subtract(firstDayOfMonth, Period.FromDays(1));
            }

            DayOfWeekInfo firstDayOfMonthDayOfWeek = daysOfWeek.Single(d => d.IsoDayOfWeek == firstDayOfMonth.DayOfWeek);

            int prevMonthDaysInCurrentMonthView = (firstDayOfMonthDayOfWeek.DayOfWeekNumber - 1);
            int nextMonthDaysInCurrentMonthView = 42 - thisMonthDaysCount - prevMonthDaysInCurrentMonthView;

            Days = new List <CalendarDay>(42);

            LocalDate today = new LocalDate(DateTimeOffset.Now.Year, DateTimeOffset.Now.Month, DateTimeOffset.Now.Day, CalendarSystem.Gregorian).WithCalendar(CalendarSystem);

            for (int i = 0; i < prevMonthDaysInCurrentMonthView; i++)
            {
                Days.Add(null);
            }

            for (int i = 1; i <= thisMonthDaysCount; i++)
            {
                Days.Add(new CalendarDay
                {
                    LocalDate = new LocalDate(CurrentDay.Year, CurrentDay.Month, i, CurrentDay.Calendar),
                    IsToday   = today.Year == CurrentDay.Year && today.Month == CurrentDay.Month && today.Day == i ? true : false
                });
            }

            for (int i = 0; i < nextMonthDaysInCurrentMonthView; i++)
            {
                Days.Add(null);
            }

            if (Days.Count != 42)
            {
                throw new InvalidOperationException($"{nameof(Days)}'s count is {Days.Count}, but it should be 42");
            }
        }