コード例 #1
0
        public HelpmeCalculeteModel GetPublicHolidayByContryId(string Date, int Id)
        {
            HelpmeCalculeteModel model = new HelpmeCalculeteModel();

            DateTime stdate = new DateTime();

            if (Date != null && Date != "")
            {
                var st = DateTime.ParseExact(Date, inputFormat, CultureInfo.InvariantCulture);
                stdate = Convert.ToDateTime(st.ToString(outputFormat));
                DateTime yearStart        = new DateTime(stdate.Year, 1, 1);
                DateTime yeatend          = new DateTime(stdate.Year, 12, 31);
                var      totalWorkingDays = Weekdays(yearStart, yeatend);
                var      remainiingDays   = Weekdays(stdate, yeatend);

                var TotalHolidayYear = _db.PublicHolidays.Where(x => x.PublicHolidayCountryID == Id && x.Date >= yearStart && x.Date <= yeatend).ToList();

                var TotalRemainingHolidays = _db.PublicHolidays.Where(x => x.PublicHolidayCountryID == Id && x.Date >= stdate && x.Date <= yeatend).ToList();

                var ExpiredHolidays = _db.PublicHolidays.Where(x => x.PublicHolidayCountryID == Id && x.Date >= yearStart && x.Date <= stdate).ToList();

                model.TotalHolidayYear       = TotalHolidayYear.Count;
                model.TotalRemainingHolidays = TotalRemainingHolidays.Count;
                model.ExpiredHolidays        = ExpiredHolidays.Count;
                model.TotalHolidayYear       = TotalHolidayYear.Count;
                model.totalWorkingDays       = totalWorkingDays;
                model.remainiingDays         = remainiingDays;
            }
            return(model);
        }
コード例 #2
0
        public ActionResult HelpMeCalculate(HelpmecalculateviewModel model)
        {
            EmployeeEmploymentViewModel emodel = new EmployeeEmploymentViewModel();
            var userinfo = _db.AspNetUsers.Where(x => x.Id == model.EmployeeID).FirstOrDefault();

            model.StartDate = String.Format("{0:dd-MM-yyyy}", userinfo.StartDate);
            if (userinfo.JobContryID == null)
            {
                userinfo.JobContryID = 1;
            }
            model.CountryId = (int)userinfo.JobContryID;
            List <SelectListItem> data    = new List <SelectListItem>();
            HelpmeCalculeteModel  Details = new HelpmeCalculeteModel();
            int totalDays = 0;
            int enti      = Convert.ToInt32(model.FullTimeEntitlement);

            Details = _employeeMethod.GetPublicHolidayByContryId(model.StartDate, model.CountryId);
            if (model.IncludePublicHolidays == "on")
            {
                emodel.includeThisYear = HolidayIncludeContractDays(model.EmployeeID, enti);
                data.Add(new SelectListItem {
                    Text = emodel.includeThisYear.ToString(), Value = "holidaysThisYear"
                });
            }
            else
            {
                emodel.notincludeThisYear = HolidayNotIncludeContractDays(model.EmployeeID, enti);
                data.Add(new SelectListItem {
                    Text = emodel.notincludeThisYear.ToString(), Value = "holidaysThisYear"
                });
            }
            if (enti != null && enti != 0)
            {
                double totalHoliday = HolidayIncludeContractDays(model.EmployeeID, enti);
                var    edata        = _db.Employee_Salary.Where(x => x.Archived == false && x.EmployeeID == model.EmployeeID).FirstOrDefault();
                if (edata != null)
                {
                    double rate = Convert.ToDouble(edata.TotalSalary) / totalHoliday;
                    data.Add(new SelectListItem {
                        Text = emodel.rate.ToString(), Value = "recovryRate"
                    });
                }
            }
            data.Add(new SelectListItem {
                Text = enti.ToString(), Value = "holidaysNextYear"
            });

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #3
0
        public ActionResult HelpMeCalculate(HelpmecalculateviewModel model)
        {
            var userinfo = _db.AspNetUsers.Where(x => x.Id == model.EmployeeID).FirstOrDefault();

            model.StartDate = String.Format("", userinfo.StartDate);
            if (userinfo.JobContryID == null)
            {
                userinfo.JobContryID = 1;
            }
            model.CountryId = (int)userinfo.JobContryID;
            List <SelectListItem> data    = new List <SelectListItem>();
            HelpmeCalculeteModel  Details = new HelpmeCalculeteModel();
            int totalDays = 0;

            Details = _employeeMethod.GetPublicHolidayByContryId(model.StartDate, model.CountryId);
            if (model.IncludePublicHolidays == "on")
            {
                decimal contractdays                  = Details.totalWorkingDays - (Details.TotalHolidayYear + (Convert.ToInt16(model.FullTimeEntitlement) - Details.TotalHolidayYear));
                decimal Accrualholidayrateperday      = Math.Round((Convert.ToDecimal(model.FullTimeEntitlement) - Details.TotalHolidayYear) / contractdays, 2);
                int     Remainingholidays             = Convert.ToInt16(Accrualholidayrateperday * Details.remainiingDays);
                decimal RemainingHolidyasFromStatDate = Details.TotalRemainingHolidays;
                totalDays = Convert.ToInt16(Remainingholidays + RemainingHolidyasFromStatDate);
            }
            else
            {
                decimal contractdays                  = Details.totalWorkingDays - (Details.TotalHolidayYear + Convert.ToInt16(model.FullTimeEntitlement));
                decimal Accrualholidayrateperday      = Math.Round((Convert.ToDecimal(model.FullTimeEntitlement) - Details.TotalHolidayYear) / contractdays, 2);
                decimal Remainingholidays             = Accrualholidayrateperday * Details.remainiingDays;
                decimal RemainingHolidyasFromStatDate = Details.TotalRemainingHolidays;
                totalDays = Convert.ToInt16(Remainingholidays + RemainingHolidyasFromStatDate);
                if (totalDays > 16)
                {
                    totalDays = totalDays + Convert.ToInt16(RemainingHolidyasFromStatDate);
                }
            }
            data.Add(new SelectListItem {
                Text = totalDays.ToString(), Value = "holidaysThisYear"
            });
            data.Add(new SelectListItem {
                Text = model.FullTimeEntitlement.ToString(), Value = "holidaysNextYear"
            });

            return(Json(data, JsonRequestBehavior.AllowGet));
        }