Пример #1
0
        public bool IsPreferedDay(DateTime d)
        {
            if (Never == true)
            {
                return(false);
            }
            else if (Always == true)
            {
                return(true);
            }
            else if (DayInWeek != null)
            {
                if (DayInWeek.Any <DayOfWeek>(x => x == d.DayOfWeek))
                {
                    return(true);
                }
            }
            else if (DayOfMonth != null)
            {
                if (DayOfMonth == d.Day)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #2
0
 private void ListView_MouseUp(object sender, MouseButtonEventArgs e)
 {
     if (tabWeekylist.IsSelected)
     {
         if (btnMove.IsChecked == true && tvWeekylist.SelectedItem != null)
         {
             BussinessObject.Entities.Task task = tvWeekylist.SelectedItem as dynamic;
             dynamic   data      = sender as dynamic;
             DayInWeek dayInWeek = data.DataContext as DayInWeek;
             dynamic   setTime   = dpTime.SelectedDate;
             DateTime  startDay  = getDateTimeOfWeek(setTime, dayInWeek.DayName);
             Work      work      = new Work()
             {
                 TaskId    = task.Id,
                 StartTime = startDay
             };
             WeekyTaskData weekyTaskData = new WeekyTaskData();
             if (weekyTaskData.MakeWorkFromWeekyTask(work))
             {
                 DayInWeek dataContext = data.DataContext as DayInWeek;
                 DataTable dtId        = weekyTaskData.GetInsertWorkId();
                 work.Id = dtId.Select()[0].ItemArray[0] as dynamic;
                 dataContext.MorningTask.Add(new WeekyWork(task, work));
                 DateTime startTime = getDateTimeOfWeek(setTime, DayOfWeek.Monday);
                 DateTime endTime   = startTime.AddDays(7).Date;
                 setProccess(startTime, endTime);
                 //CollectionViewSource.GetDefaultView(dataContext.MorningTask).Refresh();
             }
         }
     }
 }
Пример #3
0
        private void addWeekyWorkToDay(DayInWeek dayInWeek, WeekyWork weekyWork)
        {
            switch (weekyWork.StatusId)
            {
            case 2:
            case 3:
            case 4:
            case 1:
                dayInWeek.MorningTask.Add(weekyWork);
                break;

            case 5:
                dayInWeek.EverningTask.Add(weekyWork);
                break;
            }
        }
Пример #4
0
        /// <summary>
        /// Lấy 1 list các DayInWeek để hiển thị
        /// </summary>
        /// <returns>List DayInWeek</returns>
        public List <DayInWeek> GetListDayInWeekForShow(DateTime startTime, DateTime endTime)
        {
            List <DayInWeek> result    = new List <DayInWeek>();
            DayInWeek        monday    = new DayInWeek(DayOfWeek.Monday);
            DayInWeek        tuesday   = new DayInWeek(DayOfWeek.Tuesday);
            DayInWeek        wednesday = new DayInWeek(DayOfWeek.Wednesday);
            DayInWeek        thursday  = new DayInWeek(DayOfWeek.Thursday);
            DayInWeek        friday    = new DayInWeek(DayOfWeek.Friday);
            DayInWeek        saturday  = new DayInWeek(DayOfWeek.Saturday);
            DayInWeek        sunday    = new DayInWeek(DayOfWeek.Sunday);

            result.Add(monday);
            result.Add(tuesday);
            result.Add(wednesday);
            result.Add(thursday);
            result.Add(friday);
            result.Add(saturday);
            result.Add(sunday);

            foreach (DataRow row in GetWorkForShow(startTime, endTime).Rows)
            {
                WeekyWork weekyWork = new WeekyWork();
                weekyWork.Id          = int.Parse(row["Id"].ToString());
                weekyWork.TaskId      = int.Parse(row["TaskId"].ToString());
                weekyWork.Title       = row["Title"].ToString();
                weekyWork.Description = row["Description"].ToString();
                if (row["StartTime"].ToString().Length > 0)
                {
                    weekyWork.StartTime = DateTime.Parse(row["StartTime"].ToString());
                }
                if (row["AlertTime"].ToString().Length > 0)
                {
                    weekyWork.AlertTime = DateTime.Parse(row["AlertTime"].ToString());
                }
                if (row["Deadline"].ToString().Length > 0)
                {
                    weekyWork.DeadLine = DateTime.Parse(row["Deadline"].ToString());
                }
                weekyWork.StatusId = int.Parse(row["StatusId"].ToString());

                switch (weekyWork.StartTime.DayOfWeek.ToString())
                {
                case "Monday":
                    addWeekyWorkToDay(monday, weekyWork);
                    break;

                case "Tuesday":
                    addWeekyWorkToDay(tuesday, weekyWork);
                    break;

                case "Wednesday":
                    addWeekyWorkToDay(wednesday, weekyWork);
                    break;

                case "Thursday":
                    addWeekyWorkToDay(thursday, weekyWork);
                    break;

                case "Friday":
                    addWeekyWorkToDay(friday, weekyWork);
                    break;

                case "Saturday":
                    addWeekyWorkToDay(saturday, weekyWork);
                    break;

                case "Sunday":
                    addWeekyWorkToDay(sunday, weekyWork);
                    break;
                }
            }

            return(result);
        }