示例#1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;

            this.Left = desktopWorkingArea.Right - this.Width;
            this.Top  = desktopWorkingArea.Bottom - this.Height;

            UserHoliday uholiday = new UserHoliday();

            uholiday.getUpcoming();
            if (holidays.holitem._HOLIDAY_NAME == null)
            {
                Event.Text = "None";
                Date.Text  = "None";
                Type.Text  = "None";
            }
            else
            {
                DateTime fdate    = DateTime.Parse(holidays.holitem._HOLIDAY_DATE.ToString());
                string   passdate = fdate.ToString("MMMM dd, yyyy");


                Event.Text = "" + holidays.holitem._HOLIDAY_NAME + "";
                Date.Text  = "" + passdate + "";
                Type.Text  = "" + holidays.holitem._HOLIDAY_TYPE + "";
            }
        }
示例#2
0
        /// <summary>
        /// 年假HTML数据
        /// </summary>
        /// <param name="holiday"></param>
        /// <returns></returns>
        public string HolidayDataConvert2Html(UserHoliday holiday)
        {
            StringBuilder result = new StringBuilder();
            string        name   = holiday.StaffName;
            //计算员工年假剩余总时间,过期时间
            string contentRespect        = string.Format(_contentRespect, name);
            string holidayContentComment = _holidayContentComment;

            //数据结构转化为HTML表格
            DataTable detail = JsonConvert.DeserializeObject <DataTable>(
                JsonConvert.SerializeObject(new List <object> {
                new {
                    name           = holiday.StaffName,
                    begin          = holiday.PaidLeaveBeginDate.ToString("yyyy-MM-dd"),
                    end            = holiday.PaidLeaveEndDate.ToString("yyyy-MM-dd"),
                    before         = holiday.BeforeRemainingHours,
                    legal          = holiday.CurrentLegalHours,
                    welfare        = holiday.CurrentWelfareHours,
                    totalAvailable = holiday.BeforeRemainingHours + holiday.CurrentLegalHours + holiday.CurrentWelfareHours,
                    used           = holiday.CurrentUsedHours,
                    remaining      = holiday.BeforeRemainingHours + holiday.CurrentLegalHours + holiday.CurrentWelfareHours - holiday.CurrentUsedHours,
                    available      = holiday.CurrentAvailableRemainingHours
                }
            }));
            string data = HolidayTableConvertHtml(detail);

            result.Append(contentRespect).Append(newLine).Append(newLine)
            .Append(holidayContentComment).Append(newLine).Append(newLine)
            .Append(data).Append(newLine).Append(_holidayTagComment).Append(newLine)
            .Append(_mailSenderSignature);
            return(result.ToString());
        }
示例#3
0
        public IActionResult Create(string dateRangeSearch)
        {
            try
            {
                //current user
                var currentUser = _userManager.GetUserAsync(HttpContext.User).Result;

                //find startDate and EndDate from dateRangeSearch string
                var thisStringArray = dateRangeSearch.Split(" ");
                var startDate       = DateTime.Parse(thisStringArray[0]);
                var endDate         = DateTime.Parse(thisStringArray[2]);

                //get all userHolidays entries for current user and between start and end date
                //for do not regist same date twice
                var holidaysOfUser = _context.UserHolidays.Where(c => c.UserId == currentUser.Id &&
                                                                 c.HolidayDay.Date >= startDate.Date && c.HolidayDay.Date <= endDate.Date).ToList();

                while (startDate <= endDate)
                {
                    //add to db if this date is not existed yet
                    var containsDate = holidaysOfUser.FirstOrDefault(c => c.HolidayDay.Date == startDate.Date);

                    if (containsDate == null)
                    {
                        var newUserHoliday = new UserHoliday()
                        {
                            HolidayDay = startDate,
                            UserId     = currentUser.Id
                        };

                        _context.UserHolidays.Add(newUserHoliday);
                        _context.SaveChanges();
                    }

                    startDate = startDate.AddDays(1);
                }
                TempData["Success"] = "Obrigada. Os dias de férias estão adicionados com sucesso.";
                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception)
            {
                ModelState.AddModelError(String.Empty, "Algo correu errado, por favor, tente novamente ou contacte Administrador do Sistema.");
            }

            return(View());
        }