示例#1
0
        protected void RadGridDays_Load(object sender, EventArgs e)
        {
            var cVacationSchema = new CVacationSchema();
            CVacationTypeInfoModel vacationTypeInfoModel = cVacationSchema.GetVacationTypeInfoModel(Convert.ToInt32(ViewState["UserId"]));

            ((RadGrid)sender).DataSource = cVacationSchema.Get(vacationTypeInfoModel);
        }
示例#2
0
        protected void RadCalendar1_OnSelectionChanged(object sender, SelectedDatesEventArgs e)
        {
            if ((bool)ViewState["IsRadCalder"] == false)
            {
                RadCalendar1.SelectedDates.Clear();
                var selectedDateList = (DateTime[])ViewState["SelectedDates"];
                foreach (var d in selectedDateList)
                {
                    RadCalendar1.SelectedDates.Add(new RadDate(d));
                }
                return;
            }

            // if half day
            if (Convert.ToInt32(RadComboBoxDayType.SelectedValue) == 0)
            {
                if (RadCalendar1.SelectedDates.Count > 0)
                {
                    // only choose one day
                    DateTime halfDay = RadCalendar1.SelectedDates[RadCalendar1.SelectedDates.Count - 1].Date;
                    RadCalendar1.SelectedDates.Clear();
                    RadCalendar1.SelectedDates.Add(new RadDate(halfDay));
                }
            }

            CVacationTypeInfoModel vacationTypeInfoModel = (CVacationTypeInfoModel)ViewState["VacationTypeInfoModel"];

            double selectedThisYearUsedDays = 0;
            double selectedNextYearUsedDays = 0;

            double thisYearTotalDays = 0;
            double thisYearUsedDays  = 0;
            double nextYearTotalDays = 0;
            double nextYearUsedDays  = 0;

            DateTime compareDate = DateTime.Now;

            switch (Convert.ToInt32(RadComboBoxVacationType.SelectedValue))
            {
            // paid
            case (int)CConstValue.VacationType.PaidVacationDay:
                compareDate = vacationTypeInfoModel.ThisYear.PaidDate;

                thisYearTotalDays = vacationTypeInfoModel.ThisYear.PaidTotalDays;
                thisYearUsedDays  = vacationTypeInfoModel.ThisYear.PaidUsedDays;

                nextYearTotalDays = vacationTypeInfoModel.NextYear.PaidTotalDays;
                nextYearUsedDays  = vacationTypeInfoModel.NextYear.PaidUsedDays;
                break;

            // unpaid
            case (int)CConstValue.VacationType.UnPaidVacationDay:
                // nothing
                break;

            // sick
            case (int)CConstValue.VacationType.SickDay:
                compareDate = vacationTypeInfoModel.ThisYear.SickDate;

                thisYearTotalDays = vacationTypeInfoModel.ThisYear.SickTotalDays;
                thisYearUsedDays  = vacationTypeInfoModel.ThisYear.SickUsedDays;

                nextYearTotalDays = vacationTypeInfoModel.NextYear.SickTotalDays;
                nextYearUsedDays  = vacationTypeInfoModel.NextYear.SickUsedDays;
                break;

            // entitlement
            case (int)CConstValue.VacationType.EntitlementDay:
                compareDate = vacationTypeInfoModel.ThisYear.EntitlementDate;

                thisYearTotalDays = vacationTypeInfoModel.ThisYear.EntitlementTotalDays;
                thisYearUsedDays  = vacationTypeInfoModel.ThisYear.EntitlementUsedDays;

                nextYearTotalDays = vacationTypeInfoModel.NextYear.EntitlementTotalDays;
                nextYearUsedDays  = vacationTypeInfoModel.NextYear.EntitlementUsedDays;
                break;
            }

            // without unpaid
            if (Convert.ToInt32(RadComboBoxVacationType.SelectedValue) != 1)
            {
                foreach (RadDate radDate in RadCalendar1.SelectedDates)
                {
                    // next year
                    if (radDate.Date > compareDate)
                    {
                        // full day
                        if (Convert.ToInt32(RadComboBoxDayType.SelectedValue) == 1)
                        {
                            selectedNextYearUsedDays++;
                        }
                        else
                        {
                            selectedNextYearUsedDays += 0.5;
                        }
                    }
                    // this year
                    else
                    {
                        // full day
                        if (Convert.ToInt32(RadComboBoxDayType.SelectedValue) == 1)
                        {
                            selectedThisYearUsedDays++;
                        }
                        else
                        {
                            selectedThisYearUsedDays += 0.5;
                        }
                    }
                }

                // compare used date
                if ((selectedThisYearUsedDays + thisYearUsedDays) <= thisYearTotalDays && (selectedNextYearUsedDays + nextYearUsedDays) <= nextYearTotalDays)
                {
                    // success
                }
                else
                {
                    ShowMessage("Not available days");

                    RadCalendar1.SelectedDates.Clear();
                    var selectedDateList = (DateTime[])ViewState["SelectedDates"];
                    if (selectedDateList != null)
                    {
                        foreach (var d in selectedDateList)
                        {
                            RadCalendar1.SelectedDates.Add(new RadDate(d));
                        }
                    }
                    return;
                }
            }

            SetDataInformation();
            // save selectedDates
            ViewState["SelectedDates"] = RadCalendar1.SelectedDates.ToArray();
        }