示例#1
0
        /// <summary>
        /// This is overridden to allow proper comparison of FloatingHoliday objects
        /// </summary>
        /// <param name="obj">The object to which this instance is compared</param>
        /// <returns>Returns true if the object equals this instance, false if it does not</returns>
        public override bool Equals(object obj)
        {
            FloatingHoliday h = obj as FloatingHoliday;

            if (h == null)
            {
                return(false);
            }

            return(this == h || (this.Month == h.Month && dayOfWeek == h.Weekday &&
                                 holidayOccurrence == h.Occurrence && holidayOffset == h.Offset && this.Description == h.Description));
        }
示例#2
0
        /// <summary>
        /// Update a holiday item in the collection
        /// </summary>
        /// <param name="source">The source of the event</param>
        /// <param name="e">The event arguments</param>
        protected void dgHolidays_UpdateCommand(object source, DataGridCommandEventArgs e)
        {
            HolidayCollection hc = (HolidayCollection)Session["Holidays"];

            if(!Page.IsValid)
                return;

            DropDownList cboMonth = (DropDownList)e.Item.FindControl("cboMonth");
            RadioButton rbFloating = (RadioButton)e.Item.FindControl("rbFloating");

            // Create holiday object and replace it in the collection
            if(rbFloating.Checked)
            {
                FloatingHoliday fl = new FloatingHoliday();

                fl.Month = cboMonth.SelectedIndex + 1;
                fl.Description = ((TextBox)e.Item.FindControl("txtDescription")).Text;
                fl.Occurrence = (DayOccurrence)((DropDownList)e.Item.FindControl("cboOccurrence")).SelectedIndex + 1;
                fl.Weekday = (System.DayOfWeek)((DropDownList)e.Item.FindControl("cboDayOfWeek")).SelectedIndex;
                fl.Offset = Convert.ToInt32(((TextBox)e.Item.FindControl("txtOffset")).Text);

                hc[e.Item.ItemIndex] = fl;
            }
            else
            {
                // See if the day of the month is valid for the month.  We won't accept Feb 29th either.
                int day = Convert.ToInt32(((TextBox)e.Item.FindControl("txtDayOfMonth")).Text);

                if(day > DateTime.DaysInMonth(2007, cboMonth.SelectedIndex + 1))
                {
                    ((RangeValidator)e.Item.FindControl("rvDOM")).IsValid = false;
                    return;
                }

                FixedHoliday fx = new FixedHoliday();

                fx.Month = cboMonth.SelectedIndex + 1;
                fx.Description = ((TextBox)e.Item.FindControl("txtDescription")).Text;
                fx.AdjustFixedDate = ((CheckBox)e.Item.FindControl("chkAdjustDate")).Checked;
                fx.Day = Convert.ToInt32(((TextBox)e.Item.FindControl("txtDayOfMonth")).Text);

                hc[e.Item.ItemIndex] = fx;
            }

            dgHolidays.EditItemIndex = -1;
            dgHolidays.DataSource = hc;
            dgHolidays.DataBind();
        }