protected void BtnSubmitNewSkill_Click(object sender, EventArgs e)
        {
            Debug.WriteLine("Entering BtnSubmitNewSkill_Click");
            int test = 0;
            int result;
            expertObj = (Expert)Session["expertProfileObj"];

            if (string.IsNullOrWhiteSpace(txtAddNewSkill.Text)==false)
            {
                //search expert's skillset to see if the skill added already exsists
                //search all skill to see if the skill added exsists
                //if not to both, add a new skill
                foreach (Tuple<int,String> skill in expertObj.AllExpertSkills)//test if skill added is already in Expert's Skill Set
                {
                    if(skill.Item2.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase))
                    {
                        test = -1;
                        break;
                    }
                }
                if (test != -1)
                {
                    List<Skills> allSkills = DbMethods.GetSkills();
                    foreach (Skills skill in allSkills)//handle adding the skill
                    {
                        if (skill.SkillName.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase))
                        {
                            result = DbMethods.AddSkillToUser(expertObj.tuID, skill.SkillID);//adding excisting skill to expert
                            if (result != -1)
                            {
                                lblAddSkillTest.Text = "Success! New Skill was added to Skills and Expert_Skills Tables.";
                                test = -2;
                                break;
                            }
                            else
                                lblAddSkillTest.Text = "Error: Process did not execute successfully. :(";
                            break;
                        }
                    }
                    if(test != -2)
                    {
                        result = DbMethods.AddNewSkillToUser(expertObj.tuID, txtAddNewSkill.Text);//adding brandnew skill
                        if (result != -1)
                            lblAddSkillTest.Text = "Success! New Skill was added to Skills and Expert_Skills Tables.";
                        else
                            lblAddSkillTest.Text = "Error: Process did not execute successfully. :(";
                    }
                    sm.storeExpertDataInSession();//now get the whole expert object
                    FillControls();
                }
                else
                    lblAddSkillTest.Text = "Cannot add this skill. you already have this skill in your skill set.";
            }//end if statement for textBoxes
            else
                lblAddSkillTest.Text = "Error: Invalid input.";
        }//end add new skill
示例#2
0
        protected void BtnSubmitNewSkill_Click(object sender, EventArgs e)
        {
            Expert tempExpert = new Expert {
                tuID = (string)Session["TU_ID"]
            };
            int test = 0;
            int result;

            if (string.IsNullOrWhiteSpace(txtAddNewSkill.Text) == false)
            {
                //search expert's skillset to see if the skill added already exsists
                //search all skill to see if the skill added exsists
                //if not to both, add a new skill
                foreach (Tuple <int, String> skill in tempExpert.AllExpertSkills)//test if skill added is already in Expert's Skill Set
                {
                    if (skill.Item2.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase))
                    {
                        test = -1;
                        break;
                    }
                }
                if (test != -1)
                {
                    List <Skills> allSkills = db.GetSkills();
                    foreach (Skills skill in allSkills)//handle adding the skill
                    {
                        if (skill.SkillName.Equals(txtAddNewSkill.Text, StringComparison.OrdinalIgnoreCase))
                        {
                            result = db.AddSkillToUser(tempExpert.tuID, skill.SkillID);//adding existing skill to expert
                            if (result != -1)
                            {
                                lblAddSkillTest.Text = "Success! New Skill was added to Skills and Expert_Skills Tables.";
                                test = -2;
                                break;
                            }
                            else
                            {
                                lblAddSkillTest.Text = "Error: Process did not execute successfully. :(";
                            }
                            break;
                        }
                    }
                    if (test != -2)
                    {
                        result = db.AddNewSkillToUser(tempExpert.tuID, txtAddNewSkill.Text);//adding brandnew skill
                        if (result != -1)
                        {
                            lblAddSkillTest.Text = "Success! New Skill was added to Skills and Expert_Skills Tables.";
                        }
                        else
                        {
                            lblAddSkillTest.Text = "Error: Process did not execute successfully. :(";
                        }
                    }
                    //sm.storeExpertDataInSession();//now get the whole expert object
                    gvDeleteSkills.DataSource = db.GetExpertsSkills(tempExpert.tuID);
                    gvDeleteSkills.DataBind();
                }
                else
                {
                    lblAddSkillTest.Text = "Cannot add this skill. you already have this skill in your skill set.";
                }
            }//end if statement for textBoxes
            else
            {
                lblAddSkillTest.Text = "Error: Invalid input.";
            }
        }