人事树上显示在线人员,要怎么做??? 常见的人事树,按部门,岗位,人员显示,其中部门和岗位都是多个层次的现在要显示在线人员的人事树,就是不要显示那些没有在线人员的部门和岗位如果部门和岗位都只一个层次,我还会,可是多个层次的话,只有显示到人员那一级才知道该部门/岗位该部该显示,感觉是递归再逆向,请问该怎么做呢?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.把树存储在缓存中。2.用getparent()获取父节点层次 通过登录日志,查询在线人员,获取数据集。再递归绑定数据。 if (!IsPostBack) { BindJG(); } } private void BindJG() { DataSet ds = new DataSet(); DB c = new DB(); //获取数据 DataTable dtb = ds.Tables[0]; TreeNode root = new TreeNode(); root.Value = "0"; root.Text = ""; root.ImageUrl = "../images/folder.gif"; root.Expanded = true; this.TreeView1.Nodes.Add(root); initTree(dtb, "", root); this.TreeView1.ExpandAll(); } protected void initTree(DataTable dt, string nFatherid, TreeNode fatherNode) { DataView dv = new DataView(dt); if (nFatherid == "") dv.RowFilter = "depth='1'"; else dv.RowFilter = "shangjjgbh='"+nFatherid+"'"; foreach (DataRowView Row in dv) { TreeNode node = new TreeNode(); if (fatherNode.Value == "0") { node.Value = Row["BH"].ToString(); node.Text = Row["mc"].ToString(); node.NavigateUrl = ""; node.ImageUrl = "../images/folder.gif"; fatherNode.ChildNodes.Add(node); initTree(dt, Row["BH"].ToString(), node); } else { node.Text = Row["mc"].ToString(); node.Value = Row["BH"].ToString(); node.ImageUrl = "../images/jg.gif"; fatherNode.ChildNodes.Add(node); } } } 目前数据库的相关表有:部门表Department:DeptID,DeptNam,ParentID岗位表Station:StationID,StationNam,ParentID,DepartID员工表Employee:EmpID,StationID,IsOnline说明:1.部门和岗位都是多个层次的2.3个表的关系是:人员属于岗位,岗位属于部门3.是否在线对应员工表里的IsOnline字段4.暂时认为用户通过提供的"注销"按钮退出,不考虑直接关闭网页的情况给出大概的思路和算法就可以了,谢谢 excel导入sql重复数据处理 DropDownList无限级分级问题 javascript 运行次数问题,急啊! 如何用CSS来实现鼠标经过图像凸起? 请问web.config里的<httpModules>做什么用? login登录到主页面不成功 给大家推荐一个.net 专业论坛:CnAspx.Net asp.net中执行ntfs分区中可执行文件的问题 AJAX即时刷新,类似谷歌音乐 xml问题 (在线等待......)一个困扰很长很长时间的问题,弹出窗口返回值&查出的结果做条件? 一个查询数据库的类出问题,麻烦看下,谢谢.
2.用getparent()获取父节点层次
再递归绑定数据。
if (!IsPostBack)
{
BindJG();
}
}
private void BindJG()
{
DataSet ds = new DataSet();
DB c = new DB();
//获取数据
DataTable dtb = ds.Tables[0];
TreeNode root = new TreeNode();
root.Value = "0";
root.Text = "";
root.ImageUrl = "../images/folder.gif";
root.Expanded = true;
this.TreeView1.Nodes.Add(root);
initTree(dtb, "", root);
this.TreeView1.ExpandAll();
}
protected void initTree(DataTable dt, string nFatherid, TreeNode fatherNode)
{
DataView dv = new DataView(dt); if (nFatherid == "")
dv.RowFilter = "depth='1'";
else
dv.RowFilter = "shangjjgbh='"+nFatherid+"'";
foreach (DataRowView Row in dv)
{
TreeNode node = new TreeNode();
if (fatherNode.Value == "0")
{
node.Value = Row["BH"].ToString();
node.Text = Row["mc"].ToString();
node.NavigateUrl = "";
node.ImageUrl = "../images/folder.gif";
fatherNode.ChildNodes.Add(node);
initTree(dt, Row["BH"].ToString(), node);
}
else
{
node.Text = Row["mc"].ToString();
node.Value = Row["BH"].ToString();
node.ImageUrl = "../images/jg.gif";
fatherNode.ChildNodes.Add(node); }
} }
部门表Department:DeptID,DeptNam,ParentID
岗位表Station:StationID,StationNam,ParentID,DepartID
员工表Employee:EmpID,StationID,IsOnline说明:
1.部门和岗位都是多个层次的
2.3个表的关系是:人员属于岗位,岗位属于部门
3.是否在线对应员工表里的IsOnline字段
4.暂时认为用户通过提供的"注销"按钮退出,不考虑直接关闭网页的情况给出大概的思路和算法就可以了,谢谢