コード例 #1
0
    protected void OnGridContactNeedDataSource(object source, GridNeedDataSourceEventArgs e)
    {
        int candidateID = -1;
        if (!string.IsNullOrEmpty(Request.QueryString["CandidateId"]))
            candidateID = Int32.Parse(Request.QueryString["CandidateId"]);
        else if (SessionManager.CurrentCandidate != null)
            candidateID = SessionManager.CurrentCandidate.CandidateId;

        if (candidateID != -1)
        {
            CandidateTelephoneRepository repo = new CandidateTelephoneRepository();
            IList<CandidateTelephone> contactList = repo.GetCandidateTelephonesByCandidateID(candidateID);
            foreach (CandidateTelephone item in contactList)
            {
                if (!string.IsNullOrEmpty(item.Type))
                {
                    if (item.Type == "T")
                        item.TypeLabel = ResourceManager.GetString("candidateContactPhone");
                    else if (item.Type == "F")
                        item.TypeLabel = ResourceManager.GetString("candidateContactFax");
                    else if (item.Type == "G")
                        item.TypeLabel = ResourceManager.GetString("candidateContactMobile");
                    else if (item.Type == "E")
                        item.TypeLabel = ResourceManager.GetString("candidateContactEmail");
                }
            }
            gridContact.DataSource = contactList;
        }
        else
        {
            if (string.IsNullOrEmpty(Request.QueryString["CandidateId"]))
            {
                gridContact.DataSource = SessionManager.NewCandidateTelephoneList;//new List<CandidateTelephone>();
            }
        }
    }
コード例 #2
0
    private void BindContactGridOfCurrentCandidate(Candidate currentCandidate)
    {
        int candidateID = -1;
        if (!string.IsNullOrEmpty(Request.QueryString["CandidateId"]))
            candidateID = Int32.Parse(Request.QueryString["CandidateId"]);
        else if (SessionManager.CurrentCandidate != null)
            candidateID = SessionManager.CurrentCandidate.CandidateId;
        else if (currentCandidate != null)
            candidateID = currentCandidate.CandidateId;

        if (candidateID != -1)
        {
            CandidateTelephoneRepository repo = new CandidateTelephoneRepository();
            IList<CandidateTelephone> contactList = repo.GetCandidateTelephonesByCandidateID(candidateID);
            foreach (CandidateTelephone item in contactList)
            {
                if (!string.IsNullOrEmpty(item.Type))
                {
                    if (item.Type == "T")
                        item.TypeLabel = ResourceManager.GetString("candidateContactPhone");
                    else if (item.Type == "F")
                        item.TypeLabel = ResourceManager.GetString("candidateContactFax");
                    else if (item.Type == "G")
                        item.TypeLabel = ResourceManager.GetString("candidateContactMobile");
                    else if (item.Type == "E")
                        item.TypeLabel = ResourceManager.GetString("candidateContactEmail");
                }
            }
            gridContact.DataSource = contactList;
        }
        else //creating a new candidate
        {
            if (SessionManager.NewCandidateTelephoneList != null)
            {
                gridContact.DataSource = SessionManager.NewCandidateTelephoneList;
            }
            else
                gridContact.DataSource = new List<CandidateTelephone>();
        }
        gridContact.DataBind();
    }