D:\NorthwindForWeb\Northwind\CS\DotNet\ADO.Net\Northwind\WebControls\TreeBase.cs
/*
* This file was generated by ProCG version 2.0
*
* File name: Northwind\WebControls\TreeBase.cs
* Language: C# - ADO.Net
* Database: My Sql
*
* Copyright (c) 2002-2019 iGenXSoft.
* For more information visit http://www.igenxsoft.com
*/
using System;
using System.Text;
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 Northwind.General;
using Northwind.Data;
namespace Northwind.WebControls
{
/// <summary>
/// Summary description for Tree.
/// </summary>
public class TreeBase : NorthwindPage
{
protected CNorthwindUser m_CurrentLoginUser;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!IsPostBack && !SessionManager.UserExist && Application[Request.UserHostAddress] != null)
{
SessionManager.User = (CNorthwindUser)Application[Request.UserHostAddress];
Application.Remove(Request.UserHostAddress);
}
}
public virtual string GetAllTreeNodes()
{
if (SessionManager.UserExist)
{
TreePanel.Visible = true;
return GetAllTreeNodes(User);
}
else
{
TreePanel.Visible = false;
return "";
}
}
public virtual Panel TreePanel
{
get
{
throw new NotImplementedException("TreePanel must be implemented in " + this.GetType().ToString());
}
}
public virtual string GetAllTreeNodes(CNorthwindUser user)
{
StringBuilder stringBuilder = new StringBuilder();
this.m_CurrentLoginUser = user;
AddTreeHeader(stringBuilder);
AddCacheManagementOption(stringBuilder);
AddBackupEntityTreeOptions(stringBuilder);
AddCodesTreeOptions(stringBuilder);
AddCriteriaDefinitionTreeOptions(stringBuilder);
AddCriteriaFieldTreeOptions(stringBuilder);
AddCriteriaOrderByTreeOptions(stringBuilder);
AddCustomerTreeOptions(stringBuilder);
AddLastValueTreeOptions(stringBuilder);
AddNorthwindUserTreeOptions(stringBuilder);
AddOrderTreeOptions(stringBuilder);
AddOrderItemTreeOptions(stringBuilder);
AddProductTreeOptions(stringBuilder);
AddSupplierTreeOptions(stringBuilder);
AddTestTableTreeOptions(stringBuilder);
AddTreeEnd(stringBuilder);
return (stringBuilder.ToString());
}
public virtual void AddSubSystem(StringBuilder stringBuilder, string subSystem, bool resetFather = true)
{
if (!string.IsNullOrEmpty(subSystem))
{
if (resetFather)
stringBuilder.Append(" d.add(i++,0,'" + subSystem + "'); father=i-1;\n");
else
stringBuilder.Append(" d.add(i++,father,'" + subSystem + "'); father=i-1;\n");
}
else
stringBuilder.Append(" father=0;\n");
}
public virtual void AddTreeHeader(StringBuilder stringBuilder)
{
string loginPageName = "../Login.aspx?Action=Login";
string logoutPageName = "../Login.aspx?Action=Logout";
stringBuilder.Append(" <script type=\"text/javascript\">\n");
stringBuilder.Append(" <!--\n");
stringBuilder.Append(" d = new dTree('d');\n");
stringBuilder.Append(" var i = 0;\n");
stringBuilder.Append(" var father = 0;\n");
stringBuilder.Append(" d.add(i++,-1,'Northwind');\n");
if (m_CurrentLoginUser == null || m_CurrentLoginUser.UserName.Equals("") )
stringBuilder.Append(" d.add(i++,father,'Login',\"javascript:window.parent.SetWork('"+loginPageName+"')\");\n");
else
stringBuilder.Append(" d.add(i++,father,'Logout',\"javascript:window.parent.SetWork('"+logoutPageName+"')\");\n");
}
public virtual void AddTreeEnd(StringBuilder stringBuilder)
{
stringBuilder.Append(" document.write(d);\n");
stringBuilder.Append(" //-->\n");
stringBuilder.Append(" </script>\n");
}
public virtual void AddCacheManagementOption(StringBuilder stringBuilder)
{
string chacheManagmentPageName = "../CacheManagement.aspx";
stringBuilder.Append(" d.add(i++,father,'Cache Managment',\"javascript:window.parent.SetWork('" + chacheManagmentPageName + "')\");\n");
}
////////////////////////////////////////////////
// If you want BackupEntity to be added with all options to the tree please define for it code and description fields
// and you need to have atleast two access methods one for read by primary key
// and the second access method to get all records from the table
// warning: No code field was define for BackupEntity
// warning: No description field was define for BackupEntity
/////////////////////////////////////////////////
public virtual void AddBackupEntityTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"BackupEntity","Backup Entity","Backup Entitys",0, 4,null);
}
catch (Exception) { } // ignore if table does not exis
}
public virtual void AddCodesTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"Codes","Codes","Codess",(int)CCodes.FIELDS_ENUM.DESCRIPTION, 3, DataManager.CodesRecord.GetCodesTablesCollection());
}
catch (Exception) { } // ignore if table does not exis
}
public virtual void AddCriteriaDefinitionTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"CriteriaDefinition","Criteria Definition","Criteria Definitions",(int)CCriteriaDefinition.FIELDS_ENUM.NAME, 99, DataManager.CriteriaDefinitionRecord.GetAllCriteriaDefinitionsCollection());
}
catch (Exception) { } // ignore if table does not exis
}
////////////////////////////////////////////////
// If you want CriteriaField to be added with all options to the tree please define for it code and description fields
// and you need to have atleast two access methods one for read by primary key
// and the second access method to get all records from the table
// warning: No code field was define for CriteriaField
// warning: No description field was define for CriteriaField
/////////////////////////////////////////////////
public virtual void AddCriteriaFieldTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"CriteriaField","Criteria Field","Criteria Fields",0, 3,null);
}
catch (Exception) { } // ignore if table does not exis
}
////////////////////////////////////////////////
// If you want CriteriaOrderBy to be added with all options to the tree please define for it code and description fields
// and you need to have atleast two access methods one for read by primary key
// and the second access method to get all records from the table
// warning: No code field was define for CriteriaOrderBy
// warning: No description field was define for CriteriaOrderBy
/////////////////////////////////////////////////
public virtual void AddCriteriaOrderByTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"CriteriaOrderBy","Criteria Order By","Criteria Order Bys",0, 3,null);
}
catch (Exception) { } // ignore if table does not exis
}
////////////////////////////////////////////////
// If you want Customer to be added with all options to the tree please define for it code and description fields
// and you need to have atleast two access methods one for read by primary key
// and the second access method to get all records from the table
// warning: No code field was define for Customer
// warning: No description field was define for Customer
/////////////////////////////////////////////////
public virtual void AddCustomerTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"Customer","Customer","Customers",0, 99,null);
}
catch (Exception) { } // ignore if table does not exis
}
////////////////////////////////////////////////
// If you want LastValue to be added with all options to the tree please define for it code and description fields
// and you need to have atleast two access methods one for read by primary key
// and the second access method to get all records from the table
// warning: No code field was define for LastValue
// warning: No description field was define for LastValue
/////////////////////////////////////////////////
public virtual void AddLastValueTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"LastValue","Last Value","Last Values",0, 4,null);
}
catch (Exception) { } // ignore if table does not exis
}
public virtual void AddNorthwindUserTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"NorthwindUser","Northwind User","Northwind Users",(int)CNorthwindUser.FIELDS_ENUM.FULL_NAME, 2, DataManager.NorthwindUserRecord.GetAllUsersCollection());
}
catch (Exception) { } // ignore if table does not exis
}
////////////////////////////////////////////////
// If you want Order to be added with all options to the tree please define for it code and description fields
// and you need to have atleast two access methods one for read by primary key
// and the second access method to get all records from the table
// warning: No code field was define for Order
// warning: No description field was define for Order
/////////////////////////////////////////////////
public virtual void AddOrderTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"Order","Order","Orders",0, 99,null);
}
catch (Exception) { } // ignore if table does not exis
}
////////////////////////////////////////////////
// If you want OrderItem to be added with all options to the tree please define for it code and description fields
// and you need to have atleast two access methods one for read by primary key
// and the second access method to get all records from the table
// warning: No code field was define for OrderItem
// warning: No description field was define for OrderItem
/////////////////////////////////////////////////
public virtual void AddOrderItemTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"OrderItem","Order Item","Order Items",0, 99,null);
}
catch (Exception) { } // ignore if table does not exis
}
////////////////////////////////////////////////
// If you want Product to be added with all options to the tree please define for it code and description fields
// and you need to have atleast two access methods one for read by primary key
// and the second access method to get all records from the table
// warning: No code field was define for Product
// warning: No description field was define for Product
/////////////////////////////////////////////////
public virtual void AddProductTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"Product","Product","Products",0, 99,null);
}
catch (Exception) { } // ignore if table does not exis
}
public virtual void AddSupplierTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"Supplier","Supplier","Suppliers",(int)CSupplier.FIELDS_ENUM.COMPANY_NAME, 99, DataManager.SupplierRecord.GetAllSuppliersCollection());
}
catch (Exception) { } // ignore if table does not exis
}
public virtual void AddTestTableTreeOptions(StringBuilder stringBuilder)
{
try
{
AddTableTreeOptions(stringBuilder,"TestTable","Test Table","Test Tables",(int)CTestTable.FIELDS_ENUM.NAME, 99, DataManager.TestTableRecord.GetAllTestTablesCollection());
}
catch (Exception) { } // ignore if table does not exis
}
public virtual void AddTableTreeOptions(StringBuilder stringBuilder, string tableName, string singleDisplayName, string pluralDisplayName, int descriptionFieldNum, int accessMethod, IStructDataCollection allCollection, int numItemsToShowInTree = 20)
{
string entityPageName = string.Format("../Records/{0}/{0}Entity.aspx",tableName);
string queryPageName = string.Format("../Records/{0}/{0}Query.aspx",tableName);
string editPageName = string.Format("../Records/{0}/{0}Edit.aspx",tableName);
stringBuilder.Append(" keepFather = father;\n");
stringBuilder.Append(" d.add(i++,father,'"+singleDisplayName+"'); father=i-1;\n");
stringBuilder.Append(" d.add(i++,father,'New',\"javascript:window.parent.SetWork('"+entityPageName+ "?Mode=New')\");\n");
stringBuilder.Append(" d.add(i++,father,'All',\"javascript:window.parent.SetWork('"+entityPageName+ "?AcmNum="+accessMethod+"&Collection=1')\");\n");
stringBuilder.Append(" d.add(i++,father,'Query',\"javascript:window.parent.SetWork('"+queryPageName+"')\");\n");
//stringBuilder.Append(" d.add(i++,father,'Edit',\"javascript:window.parent.SetWork('"+editPageName+"')\");\n");
if (allCollection != null && allCollection.Count > 0 && allCollection.Count <= numItemsToShowInTree)
{
stringBuilder.Append("d.add(i++,father,'"+singleDisplayName+"'); father = i-1;\n");
foreach (CRecordData recordData in allCollection)
{
stringBuilder.Append(" d.add(i++,father,'"+recordData.GetFieldStringValue(descriptionFieldNum).Replace('\'','"')+"',\"javascript:window.parent.SetWork('"+entityPageName+"?AcmNum=1&Collection=0&AcmParams="+recordData.GetPrimaryKeyAsString()+"')\");\n");
}
}
stringBuilder.Append(" father = keepFather;\n");
}
}
}
// 13916 ProCG uses this line - don't edit it