Exemplo n.º 1
0
    /// <summary>
    /// Load all users
    /// </summary>
    private void LoadUsers()
    {
        School   school   = null;
        Category category = null;
        RoleType role     = RoleType.All;
        Region   region   = null;
        Area     area     = null;

        if (ddlSearchRegion.SelectedValue != "-1")
        {
            region = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
        }
        if (ddlCategories.SelectedValue != "-1")
        {
            category = CategoryService.GetCategory(region, ddlCategories.SelectedValue);
        }
        if (ddlSearchArea.SelectedValue != "-1")
        {
            area = RegionService.GetArea(region, ddlSearchArea.SelectedValue);
        }
        if (ddlSearchSchool.SelectedValue != "-1")
        {
            school = RegionService.GetSchool(ddlSearchSchool.SelectedValue);
        }
        if (ddlUserType.SelectedValue != "-1")
        {
            role = (RoleType)Convert.ToInt32(ddlUserType.SelectedValue);
        }
        string orderby           = (SortDirection == SortDirection.Ascending) ? " order by " + SortColumn + " ASC " : " order by " + SortColumn + " DESC ";
        IList <DisplayUser> list = UserService.GetAllUsers(region, area, school, category, txtSearchUserName.Text, role, orderby);

        gvUsers.DataSource = list;
        gvUsers.DataBind();
        lblRecCount.Text = string.Format("{0:d} users found", list.Count);
    }
Exemplo n.º 2
0
 protected void btnFinal_Click(object sender, EventArgs e)
 {
     if (ddlStatus.SelectedValue != "-1")
     {
         Status status   = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue);
         string title    = DateTime.Now.Year.ToString() + " ";
         string fileName = string.Empty;
         if (ddlArea.SelectedValue != "-1")
         {
             Area area = RegionService.GetArea(ddlArea.SelectedValue);
             fileName = Path.Combine(Path.GetTempPath(), area.Name + ".pdf");
             title    = DateTime.Now.Year.ToString() + " " + area.Name + " Area Finalists";
             ReportService.CreateFinalistReport(fileName, status, area, title);
         }
         else
         {
             Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
             title   += region.Name + " Finalists";
             fileName = Path.Combine(Path.GetTempPath(), "report.pdf");
             ReportService.CreateFinalistReport(fileName, status, null, title);
         }
         byte[] buf = FileUtils.LoadFile(fileName);
         Response.Clear();
         Response.ContentType = "application/zip";
         Response.AddHeader("Content-Disposition", "attachment; filename=" + System.IO.Path.GetFileName(fileName));
         Response.AddHeader("Content-Length", buf.Length.ToString());
         Response.BinaryWrite(buf);
         Response.End();
         System.IO.File.Delete(fileName);
     }
 }
Exemplo n.º 3
0
    protected void btnSave_Click(object sender, EventArgs e)
    {
        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;

        UserInput input = new UserInput();

        input.Id       = Convert.ToInt32(lblId.Text);
        input.FullName = txtFullName.Text;
        input.EMail    = txtEmail.Text;
        input.Comment  = txtComment.Text;
        input.Phone    = txtPhone.Text;
        input.Role     = (RoleType)Convert.ToInt32(ddlRoleType.SelectedValue);

        if (input.Role == RoleType.RegionAdministrator)
        {
            Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
            input.Area = RegionService.GetArea(region, ddlArea.SelectedValue);
        }
        if (input.Role == RoleType.AreaJudge | input.Role == RoleType.RegionJudge)
        {
            input.Area     = RegionService.GetArea(ddlArea.SelectedValue);
            input.Category = CategoryService.GetCategory(input.Area.Region, ddlCategory.SelectedValue);
        }
        else if (input.Role == RoleType.Coordinator | input.Role == RoleType.Principal | input.Role == RoleType.Nominee)
        {
            input.School = RegionService.GetSchool(ddlSchool.SelectedValue);
            if (input.Role == RoleType.Nominee)
            {
                input.Category = CategoryService.GetCategory(input.Area.Region, ddlCategory.SelectedValue);
            }
        }

        MembershipCreateStatus status = UserService.AddNewUser(input);

        if (status == MembershipCreateStatus.DuplicateEmail)
        {
            labCustomError.Text    = "The email address is a duplicate, please enter a different email address";
            labCustomError.Visible = true;
        }
        else
        {
            User user = UserService.GetUser(input.EMail);
            if (input.Id <= 0)
            {
                UserService.SendUserEmail(user, "Sterling Scholar Registration Request", System.Web.HttpContext.Current.Server.MapPath("~/") + "/assets/NewUserTemplate.html");
            }
            modalDialog.HideModal();
        }
    }
Exemplo n.º 4
0
 protected void ddlArea_OnSelectedIndexChanged(object sender, EventArgs e)
 {
     if (!"-1".Equals(ddlArea.SelectedValue))
     {
         Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
         Area   area   = RegionService.GetArea(region, ((DropDownList)sender).SelectedValue);
         LoadSchools(area);
     }
 }
Exemplo n.º 5
0
    private void LoadAreas(Region region)
    {
        ddlArea.DataMember    = "Id";
        ddlArea.DataTextField = "Name";
        ddlArea.DataSource    = region.Areas;
        ddlArea.DataBind();
        if (CurrentUser.Role == RoleType.Administrator)
        {
            ddlArea.Items.Insert(0, new ListItem("All", "-1"));
        }
        Area area = RegionService.GetArea(region, ddlArea.SelectedValue);

        LoadSchools(area);
    }
Exemplo n.º 6
0
    private IList <Portfolio> GetPortfolios()
    {
        School   school   = null;
        Category category = null;
        Region   region   = null;

        string where = " where 1=1 ";

        if (ddlRegion.SelectedValue != "-1")
        {
            region = RegionService.GetRegion(ddlRegion.SelectedValue);
            where += " and p.School.Area.Region.Id = " + region.Id;
        }
        if (ddlCategories.SelectedValue != "-1" && null != region)
        {
            category = CategoryService.GetCategory(region, ddlCategories.SelectedValue);
            where   += " and p.Category.Id = " + category.Id;
        }

        if (ddlArea.SelectedValue != "-1" && null != region)
        {
            Area area = null;
            if (null != region)
            {
                area = RegionService.GetArea(region, ddlArea.SelectedValue);
            }
            where += " and p.School.Area.Id = " + area.Id;
        }
        if (ddlSchools.SelectedValue != "-1")
        {
            school = RegionService.GetSchool(ddlSchools.SelectedValue);
            where += " and p.School.Id = " + school.Id;
        }

        if (ddlStatus.SelectedValue != "-1")
        {
            Status status = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue);
            where += " and p.Status = " + (int)status;
        }
        string            orderby = (SortDirection == SortDirection.Ascending) ? " order by " + SortColumn + " ASC " : " order by " + SortColumn + " DESC ";
        IList <Portfolio> list    = PortfolioService.GetPortfolios(where + orderby);

        return(list);
    }
Exemplo n.º 7
0
 private void LoadSchools()
 {
     if (!"-1".Equals(ddlSearchRegion.SelectedValue))
     {
         Region         region  = RegionService.GetRegion(ddlSearchRegion.SelectedValue);
         Area           area    = RegionService.GetArea(region, ddlSearchArea.SelectedValue);
         IList <School> schools = RegionService.GetSchools(area);
         ddlSearchSchool.DataSource    = schools;
         ddlSearchSchool.DataMember    = "Id";
         ddlSearchSchool.DataTextField = "Name";
         ddlSearchSchool.DataBind();
         ddlSearchSchool.Items.Insert(0, new ListItem("All", "-1"));
     }
     else
     {
         ddlSearchSchool.DataSource = null;
         ddlSearchSchool.DataBind();
         ddlSearchSchool.Items.Insert(0, new ListItem("All", "-1"));
     }
 }
Exemplo n.º 8
0
    private string GetWhereClause()
    {
        School   school   = null;
        Category category = null;
        Region   region   = null;

        string where = " where 1=1 ";
        if (ddlRegion.SelectedValue != "-1")
        {
            region = RegionService.GetRegion(ddlRegion.SelectedValue);
            where += " and p.School.Area.Region.Id = " + region.Id;
        }
        if (ddlCategories.SelectedValue != "-1")
        {
            category = CategoryService.GetCategory(region, ddlCategories.SelectedValue);
            where   += " and p.Category.Id = " + category.Id;
        }

        if (ddlArea.SelectedValue != "-1")
        {
            Area area = RegionService.GetArea(ddlArea.SelectedValue);
            where += " and p.School.Area.Id = " + area.Id;
        }
        if (ddlSchools.SelectedValue != "-1")
        {
            school = RegionService.GetSchool(ddlSchools.SelectedValue);
            where += " and p.School.Id = " + school.Id;
        }

        if (ddlStatus.SelectedValue != "-1")
        {
            Status status = (Status)Enum.Parse(typeof(Status), ddlStatus.SelectedValue);
            where += " and p.Status = " + (int)status;
        }


        return(where);
    }
Exemplo n.º 9
0
    protected void ddlArea_OnSelectedIndexChanged(object sender, EventArgs e)
    {
        Area area = RegionService.GetArea(((DropDownList)sender).SelectedValue);

        LoadSchools(area);
    }
Exemplo n.º 10
0
    private void ShowDropDowns(RoleType role)
    {
        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        labRole     = modalDialog.FindControl("labRole") as Label;
        Label        labSchool   = modalDialog.FindControl("labSchool") as Label;
        Label        labRegion   = modalDialog.FindControl("labRegion") as Label;
        Label        labArea     = modalDialog.FindControl("labArea") as Label;
        Label        labCategory = modalDialog.FindControl("labCategory") as Label;

        if (role == RoleType.AreaJudge | role == RoleType.RegionJudge)
        {
            ddlRegion.Visible   = true;
            ddlArea.Visible     = (role == RoleType.AreaJudge);
            labArea.Visible     = (role == RoleType.AreaJudge);
            ddlSchool.Visible   = false;
            labSchool.Visible   = false;
            ddlCategory.Visible = true;
            labCategory.Visible = true;
        }
        else if (role == RoleType.Coordinator | role == RoleType.Principal)
        {
            ddlRegion.Visible   = true;
            labRegion.Visible   = true;
            ddlArea.Visible     = true;
            labArea.Visible     = true;
            ddlSchool.Visible   = true;
            labSchool.Visible   = true;
            ddlCategory.Visible = false;
            labCategory.Visible = false;
            Area area = RegionService.GetArea(ddlArea.SelectedValue);
            LoadSchools(area);
        }
        else if (role == RoleType.Administrator)
        {
            ddlRegion.Visible   = false;
            ddlArea.Visible     = false;
            ddlCategory.Visible = false;
            ddlSchool.Visible   = false;
            labSchool.Visible   = false;
            labRegion.Visible   = false;
            labArea.Visible     = false;
            labCategory.Visible = false;
        }
        else if (role == RoleType.RegionAdministrator)
        {
            ddlRegion.Visible   = true;
            ddlArea.Visible     = true;
            ddlCategory.Visible = false;
            ddlSchool.Visible   = false;
            labSchool.Visible   = false;
            labRegion.Visible   = true;
            labArea.Visible     = true;
            labCategory.Visible = false;
        }
        else if (role == RoleType.Nominee)
        {
            ddlRegion.Visible   = true;
            labRegion.Visible   = true;
            ddlArea.Visible     = true;
            labArea.Visible     = true;
            ddlSchool.Visible   = true;
            labSchool.Visible   = true;
            ddlCategory.Visible = true;
            labCategory.Visible = true;
            Region region = RegionService.GetRegion(ddlRegion.SelectedValue);
            Area   area   = RegionService.GetArea(region, ddlArea.SelectedValue);
            LoadSchools(area);
        }
    }