using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Collections;
namespace WebUI.classes
{
    public class Common
    {
        public static ArrayList al = new ArrayList();
        public static ArrayList all = new ArrayList();
        /// <summary>
        /// 根据当前的页数显示的当前页的底部分页
        /// </summary>
        /// <param name="current"></param>
        /// <param name="size"></param>
        /// <param name="zong"></param>
        /// <returns></returns>
        public static string GetPage(int current,int size,int zong)
        {
        
            int pagecount = zong % size == 0 ? (zong / size) : (zong / size + 1);
            int num = current / 10;
  
            System.Text.StringBuilder sball = new System.Text.StringBuilder("");
            int xian = current / 10 + 1;
 
            int before = current%10==0?(current/10):(current/10);
            sball.Append("&nbsp;<a href='index.html'>首页</a>&nbsp;");
            for (int i = ((before * 10 - 5) > 0 ? (before * 10 - 5) : (1)); i <= (before * 10 == 0 ? (1) : (before * 10)); i++)
            {


                if ((before * 10 - 5) < 0)
                    continue;
                    sball.Append("&nbsp;<a href='index").Append((i).ToString()).Append(".html'>").Append((i)).Append("</a>");
    
        
                sball.Append("&nbsp;");
            }
  
            for (int i = (xian - 1) * 10 > pagecount ? (pagecount) : ((xian - 1) * 10); i < (xian * 10 < pagecount ? (xian * 10) : (pagecount)); i++)
            {

                if (i == 0)
                    sball.Append("<a href='index.html'>").Append((i + 1)).Append("</a>");
  
                else
                    sball.Append("&nbsp;&nbsp;<a href='index").Append((i + 1)).Append(".html'>").Append((i+1)).Append("</a>");
             
              
            }
            sball.Append("&nbsp;<a href='index" + (pagecount == 1 ? ("") : (pagecount.ToString())) + ".html'>末页</a>");
            sball.Append("&nbsp;&nbsp;共").Append(zong.ToString()).Append("条&nbsp;&nbsp;当前第").Append((current).ToString()).Append("页").Append("共").Append(pagecount).Append("页").Append("<input type=text id='pagenum' value='' size=\"5\"/>&nbsp;<input type=button value='GO' onclick=document.location='index'+document.getElementById(\"pagenum\").value+'.html'>");
     
            return sball.ToString();
        }
        /// <summary>
        /// 根据子类获取父类的所有的
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static string GetP(string id)
        {
            //DataTable dt = DbHelperOleDb.Query("select * from zone").Tables[0];
            //DataView dv = dt.DefaultView;

            DataTable dt = DbHelperOleDb.Query("select * from zone where classid=" + id).Tables[0];
            if (dt.Rows.Count < 1)
                return "";
            if (Convert.ToString(dt.Rows[0]["ParentID"]) != " 0")
            {
                //demo += Convert.ToString(dt.Rows[0]["ClassName"]);
                //if (Convert.ToString(dt.Rows[0]["depth"]) == dep)
                ////{
                //    return GetP(Convert.ToString(dt.Rows[0]["ParentID"])) + "<a href='/" + Convert.ToString(dt.Rows[0]["links"]) + "'>" + Convert.ToString(dt.Rows[0]["ClassName"]) + "</a>&nbsp;&nbsp;";
                //}
                //else
                //{
                return GetP(Convert.ToString(dt.Rows[0]["ParentID"])) + "<a href='/" + Convert.ToString(dt.Rows[0]["links"]) + "/index.html'>" + Convert.ToString(dt.Rows[0]["ClassName"]) + "</a>&nbsp;&nbsp;>>";
                //}

            }
            else
            {
                return "";
            }

 

        }
        ///
        public static bool CheckContent(string user, string content)
        {
            bool check = false;
            if (user == "admin")
                return false;
            DataTable dt = DbHelperOleDb.Query("select * from keys").Tables[0];
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                if (content.IndexOf(Convert.ToString(dt.Rows[i]["keys"])) >= 0)
                {
                    return true;
                }
            }
            return false;
        }
        //获取子节点
        public static string GetChilds(string pid)
        {
            DataTable dt = DbHelperOleDb.Query("select * from zone where ParentID=" + pid).Tables[0];
            if (dt.Rows.Count < 1)
            {
                if (!al.Contains(pid))
                al.Add(pid);
            }
            else
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataTable dtbottom = DbHelperOleDb.Query("select * from zone where ParentID=" + Convert.ToString(dt.Rows[i]["classid"])).Tables[0];
                    if (dtbottom.Rows.Count < 1)
                    {
                        if (!al.Contains(Convert.ToString(dt.Rows[i]["classid"])))
                        al.Add(Convert.ToString(dt.Rows[i]["classid"]));
                    }

                    GetChilds(Convert.ToString(dt.Rows[i]["classid"]));

                }


            }
            return "";
        }
        /// <summary>
        /// 下拉框的值
        /// </summary>
        /// <param name="pid"></param>
        /// <returns></returns>
        public static void GetChilds(string pid,string pname)
        {
            DataTable dt = DbHelperOleDb.Query("select * from zone where ParentID=" + pid).Tables[0];
            if (dt.Rows.Count < 1)
            {
                if (!al.Contains(new DropItem(pid, pname)))
                all.Add(new DropItem(pid, pname));
            }
            else
            {
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    DataTable dtbottom = DbHelperOleDb.Query("select * from zone where ParentID=" + Convert.ToString(dt.Rows[i]["classid"])).Tables[0];
                    if (dtbottom.Rows.Count < 1)
                    {
                        if (!al.Contains(new DropItem(Convert.ToString(dt.Rows[i]["classid"]), Convert.ToString(dt.Rows[i]["classname"]))))
                        all.Add(new DropItem(Convert.ToString(dt.Rows[i]["classid"]), Convert.ToString(dt.Rows[i]["classname"])));
                    }

                    GetChilds(Convert.ToString(dt.Rows[i]["classid"]), Convert.ToString(dt.Rows[i]["classname"]));

                }


            }
          
        }

    }
    public class DropItem
    {
        public string id;
        public string name;
        public DropItem(string id, string name)
        {
            this.id = id;
            this.name = name;
        }
    }

}


文章来源:http://www.cnblogs.com/wangdetian168/archive/2008/09/17/1292245.html
posted on 2010-09-29 13:28 sanmao 阅读(81) 评论(0)  编辑  收藏

只有注册用户登录后才能发表评论。


网站导航:
 

常用链接

留言簿(5)

随笔分类

随笔档案

搜索

  •  

最新评论

阅读排行榜

评论排行榜