示例#1
0
 private void LoadAreas()
 {
     if (!"-1".Equals(ddlSearchRegion.SelectedValue))
     {
         Region region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
         ddlSearchArea.DataSource    = RegionService.GetAreas(region);
         ddlSearchArea.DataMember    = "Id";
         ddlSearchArea.DataTextField = "Name";
         ddlSearchArea.DataBind();
         if (region.Areas.Count > 1)
         {
             ddlSearchArea.Items.Insert(0, new ListItem("All", "-1"));
         }
         ddlCategories.DataSource    = CategoryService.GetCategories(region);
         ddlCategories.DataMember    = "Id";
         ddlCategories.DataTextField = "Name";
         ddlCategories.DataBind();
         ddlCategories.Items.Insert(0, new ListItem("All", "-1"));
     }
     else
     {
         ddlSearchArea.DataSource = null;
         ddlSearchArea.DataBind();
         ddlCategories.DataSource = null;
         ddlCategories.DataBind();
         ddlSearchArea.Items.Insert(0, new ListItem("All", "-1"));
         ddlCategories.Items.Insert(0, new ListItem("All", "-1"));
     }
 }
示例#2
0
    private void EditUser(int id)
    {
        UserInput input = UserService.GetUserProfile(id);

        Label        lblId          = modalDialog.FindControl("lblId") as Label;
        TextBox      txtFullName    = modalDialog.FindControl("txtFullName") as TextBox;
        TextBox      txtEmail       = modalDialog.FindControl("txtEmail") as TextBox;
        TextBox      txtComment     = modalDialog.FindControl("txtComment") as TextBox;
        TextBox      txtPhone       = modalDialog.FindControl("txtPhone") as TextBox;
        DropDownList ddlRoleType    = modalDialog.FindControl("ddlRoleType") as DropDownList;
        DropDownList ddlRegion      = modalDialog.FindControl("ddlRegion") as DropDownList;
        DropDownList ddlArea        = modalDialog.FindControl("ddlArea") as DropDownList;
        DropDownList ddlCategory    = modalDialog.FindControl("ddlCategory") as DropDownList;
        DropDownList ddlSchool      = modalDialog.FindControl("ddlSchool") as DropDownList;
        Label        labCustomError = modalDialog.FindControl("labCustomError") as Label;

        labCustomError.Text    = "";
        labCustomError.Visible = false;
        lblId.Text             = id.ToString();
        txtFullName.Text       = input.FullName;
        txtEmail.Text          = input.EMail;
        txtComment.Text        = input.Comment;
        txtPhone.Text          = input.Phone;
        int i = 0;

        ddlRoleType.Items.Clear();
        ddlRegion.Items.Clear();
        ddlArea.Items.Clear();
        ddlCategories.Items.Clear();
        ddlSchool.Items.Clear();


        Region region = null;

        if (CurrentUser.Role == RoleType.Administrator)
        {
            ddlRoleType.Items.Insert(i++, new ListItem("Administrator", "0", true));
            ddlRegion.DataMember    = "Id";
            ddlRegion.DataTextField = "Name";
            IList <Region> regions = RegionService.GetRegions();
            ddlRegion.DataSource = regions;
            ddlRegion.DataBind();
            region = regions[0];
        }
        else if (CurrentUser.Role == RoleType.RegionAdministrator)
        {
            AreaUser au = UserService.GetAreaUser(CurrentUser);
            ddlRegion.Items.Insert(0, new ListItem(au.Area.Region.Name, au.Area.Region.Name));
            region = au.Area.Region;
        }
        if (id == -1)
        {
            input.Role = RoleType.Nominee;
        }

        ddlRoleType.Items.Insert(i++, new ListItem("Region Administrator", "7"));
        ddlRoleType.Items.Insert(i++, new ListItem("School Coordinator", "1", true));
        ddlRoleType.Items.Insert(i++, new ListItem("Area Judge", "2"));
        ddlRoleType.Items.Insert(i++, new ListItem("Region Judge", "3", true));
        ddlRoleType.Items.Insert(i++, new ListItem("Nominee", "4"));
        ddlRoleType.Items.Insert(i++, new ListItem("Principal", "5", true));
        ddlRoleType.SelectedValue = Convert.ToInt32(input.Role).ToString();

        if (null != input && null != input.Area && input.Id > 0)
        {
            ddlRegion.SelectedValue = input.Area.Region.Name;
            ddlArea.DataMember      = "Id";
            ddlArea.DataTextField   = "Name";
            ddlArea.DataSource      = RegionService.GetAreas(input.Area.Region);
            ddlArea.DataBind();
            ddlArea.SelectedValue     = input.Area.Name;
            ddlCategory.DataMember    = "Id";
            ddlCategory.DataTextField = "Name";
            ddlCategory.DataSource    = CategoryService.GetCategories(input.Area.Region);
            ddlCategory.DataBind();
            if (null != input.Category)
            {
                ddlCategory.SelectedValue = input.Category.Name;
            }
            LoadSchools(input.Area);
            if (null != input.School)
            {
                ddlSchool.SelectedValue = input.School.Name;
            }
        }
        else
        {
            ddlRegion.SelectedValue = region.Name;
            ddlArea.DataMember      = "Id";
            ddlArea.DataTextField   = "Name";
            ddlArea.DataSource      = RegionService.GetAreas(region);
            ddlArea.DataBind();
            ddlArea.SelectedValue = region.Areas[0].Name;

            ddlCategory.DataMember    = "Id";
            ddlCategory.DataTextField = "Name";
            ddlCategory.DataSource    = CategoryService.GetCategories(region);
            ddlCategory.DataBind();
        }

        ShowDropDowns(input.Role);
        modalDialog.ShowModal();
    }