public static DataSet GetEmployeeHiearchicalInfo()
{
DataSet ds = new DataSet();
SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["RosConn"].ConnectionString);
try
{
SqlCommand cmd = new SqlCommand();
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "Tree_Hierarchy";
cmd.Connection = conn;
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(ds);
}
catch (SqlException)
{
throw;
}
finally
{
}
return ds;
}
public void PopulateTree(DataRow dataRow, JsTreeNode jsTNode, DataTable tableNodes)
{
jsTNode.children = new List<JsTreeNode>();
foreach (DataRow dr in tableNodes.Rows)
{
if (dr != null)
{
if (Convert.ToInt32(dr["level"]) == Convert.ToInt32(dataRow["level"]) + 1
&& Convert.ToInt32(dr["MangP_ID"]) == Convert.ToInt32(dataRow["Person_ID"])
)
{
JsTreeNode cnode = new JsTreeNode();
cnode.attr = new Attributes();
cnode.attr.id = Convert.ToString(dr["Person_ID"]);
//cnode.attributes.rel = "folder" + Convert.ToString(dr["Person_ID"]);
cnode.data = new Data();
cnode.data.title = Convert.ToString(dr["Name"]);
cnode.data.icon = null;
cnode.state = "leaf";
cnode.attr.mdata = "{ draggable : false, max_children : 100, max_depth : 100 }";
jsTNode.children.Add(cnode);
PopulateTree(dr, cnode, tableNodes);
}
}
}
}
public JsonResult GetEmployeeInfo()
{
DataSet dsNodes = RosterRepository.GetEmployeeHiearchicalInfo();
DataTable tableNodes = dsNodes.Tables[0];
DataRow parentDr = tableNodes.Rows[0];
JsTreeNode rootNode = new JsTreeNode();
rootNode.attr = new Attributes();
rootNode.attr.id = Convert.ToString(parentDr["Person_ID"]);
rootNode.attr.rel = "root" + Convert.ToString(parentDr["Person_ID"]);
rootNode.data = new Data();
rootNode.data.title = Convert.ToString(parentDr["Name"]);
rootNode.attr.mdata = "{ icon :null : false, max_children : 100, max_depth : 100 }";
rr.PopulateTree(parentDr, rootNode, tableNodes);
return Json(rootNode, JsonRequestBehavior.AllowGet);
}
How can I convert this to use EFExperts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.
When asked, what has been your best career decision?
Deciding to stick with EE.
Being involved with EE helped me to grow personally and professionally.
Connect with Certified Experts to gain insight and support on specific technology challenges including:
We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE