Beispiel #1
0
    /// <summary>
    /// Binds all Sales Rep Drop Down
    /// </summary>
    private void BindSalesRepDropDown()
    {
        //Fill salesrep dropdown

        var currentOrgRole = IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole;

        if (currentOrgRole.CheckRole((long)Roles.FranchisorAdmin) || currentOrgRole.CheckRole((long)Roles.FranchiseeAdmin))
        {
            spanSalesPerson.Style.Add(HtmlTextWriterStyle.Display, "block");
        }
        else
        {
            spanSalesPerson.Style.Add(HtmlTextWriterStyle.Display, "none");
        }

        ISalesRepresentativeRepository salesRepRepo = new SalesRepresentativeRepository();
        List <SalesRepresentative>     salesReps    = null;

        if (currentOrgRole.CheckRole((long)Roles.FranchiseeAdmin))
        {
            salesReps = salesRepRepo.GetSalesRepresentativesForFranchisee(IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole.OrganizationId);
        }
        else if (currentOrgRole.CheckRole((long)Roles.FranchisorAdmin))
        {
            salesReps = salesRepRepo.GetAllSalesRepresentatives();
        }

        if (salesReps != null)
        {
            ddlSalesPerson.DataSource     = salesReps;
            ddlSalesPerson.DataTextField  = "NameAsString";
            ddlSalesPerson.DataValueField = "Id";
            ddlSalesPerson.DataBind();
            ddlSalesPerson.Items.Insert(0, new ListItem("All", "0"));
        }

        hidUserId.Value = IoC.Resolve <ISessionContext>().UserSession.UserId.ToString();
        if (FranchiseeView == false)
        {
            if (ddlSalesPerson.Items.FindByValue(hidUserId.Value) != null)
            {
                ddlSalesPerson.Items.FindByValue(hidUserId.Value).Selected = true;
                ddlSalesPerson.Enabled           = false;
                _spnDistance.Attributes["class"] = "titletext_default";
            }
        }
        hidRole.Value = IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole.RoleAlias;
    }
Beispiel #2
0
    private void BindSalesRepOnTerritory()
    {
        long franchiseeId = 0;

        var userSession = IoC.Resolve <ISessionContext>().UserSession;

        if (userSession.CurrentOrganizationRole.CheckRole((long)Roles.SalesRep))
        {
            var franchiseeDAL = new FranchiseeDAL();
            var franchisee    = franchiseeDAL.GetAllSalesRepOnTerritory(userSession.CurrentOrganizationRole.OrganizationRoleUserId);

            if (franchisee.Count > 0)
            {
                _assignedTo.Items.Add(new ListItem("ALL", "0"));
                foreach (EFranchiseeFranchiseeUser t in franchisee)
                {
                    _assignedTo.Items.Add(new ListItem(t.FranchiseeUser.User.FirstName + " " + t.FranchiseeUser.User.LastName, t.FranchiseeFranchiseeUserID.ToString()));
                }
            }
            else
            {
                franchiseeId = userSession.CurrentOrganizationRole.OrganizationId;

                _assignedTo.Items.Add(new ListItem("ALL", "0"));
                try
                {
                    ISalesRepresentativeRepository _salesRepresentativeRepository = new SalesRepresentativeRepository();
                    List <SalesRepresentative>     salesRepresentatives           = _salesRepresentativeRepository.
                                                                                    GetSalesRepresentativesForFranchisee(franchiseeId).OrderBy(sr => sr.Name.FullName).ToList();
                    for (int count = 0; count < salesRepresentatives.Count; count++)
                    {
                        _assignedTo.Items.Add(new ListItem(salesRepresentatives[count].Name.FullName, salesRepresentatives[count].SalesRepresentativeId.ToString()));
                    }
                }
                catch
                { }
            }
            _spnAssignedTo.Style.Add(HtmlTextWriterStyle.Display, "block");
        }
        else
        {
            // Hide drop down
            _spnAssignedTo.Style.Add(HtmlTextWriterStyle.Display, "none");
        }
    }
    private void LoadSalesRepDropDownList()
    {
        long franchiseeId = IoC.Resolve <ISessionContext>().UserSession.CurrentOrganizationRole.OrganizationId;
        ISalesRepresentativeRepository salesRepresentativeRepository =
            new SalesRepresentativeRepository();

        List <SalesRepresentative> salesRepresentatives = salesRepresentativeRepository.
                                                          GetSalesRepresentativesForFranchisee(franchiseeId).OrderBy(sr => sr.Name.FullName).ToList();
        var namesAndIds = salesRepresentatives.Select(s => new { s.Name.FullName, s.SalesRepresentativeId });

        if (namesAndIds.Count() > 0)
        {
            ddlSalesPerson.DataSource     = namesAndIds;
            ddlSalesPerson.DataTextField  = "FullName";
            ddlSalesPerson.DataValueField = "SalesRepresentativeId";
            ddlSalesPerson.DataBind();
            ddlSalesPerson.Items.Insert(0, new ListItem("Select SalesRep", "0"));
        }
        else
        {
            ddlSalesPerson.Items.Add(new ListItem("Select SalesRep", "0"));
        }
    }
Beispiel #4
0
    private List <SalesRepresentative> GetSalesRepresentativesForFranchisee(long franchiseeId)
    {
        ISalesRepresentativeRepository salesRepresentativeRepository = new SalesRepresentativeRepository();

        return(franchiseeId == 0 ? salesRepresentativeRepository.GetAllSalesRepresentatives() : salesRepresentativeRepository.GetSalesRepresentativesForFranchisee(franchiseeId));
    }