/// <summary>
        /// ######### ######### # #########
        /// </summary>
        /// <param name="previousSelectedDay">###### ### # #########</param>
        /// <returns>##/###</returns>
        protected bool SaveChangesToStore(DayInCalendarObject previousSelectedDay)
        {
            bool isDiffFromParent  = GetIsCurrentDayDiffFromParent();
            bool wasDiffFromParent = GetIsDiffFromParent(previousSelectedDay);
            Guid dayInCalendarId   = previousSelectedDay.Id;
            bool isUpdated         = true;

            if (!isDiffFromParent && wasDiffFromParent)
            {
                ChangesStore.AddRemovedDay(previousSelectedDay);
            }
            else if (isDiffFromParent && !wasDiffFromParent)
            {
                var newDay = (DayInCalendarObject)previousSelectedDay.Clone();
                newDay.Id                 = Guid.NewGuid();
                newDay.DayTypeId          = (Guid)DayTypeEdit.Value;
                newDay.CalendarId         = _page.DataSource.ActiveRowPrimaryColumnValue;
                newDay.IsCalendarDayValue = IsCalendarDayValue;
                ChangesStore.AddNewDay(newDay);
                dayInCalendarId = newDay.Id;
                ChangedWorkingTimeIntervalsIndexes = GetChagedTimeIntervalIndexesFromFilledControls().ToList();
                CurrentWorkingTimeIntervalsData.Clear();
            }
            else if (isDiffFromParent && NeedUpdateDayInCalendarData(previousSelectedDay))
            {
                previousSelectedDay.DayTypeId = (Guid)DayTypeEdit.Value;
                ChangesStore.AddChangedDay(previousSelectedDay);
            }
            else
            {
                isUpdated = false;
            }
            UpdateIntervals(dayInCalendarId);
            return(isUpdated);
        }
 /// <summary>
 /// ########### ######## ######### ########## ########## ### #########
 /// </summary>
 /// <param name="day">###### ### #########</param>
 protected virtual void DisplayDayRecord(DayInCalendarObject day)
 {
     IsDiffFromParentEdit.Value = GetIsDiffFromParent(day);
     DayTypeEdit.SetValueAndText(day.DayTypeId, GetDayTypeNames()[day.DayTypeId]);
     DisplayWorkingTimeIntervals(day);
     ChangedWorkingTimeIntervalsIndexes.Clear();
 }
        /// <summary>
        /// ########### ########## #######
        /// </summary>
        /// <param name="day">#### #########</param>
        private void DisplayWorkingTimeIntervals(DayInCalendarObject day)
        {
            var calendarUtils = new CalendarUtils(UserConnection);
            IEnumerable <WorkingTimeInterval> timeIntervalsEntities = calendarUtils.GetWorkingTimeIntervals(day.Id);
            List <WorkingTimeIntervalObject>  timeIntervals         =
                ChangesStore.MergeIntervals(day.Id, timeIntervalsEntities
                                            .Select(t => new WorkingTimeIntervalObject(t))).ToList();

            CurrentWorkingTimeIntervalsData = timeIntervals;
            ClearIntervalDateTimeControls();
            var container = _page.PageContainer;

            foreach (WorkingTimeIntervalObject timeInterval in CurrentWorkingTimeIntervalsData)
            {
                var i        = timeInterval.Index;
                var fromDate =
                    (DateTimeEdit)
                    container.FindControl(string.Format(FromControlNameFormat, TimeIntervalTypeControlAlias, i));
                var toDate =
                    (DateTimeEdit)
                    container.FindControl(string.Format(ToControlNameFormat, TimeIntervalTypeControlAlias, i));
                fromDate.SuspendAjaxEvents();
                toDate.SuspendAjaxEvents();
                fromDate.SelectedDate = timeInterval.From;
                toDate.SelectedDate   = timeInterval.To;
                fromDate.ResumeAjaxEvents();
                toDate.ResumeAjaxEvents();
            }
        }
        protected override Entity CreateDayVirtualDataSourceRow(VirtualDataSource daysDataSource,
                                                                DayInCalendarObject day, Guid gridRecordId)
        {
            Entity row = base.CreateDayVirtualDataSourceRow(daysDataSource, day, gridRecordId);

            row.SetColumnValue(DateStringVirtualColumnName, day.Date.ToString("ddd dd MMMM yyyy"));
            return(row);
        }
Esempio n. 5
0
        /// <summary>
        /// ######### ##### #### # ######### #########.
        /// </summary>
        /// <param name="day">##### ####</param>
        public void AddNewDay(DayInCalendarObject day)
        {
            DayInCalendarChangedObject existedDay = Days.SingleOrDefault(d => d.EntityId == day.Id);

            if (existedDay != null)
            {
                Days.Remove(existedDay);
            }
            Days.Add(new DayInCalendarChangedObject(day, ChangedStatus.New));
        }
        /// <summary>
        /// ######## ########### ######### ### #########
        /// </summary>
        /// <param name="treeGridRecordId">############# ### ######### # ######</param>
        protected void RefreshDayVirtualDataSourceRecord(Guid treeGridRecordId)
        {
            VirtualDataSource   dataSource          = GetDaysVirtualDataSource();
            DayInCalendarObject actualDayInCalendar = GetDay(treeGridRecordId);

            CurrentDaysGridData[treeGridRecordId] = actualDayInCalendar;
            Entity row = CreateDayVirtualDataSourceRow(dataSource, actualDayInCalendar, treeGridRecordId);

            dataSource.Update(row);
            dataSource.LoadRow(treeGridRecordId);
        }
Esempio n. 7
0
        /// <summary>
        /// ######### ########## #### # ######### #########.
        /// </summary>
        /// <param name="day">########## ####</param>
        public void AddChangedDay(DayInCalendarObject day)
        {
            var changedStatus = ChangedStatus.Changed;
            DayInCalendarChangedObject existedDay = Days.SingleOrDefault(d => d.EntityId == day.Id);

            if (existedDay != null)
            {
                changedStatus = existedDay.ChangedStatus == ChangedStatus.New
                                        ? ChangedStatus.New
                                        : ChangedStatus.Changed;
                Days.Remove(existedDay);
            }
            Days.Add(new DayInCalendarChangedObject(day, changedStatus));
        }
Esempio n. 8
0
        /// <summary>
        /// ######### ######### #### # ######### #########.
        /// </summary>
        /// <param name="day">######### ####</param>
        public void AddRemovedDay(DayInCalendarObject day)
        {
            DayInCalendarChangedObject existedDay = Days.SingleOrDefault(d => d.EntityId == day.Id);

            if (existedDay != null)
            {
                RemoveChangedDayIntervals(existedDay);
                Days.Remove(existedDay);
                if (existedDay.ChangedStatus == ChangedStatus.New)
                {
                    return;
                }
            }
            Days.Add(new DayInCalendarChangedObject(day, ChangedStatus.Deleted));
        }
        /// <summary>
        /// ####### ###### # ########### ########## ### #########
        /// </summary>
        /// <param name="daysDataSource">########### ######### ### #########</param>
        /// <param name="day">###### ### #########</param>
        /// <param name="gridRecordId">############# ### ######### # ######</param>
        /// <returns>######## ### ######### # ##########</returns>
        protected virtual Entity CreateDayVirtualDataSourceRow(VirtualDataSource daysDataSource, DayInCalendarObject day,
                                                               Guid gridRecordId)
        {
            Entity row = daysDataSource.CreateRow();

            row.SetColumnValue("DayOfWeekId", day.DayOfWeekId);
            row.SetColumnValue("DayOfWeekName", GetDayOfWeekNames()[day.DayOfWeekId]);
            row.SetColumnValue("DayTypeId", day.DayTypeId);
            row.SetColumnValue("DayTypeName", GetDayTypeNames()[day.DayTypeId]);
            row.SetColumnValue("CalendarId", day.CalendarId);
            row.SetColumnValue(GridRecordIdColumnName, gridRecordId);
            if (day.Date.Date != DateTime.MinValue.Date)
            {
                row.SetColumnValue("Date", day.Date);
            }
            return(row);
        }
 protected abstract bool GetIsDiffFromParent(DayInCalendarObject day);
        /// <summary>
        /// ######### ############# ######### ###### ### # #########
        /// </summary>
        /// <param name="day">###### ### # #########</param>
        /// <returns>##/###</returns>
        private bool NeedUpdateDayInCalendarData(DayInCalendarObject day)
        {
            var selectedDayTypeId = (Guid)DayTypeEdit.Value;

            return(day.DayTypeId != selectedDayTypeId && selectedDayTypeId != Guid.Empty);
        }
 protected override bool GetIsDiffFromParent(DayInCalendarObject day)
 {
     return(_page.DataSource.ActiveRow.PrimaryColumnValue == day.CalendarId && day.IsCalendarDayValue);
 }
Esempio n. 13
0
 public DayInCalendarChangedObject(DayInCalendarObject dayInCalendar, ChangedStatus changedStatus)
 {
     ChangedStatus = changedStatus;
     DayInCalendar = dayInCalendar;
 }