private IList<CandidateKnowledge> CopyCanKnowledgeList(IList<CandidateKnowledge> sourceList)
 {
     IList<CandidateKnowledge> result = new List<CandidateKnowledge>();
     foreach (CandidateKnowledge item in sourceList)
     {
         CandidateKnowledge newItem = new CandidateKnowledge();
         newItem.CandidateKnowledgeID = item.CandidateKnowledgeID;
         newItem.CandidateID = item.CandidateID;
         newItem.Code = item.Code;
         newItem.KnowledgeID = item.KnowledgeID;
         newItem.Group = item.Group;
         newItem.Type = item.Type;
         result.Add(newItem);
     }
     return result;
 }
    protected void OnBtnKnowFuncAddClicked(object sender, EventArgs e)
    {
        if (lblKnowFuncDestination.Text == ResourceManager.GetString("lblCanFunctionGrid"))
        {
            for (int i = listKnowFuncOriginal.Items.Count - 1; i >= 0; i--)
            {
                ListItem selectedItem = listKnowFuncOriginal.Items[i];
                if (selectedItem.Selected)
                {
                    string value = selectedItem.Value;

                    bool itemExist = false;
                    foreach (CandidateFunction oldItem in SessionManager.CanFunctionDesList)
                    {
                        if (oldItem.FunctionID.Value.ToString() == value)
                        {
                            itemExist = true;
                        }
                    }
                    if (!itemExist)
                    {
                        CandidateFunction addedItem = new CandidateFunction();
                        addedItem.CandidateFunctionID = -1;
                        addedItem.FunctionID = int.Parse(value);
                        addedItem.Code = selectedItem.Text;
                        addedItem.Type = ddlKnowFuncUnit.SelectedValue;
                        addedItem.Group = ddlKnowFuncFam.SelectedValue;
                        SessionManager.CanFunctionDesList.Add(addedItem);
                    }
                }
            }
            gridKnowFuncDestination.DataSource = SessionManager.CanFunctionDesList;
            gridKnowFuncDestination.DataBind();
        }
        else
        {
            for (int i = listKnowFuncOriginal.Items.Count - 1; i >= 0; i--)
            {
                ListItem selectedItem = listKnowFuncOriginal.Items[i];
                if (selectedItem.Selected)
                {
                    string value = selectedItem.Value;

                    bool itemExist = false;
                    foreach (CandidateKnowledge oldItem in SessionManager.CanKnowledgeDesList)
                    {
                        if (oldItem.KnowledgeID.Value.ToString() == value)
                        {
                            itemExist = true;
                        }
                    }
                    if (!itemExist)
                    {
                        CandidateKnowledge addedItem = new CandidateKnowledge();
                        addedItem.CandidateKnowledgeID = -1;
                        addedItem.KnowledgeID = int.Parse(value);
                        addedItem.Code = selectedItem.Text;
                        addedItem.Type = ddlKnowFuncUnit.SelectedValue;
                        addedItem.Group = ddlKnowFuncFam.SelectedValue;
                        SessionManager.CanKnowledgeDesList.Add(addedItem);
                    }
                }
            }
            gridKnowFuncDestination.DataSource = SessionManager.CanKnowledgeDesList;
            gridKnowFuncDestination.DataBind();
        }
    }