Пример #1
0
        private void BindData()
        {
            //Grid
            var i = 0;

            _colLocations           = _objCtlLocation.EventsLocationList(PortalId);
            GrdLocations.DataSource = _colLocations;
            GrdLocations.DataBind();
            if (GrdLocations.Items.Count > 0)
            {
                GrdLocations.Visible = true;
                for (i = 0; i <= GrdLocations.Items.Count - 1; i++)
                {
                    ((ImageButton)GrdLocations.Items[i].FindControl("DeleteButton")).Attributes.Add(
                        "onclick",
                        "javascript:return confirm('" +
                        Localization.GetString(
                            "AreYouSureYouWishToDelete.Text",
                            LocalResourceFile) +
                        "');");
                }
            }
        }
Пример #2
0
        private void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Add the external Validation.js to the Page
                const string csname = "ExtValidationScriptFile";
                var          cstype = MethodBase.GetCurrentMethod().GetType();
                var          cstext = "<script src=\"" + ResolveUrl("~/DesktopModules/Events/Scripts/Validation.js") +
                                      "\" type=\"text/javascript\"></script>";
                if (!Page.ClientScript.IsClientScriptBlockRegistered(csname))
                {
                    Page.ClientScript.RegisterClientScriptBlock(cstype, csname, cstext, false);
                }

                ddlLocations.EmptyMessage = Localization.GetString("NoLocations", LocalResourceFile);
                ddlLocations.Localization.AllItemsCheckedString =
                    Localization.GetString("AllLocations", LocalResourceFile);
                ddlLocations.Localization.CheckAllString =
                    Localization.GetString("SelectAllLocations", LocalResourceFile);
                if (Settings.Enablelocations == EventModuleSettings.DisplayLocations.SingleSelect)
                {
                    ddlLocations.CheckBoxes = false;
                }

                if (!Page.IsPostBack)
                {
                    //Bind DDL
                    var ctrlEventLocations = new EventLocationController();
                    var lstLocations       = ctrlEventLocations.EventsLocationList(PortalId);

                    var arrLocations = new ArrayList();
                    if (Settings.Restrictlocations)
                    {
                        foreach (EventLocationInfo dbLocation in lstLocations)
                        {
                            foreach (int location in Settings.ModuleLocationIDs)
                            {
                                if (dbLocation.Location == location)
                                {
                                    arrLocations.Add(dbLocation);
                                }
                            }
                        }
                    }
                    else
                    {
                        arrLocations.AddRange(lstLocations);
                    }

                    if (lstLocations.Count == 0)
                    {
                        Visible = false;
                        SelectedLocation.Clear();
                        return;
                    }

                    //Restrict locations by events in time frame.
                    if (Settings.RestrictLocationsToTimeFrame)
                    {
                        //Only for list view.
                        var whichView = string.Empty;
                        if (!(Request.QueryString["mctl"] == null) && ModuleId ==
                            Convert.ToInt32(Request.QueryString["ModuleID"]))
                        {
                            if (Request["mctl"].EndsWith(".ascx"))
                            {
                                whichView = Request["mctl"];
                            }
                            else
                            {
                                whichView = Request["mctl"] + ".ascx";
                            }
                        }
                        if (whichView.Length == 0)
                        {
                            if (!ReferenceEquals(
                                    Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)), null))
                            {
                                whichView = Request.Cookies.Get("DNNEvents" + Convert.ToString(ModuleId)).Value;
                            }
                            else
                            {
                                whichView = Settings.DefaultView;
                            }
                        }

                        if (whichView == "EventList.ascx" || whichView == "EventRpt.ascx")
                        {
                            var objEventInfoHelper =
                                new EventInfoHelper(ModuleId, TabId, PortalId, Settings);
                            var lstEvents = default(ArrayList);

                            var getSubEvents = Settings.MasterEvent;
                            var numDays      = Settings.EventsListEventDays;
                            var displayDate  = default(DateTime);
                            var startDate    = default(DateTime);
                            var endDate      = default(DateTime);
                            if (Settings.ListViewUseTime)
                            {
                                displayDate = DisplayNow();
                            }
                            else
                            {
                                displayDate = DisplayNow().Date;
                            }
                            if (Settings.EventsListSelectType == "DAYS")
                            {
                                startDate = displayDate.AddDays(Settings.EventsListBeforeDays * -1);
                                endDate   = displayDate.AddDays(Settings.EventsListAfterDays * 1);
                            }
                            else
                            {
                                startDate = displayDate;
                                endDate   = displayDate.AddDays(numDays);
                            }

                            lstEvents = objEventInfoHelper.GetEvents(startDate, endDate, getSubEvents,
                                                                     new ArrayList(Convert.ToInt32(new[] { "-1" })),
                                                                     new ArrayList(Convert.ToInt32(new[] { "-1" })), -1,
                                                                     -1);

                            var eventLocationIds = new ArrayList();
                            foreach (EventInfo lstEvent in lstEvents)
                            {
                                eventLocationIds.Add(lstEvent.Location);
                            }
                            foreach (EventLocationInfo lstLocation in lstLocations)
                            {
                                if (!eventLocationIds.Contains(lstLocation.Location))
                                {
                                    arrLocations.Remove(lstLocation);
                                }
                            }
                        }
                    }

                    //Bind locations.
                    ddlLocations.DataSource = arrLocations;
                    ddlLocations.DataBind();

                    if (Settings.Enablelocations == EventModuleSettings.DisplayLocations.SingleSelect)
                    {
                        ddlLocations.Items.Insert(
                            0,
                            new RadComboBoxItem(Localization.GetString("AllLocations", LocalResourceFile),
                                                "-1"));
                        ddlLocations.SelectedIndex = 0;
                    }
                    ddlLocations.OnClientDropDownClosed =
                        "function() { btnUpdateClick('" + btnUpdate.UniqueID + "','" + ddlLocations.ClientID +
                        "');}";
                    ddlLocations.OnClientLoad = "function() { storeText('" + ddlLocations.ClientID + "');}";
                    if (Settings.Enablelocations == EventModuleSettings.DisplayLocations.SingleSelect)
                    {
                        foreach (int location in SelectedLocation)
                        {
                            ddlLocations.SelectedIndex =
                                ddlLocations.FindItemByValue(location.ToString()).Index;
                            break;
                        }
                    }
                    else
                    {
                        foreach (int location in SelectedLocation)
                        {
                            foreach (RadComboBoxItem item in ddlLocations.Items)
                            {
                                if (item.Value == location.ToString())
                                {
                                    item.Checked = true;
                                }
                            }
                        }

                        if (Convert.ToInt32(SelectedLocation[0]) == -1)
                        {
                            foreach (RadComboBoxItem item in ddlLocations.Items)
                            {
                                item.Checked = true;
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
                //ProcessModuleLoadException(Me, exc)
            }
        }