Advertisement
Advertisement
| 08.07.2008 at 07:33AM PDT, ID: 23629431 |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: 286: 287: 288: 289: 290: 291: 292: 293: 294: 295: 296: 297: 298: 299: 300: 301: 302: 303: 304: 305: 306: 307: 308: 309: 310: 311: 312: 313: 314: 315: 316: 317: 318: 319: 320: 321: 322: 323: 324: 325: 326: 327: 328: 329: 330: 331: 332: 333: 334: 335: 336: 337: 338: 339: 340: 341: 342: 343: 344: 345: 346: 347: 348: 349: 350: 351: 352: 353: 354: 355: 356: 357: 358: 359: 360: 361: 362: 363: 364: 365: 366: 367: 368: 369: 370: 371: 372: 373: 374: 375: 376: 377: 378: 379: 380: 381: 382: 383: 384: 385: 386: 387: 388: 389: 390: 391: 392: 393: 394: 395: 396: 397: 398: 399: 400: 401: 402: 403: 404: 405: 406: 407: 408: 409: 410: 411: 412: 413: 414: 415: 416: 417: 418: 419: 420: 421: 422: 423: 424: 425: 426: 427: 428: 429: 430: 431: 432: 433: 434: 435: 436: 437: 438: 439: 440: 441: 442: 443: 444: 445: 446: 447: 448: 449: 450: 451: 452: 453: 454: 455: 456: 457: 458: 459: 460: 461: 462: 463: 464: 465: 466: 467: 468: 469: 470: 471: 472: 473: 474: 475: 476: 477: 478: 479: 480: 481: 482: 483: 484: 485: 486: 487: 488: 489: 490: 491: 492: 493: 494: 495: 496: 497: 498: 499: 500: 501: 502: 503: 504: 505: 506: 507: 508: 509: 510: 511: 512: 513: 514: 515: 516: 517: 518: 519: 520: 521: 522: 523: 524: 525: 526: 527: 528: 529: 530: 531: 532: 533: 534: 535: 536: 537: 538: 539: 540: 541: 542: 543: 544: 545: 546: 547: 548: 549: 550: 551: 552: 553: 554: 555: 556: 557: 558: 559: 560: 561: 562: 563: 564: 565: 566: 567: 568: 569: 570: 571: 572: 573: 574: 575: 576: 577: 578: 579: 580: 581: 582: 583: 584: 585: 586: 587: 588: 589: 590: 591: 592: 593: 594: 595: 596: 597: 598: 599: 600: 601: 602: 603: |
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Data.SqlClient;
using System.Configuration;
//using Microsoft.Web.UI.WebControls;
namespace EPDashboardTreeView
{
public partial class TreeView : System.Web.UI.Page
{
private SqlConnection sqlcon;
protected System.Web.UI.HtmlControls.HtmlInputHidden hdnStatus;
//protected Microsoft.Web.UI.WebControls.TreeView EPTreeView;
protected System.Web.UI.WebControls.TreeView EPTreeView;
private int intExpandLevel = 5;//value from Query String.
private void Page_Load(object sender, System.EventArgs e)
{
try
{
if (!Page.IsPostBack)
{
DataSet dsNodeList = null;
Hashtable ht;
AddHandlers();//To add handlers
//System.Web.UI.WebControls.TreeNode rootNode = null;
//TreeNodeEventArgs tna = ( System.Web.UI.WebControls.TreeNodeEventArgs)e;
// {
// getTreeList(ref dsNodeList, rootNode);
// }
getTreeList(ref dsNodeList);
if (Request.QueryString["ID"] != null)
{
intExpandLevel = int.Parse(Request.QueryString["ID"]);
}
else
{
intExpandLevel = int.Parse(hdnStatus.Value);
}
if (intExpandLevel > 0)
{
ht = new Hashtable();
AllParents(ref ht, dsNodeList, intExpandLevel);//Get all Parent Nodes
doExpand(EPTreeView.Nodes, ht, intExpandLevel); //Expand Parent of its all
}
else//Node ID =0
{
EPTreeView.ExpandAll(); //initial state
}
}
else
{
EPTreeView.ExpandAll();
}
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="dsNodeList"></param>
/// <returns></returns>
private int getTreeList(ref System.Data.DataSet dsNodeList)
{
//Microsoft.Web.UI.WebControls.TreeNode rootNode = null;
System.Web.UI.WebControls.TreeNode rootNode = null;
//Microsoft.Web.UI.WebControls.TreeNode tn, tc;
//System.Web.UI.WebControls.TreeNode tn, tc;
// System.Web.UI.WebControls.TreeNode tn;
int intParentID = 0;
int intNodeID = 0;
int intLevelAt = 0;
int isPopUP;
string strNodeName, strURL;
//string strImgURL = "treeimages/arrow.gif";
string strImgURL = "";
try
{
dsNodeList = ExecuteSP("GetTreeNodes", null);
if (dsNodeList != null)
{
for (int index = 0; index < dsNodeList.Tables[0].Rows.Count; index++)
{
intNodeID = int.Parse(dsNodeList.Tables[0].Rows[index]["OrgID"].ToString());
strNodeName = dsNodeList.Tables[0].Rows[index]["OrgName"].ToString();
//strURL = dsNodeList.Tables[0].Rows[index]["URL"].ToString();
intParentID = int.Parse(dsNodeList.Tables[0].Rows[index]["ParentID"].ToString());
intLevelAt = int.Parse(dsNodeList.Tables[0].Rows[index]["PathLength"].ToString());
//isPopUP = int.Parse(dsNodeList.Tables[0].Rows[index]["IsPopUP"].ToString());
if (intNodeID == 1075) //Root Node
{
AddParent(rootNode, intNodeID, intParentID, strNodeName);
}
else
{
AddChild(rootNode, dsNodeList, intNodeID, intParentID, intLevelAt, strNodeName);
}
}
}
}
catch (Exception ex)
{
//Excepiton goes here
Response.Write(ex.Message + "<br/> Level at Database is wrong Node ID : " + intNodeID);
return -1;
}
return 0;
}
bool ChildElement(DataSet dsNodeList, int NodeID)
{
DataRow[] dr;
dr = dsNodeList.Tables[0].Select("ParentID= " + NodeID);
if (dr == null || dr.Length == 0)
{
return true;
}
return false;
}
/// <summary>
///
/// </summary>
/// <param name="t"></param>
/// <param name="strParentID"></param>
/// <param name="Tfin"></param>
private void AddParent(TreeNode node,int strOrgId, int intParentID, string strOrgName)
{
System.Web.UI.WebControls.TreeNode tn;
TreeNode newNode = new TreeNode();
newNode.Text = "<font color = white font family = Tahoma size=1>" + strOrgName + "</font>";
newNode.Value = strOrgId.ToString();
// Set the PopulateOnDemand property to true so that the child nodes can be
// dynamically populated.
newNode.PopulateOnDemand = true;
// Set additional properties for the node.
newNode.SelectAction = TreeNodeSelectAction.Select;
newNode.Target = "_top";
// Add the new node to the ChildNodes collection of the parent node.
//node.ChildNodes.Add(newNode);
//EPTreeView.Nodes.Add(node);
tn = new System.Web.UI.WebControls.TreeNode();
//if (tn != null)
//{
// tn.ChildNodes.AddAt(intTmpLvel, NewNode);
//tn.ChildNodes.Add(newNode);
//EPTreeView.Nodes.Add(node);
EPTreeView.Nodes.Add(newNode);
//}
}
private void AddChild(TreeNode node, DataSet dsNodeList, int strOrgId, int intParentID, int intLvl, string strOrgName)
{
int intTmpLvel;
System.Web.UI.WebControls.TreeNode tn;
intTmpLvel = intLvl - 1;
//doRecursion(EPTreeView.Nodes, intParentID.ToString(), tn);
TreeNode NewNode = new TreeNode();
NewNode.Text = "<font color = white font family = Tahoma size=1>" + strOrgName + "</font>";
NewNode.Value = strOrgId.ToString();
// Set the PopulateOnDemand property to false, because these are leaf nodes and do not need to be populated.
NewNode.PopulateOnDemand = false;
// Set additional properties for the node.
NewNode.SelectAction = TreeNodeSelectAction.None;
// Add the new node to the ChildNodes collection of the parent node.
tn = new System.Web.UI.WebControls.TreeNode();
if (tn != null)
{
//int x = tn.Depth;
tn.ChildNodes.AddAt(intTmpLvel, NewNode);
//EPTreeView.Nodes.Add(node);
EPTreeView.Nodes.Add(tn);
}
}
// void doRecursion(Microsoft.Web.UI.WebControls.TreeNodeCollection t, string strParentID, ref Microsoft.Web.UI.WebControls.TreeNode Tfin)
void doRecursion(System.Web.UI.WebControls.TreeNodeCollection t, string strParentID, System.Web.UI.WebControls.TreeNode Tfin)
{
bool bln = false;
try
{
//foreach (Microsoft.Web.UI.WebControls.TreeNode tn in t)
foreach (System.Web.UI.WebControls.TreeNode tn in t)
{
if (tn.Value.Trim() == strParentID.Trim())
{
Tfin = tn;
bln = true;
return;
}
doRecursion(tn.ChildNodes, strParentID, Tfin);
}
}
catch
{
bln = false;
}
if (bln) return;
}
/// <summary>
///
/// </summary>
/// <param name="spname"></param>
/// <param name="parmArry"></param>
/// <returns></returns>
private System.Data.DataSet ExecuteSP(string spname, string[][] parmArry)
{
System.Data.DataSet dsResult = new System.Data.DataSet();
string strParameterNam;
string strParameterVal;
try
{
sqlcon = new SqlConnection(ConfigurationSettings.AppSettings["ConnectionString"]);
if (sqlcon.State == System.Data.ConnectionState.Closed)
{
sqlcon.Open();
}
SqlCommand cmd = sqlcon.CreateCommand();
cmd.CommandText = spname;
cmd.CommandType = System.Data.CommandType.StoredProcedure;
if (parmArry != null)
{
for (int index = 0; index < parmArry.Length; index++)
{
strParameterNam = parmArry[index][0];
strParameterVal = parmArry[index][1];
if (strParameterNam != null && strParameterVal != null)
{
}
}
}
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dsResult);
}
catch
{
dsResult = null;
//Excepiton goes here
}
finally
{
sqlcon.Close();
}
return dsResult;
}
/// <summary>
/// Get all of itsParents
/// </summary>
/// <param name="ht"></param>
/// <param name="dsList"></param>
/// <param name="intNodeID"></param>
void AllParents(ref Hashtable ht, DataSet dsList, int intNodeID)
{
DataRow[] dr = null;
object objKey = "";
try
{
ht.Add(intNodeID, intNodeID);
while (true)
{
dr = dsList.Tables[0].Select("NodeID =" + intNodeID);
objKey = (object)dr[0]["ParentID"];
ht.Add(objKey, objKey);
intNodeID = (int)objKey;
if (intNodeID == 0) //root Node
{
break;
}
}
}
catch
{
}
}
/// <summary>
/// Expand all nodes to specified Node
/// </summary>
//void doExpand(Microsoft.Web.UI.WebControls.TreeNodeCollection t, Hashtable ht, int NodeID)//,string intExpandParentID)
void doExpand(System.Web.UI.WebControls.TreeNodeCollection t, Hashtable ht, int NodeID)//,string intExpandParentID)
{
try
{
//foreach (Microsoft.Web.UI.WebControls.TreeNode tn in t)
foreach (System.Web.UI.WebControls.TreeNode tn in t)
{
if ((int.Parse(tn.Value) <= NodeID) && (ht.ContainsKey(int.Parse(tn.Value))))
{
tn.Expanded = true;
}
else
{
tn.Expanded = false;
}
doExpand(tn.ChildNodes, ht, NodeID);
}
}
catch
{
}
}
private void AddHandlers()
{
string clickHandler = "";
// Create and wire up the javascript event handlers.
//
clickHandler = "IndexChanged(this.clickedNodeIndex);";
this.EPTreeView.Attributes.Add("onselectedindexchange", clickHandler);
clickHandler = "NodeExpand(this.clickedNodeIndex);";
this.EPTreeView.Attributes.Add("onexpand", clickHandler);
}
}
}
|