Exemple #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,DueBy,IsDone,StartDate")] DayItem dayItem)
        {
            if (id != dayItem.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dayItem);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DayItemExists(dayItem.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(dayItem));
        }
        public static List <CalendarADay> Turn(List <AttendanceInAndOutRecord> originalDataList, List <CalendarADay> retList
                                               , List <PlanDutyDetail> planDutyDetailList
                                               , DateTime from, DateTime to)
        {
            for (int i = 0; from.AddDays(i).Date <= to.Date; i++)
            {
                PlanDutyDetail planDutyDetail =
                    PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, from.AddDays(i).Date);
                if (planDutyDetail == null || planDutyDetail.PlanDutyClass.IsWeek)
                {
                    continue;
                }
                CalendarADay calendarADay = CalendarADay.CreateOrGetCalendarADayByDate(retList, from.AddDays(i).Date);
                List <AttendanceInAndOutRecord> dtOriginalDataList =
                    AttendanceInAndOutRecord.GetAttendanceInAndOutRecordByDate(originalDataList, from.AddDays(i).Date);
                if (dtOriginalDataList.Count == 0)
                {
                    MonthItem monthNoRecord = new MonthItem();
                    monthNoRecord.CType  = CalendarShowType.Attendance;
                    monthNoRecord.Title  = "无打卡记录";
                    monthNoRecord.Date   = from.AddDays(i).Date;
                    monthNoRecord.Detail = "无打卡记录";
                    calendarADay.MonthItems.Add(monthNoRecord);
                    Utility.Clean(calendarADay);
                    continue;
                }
                DateTime dtStart = AttendanceInAndOutRecord.FindEarlistTime(dtOriginalDataList);
                DateTime dtEnd   = AttendanceInAndOutRecord.FindLatestTime(dtOriginalDataList);

                if (!IsInitTime(dtStart))
                {
                    DayItem day = new DayItem();
                    day.CType     = CalendarShowType.Attendance;
                    day.Start     = day.End = dtStart;
                    day.DayDetail = "打卡 " + dtStart.ToShortTimeString();
                    calendarADay.DayItems.Add(day);
                }
                if (!IsInitTime(dtEnd))
                {
                    DayItem day = new DayItem();
                    day.CType     = CalendarShowType.Attendance;
                    day.Start     = day.End = dtEnd;
                    day.DayDetail = "打卡 " + dtEnd.ToShortTimeString();
                    calendarADay.DayItems.Add(day);
                }

                MonthItem month = new MonthItem();
                month.CType = CalendarShowType.Attendance;
                month.Title = "打卡 " + (!IsInitTime(dtStart) ? dtStart.ToShortTimeString() : "") +
                              "--" + (!IsInitTime(dtEnd) ? dtEnd.ToShortTimeString() : "");
                month.Date   = from.AddDays(i).Date;
                month.Detail = "最早打卡时间:" + (!IsInitTime(dtStart) ? dtStart.ToString() : "--") + "<br>" + "最晚打卡时间:" +
                               (!IsInitTime(dtEnd) ? dtEnd.ToString() : "--");
                calendarADay.MonthItems.Add(month);
                Utility.Clean(calendarADay);
            }

            return(retList);
        }
Exemple #3
0
        private void ListBoxMouseMove(object sender, MouseEventArgs e)
        {
            var day = listbox.Items.OfType <DayItem>()
                      .FirstOrDefault(d => d.Bounds.Contains(e.Location));

            CalendarPage page = null;

            if (day != null)
            {
                page = day.Pages.FirstOrDefault(p => p.Bounds.Contains(e.Location));
            }

            if (page == hotpage)
            {
                if (hotpage != null)
                {
                    Native.SetCursor(hand);
                }
                return;
            }

            if (hotpage != null)
            {
                using (var g = listbox.CreateGraphics())
                {
                    var index = listbox.Items.IndexOf(hotday);
                    g.FillRectangle(index % 2 == 1 ? AppColors.RowBrush : Brushes.White, hotpage.Bounds);

                    g.DrawString(hotpage.Title,
                                 hotpage.IsDeleted ? deletedFont : listbox.Font,
                                 hotpage.IsDeleted ? Brushes.Gray : Brushes.Black,
                                 hotpage.Bounds, format);
                }

                HoverPage?.Invoke(this, new CalendarPageEventArgs(null));

                hotday  = null;
                hotpage = null;
            }

            if (page != null)
            {
                using (var g = listbox.CreateGraphics())
                {
                    var index = listbox.Items.IndexOf(day);
                    g.FillRectangle(index % 2 == 1 ? AppColors.RowBrush : Brushes.White, page.Bounds);

                    g.DrawString(page.Title,
                                 page.IsDeleted ? deletedFont : hotFont,
                                 Brushes.DarkOrchid, page.Bounds, format);
                }

                HoverPage?.Invoke(this, new CalendarPageEventArgs(page));

                hotday  = day;
                hotpage = page;
                Native.SetCursor(hand);
            }
        }
Exemple #4
0
        public static List <CalendarADay> Turn(List <PlanDutyDetail> originalDataList, List <CalendarADay> retList)
        {
            foreach (PlanDutyDetail originalData in originalDataList)
            {
                CalendarADay calendarADay = CalendarADay.CreateOrGetCalendarADayByDate(retList, originalData.Date);

                MonthItem month = new MonthItem();
                month.CType    = CalendarShowType.DutyClass;
                month.ObjectID = originalData.PlanDutyClass.DutyClassID;
                month.Date     = originalData.Date;
                month.Title    = originalData.PlanDutyClass.DutyClassName;
                if (originalData.PlanDutyClass.DutyClassID != -1)
                {
                    TimeSpan ts = originalData.PlanDutyClass.FirstStartToTime -
                                  originalData.PlanDutyClass.FirstStartFromTime;

                    DayItem day1 = new DayItem();
                    DayItem day2 = new DayItem();
                    day1.CType     = CalendarShowType.DutyClass;
                    day1.ObjectID  = originalData.PlanDutyClass.DutyClassID;
                    day1.Start     = originalData.PlanDutyClass.FirstStartFromTime;
                    day1.End       = originalData.PlanDutyClass.FirstEndTime;
                    day1.DayDetail = "";
                    calendarADay.DayItems.Add(day1);

                    day2.CType     = CalendarShowType.DutyClass;
                    day2.ObjectID  = originalData.PlanDutyClass.DutyClassID;
                    day2.Start     = originalData.PlanDutyClass.SecondStartTime;
                    day2.End       = originalData.PlanDutyClass.SecondEndTime.Add(ts);
                    day2.DayDetail = "";
                    calendarADay.DayItems.Add(day2);

                    month.Detail = "上午上班时间:" + originalData.PlanDutyClass.FirstStartFromTime.ToShortTimeString() + "/" +
                                   originalData.PlanDutyClass.FirstStartToTime.ToShortTimeString() + "--" +
                                   originalData.PlanDutyClass.FirstEndTime.ToShortTimeString() + "<br>下午午上班时间:" +
                                   originalData.PlanDutyClass.SecondStartTime.ToShortTimeString() + "--" +
                                   originalData.PlanDutyClass.SecondEndTime.ToShortTimeString() + "/" +
                                   originalData.PlanDutyClass.SecondEndTime.Add(ts).ToShortTimeString() +
                                   "<br>迟到判定:上班晚于" +
                                   originalData.PlanDutyClass.LateTime + "分钟记迟到<br>早退判定:下班早于" +
                                   originalData.PlanDutyClass.EarlyLeaveTime + "分钟记早退<br>旷工判定:迟到" +
                                   originalData.PlanDutyClass.AbsentLateTime + "分钟或早退" +
                                   originalData.PlanDutyClass.AbsentEarlyLeaveTime + "分钟,为旷工";
                }
                else
                {
                    month.BackgroundColor = "#FFEDED";
                    month.Detail          = originalData.PlanDutyClass.DutyClassName;
                }
                calendarADay.MonthItems.Add(month);
                Utility.Clean(calendarADay);
            }
            return(retList);
        }
Exemple #5
0
        public async Task <IActionResult> Create([Bind("ID,Name,DueBy,IsDone,StartDate")] DayItem dayItem)
        {
            if (ModelState.IsValid)
            {
                _context.Add(dayItem);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(dayItem));
        }
Exemple #6
0
        private void CopyItemDown(int day)
        {
            DayItem dayItem = _dayItems[day - 1];

            if (_dayItems[day].IsEqual(dayItem))
            {
                return;
            }
            ListingItem newItem = Listing.ReplaceItem(day + 1, dayItem.Locality, dayItem.ListingItem.TimeSetting);

            _dayItems[day].Update(newItem);

            _listingFacade.Save(Listing);
        }
Exemple #7
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            if (source != null && source.Count > 0)
            {
                _AccountID = source[0].Owner.Id;
                foreach (Notes notes in source)
                {
                    if (notes.RepeatType is MonthRepeat)
                    {
                        MonthRepeat type = (MonthRepeat)notes.RepeatType;

                        DateTime tempstart = type.RangeStart > start ? type.RangeStart : start;
                        DateTime tempend   = type.RangeEnd == null || type.RangeEnd > end
                                               ? end
                                               : Convert.ToDateTime(type.RangeEnd);
                        DateTime date = tempstart;
                        int      days = (tempend.Date - tempstart.Date).Days;
                        _PlanDutyFrom = new DateTime(tempstart.Year, tempstart.Month, 1);
                        _PlanDutyTo   = GetLastDate(tempend);
                        for (int i = 0; i <= days; i++)
                        {
                            if (RepeatValid(type, date))
                            {
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content,
                                                  RepeatUtility.DetailString(notes, notes.Start, notes.End), date,
                                                  CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  =
                                    new DayItem(RepeatUtility.ConvertToDateTime(date, notes.Start),
                                                RepeatUtility.ConvertToDateTime(date, notes.End), notes.Content,
                                                CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(date, monthitems, dayitems);
                                cd.Add(aday);
                            }
                            date = date.AddDays(1);
                        }
                    }
                }
            }

            return(cd);
        }
Exemple #8
0
        private List <DayItem> PrepareDayItems(Listing listing)
        {
            List <DayItem> dayItems = new List <DayItem>();

            DateTime now = DateTime.Now;
            DayItem  dayItem;

            for (int day = 0; day < listing.DaysInMonth; day++)
            {
                dayItem = new DayItem(listing, day + 1);
                dayItems.Add(dayItem);
            }

            return(dayItems);
        }
Exemple #9
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            if (source != null && source.Count > 0)
            {
                foreach (Notes notes in source)
                {
                    if (notes.RepeatType is WeekRepeat)
                    {
                        WeekRepeat type = (WeekRepeat)notes.RepeatType;

                        DateTime tempstart = type.RangeStart > start ? type.RangeStart : start;
                        DateTime tempend   = type.RangeEnd == null || type.RangeEnd > end
                                               ? end
                                               : Convert.ToDateTime(type.RangeEnd);
                        DateTime date             = tempstart;
                        int      days             = (tempend.Date - tempstart.Date).Days;
                        DateTime rangestartmonday =
                            type.RangeStart.AddDays(-Convert.ToInt32(type.RangeStart.DayOfWeek) + 1);
                        for (int i = 0; i <= days; i++)
                        {
                            if ((date.Date.AddDays(-Convert.ToInt32(date.DayOfWeek) + 1) - rangestartmonday.Date).Days % type.NWeek == 0 &&
                                type.WeekList.Contains((Convert.ToInt32(date.DayOfWeek)).ToString()))
                            {
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content, RepeatUtility.DetailString(notes, notes.Start, notes.End), date, CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  =
                                    new DayItem(RepeatUtility.ConvertToDateTime(date, notes.Start),
                                                RepeatUtility.ConvertToDateTime(date, notes.End), notes.Content,
                                                CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(date, monthitems, dayitems);
                                cd.Add(aday);
                            }
                            date = date.AddDays(1);
                        }
                    }
                }
            }

            return(cd);
        }
Exemple #10
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            foreach (Notes notes in source)
            {
                if (notes.RepeatType is NoRepeat)
                {
                    DateTime from = notes.Start;
                    DateTime to   = notes.End;
                    if (to >= from)
                    {
                        int      days = (to.Date - from.Date).Days;
                        DateTime date = from;
                        for (int i = 0; i <= days; i++)
                        {
                            if (date.Date <= end.Date && date.Date >= start.Date)
                            {
                                DateTime fromtemp = new DateTime(date.Year, date.Month, date.Day, 0, 0, 0);
                                DateTime totemp   = fromtemp.AddDays(1).AddSeconds(-1);
                                if (i == 0)
                                {
                                    fromtemp = from;
                                }
                                if (i == days)
                                {
                                    totemp = to;
                                }
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content, RepeatUtility.DetailString(notes, fromtemp, totemp), fromtemp, CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  = new DayItem(fromtemp, totemp, notes.Content, CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(fromtemp.Date, monthitems, dayitems);
                                cd.Add(aday);
                                date = date.AddDays(1);
                            }
                        }
                    }
                }
            }
            return(cd);
        }
        private void SaveListingItem()
        {
            ListingItem newItem = _dayItem.Listing.ReplaceItem(
                _dayItem.Day,
                string.IsNullOrEmpty(_locality) ? null : _locality.Trim(),
                new Time(WorkedTimeViewModel.StartTime),
                new Time(WorkedTimeViewModel.EndTime),
                new Time(WorkedTimeViewModel.LunchStart),
                new Time(WorkedTimeViewModel.LunchEnd),
                new Time(WorkedTimeViewModel.OtherHours)
                );

            _listingFacade.Save(_dayItem.Listing);

            DayItem.Update(newItem);

            EventAggregator.PublishOnUIThread(new ChangeViewMessage(nameof(ListingDetailViewModel)));
        }
Exemple #12
0
    private void InitDays()
    {
        for (int i = 0; i < rowCount; i++)
        {
            for (int j = 0; j < columnCount; j++)
            {
                GameObject go      = Instantiate(dayPrefab, dayParent.transform);
                DayItem    dayItem = go.GetComponent <DayItem>();

                DayItemData data = new DayItemData();
                data.index   = CalendarIndex(i, j);
                data.date    = DateTime.Today;
                dayItem.Data = data;

                m_allDayItems.Add(data.index, dayItem);
            }
        }
    }
        public static List <CalendarADay> Turn(List <OverWork> originalDataList,
                                               List <PlanDutyDetail> planDutyDetailList, List <SpecialDate> specialList, List <CalendarADay> retList)
        {
            foreach (OverWork overWork in originalDataList)
            {
                foreach (OverWorkItem originalDataItem in overWork.Item)
                {
                    string typeName = "加班";
                    // -1 全部;0 新增;1 提交;2 审核不通过;3 审核通过;4 取消请假;5 拒绝取消假期;6 批准取消假期;7 审核中;8 审核取消中
                    if (originalDataItem.Status == RequestStatus.New ||
                        originalDataItem.Status == RequestStatus.Submit ||
                        originalDataItem.Status == RequestStatus.Approving ||
                        originalDataItem.Status == RequestStatus.CancelApproving ||
                        originalDataItem.Status == RequestStatus.Cancelled)
                    {
                        typeName = typeName + "(" + originalDataItem.Status.Name + ")";
                    }
                    CalendarADay calendarADay = CalendarADay.CreateOrGetCalendarADayByDate(retList, originalDataItem.FromDate.Date);
                    DayItem      day          = new DayItem();
                    day.ObjectID  = originalDataItem.ItemID;
                    day.CType     = CalendarShowType.OverWork;
                    day.Start     = originalDataItem.FromDate;
                    day.End       = originalDataItem.ToDate;
                    day.DayDetail = typeName + " " + originalDataItem.CostTime + "小时<br>项目:" + overWork.ProjectName +
                                    "<br>理由:" + overWork.Reason;
                    calendarADay.DayItems.Add(day);

                    MonthItem month = new MonthItem();
                    month.ObjectID = originalDataItem.ItemID;
                    month.CType    = CalendarShowType.OverWork;
                    month.Title    = typeName + " " + originalDataItem.CostTime + "小时";
                    month.Date     = originalDataItem.FromDate;
                    month.Detail   = typeName + " 时段:" +
                                     originalDataItem.FromDate.ToShortDateString() + " " +
                                     originalDataItem.FromDate.ToShortTimeString() + "--" +
                                     originalDataItem.ToDate.ToShortDateString() + " " +
                                     originalDataItem.ToDate.ToShortTimeString() + " 加班时间(小时):" +
                                     originalDataItem.CostTime + " 项目:" + overWork.ProjectName + " 理由:" + overWork.Reason;
                    calendarADay.MonthItems.Add(month);
                    Utility.Clean(calendarADay);
                }
            }
            return(retList);
        }
Exemple #14
0
        /// <summary>
        /// dongdt 22/11/2017
        /// </summary>
        /// <param name="dateTime">Ngày</param>
        /// <returns>Danh sách ngày trong tháng</returns>
        public static List <DayItem> ListDayInMonth(DateTime dateTime)
        {
            var listday = new List <DayItem>();
            var sttd    = 0;

            for (var i = dateTime; i < dateTime.AddMonths(1); i = i.AddDays(1))
            {
                var obj = new DayItem
                {
                    Item = new DateItem {
                        I = sttd++, S = i.TotalSeconds(), E = i.AddDays(1).TotalSeconds()
                    },
                    Date = i,
                    Thu  = i.Thu(),
                };
                listday.Add(obj);
            }
            return(listday);
        }
Exemple #15
0
 public SeasonModels()
 {
     StartDate = DateTime.Now;
     EndDate   = DateTime.Now;
     //=================
     ListDay        = new List <int>();
     ListRepeatType = new List <SelectListItem>()
     {
         new SelectListItem()
         {
             Text = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(Commons.PromotionDayOfWeek).ToString(), Value = Commons.ERepeatType.DayOfWeek.ToString("d")
         },
         new SelectListItem()
         {
             Text = _AttributeForLanguage.CurrentUser.GetLanguageTextFromKey(Commons.PromotionDayOfMonth).ToString(), Value = Commons.ERepeatType.DayOfMonth.ToString("d")
         }
     };
     ListWeekDayV2  = new List <DayItem>();
     ListMonthDayV2 = new List <DayItem>();
     for (int i = 2; i < 9; i++)
     {
         string  dayName = i == 8 ? Enum.GetName(typeof(DayOfWeek), 0) : Enum.GetName(typeof(DayOfWeek), i - 1);
         DayItem dItem   = new DayItem
         {
             Index    = i,
             Name     = dayName,
             IsActive = false,
             Status   = 9
         };
         ListWeekDayV2.Add(dItem);
     }
     for (int i = 1; i < 32; i++)
     {
         DayItem dItem = new DayItem
         {
             Index    = i,
             Name     = i.ToString(),
             IsActive = false,
             Status   = 9
         };
         ListMonthDayV2.Add(dItem);
     }
 }
Exemple #16
0
        private static void CreateOutApplicationInfoInADay(List <CalendarADay> retList, DateTime date,
                                                           decimal hour, OutApplication originalData, OutApplicationItem originalDataItem,
                                                           DateTime from, DateTime to)
        {
            CalendarADay calendarADay = CalendarADay.CreateOrGetCalendarADayByDate(retList, date.Date);
            string       typeName     = originalData.OutType.Name;

            // -1 全部;0 新增;1 提交;2 审核不通过;3 审核通过;4 取消请假;5 拒绝取消假期;6 批准取消假期;7 审核中;8 审核取消中
            if (originalDataItem.Status == RequestStatus.New ||
                originalDataItem.Status == RequestStatus.Submit ||
                originalDataItem.Status == RequestStatus.Approving ||
                originalDataItem.Status == RequestStatus.CancelApproving ||
                originalDataItem.Status == RequestStatus.Cancelled)
            {
                typeName = typeName + "(" + originalDataItem.Status.Name + ")";
            }

            DayItem day = new DayItem();

            day.ObjectID  = originalDataItem.ItemID;
            day.CType     = CalendarShowType.Out;
            day.Start     = from;
            day.End       = to;
            day.DayDetail = typeName + " " + Convert.ToSingle(hour) + "小时<br>地点:" + originalData.OutLocation + "<br>理由:" +
                            originalData.Reason;
            calendarADay.DayItems.Add(day);

            MonthItem month = new MonthItem();

            month.ObjectID = originalDataItem.ItemID;
            month.CType    = CalendarShowType.Out;
            month.Title    = typeName + " " + Convert.ToSingle(hour) + "小时";
            month.Date     = date;
            month.Detail   = typeName + " 时段:" +
                             originalDataItem.FromDate.ToShortDateString() + " " +
                             originalDataItem.FromDate.ToShortTimeString() + "--" +
                             originalDataItem.ToDate.ToShortDateString() + " " +
                             originalDataItem.ToDate.ToShortTimeString() + " 外出时间(小时):" +
                             originalDataItem.CostTime + " 地点:" + originalData.OutLocation + " 理由:" + originalData.Reason;
            calendarADay.MonthItems.Add(month);
            Utility.Clean(calendarADay);
        }
Exemple #17
0
    /// <summary>
    /// 设置日历当前显示的年月
    /// </summary>
    /// <param name="year"></param>
    /// <param name="month"></param>
    public void SetMonth(int year, int month)
    {
        // 日历当前的日期
        m_currentDateTime = new DateTime(year, month, m_currentDateTime.Day);

        RandomSelectionExample();

        if (uiYearMonth != null)
        {
            uiYearMonth.text = string.Format("{0}/{1:00}", year, month);
        }

        // 当月第1天
        DateTime monthDay1 = new DateTime(year, month, 1);

        // 当月第1天的星期
        DayOfWeek monthDay1Week = monthDay1.DayOfWeek;

        // 日历index为0的那一天
        DateTime day0 = monthDay1 - new TimeSpan((int)monthDay1Week, 0, 0, 0);

        // 当月总天数
        int selectionIndex = 0;

        for (int i = 0; i < rowCount; i++)
        {
            for (int j = 0; j < columnCount; j++)
            {
                int     index   = CalendarIndex(i, j);
                DayItem dayItem = m_allDayItems[index];
                dayItem.Date = day0 + new TimeSpan(index, 0, 0, 0);

                dayItem.IsCurrentMonth = (dayItem.Date.Year == year && dayItem.Date.Month == month);

                if (dayItem.IsCurrentMonth && m_selectionsList != null && m_selectionsList.Contains(dayItem.Date.Day))
                {
                    dayItem.SelectionIndex = selectionIndex;
                    selectionIndex++;
                }
            }
        }
    }
Exemple #18
0
        /// <summary>
        /// dongdt 22/11/2017
        /// </summary>
        /// <param name="dateTime">Ngày</param>
        /// <returns>Danh sách ngày trong tuần</returns>
        public static List <DayItem> ListDayInWeek(DateTime dateTime)
        {
            var listday = new List <DayItem>();
            var sttd    = 0;
            var start   = dateTime.AddDays(1 - dateTime.Thu());

            for (var i = start; i < start.AddDays(7); i = i.AddDays(1))
            {
                var obj = new DayItem
                {
                    Item = new DateItem {
                        I = sttd++, S = i.TotalSeconds(), E = i.AddDays(1).TotalSeconds()
                    },
                    Date = i,
                    Thu  = i.Thu(),
                };
                listday.Add(obj);
            }
            return(listday);
        }
        private void Reset(DayItem dayItem)
        {
            string date = CultureInfo.CurrentCulture.TextInfo.ToTitleCase((new DateTime(dayItem.Year, dayItem.Month, dayItem.Day)).ToLongDateString().ToLower());

            WindowTitle.Text = String.Format("{0} - {1}", date, dayItem.Listing.Name);
            _defaultSettings = _settingFacade.GetDefaultSettings();
            Locality         = null;

            if (dayItem.ListingItem != null)
            {
                ListingItem l = dayItem.ListingItem;
                Locality = l.Locality;

                WorkedTimeViewModel = new WorkedTimeSettingViewModel(_defaultSettings.Time, l.TimeSetting, _defaultSettings.TimeTickInMinutes);
            }
            else
            {
                WorkedTimeViewModel = new WorkedTimeSettingViewModel(_defaultSettings.Time, _defaultSettings.Time, _defaultSettings.TimeTickInMinutes);
            }

            Localities = new ObservableCollection <string>(dayItem.Localities);
        }
Exemple #20
0
        public static List <CalendarADay> Turn(List <WorkTask> originalDataList, List <CalendarADay> retList,
                                               List <PlanDutyDetail> planDutyDetailList, int accountID, DateTime startDate, DateTime endDate)
        {
            foreach (WorkTask originalData in originalDataList)
            {
                for (int i = 0; originalData.StartDate.AddDays(i).Date <= originalData.EndDate.Date; i++)
                {
                    if (originalData.StartDate.AddDays(i).Date < startDate.Date ||
                        originalData.StartDate.AddDays(i).Date > endDate.Date)
                    {
                        continue;
                    }
                    PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, originalData.StartDate.AddDays(i).Date);
                    if (detail != null && detail.PlanDutyClass != null && detail.PlanDutyClass.IsWeek)
                    {
                        continue;
                    }
                    CalendarADay calendarADay =
                        CalendarADay.CreateOrGetCalendarADayByDate(retList, originalData.StartDate.AddDays(i).Date);

                    MonthItem month = new MonthItem();
                    month.CType  = CalendarShowType.WorkTask;
                    month.Title  = originalData.Title;
                    month.Date   = originalData.StartDate.AddDays(i).Date;
                    month.Detail = month.Title +
                                   (originalData.Account.Id == accountID ? "" : "<br>创建人:" + originalData.Account.Name)
                                   + "<br>时段:" + originalData.StartDate.ToShortDateString() + "--" +
                                   originalData.EndDate.ToShortDateString() + " 状态:<span class=\"" +
                                   originalData.Status.Style + "\">" + originalData.Status.Name +
                                   "</span><br>" + originalData.Description;
                    calendarADay.MonthItems.Add(month);

                    DayItem day = new DayItem();
                    day.CType = CalendarShowType.WorkTask;
                    day.Start = day.End = originalData.StartDate.AddDays(i).Date;

                    if (detail != null)
                    {
                        day.Start =
                            new DateTime(day.Start.Year, day.Start.Month, day.Start.Day,
                                         detail.PlanDutyClass.FirstStartFromTime.Hour,
                                         detail.PlanDutyClass.FirstStartFromTime.Minute,
                                         detail.PlanDutyClass.FirstStartFromTime.Second); //todo by wsl
                        day.End =
                            new DateTime(day.End.Year, day.End.Month, day.End.Day,
                                         detail.PlanDutyClass.SecondEndTime.Hour,
                                         detail.PlanDutyClass.SecondEndTime.Minute,
                                         detail.PlanDutyClass.SecondEndTime.Second);
                    }
                    else
                    {
                        day.Start = new DateTime(day.Start.Year, day.Start.Month, day.Start.Day, 9, 0, 0);
                        day.End   = new DateTime(day.End.Year, day.End.Month, day.End.Day, 17, 0, 0);
                    }

                    day.DayDetail = month.Title +
                                    (originalData.Account.Id == accountID ? "" : "<br>创建人:" + originalData.Account.Name)
                                    + "<br>时段:" +
                                    originalData.StartDate.ToShortDateString() + "--" +
                                    originalData.EndDate.ToShortDateString() + "<br>状态:" + originalData.Status.Name +
                                    "<br>" + originalData.Description;
                    calendarADay.DayItems.Add(day);
                    Utility.Clean(calendarADay);
                }
            }
            return(retList);
        }
Exemple #21
0
 public SelectedDayItemArgs(DayItem dayItem)
 {
     DayItem = dayItem;
 }
Exemple #22
0
        public static List <CalendarADay> Turn(List <AttendanceBase> originalDataList,
                                               List <CalendarADay> retList, List <PlanDutyDetail> planDutyDetailList,
                                               List <OutApplication> outApplicationList, List <LeaveRequest> leaveRequestList, List <AttendanceInAndOutRecord> attendanceInAndOutRecordList)
        {
            foreach (AttendanceBase originalData in originalDataList)
            {
                PlanDutyDetail theDayPlanDuty =
                    PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, originalData.TheDay);
                if (theDayPlanDuty == null)
                {
                    continue;
                }
                CalendarADay calendarADay = CalendarADay.CreateOrGetCalendarADayByDate(retList, originalData.TheDay);

                DayItem   day   = new DayItem();
                MonthItem month = new MonthItem();
                day.ObjectID = month.ObjectID = originalData.AttendanceId;
                day.CType    = month.CType = CalendarShowType.Absent;
                day.ObjectID = month.ObjectID = originalData.AttendanceId;
                month.Date   = calendarADay.Date;
                LaterAttendance      late;
                EarlyLeaveAttendance early;
                if (originalData is AbsentAttendance)
                {
                    day.Start = theDayPlanDuty.PlanDutyClass.FirstStartFromTime;
                    day.End   = originalData.Days == 1
                                  ? theDayPlanDuty.PlanDutyClass.SecondEndTime
                                  : theDayPlanDuty.PlanDutyClass.FirstEndTime;
                    if (originalData.Days != 1)
                    {
                        List <UnKownTimeSpan> uktsList =
                            CaculateAbsentTimes(originalData.TheDay, theDayPlanDuty, outApplicationList,
                                                leaveRequestList,
                                                attendanceInAndOutRecordList);
                        foreach (UnKownTimeSpan span in uktsList)
                        {
                            if ((span.To - span.From).TotalMinutes >= theDayPlanDuty.PlanDutyClass.AbsentLateTime
                                ||
                                (span.To - span.From).TotalMinutes >= theDayPlanDuty.PlanDutyClass.AbsentEarlyLeaveTime)
                            {
                                day.Start = span.From;
                                day.End   = span.To;
                            }
                        }
                    }
                    day.DayDetail = originalData.Name + " " + Utility.FormatNumData(originalData.Days * 8) + "小时";
                    month.Title   = month.Detail = originalData.Name + " " + Utility.FormatNumData(originalData.Days * 8) + "小时";
                }
                else if ((early = originalData as EarlyLeaveAttendance) != null)
                {
                    day.Start        = theDayPlanDuty.PlanDutyClass.SecondEndTime.AddMinutes(-early.EarlyLeaveMinutes);
                    day.End          = theDayPlanDuty.PlanDutyClass.SecondEndTime;
                    day.DayDetail    = early.Name + " " + Utility.FormatNumData(early.EarlyLeaveMinutes) + "分钟";
                    month.Title      =
                        month.Detail = early.Name + " " + Utility.FormatNumData(early.EarlyLeaveMinutes) + "分钟";
                }
                else if ((late = originalData as LaterAttendance) != null)
                {
                    day.Start     = theDayPlanDuty.PlanDutyClass.FirstStartFromTime;
                    day.End       = theDayPlanDuty.PlanDutyClass.FirstStartFromTime.AddMinutes(late.LaterMinutes);
                    day.DayDetail = late.Name + " " + Utility.FormatNumData(late.LaterMinutes) + "分钟";
                    month.Title   = month.Detail = late.Name + " " + Utility.FormatNumData(late.LaterMinutes) + "分钟";
                }

                calendarADay.DayItems.Add(day);
                calendarADay.MonthItems.Add(month);
                Utility.Clean(calendarADay);
            }
            return(retList);
        }
 public EditDayItemMessage(DayItem dayItem)
 {
     _dayItem = dayItem;
 }
Exemple #24
0
        public List <CalendarADay> GetByDate(DateTime start, DateTime end, List <Notes> source)
        {
            List <CalendarADay> cd = new List <CalendarADay>();

            if (source != null && source.Count > 0)
            {
                List <PlanDutyDetail> planDutyDetailList =
                    new PlanDutyFacade().GetPlanDutyDetailByAccount(source[0].Owner.Id, start, end);

                foreach (Notes notes in source)
                {
                    if (notes.RepeatType is DayRepeat)
                    {
                        DayRepeat type = (DayRepeat)notes.RepeatType;

                        DateTime tempstart = type.RangeStart > start ? type.RangeStart : start;
                        DateTime tempend   = type.RangeEnd == null || type.RangeEnd > end
                                               ? end
                                               : Convert.ToDateTime(type.RangeEnd);
                        DateTime date = tempstart;
                        int      days = (tempend.Date - tempstart.Date).Days;
                        for (int i = 0; i <= days; i++)
                        {
                            bool isadd = false;
                            if (type.EveryWork || type.EveryWeek)
                            {
                                PlanDutyDetail detail = PlanDutyDetail.GetPlanDutyDetailByDate(planDutyDetailList, date);
                                if ((type.EveryWork && !detail.PlanDutyClass.IsWeek) ||
                                    (type.EveryWeek && detail.PlanDutyClass.IsWeek))
                                {
                                    isadd = true;
                                }
                            }
                            else
                            {
                                if ((date.Date - type.RangeStart.Date).Days % type.NDayOnce == 0)
                                {
                                    isadd = true;
                                }
                            }
                            if (isadd)
                            {
                                List <MonthItem> monthitems = new List <MonthItem>();
                                MonthItem        monthitem  =
                                    new MonthItem(notes.Content, RepeatUtility.DetailString(notes, notes.Start, notes.End), date, CalendarShowType.Note);
                                monthitems.Add(monthitem);
                                List <DayItem> dayitems = new List <DayItem>();
                                DayItem        dayItem  =
                                    new DayItem(RepeatUtility.ConvertToDateTime(date, notes.Start),
                                                RepeatUtility.ConvertToDateTime(date, notes.End), notes.Content,
                                                CalendarShowType.Note);
                                dayItem.ObjectID = notes.PKID;
                                dayitems.Add(dayItem);
                                CalendarADay aday = new CalendarADay(date, monthitems, dayitems);
                                cd.Add(aday);
                            }
                            date = date.AddDays(1);
                        }
                    }
                }
            }

            return(cd);
        }