protected void OnBtnSaveClicked(object sender, EventArgs e)
    {
        CandidateTelephoneRepository repo = new CandidateTelephoneRepository();
        CandidateTelephone saveItem = GetCadidateTelephone();
        if (string.IsNullOrEmpty(Request.QueryString["TelePhoneId"]))
        {
            if (!string.IsNullOrEmpty(Request.QueryString["candidateID"]))
            {
                //Insert new record
                repo.Insert(saveItem);
            }
            else
            {
                //save to session
                List<CandidateTelephone> list = SessionManager.NewCandidateTelephoneList;
                saveItem.TelePhoneId = 0 - list.Count - 2;
                list.Add(saveItem);
                SessionManager.NewCandidateTelephoneList = list;
            }
        }
        else
        {
            int telephoneID = int.Parse(Request.QueryString["TelePhoneId"]);
            if (telephoneID > 0)//existed in database
            {
                //Update the record.
                saveItem.TelePhoneId = telephoneID;
                repo.Update(saveItem);
            }
            else //get from session data
            {
                List<CandidateTelephone> list = SessionManager.NewCandidateTelephoneList;
                CandidateTelephone existedItem = list.Find(delegate(CandidateTelephone t) { return t.TelePhoneId == telephoneID; });
                if (existedItem != null)
                {
                    int index = list.IndexOf(existedItem);
                    list.Remove(existedItem);
                    saveItem.TelePhoneId = existedItem.TelePhoneId;
                    list.Insert(index, saveItem);
                    SessionManager.NewCandidateTelephoneList = list;
                }
            }
        }
        string script = "<script type=\"text/javascript\">";
        script += " OnBtnSaveClientClicked();";
        script += " </script>";

        if (!ClientScript.IsClientScriptBlockRegistered("redirectUser"))
            ClientScript.RegisterStartupScript(this.GetType(), "redirectUser", script);

        //this.Page.ClientScript.RegisterStartupScript(this.GetType(), this.Page.ClientID, script);
    }
Esempio n. 2
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>();
            }
        }
    }
Esempio n. 3
0
 protected void OnCandidateContactDeleteClicked(object sender, EventArgs e)
 {
     LinkButton lnkItem = (LinkButton)sender;
     int canTelephonID = int.Parse(lnkItem.CommandArgument);
     if (canTelephonID > 0) //existed in database
     {
         CandidateTelephone deleteItem = new CandidateTelephone(canTelephonID);
         CandidateTelephoneRepository repo = new CandidateTelephoneRepository();
         repo.Delete(deleteItem);
     }
     else
     {
         List<CandidateTelephone> list = SessionManager.NewCandidateTelephoneList;
         CandidateTelephone existedItem = list.Find(delegate(CandidateTelephone t) { return t.TelePhoneId == canTelephonID; });
         if (existedItem != null)
         {
             list.Remove(existedItem);
             SessionManager.NewCandidateTelephoneList = list;
         }
     }
     BindContactGridOfCurrentCandidate(null);
 }
Esempio n. 4
0
    /// <summary>
    /// save the candidate telephone in case adding a new candidate
    /// </summary>
    private void SaveContactTelephone(Candidate candidate)
    {
        if (SessionManager.NewCandidateTelephoneList != null && SessionManager.NewCandidateTelephoneList.Count > 0)
        {
            foreach (CandidateTelephone phone in SessionManager.NewCandidateTelephoneList)
            {
                CandidateTelephoneRepository phoneRepo = new CandidateTelephoneRepository();

                phone.CandidateID = candidate.CandidateId;
                phoneRepo.Insert(phone);
            }
        }
    }
Esempio n. 5
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();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (SessionManager.CurrentUser == null)
        {
            Common.RedirectToLoginPage(this);
            return;
        }
        else if (!IsPostBack)
        {
            FillLabelLanguage();
            InitControls();
            ddlType.Items.Add(new RadComboBoxItem(ResourceManager.GetString("candidateContactPhone"), "T"));
            ddlType.Items.Add(new RadComboBoxItem(ResourceManager.GetString("candidateContactFax"), "F"));
            ddlType.Items.Add(new RadComboBoxItem(ResourceManager.GetString("candidateContactMobile"), "G"));
            ddlType.Items.Add(new RadComboBoxItem(ResourceManager.GetString("candidateContactEmail"), "E"));

        }
        if (!string.IsNullOrEmpty(Request.QueryString["TelePhoneId"]))
        {
            if (!IsPostBack)
            {
                CandidateTelephone telephone = new CandidateTelephone();
                int telephoneID = int.Parse(Request.QueryString["TelePhoneId"]);
                if (telephoneID > 0) //existed in database
                {
                    CandidateTelephoneRepository repo = new CandidateTelephoneRepository();
                    telephone = repo.FindOne(new CandidateTelephone(telephoneID));

                }
                else //get from session data
                {
                    telephone = SessionManager.NewCandidateTelephoneList.Find(delegate(CandidateTelephone t) { return t.TelePhoneId == telephoneID; });
                }

                ddlType.SelectedValue = telephone.Type;
                txtZone.Text = telephone.PhoneArea;
                txtPhoneMail.Text = telephone.PhoneMail;
                txtPlace.Text = telephone.Location;
            }
        }
    }
 private CandidateTelephone GetCadidateTelephone()
 {
     CandidateTelephone saveItem = new CandidateTelephone();
     if (!string.IsNullOrEmpty(Request.QueryString["TelePhoneId"]))
     {
         int telId = int.Parse(Request.QueryString["TelePhoneId"]);
         if (telId > 0)
         {
             saveItem = new CandidateTelephoneRepository().FindOne(new CandidateTelephone(telId));
         }
     }
     if (!string.IsNullOrEmpty(Request.QueryString["candidateID"]))
         saveItem.CandidateID = Convert.ToInt32(Request.QueryString["candidateID"]);
     saveItem.Type = ddlType.SelectedValue;
     saveItem.TypeLabel = ddlType.Text;
     saveItem.PhoneArea = txtZone.Text.Trim();
     saveItem.PhoneMail = txtPhoneMail.Text.Trim();
     saveItem.Location = txtPlace.Text.Trim();
     return saveItem;
 }
 private IList<Candidate> FillContactInfo(IList<Candidate> candidateList)
 {
     foreach (Candidate item in candidateList)
     {
         item.ContactInfo = string.Empty;
         item.ContactInfoFull = string.Empty;
         IList<CandidateTelephone> contactList =
             new CandidateTelephoneRepository().GetCandidateTelephonesByCandidateID(item.CandidateId);
         foreach (CandidateTelephone contact in contactList)
         {
             if (!string.IsNullOrEmpty(contact.Type))
             {
                 if (contact.Type == "T")
                 {
                     item.ContactInfoFull += ResourceManager.GetString("candidateContactPhone")
                         + ": " + contact.PhoneMail + "<br />";
                     if (item.ContactInfo == string.Empty)
                         item.ContactInfo = ResourceManager.GetString("candidateContactPhone") + ": " + contact.PhoneMail;
                 }
                 else if (contact.Type == "F")
                 {
                     item.ContactInfoFull += ResourceManager.GetString("candidateContactFax")
                         + ": " + contact.PhoneMail + "<br />";
                     if (item.ContactInfo == string.Empty)
                         item.ContactInfo = ResourceManager.GetString("candidateContactFax") + ": " + contact.PhoneMail;
                 }
                 else if (contact.Type == "G")
                 {
                     item.ContactInfoFull += ResourceManager.GetString("candidateContactMobile")
                         + ": " + contact.PhoneMail + "<br />";
                     if (item.ContactInfo == string.Empty)
                         item.ContactInfo = ResourceManager.GetString("candidateContactMobile") + ": " + contact.PhoneMail;
                 }
                 else if (contact.Type == "E")
                 {
                     item.ContactInfoFull += ResourceManager.GetString("candidateContactEmail")
                         + ": " + contact.PhoneMail + "<br />";
                     if (item.ContactInfo == string.Empty)
                         item.ContactInfo = ResourceManager.GetString("candidateContactEmail") + ": " + contact.PhoneMail;
                 }
             }
         }
     }
     return candidateList;
 }