现在我正在使用搜索功能。我有一个文本框和一个按钮,并在一个充满员工的数据库中搜索。在另一个 Web 部件中,员工可以将他们的技术技能保存在数据库中,以及他们所处的级别(初级、中级、高级或专家)。当我作为管理员想要查找知道例如 C# 的员工时,我只需搜索它,所有具有该技能的员工都会出现在网格视图中。
但我的问题是:
是否可以过滤这些结果?例如,如果我在搜索后放入一个复选框列表,并且我想过滤 C# 上“专家”的员工,是否可以只显示它们?对不起我的英语,但我尽力了。希望我能得到答案。
这是我如何搜索的代码示例:
private void SearchEmployeeSkillEng()
{
using (var db = new KnowItCvdbEntities())
{
var searchTechSkill = (from p in db.EMPLOYEES
join ets in db.EMPLOYEES_TECHNICAL_SKILLS on p.employee_id equals
ets.employee_id
join ts in db.TECHNICAL_SKILLS_VALUES on ets.technical_skill_value_id
equals
ts.technical_skill_value_id
join tsl in db.TECHNICAL_SKILL_LEVEL on ets.technical_skill_level_id
equals
tsl.technical_skill_level_id
where
ts.skill_name.Contains(TextBoxSearchCvEng.Text) ||
ets.skill_name_other.Contains(TextBoxSearchCvEng.Text)
select new TechnicalSkillsSearch()
{
EmployeeId = p.employee_id,
FirstName = p.firstname,
LastName = p.lastname,
TechnicalSkillValueId = ts.technical_skill_value_id,
SkillName = ts.skill_name,
SkillNameOther = ets.skill_name_other,
SkillType = ts.skill_type,
TechnicalSkillLevelId = tsl.technical_skill_level_id,
SkillLevel = tsl.skill_level
}).ToList();
if(searchTechSkill.Count > 0)
{
LabelException.Visible = false;
foreach (var vTechSkill in searchTechSkill)
{
if (vTechSkill != null)
{
if (vTechSkill.SkillNameOther != null)
{
if (!_searchEmpListEng.Contains(vTechSkill.FirstName + " " + vTechSkill.LastName + "," +
vTechSkill.EmployeeId))
{
_searchEmpListEng.Add(vTechSkill.FirstName + " " + vTechSkill.LastName + "," +
vTechSkill.EmployeeId.ToString());
}
}
else
{
if (!_searchEmpListEng.Contains(vTechSkill.FirstName + " " + vTechSkill.LastName + "," +
vTechSkill.EmployeeId))
{
_searchEmpListEng.Add(vTechSkill.FirstName + " " + vTechSkill.LastName + "," +
vTechSkill.EmployeeId.ToString());
}
}
}
}
}
else
{
LabelException.Visible = true;
LabelException.Text = "Nothing found";
}
_dtEng.Clear();
}
}
TECHNICAL_SKILLS_VALUES 是例如 C#、MS ACCESS 等,TECHNICAL_SKILL_LEVEL 是例如专家、初学者等。
你的,克里斯蒂安