Beispiel #1
0
        /// <summary>
        /// Check whether the schedule is allowed to run now.
        /// </summary>
        /// <returns>True if the schedule may run.</returns>
        public bool Test()
        {
            DateTime d = DateTime.Now;

            if (AllowedYears.Length > 0 && !AllowedYears.Contains(d.Year))
            {
                return(false);
            }
            if (AllowedMonths.Length > 0 && !AllowedMonths.Contains(d.Month))
            {
                return(false);
            }
            if (AllowedDOWs.Length > 0 && !AllowedDOWs.Contains((int)d.DayOfWeek))
            {
                return(false);
            }
            if (AllowedDays.Length > 0 && !AllowedDays.Contains(d.Day))
            {
                return(false);
            }
            if (AllowedHours.Length > 0 && !AllowedHours.Contains(d.Hour))
            {
                return(false);
            }
            if (AllowedMinutes.Length > 0 && !AllowedMinutes.Contains(d.Minute))
            {
                return(false);
            }

            return(true);
        }
Beispiel #2
0
        /// <summary>
        /// Runs when the control is loaded
        /// </summary>
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    DateTime date = (SelectedYear == DateTime.Now.Year) ? DateTime.Now.Date : new DateTime(SelectedYear, DateTime.Now.Month, DateTime.Now.Day);
                    while (!AllowedDays.Contains((int)date.DayOfWeek) || date < DateTime.Now.Date.AddDays(MinOffset))
                    {
                        date = date.AddDays(1);
                    }
                    dtpStartdate.SelectedDate = date;
                    dtpEnddate.SelectedDate   = date.AddDays(MinDays);

                    valEmailOK.ValidationExpression = Globals.glbEmailRegEx;

                    SetVisibility("Firstname");
                    SetVisibility("Lastname");
                    SetVisibility("Organization");
                    SetVisibility("Street");
                    SetVisibility("City");
                    SetVisibility("PostalCode");
                    SetVisibility("Phone");
                    SetVisibility("Fax");
                    SetVisibility("Email");
                    SetVisibility("Remark");

                    BindData();
                    ShowInfo();
                    mvBooking.SetActiveView(vwCheck);
                }
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #3
0
        protected void grdBookings_ItemCommand(object source, DataGridCommandEventArgs e)
        {
            int         bookingId;
            BookingInfo booking;

            grdBookings.SelectedIndex = -1;
            phMessage.Controls.Clear();
            switch (e.CommandName)
            {
            case "New":
                pnlEdit.Visible    = true;
                hidBookingId.Value = "-1";

                DateTime date = (SelectedYear == DateTime.Now.Year) ? DateTime.Now.Date : new DateTime(SelectedYear, DateTime.Now.Month, DateTime.Now.Day);
                while (!AllowedDays.Contains((int)date.DayOfWeek) || date < DateTime.Now.Date.AddDays(MinOffset))
                {
                    date = date.AddDays(1);
                }
                dtpStartdate.SelectedDate = date;
                dtpEnddate.SelectedDate   = date.AddDays(MinDays);
                ddlState.SelectedValue    = "2";
                BindData();
                break;

            case "Edit":
                pnlEdit.Visible           = true;
                bookingId                 = Convert.ToInt32(e.CommandArgument);
                booking                   = Controller.GetBooking(bookingId);
                grdBookings.SelectedIndex = e.Item.ItemIndex;

                hidBookingId.Value        = booking.BookingId.ToString();
                dtpStartdate.SelectedDate = booking.Startdate;
                dtpEnddate.SelectedDate   = booking.Enddate;
                if (ddlUser.Items.FindByValue(booking.UserID.ToString()) != null)
                {
                    ddlUser.SelectedValue = booking.UserID.ToString();
                }
                if (ddlState.Items.FindByValue(booking.State.ToString()) != null)
                {
                    ddlState.SelectedValue = booking.State.ToString();
                }
                BindData();
                break;

            case "Delete":
                pnlEdit.Visible = false;
                bookingId       = Convert.ToInt32(e.CommandArgument);
                booking         = Controller.GetBooking(bookingId);
                try
                {
                    Controller.DeleteBooking(booking);
                }
                catch (Exception)
                {
                    string message = LocalizeString("DeleteBooking.Error");
                    DotNetNuke.UI.Skins.Skin.AddModuleMessage(this, message, ModuleMessage.ModuleMessageType.YellowWarning);
                }
                BindData();
                break;
            }
        }