Cache Code

code:

namespace HyeyManager.Memberss

{

	using System;

	using System.Data;

	using System.Drawing;

	using System.Web;

	using System.Web.UI.WebControls;

	using System.Web.UI.HtmlControls;



	/// <summary>

	///		userSortMenu 的摘要说明。

	/// </summary>

	public class userSortMenu : System.Web.UI.UserControl

	{



		private void Page_Load(object sender, System.EventArgs e)

		{

			SortLinkString();

		}



		#region Web 窗体设计器生成的代码

		override protected void OnInit(EventArgs e)

		{

			//

			// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。

			//

			InitializeComponent();

			base.OnInit(e);

		}

		

		/// <summary>

		///		设计器支持所需的方法 - 不要使用代码编辑器

		///		修改此方法的内容。

		/// </summary>

		private void InitializeComponent()

		{

			this.Load += new System.EventHandler(this.Page_Load);

		}

		#endregion



		protected string sortlingkstring="";

		protected  void SortLinkString()

		{  

			if( Cache["SortLinkString_key"] != null )

			{

				sortlingkstring =(System.String)Cache["SortLinkString_key"];

				return;			

				

			}



			DataSet UserGroup_ds = HyeyClass.DALFactory.DataAccess.CreatePE_UserGroup().GetList();

			DataSet SalesCompany_ds = HyeyClass.DALFactory.DataAccess.CreateComm().GetList("select id,CompanyName from SalesCompany");

			DataSet Partner_ds = HyeyClass.DALFactory.DataAccess.CreateComm().GetList("select partnername,partnercode,partnerid from partnerinfo");

            

			int usergroup_len=0;

			int salescompany_len=0;

			int partner_len = 0;



			if( UserGroup_ds != null && UserGroup_ds.Tables[0].Rows.Count>0 )

				usergroup_len=UserGroup_ds.Tables[0].Rows.Count;



			if( SalesCompany_ds != null && SalesCompany_ds.Tables[0].Rows.Count >0 )

				salescompany_len = SalesCompany_ds.Tables[0].Rows.Count;



			if( Partner_ds != null && Partner_ds.Tables[0].Rows.Count>0 )

				partner_len = Partner_ds.Tables[0].Rows.Count;







			System.Text.StringBuilder strBuilder = new System.Text.StringBuilder();

			int k=0;



			int nodeI = 1;



			if( usergroup_len >0 )

			{

				strBuilder.Append( " d.add("+nodeI+",0,'会员组类','#');\n "); 

	

				for(k=0;k<usergroup_len;k++ )

				{

					string usergroup_name = UserGroup_ds.Tables[0].Rows[k]["GroupName"].ToString();

					string usergroup_id = UserGroup_ds.Tables[0].Rows[k]["GroupID"].ToString();

					string linkstr = "Members.aspx?q_groupid="+usergroup_id;



					strBuilder.Append( " d.add("+(nodeI+k+1)+","+nodeI+",'"+usergroup_name+"','"+linkstr+"','"+usergroup_name+"','_self'); \n");

				}



				nodeI = nodeI + usergroup_len + 1;

			}





			if( salescompany_len >0 )

			{

				strBuilder.Append( " d.add("+nodeI+",0,'公司组类','#'); \n");



				for(k=0;k<salescompany_len;k++)

				{

					string salescompany_name = SalesCompany_ds.Tables[0].Rows[k]["CompanyName"].ToString();

					string salescompany_id = SalesCompany_ds.Tables[0].Rows[k]["id"].ToString();

					string linkstr = "Members.aspx?q_salescompany="+salescompany_id;



					strBuilder.Append( " d.add("+(nodeI+k+1)+","+nodeI+",'"+salescompany_name+"','"+linkstr+"','"+salescompany_name+"','_self'); \n");

			

				}



				nodeI = nodeI + salescompany_len + 1;

			}





			if( partner_len>0 )

			{



				strBuilder.Append( " d.add("+nodeI+",0,'合作伙伴分类','#'); \n");



				for(k=0;k<partner_len;k++)

				{

					string partner_name = Partner_ds.Tables[0].Rows[k]["partnername"].ToString();

					string partner_code = Partner_ds.Tables[0].Rows[k]["partnercode"].ToString();

					string linkstr = "Members.aspx?q_partnercompany="+partner_code;



					strBuilder.Append( " d.add("+(nodeI+k+1)+","+nodeI+",'"+partner_name+"','"+linkstr+"','"+partner_name+"','_self'); \n");			

				}

			}



			sortlingkstring = strBuilder.ToString();



			Cache.Insert("SortLinkString_key",sortlingkstring,new System.Web.Caching.CacheDependency(Server.MapPath("/Web.config")) );



		}











	}

}



 
  
 
  
 
   

 

 

 

 


 

你可能感兴趣的:(cache)