示例#1
0
    protected void LoadView()
    {
        string[] itemNames  = Enum.GetNames(typeof(NotificationGroupsEnum));
        Array    itemValues = Enum.GetValues(typeof(NotificationGroupsEnum)).Cast <int>().ToArray();

        for (int i = 0; i <= itemValues.Length - 1; i++)
        {
            string   localizationValue = NotificationStrings.GetText(itemNames[i]);
            ListItem item = new ListItem(localizationValue, itemValues.GetValue(i).ToString());
            ddlFilteringGroup.Items.Add(item);
        }
        ddlFilteringGroup.DataBind();
        var animals = AnimalCollection.FetchAll();

        animals.Add(new Animal {
            AnimalId = 0, AnimalName = "All"
        });
        ddlAnimalType.DataSource     = animals.OrderBy(x => x.AnimalId);
        ddlAnimalType.DataValueField = "AnimalId";
        ddlAnimalType.DataTextField  = "AnimalName";
        ddlAnimalType.DataBind();

        var areas = AreaCollection.FetchAll();

        areas.Add(new Area {
            AreaId = 0, AreaName = "All"
        });
        ddlArea.DataSource     = areas.OrderBy(x => x.AreaId);
        ddlArea.DataValueField = "AreaId";
        ddlArea.DataTextField  = "AreaName";
        ddlArea.DataBind();

        if (FilterId > 0)
        {
            var notificationFilter = NotificationFilter.FetchByID(FilterId);

            ddlArea.SelectedValue           = notificationFilter.AreaId.ToString();
            txtFromDate.Text                = notificationFilter.FromDate.ToString();
            txtToDate.Text                  = notificationFilter.ToDate.ToString();
            txtMaxFrequency.Text            = notificationFilter.MaxFrequency.ToString();
            txtMinFrequency.Text            = notificationFilter.MinFrequency.ToString();
            txtName.Text                    = notificationFilter.Name;
            txtPriority.Text                = notificationFilter.Priority.ToString();
            ddlAnimalType.SelectedValue     = notificationFilter.AnimalTypeId.ToString();
            ddlFilteringGroup.SelectedValue = ((int)notificationFilter.Group).ToString();
            txtMessage.Text                 = notificationFilter.MessageTemplate;
            txtRunEvery.Text                = notificationFilter.RunEvery.ToString();
            cbIsAuto.Checked                = notificationFilter.IsAuto;

            if (!string.IsNullOrEmpty(notificationFilter.AdImageUrl))
            {
                HomeImage.ImageUrl = MediaUtility.GetImagePath("Banners", notificationFilter.AdImageUrl, 0, 64, 64);
                HomeImage.ImageUrl = HomeImage.ImageUrl.Contains(".") ? HomeImage.ImageUrl : "";
                ImageFileHandler(fuImage, HomeImage, btnDeleteImage, HomeImage.ImageUrl);
            }
        }
    }