oracle三层架构()

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.Data.SqlClient;
using System.Data.OracleClient;
using System.Collections;
using System.Reflection;
using System.Text;

/// <summary>
/// Data 的摘要说明
/// </summary>
public abstract class Data
{
 public Data()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //
      
 }
 
    // ===数据库连接串设置===

    public static readonly string conn_Default = "Data Source=YTDB;User ID=ytdba;Password=ytdba001;Unicode=True"; //系统默认数据库连接串

    // ============================================================== 
    // ========================数据库底层操作==============================
    // ============================================================== 
    /// <summary>
    /// 执行ExecuteNonQuery
    /// </summary>
    /// <param name="connString">数据库连接</param>
    /// <param name="cmdType">Sql语句类型</param>
    /// <param name="cmdText">Sql语句</param>
    /// <param name="cmdParms">Parm数组</param>
    /// <returns>返回影响行数</returns>
    public static int ExecuteNonQuery(string connString, CommandType cmdType, string cmdText, params OracleParameter[] cmdParms)
    {
        OracleCommand cmd = new OracleCommand();
        using ( OracleConnection conn=new OracleConnection(connString))
        {
            conn.Open();
            cmd.Connection = conn;
            cmd.CommandText = cmdText;
            if (cmdParms != null)
            {
                foreach (OracleParameter parm in cmdParms)
                    cmd.Parameters.Add(parm);
            }
            int val = cmd.ExecuteNonQuery();
            cmd.Parameters.Clear();
            conn.Close();
            return val;
        }
    }
    /// <summary>
    /// 返回一个SqlParameter实例
    /// </summary>
    /// <param name="ParamName">字段名</param>
    /// <param name="stype">字段类型</param>
    /// <param name="size">范围</param>
    /// <param name="Value">赋值</param>
    /// <returns>返回一个SqlParameter实例</returns>
    public static OracleParameter MakeParam(string ParamName, System.Data.OracleClient.OracleType stype, int size, Object Value)
    {
        OracleParameter para = new OracleParameter(ParamName, Value);
        para.OracleType = stype;
        para.Size = size;
        return para;
    }
    /// <summary>
    /// 获得SqlParameter实例
    /// </summary>
    /// <param name="ParamName">字段名</param>
    /// <param name="Value">赋值</param>
    /// <returns>返回一个SqlParameter实例</returns>
    public static OracleParameter MakeParam(string ParamName, string Value)
    {
        return new OracleParameter(ParamName, Value);
    }
    /// <summary>
    /// 获得DateSet实例(获得单页记录)
    /// </summary>
    /// <param name="int_PageSize">一页显示的记录数</param>
    /// <param name="int_CurrentPageIndex">当前页码</param>
    /// <param name="connString">数据库连接串</param>
    /// <param name="cmdType">Sql语句类型</param>
    /// <param name="cmdText">Sql语句</param>
    /// <param name="cmdParms">Parm数组</param>
    /// <returns></returns>
    public static DataSet ExecuteDataSet(int int_PageSize, int int_CurrentPageIndex, string connString, CommandType cmdType, string cmdText, params OracleParameter[] cmdParms)
    {
        OracleConnection conn = new OracleConnection(connString);
        try
        {
            conn.Open();
            System.Data.OracleClient.OracleDataAdapter da = new OracleDataAdapter(cmdText, conn);
            da.SelectCommand.CommandType = cmdType;
            if (cmdParms != null)
            {
                foreach (OracleParameter parm in cmdParms)
                    da.SelectCommand.Parameters.Add(parm);
            }
            conn.Close();

            DataSet ds = new DataSet();
            if (int_PageSize == 0 && int_CurrentPageIndex == 0)
            {
                da.Fill(ds, "12news1234567890");
            }
            else
            {
                int int_Page = int_PageSize * (int_CurrentPageIndex - 1);
                if (int_Page < 0)
                {
                    int_Page = 0;
                }
                da.Fill(ds, int_Page, int_PageSize, "12news1234567890");
            }
            return ds;
        }
        catch
        {
            conn.Close();
            throw;
        }
    }
    /// <summary>
    /// 获得DateSet实例(获得全部记录)
    /// </summary>
    /// <param name="connString">数据库连接串</param>
    /// <param name="cmdType">Sql语句类型</param>
    /// <param name="cmdText">Sql语句</param>
    /// <param name="cmdParms">Parm数组</param>
    /// <returns></returns>
    public static DataSet ExecuteDataSet(string connString, CommandType cmdType, string cmdText, params OracleParameter[] cmdParms)
    {
        OracleConnection conn = new OracleConnection(connString);
        try
        {
            conn.Open();
            System.Data.OracleClient.OracleDataAdapter da = new OracleDataAdapter(cmdText, conn);
            da.SelectCommand.CommandType = cmdType;
            if (cmdParms != null)
            {
                foreach (OracleParameter parm in cmdParms)
                    da.SelectCommand.Parameters.Add(parm);
            }
            conn.Close();

            DataSet ds = new DataSet();
            da.Fill(ds, "12news1234567890");

            return ds;
        }
        catch
        {
            conn.Close();
            throw;
        }
    }

    /// <summary>
    /// 执行ExecuteScalar
    /// </summary>
    /// <param name="connString">数据库连接串</param>
    /// <param name="cmdType">Sql语句类型</param>
    /// <param name="cmdText">Sql语句</param>
    /// <param name="cmdParms">Parm数组</param>
    /// <returns>返回第一行第一列记录值</returns>

    public static object ExecuteScalar(string connString, CommandType cmdType, string cmdText, params OracleParameter[] cmdParms)
    {
        OracleCommand cmd = new OracleCommand();
        using (OracleConnection conn = new OracleConnection(connString))
        {
            conn.Open();
            cmd.Connection = conn;
            cmd.CommandText = cmdText;
            if (cmdParms != null)
            {
                foreach (OracleParameter parm in cmdParms)
                    cmd.Parameters.Add(parm);
            }
            object val = cmd.ExecuteScalar();
            cmd.Parameters.Clear();
            conn.Close();
            return val;
        }
    }


    // ============================================================== 
    // ===================数据库操作:插入,修改,列表显示,以及获得详细记录=================
    // ============================================================== 

    /// <summary>
    /// 执行Sql语句
    /// </summary>
    /// <param name="connString">数据库连接</param>
    /// <param name="str_Sql">sql语句(比如:insert into tablename set name='北京'')</param>
    public static void RunSql(string connString, string str_Sql)
    {
        Data.ExecuteNonQuery(connString, CommandType.Text, str_Sql);
    }
    /// <summary>
    /// 插入记录
    /// </summary>
    /// <param name="connString">数据库连接</param>
    /// <param name="cmdType">sql语句类型</param>
    /// <param name="str_Sql">sql语句</param>
    /// <param name="ht">表示层传递过来的哈希表对象</param>
    public static void Insert(string connString, string TableName, Hashtable ht)
    {
        OracleParameter[] Parms = new OracleParameter[ht.Count];
        IDictionaryEnumerator et = ht.GetEnumerator();
        int i = 0;
        // 作哈希表循环
        while (et.MoveNext())
        {
            System.Data.OracleClient.OracleParameter sp = Data.MakeParam("@" + et.Key.ToString(), et.Value.ToString());
            Parms[i] = sp; // 添加SqlParameter对象
            i = i + 1;
        }
        string str_Sql = GetInsertSqlbyHt(TableName, ht); // 获得插入sql语句
        Data.ExecuteNonQuery(connString, CommandType.Text, str_Sql, Parms);
    }
    /// <summary>
    /// 删除记录
    /// </summary>
    /// <param name="connString">数据库连接</param>
    /// <param name="cmdType">sql语句类型</param>
    /// <param name="str_Sql">sql语句</param>
    /// <param name="ht">表示层传递过来的哈希表对象</param>
    public static void Del(string connString, string TableName, string ht_Where, Hashtable ht)
    {
        OracleParameter[] Parms = new OracleParameter[ht.Count];
        IDictionaryEnumerator et = ht.GetEnumerator();
        int i = 0;
        // 作哈希表循环
        while (et.MoveNext())
        {
            System.Data.OracleClient.OracleParameter sp = Data.MakeParam("@" + et.Key.ToString(), et.Value.ToString());
            Parms[i] = sp; // 添加SqlParameter对象
            i = i + 1;
        }
        string str_Sql = GetDelSqlbyHt(TableName, ht_Where, ht); // 获得删除sql语句
        Data.ExecuteNonQuery(connString, CommandType.Text, str_Sql, Parms);
    }

    /// <summary>
    /// 修改记录
    /// </summary>
    /// <param name="connString">数据库连接</param>
    /// <param name="TableName">数据库表名</param>
    /// <param name="str_Where">传递条件,比如Id=@Id</param>
    /// <param name="ht">表示层传递过来的哈希表对象</param>
    public static void Update(string connString, string TableName, string ht_Where, Hashtable ht)
    {
        OracleParameter[] Parms = new OracleParameter[ht.Count];
        IDictionaryEnumerator et = ht.GetEnumerator();
        int i = 0;
        // 作哈希表循环
        while (et.MoveNext())
        {
            System.Data.OracleClient.OracleParameter sp = Data.MakeParam("@" + et.Key.ToString(), et.Value.ToString());
            Parms[i] = sp; // 添加SqlParameter对象
            i = i + 1;
        }
        string str_Sql = GetUpdateSqlbyHt(TableName, ht_Where, ht); // 获得插入sql语句
        Data.ExecuteNonQuery(connString, CommandType.Text, str_Sql, Parms);
    }
    /// <summary>
    /// 获得数字字段最大值(注:当该表记录为空,返回0)
    /// </summary>
    /// <param name="connString">数据库连接</param>
    /// <param name="id">Key值字段名</param>
    /// <param name="table_name">数据库名</param>
    /// <returns>返回数字字段最大值</returns>
    public static int GetMaxId(string connString, string id, string table_name)
    {
        string str_Sql = "Select Max(" + id + ") from " + table_name;
        int int_MaxId = 0;
        object obj = Data.ExecuteScalar(connString, CommandType.Text, str_Sql, null);
        if (obj == System.DBNull.Value)
        {
            int_MaxId = 0;
        }
        else
        {
            int_MaxId = Convert.ToInt32(obj);
        }

        return int_MaxId;
    }

    /// <summary>
    /// 通过传递条件获得记录条数
    /// </summary>
    /// <param name="ht">表示层传递过来的条件字段参数</param>
    /// <returns>返回记录条数</returns>
    public static int GetRsCount(string connString, string Table, string ht_Where, Hashtable ht)
    {
        if (ht == null)
        {
            string str_Sql = GetPageListCountSqlbyHt(Table, ht_Where, null);
            object obj= ExecuteScalar(connString, CommandType.Text, str_Sql, null);

            return Convert.ToInt32(obj);
        }
        else
        {
            string str_Sql = GetPageListCountSqlbyHt(Table, ht_Where, ht);
            OracleParameter[] Parms = new OracleParameter[ht.Count];
            IDictionaryEnumerator et = ht.GetEnumerator();
            int i = 0;
            // 作哈希表循环
            while (et.MoveNext())
            {
                System.Data.OracleClient.OracleParameter sp = Data.MakeParam("@" + et.Key.ToString(), et.Value.ToString());
                Parms[i] = sp; // 添加SqlParameter对象
                i = i + 1;
            }
            return (int)ExecuteScalar(connString, CommandType.Text, str_Sql, Parms);
        }
    }
    /// <summary>
    /// 通过传递条件获得记录条数
    /// </summary>
    /// <param name="connString">数据库连接</param>
    /// <param name="str_Sql">Sql语句</param>
    /// <returns>返回记录条数</returns>
    public static int GetRsCount(string connString, string str_Sql)
    {
        return (int)ExecuteScalar(connString, CommandType.Text, str_Sql, null);
    }
    /// <summary>
    /// 获得单个字段值
    /// </summary>
    /// <param name="connString">数据库连接</param>
    /// <param name="str_Sql">Sql语句,比如Select Name from Table where id=2</param>
    /// <returns></returns>
    public static string GetFiledValue(string connString, string str_Sql)
    {
        return ExecuteScalar(connString, CommandType.Text, str_Sql, null).ToString();
    }

    /// <summary>
    /// 通过运行Sql语句获得IList数据源
    /// </summary>
    /// <param name="conn_Default">数据库连接</param>
    /// <param name="int_PageSize">一页显示记录数</param>
    /// <param name="int_CurrentPageIndex">当前页码</param>
    /// <param name="str_Sql">Sql语句</param>
    /// <param name="class_Name">实体类名</param>
    /// <returns></returns>
    public static IList RunSql(string conn_Default, int int_PageSize, int int_CurrentPageIndex, string str_Sql, string class_Name)
    {
        // ===获得数据库源,返回IList为数据源===
        IList Ilst = new ArrayList();
        // 当没有传递条件参数时作的操作
        using (DataSet ds = ExecuteDataSet(int_PageSize, int_CurrentPageIndex, conn_Default, CommandType.Text, str_Sql, null))
        {
            DataTable dt = ds.Tables[0];
            for (int j = 0; j < dt.Rows.Count; j++)
            {

                Type myType = Type.GetType(class_Name);// 获得“类”类型
                Object o_Instance = System.Activator.CreateInstance(myType); // 实例化类
                // 获得类的所有属性数组
                PropertyInfo[] myPropertyInfo1 = myType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                // 循环属性数组,并给数组属性赋值
                for (int k = 0; k < myPropertyInfo1.Length; k++)
                {
                    PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo1[k];
                    Object filed_Val = dt.Rows[j][myPropInfo.Name];
                    switch (myPropInfo.PropertyType.ToString())
                    {
                        case "System.Int32":
                            myPropInfo.SetValue(o_Instance, (int)filed_Val, null);
                            break;
                        case "System.String":
                            myPropInfo.SetValue(o_Instance, filed_Val.ToString(), null);
                            break;
                        case "System.DateTime":
                            myPropInfo.SetValue(o_Instance, Convert.ToDateTime(filed_Val.ToString()), null);
                            break;
                    }

                }
                // 把一行类记录赋值给ILst对象
                Ilst.Add(o_Instance);

            }
        }
        return Ilst;
    }

    public static IList RunSql(string conn_Default, int int_PageSize, int int_CurrentPageIndex, string procName, OracleParameter[] prams, string class_Name)
    {
        // ===获得数据库源,返回IList为数据源===
        IList Ilst = new ArrayList();
        // 当没有传递条件参数时作的操作
        using (DataSet ds = ExecuteDataSet(int_PageSize, int_CurrentPageIndex, conn_Default, CommandType.StoredProcedure, procName, prams))
        {
            DataTable dt = ds.Tables[0];
            for (int j = 0; j < dt.Rows.Count; j++)
            {

                Type myType = Type.GetType(class_Name);// 获得“类”类型
                Object o_Instance = System.Activator.CreateInstance(myType); // 实例化类
                // 获得类的所有属性数组
                PropertyInfo[] myPropertyInfo1 = myType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                // 循环属性数组,并给数组属性赋值
                for (int k = 0; k < myPropertyInfo1.Length; k++)
                {
                    PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo1[k];
                    Object filed_Val = dt.Rows[j][myPropInfo.Name];
                    switch (myPropInfo.PropertyType.ToString())
                    {
                        case "System.Int32":
                            myPropInfo.SetValue(o_Instance, (int)filed_Val, null);
                            break;
                        case "System.String":
                            myPropInfo.SetValue(o_Instance, filed_Val.ToString(), null);
                            break;
                        case "System.DateTime":
                            myPropInfo.SetValue(o_Instance, Convert.ToDateTime(filed_Val.ToString()), null);
                            break;
                    }

                }
                // 把一行类记录赋值给ILst对象
                Ilst.Add(o_Instance);

            }
        }
        return Ilst;
    }

    /// <summary>
    /// 通过页大小,当前页数返回IList数据源
    /// </summary>
    /// <param name="int_PageSize">一页记录数</param>
    /// <param name="int_CurrentPageIndex">当前页数</param>
    /// <param name="Sql_Sel_Code">SQl语句</param>
    /// <param name="ht">传递条件哈希表</param>
    /// <param name="class_Name">实体类名</param>
    /// <returns>表示层传递过来的条件字段参数</returns>
    public static IList GetPageList(string conn_Default, int int_PageSize, int int_CurrentPageIndex, string Table, string ht_Where, string orderby, Hashtable ht, string class_Name)
    {
        // ===获得数据库源,返回IList为数据源===
        IList Ilst = new ArrayList();

        if (ht == null)
        {
            // 当没有传递条件参数时作的操作
            string str_Sql = GetPageListSqlbyHt(Table, ht_Where, orderby, null, class_Name);
            using (DataSet ds = ExecuteDataSet(int_PageSize, int_CurrentPageIndex, conn_Default, CommandType.Text, str_Sql, null))
            {
                DataTable dt = ds.Tables[0];
                for (int j = 0; j < dt.Rows.Count; j++)
                {

                    Type myType = Type.GetType(class_Name);// 获得“类”类型
                    Object o_Instance = System.Activator.CreateInstance(myType); // 实例化类
                    // 获得类的所有属性数组
                    PropertyInfo[] myPropertyInfo1 = myType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                    // 循环属性数组,并给数组属性赋值
                    for (int k = 0; k < myPropertyInfo1.Length; k++)
                    {
                        PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo1[k];

                        Object filed_Val = dt.Rows[j][myPropInfo.Name];
                        switch (myPropInfo.PropertyType.ToString())
                        {
                            case "System.Byte":
                                myPropInfo.SetValue(o_Instance, (int)filed_Val, null);
                                break;
                            case "System.String":
                                myPropInfo.SetValue(o_Instance, filed_Val.ToString(), null);
                                break;
                            case "System.DateTime":
                                myPropInfo.SetValue(o_Instance, Convert.ToDateTime(filed_Val.ToString()), null);
                                break;
                        }

                    }
                    // 把一行类记录赋值给ILst对象
                    Ilst.Add(o_Instance);
                }
            }
        }
        else // 当没有传递条件参数时作的操作
        {
            // 处理传递过来的参数
            OracleParameter[] Parms = new OracleParameter[ht.Count];
            IDictionaryEnumerator et = ht.GetEnumerator();
            int i = 0;
            while (et.MoveNext())
            {
                System.Data.OracleClient.OracleParameter sp = MakeParam("@" + et.Key.ToString(), et.Value.ToString());
                Parms[i] = sp;
                i = i + 1;
            }
            string str_Sql = GetPageListSqlbyHt(Table, ht_Where, orderby, ht, class_Name);
            // 返回ILst
            using (DataSet ds = ExecuteDataSet(int_PageSize, int_CurrentPageIndex, conn_Default, CommandType.Text, str_Sql, Parms))
            {
                DataTable dt = ds.Tables[0];
                for (int j = 0; j < dt.Rows.Count; j++)
                {
                    Type myType = Type.GetType(class_Name);// 获得“类”类型
                    Object o_Instance = System.Activator.CreateInstance(myType); // 实例化类
                    // 获得类的所有属性数组
                    PropertyInfo[] myPropertyInfo1 = myType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                    // 循环属性数组,并给数组属性赋值
                    for (int k = 0; k < myPropertyInfo1.Length; k++)
                    {
                        PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo1[k];
                        Object filed_Val = dt.Rows[j][myPropInfo.Name];
                        switch (myPropInfo.PropertyType.ToString())
                        {
                            case "System.Int32":
                                myPropInfo.SetValue(o_Instance, (int)filed_Val, null);
                                break;
                            case "System.String":
                                myPropInfo.SetValue(o_Instance, filed_Val.ToString(), null);
                                break;
                            case "System.DateTime":
                                myPropInfo.SetValue(o_Instance, Convert.ToDateTime(filed_Val.ToString()), null);
                                break;
                        }
                    }
                    // 把一行类记录赋值给ILst对象

 


                    Ilst.Add(o_Instance);

                }
            }

        }
        return Ilst;
    }


    /// <summary>
    /// ===通过页大小,当前页数返回IList数据源===
    /// </summary>
    /// <param name="int_PageSize">一页记录数</param>
    /// <param name="int_CurrentPageIndex">当前页数</param>
    /// <param name="Sql_Sel_Code">SQl语句</param>
    /// <param name="ht">传递条件哈希表</param>
    /// <param name="class_Name">实体类名</param>
    /// <returns>表示层传递过来的条件字段参数</returns>
    public static Object GetDetail(string conn_Default, string Table, string ht_Where, Hashtable ht, string class_Name)
    {
        // ===获得数据库源,返回IList为数据源===
        IList Ilst = new ArrayList();

        if (ht == null)
        {
            string str_Sql = GetPageListSqlbyHt(Table, ht_Where, null, null, class_Name);
            // 当没有传递条件参数时作的操作
            using (DataSet ds = ExecuteDataSet(conn_Default, CommandType.Text, str_Sql, null))
            {
                DataTable dt = ds.Tables[0];
                for (int j = 0; j < dt.Rows.Count; j++)
                {

                    Type myType = Type.GetType(class_Name);// 获得“类”类型
                    Object o_Instance = System.Activator.CreateInstance(myType); // 实例化类
                    // 获得类的所有属性数组
                    PropertyInfo[] myPropertyInfo1 = myType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                    // 循环属性数组,并给数组属性赋值
                    for (int k = 0; k < myPropertyInfo1.Length; k++)
                    {
                        PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo1[k];
                        Object filed_Val = dt.Rows[j][myPropInfo.Name];
                        switch (myPropInfo.PropertyType.ToString())
                        {
                            case "System.Int32":
                                myPropInfo.SetValue(o_Instance, (int)filed_Val, null);
                                break;
                            case "System.String":
                                myPropInfo.SetValue(o_Instance, filed_Val.ToString(), null);
                                break;
                            case "System.DateTime":
                                myPropInfo.SetValue(o_Instance, Convert.ToDateTime(filed_Val.ToString()), null);
                                break;
                        }

                    }
                    // 把一行类记录赋值给ILst对象
                    return o_Instance;
                }
            }
        }
        else // 当没有传递条件参数时作的操作
        {
            // 处理传递过来的参数
            OracleParameter[] Parms = new OracleParameter[ht.Count];
            IDictionaryEnumerator et = ht.GetEnumerator();
            int i = 0;
            while (et.MoveNext())
            {
                System.Data.OracleClient.OracleParameter sp = MakeParam("@" + et.Key.ToString(), et.Value.ToString());
                Parms[i] = sp;
                i = i + 1;
            }

            string str_Sql = GetPageListSqlbyHt(Table, ht_Where, null, ht, class_Name);
            // 返回ILst
            using (DataSet ds = ExecuteDataSet(conn_Default, CommandType.Text, str_Sql, Parms))
            {
                DataTable dt = ds.Tables[0];
                for (int j = 0; j < dt.Rows.Count; j++)
                {

                    Type myType = Type.GetType(class_Name);// 获得“类”类型
                    Object o_Instance = System.Activator.CreateInstance(myType); // 实例化类
                    // 获得类的所有属性数组
                    PropertyInfo[] myPropertyInfo1 = myType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
                    // 循环属性数组,并给数组属性赋值
                    for (int k = 0; k < myPropertyInfo1.Length; k++)
                    {
                        PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo1[k];
                        Object filed_Val = dt.Rows[j][myPropInfo.Name];
                        switch (myPropInfo.PropertyType.ToString())
                        {
                            case "System.Int32":
                                myPropInfo.SetValue(o_Instance, (int)filed_Val, null);
                                break;
                            case "System.String":
                                myPropInfo.SetValue(o_Instance, filed_Val.ToString(), null);
                                break;
                            case "System.DateTime":
                                myPropInfo.SetValue(o_Instance, Convert.ToDateTime(filed_Val.ToString()), null);
                                break;
                        }

                    }
                    // 把一行类记录赋值给ILst对象
                    return o_Instance;

                }
            }

        }
        return Ilst;
    }

 

    // ============================================================== 
    // ===========================内部调用函数============================
    // ============================================================== 
    /// <summary>
    /// 获得删除Sql语句
    /// </summary>
    /// <param name="Table">数据库表名</param>
    /// <param name="ht_Where">传递条件,比如Id=@Id</param>
    /// <param name="ht">表示层传递过来的哈希表对象</param>
    /// <returns>返回删除sql语句</returns>
    public static string GetDelSqlbyHt(string Table, string ht_Where, Hashtable ht)
    {
        string str_Sql = "";
        int i = 0;

        int ht_Count = ht.Count; // 哈希表个数
        IDictionaryEnumerator myEnumerator = ht.GetEnumerator();
        while (myEnumerator.MoveNext())
        {
            if (i == 0)
            {
                if (ht_Where.ToString().ToLower().IndexOf((myEnumerator.Key + "=@" + myEnumerator.Key).ToLower()) == -1)
                {
                    str_Sql = myEnumerator.Key + "=@" + myEnumerator.Key;
                }
            }
            else
            {
                if (ht_Where.ToString().ToLower().IndexOf(("@" + myEnumerator.Key + " ").ToLower()) == -1)
                {
                    str_Sql = str_Sql + "," + myEnumerator.Key + "=@" + myEnumerator.Key;
                }

            }
            i = i + 1;
        }
        if (ht_Where == null || ht_Where.Replace(" ", "") == "")  // 更新时候没有条件
        {
            str_Sql = "Delete " + Table;
        }
        else
        {
            str_Sql = "Delete " + Table + " where " + ht_Where;
        }
        return str_Sql;
    }

    /// <summary>
    /// 获得插入Sql语句
    /// </summary>
    /// <param name="TableName">数据库表名</param>
    /// <param name="ht">表示层传递过来的哈希表对象</param>
    /// <returns>返回插入Sql语句</returns>
    public static string GetInsertSqlbyHt(string TableName, Hashtable ht)
    {
        string str_Sql = "";
        int i = 0;

        int ht_Count = ht.Count; // 哈希表个数
        IDictionaryEnumerator myEnumerator = ht.GetEnumerator();
        string before = "";
        string behide = "";
        while (myEnumerator.MoveNext())
        {
            if (i == 0)
            {
                before = "(" + myEnumerator.Key;
            }
            else if (i + 1 == ht_Count)
            {
                before = before + "," + myEnumerator.Key + ")";
            }
            else
            {
                before = before + "," + myEnumerator.Key;
            }
            i = i + 1;
        }
        behide = " Values" + before.Replace(",", ",@").Replace("(", "(@");
        str_Sql = "Insert into " + TableName + before + behide;
        return str_Sql;

    }

    /// <summary>
    /// 获得记录数sql语句
    /// </summary>
    /// <param name="Table">数据库表</param>
    /// <param name="ht_Where">条件</param>
    /// <param name="ht">表示层传递过来的哈希表对象</param>
    /// <returns></returns>
    public static string GetPageListCountSqlbyHt(string Table, string ht_Where, Hashtable ht)
    {
        string str_Sql = "";
        if (ht_Where == "" || ht_Where == null)
        {
            string str_Ht = "";
            if (ht != null) // 用ht做条件
            {

                IDictionaryEnumerator et = ht.GetEnumerator();
                int k = 0;
                while (et.MoveNext())
                {
                    if (k == 0)
                    {
                        str_Ht = " " + et.Key.ToString() + "=@" + et.Key.ToString();
                    }
                    else
                    {
                        str_Ht = str_Ht + " and " + et.Key.ToString() + "=@" + et.Key.ToString();
                    }
                    k = k + 1;
                }
            }
            if (str_Ht != "")
            {
                str_Sql = "Select Count(*) From " + Table + " where " + str_Ht;
            }
            else
            {
                str_Sql = "Select Count(*) From " + Table;
            }
        }
        else
        {
            str_Sql = "Select Count(*) From " + Table + " where " + ht_Where;
        }

        return str_Sql;

    }


    /// <summary>
    /// 通过传递哈希表参数,获得更新Sql语句
    /// </summary>
    /// <param name="Table">数据库表名</param>
    /// <param name="ht_Where">传递条件,比如Id=@Id</param>
    /// <param name="ht">表示层传递过来的哈希表对象</param>
    /// <returns></returns>
    public static string GetUpdateSqlbyHt(string Table, string ht_Where, Hashtable ht)
    {
        string str_Sql = "";
        int i = 0;

        int ht_Count = ht.Count; // 哈希表个数
        IDictionaryEnumerator myEnumerator = ht.GetEnumerator();
        while (myEnumerator.MoveNext())
        {
            if (i == 0)
            {
                if (ht_Where.ToString().ToLower().IndexOf((myEnumerator.Key + "=@" + myEnumerator.Key).ToLower()) == -1)
                {
                    str_Sql = myEnumerator.Key + "=@" + myEnumerator.Key;
                }
            }
            else
            {
                if (ht_Where.ToString().ToLower().IndexOf(("@" + myEnumerator.Key + " ").ToLower()) == -1)
                {
                    str_Sql = str_Sql + "," + myEnumerator.Key + "=@" + myEnumerator.Key;
                }

            }
            i = i + 1;
        }
        if (ht_Where == null || ht_Where.Replace(" ", "") == "")  // 更新时候没有条件
        {
            str_Sql = "update " + Table + " set " + str_Sql;
        }
        else
        {
            str_Sql = "update " + Table + " set " + str_Sql + " where " + ht_Where;
        }
        str_Sql = str_Sql.Replace("set ,", "set ").Replace("update ,", "update ");
        return str_Sql;
    }
    /// <summary>
    /// 获得IList分页Sql语句
    /// </summary>
    /// <param name="Table">数据库表</param>
    /// <param name="ht_Where">条件</param>
    /// <param name="orderby">排序</param>
    /// <param name="ht">表示层传递过来的条件字段参数</param>
    /// <param name="class_Name">实体类名</param>
    /// <returns></returns>
    public static string GetPageListSqlbyHt(string Table, string ht_Where, string orderby, Hashtable ht, String class_Name)
    {
        string str_Sql = "";

        // 选择类型只能实现 Select * from table where a=@a and b=@b效果
        // where 后面优先权,当ht_Where不为空或者不为null,条件应该是ht_Where参数,否则,用ht做循环

        Type myType = Type.GetType(class_Name);// 获得“类”类型
        Object o_Instance = System.Activator.CreateInstance(myType); // 实例化类
        // 获得类的所有属性数组
        PropertyInfo[] myPropertyInfo1 = myType.GetProperties(BindingFlags.Public | BindingFlags.Instance);
        // 循环属性数组,并给数组属性赋值
        for (int k = 0; k < myPropertyInfo1.Length; k++)
        {
            PropertyInfo myPropInfo = (PropertyInfo)myPropertyInfo1[k];
            if (k == 0)
            {
                str_Sql = myPropInfo.Name.ToString();
            }
            else
            {
                str_Sql = str_Sql + "," + myPropInfo.Name.ToString();
            }

        }
        if (ht_Where == "" || ht_Where == null)
        {
            string str_Ht = "";
            if (ht != null) // 用ht做条件
            {

                IDictionaryEnumerator et = ht.GetEnumerator();
                int k = 0;
                while (et.MoveNext())
                {
                    if (k == 0)
                    {
                        str_Ht = " " + et.Key.ToString() + "=@" + et.Key.ToString();
                    }
                    else
                    {
                        str_Ht = str_Ht + " and " + et.Key.ToString() + "=@" + et.Key.ToString();
                    }
                    k = k + 1;
                }
            }
            if (orderby == "" || orderby == null)
            {
                if (str_Ht != "")
                {
                    str_Sql = "Select " + str_Sql + " From " + Table + " where " + str_Ht;
                }
                else
                {
                    str_Sql = "Select " + str_Sql + " From " + Table;
                }
            }
            else
            {
                if (str_Ht != "")
                {
                    str_Sql = "Select " + str_Sql + " From " + Table + " where " + str_Ht + "  order by " + orderby;

                }
                else
                {
                    str_Sql = "Select " + str_Sql + " From " + Table;
                }

            }

        }
        else // 用ht_Where做条件
        {
            if (orderby == "" || orderby == null)
            {
                str_Sql = "Select " + str_Sql + " From " + Table + " Where " + ht_Where;
            }
            else
            {
                str_Sql = "Select " + str_Sql + " From " + Table + " where " + ht_Where + "  order by " + orderby;
            }

        }

        return str_Sql;

    }

}

 

 

 

 

 

 

 

 

 

 

 

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;

/// <summary>
/// User 的摘要说明
/// </summary>
public class User
{
    DALUser dal = new DALUser(); // 实例化用户维护数据类
 public User()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //
 }


    public IList GetUsers(int int_PageSize, int int_CurrentPageIndex, Hashtable ht)
    {
        return dal.GetUsers(int_PageSize, int_CurrentPageIndex, ht);
    }

    /// <summary>
    /// 获得用户维护全部列表
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public IList GetUsers(Hashtable ht)
    {
        return dal.GetUsers(ht);
    }
    /// <summary>
    /// 获得一个用户维护详细信息
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public UserInfo GetUserDetail(Hashtable ht)
    {
        return dal.GetUserDetail(ht);
    }

    /// <summary>
    /// 获得用户维护总记录数
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public int GetUsersCount(Hashtable ht)
    {
        return dal.GetUsersCount(ht);
    }
    /// <summary>
    /// 通过帐号获得一个用户维护详细信息
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public UserInfo GetUserDetailByUserId(Hashtable ht)
    {
        return dal.GetUserDetailByUserId(ht);
    }

    // ============================================================== 
    // ============================数据操作函数===========================
    // ==============================================================

    /// <summary>
    /// 增加记录时判断帐号是否重复
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public int GetAddUsersCount(Hashtable ht)
    {
        return dal.GetAddUsersCount(ht);
    }
    /// <summary>
    /// 修改记录时判断帐号是否重复
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public int GetEditUsersCount(Hashtable ht)
    {
        return dal.GetEditUsersCount(ht);
    }
    /// <summary>
    /// 增加记录
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    public void Insert(Hashtable ht)
    {
        dal.Insert(ht);
    }
    /// <summary>
    ///  修改记录
    /// </summary>
    /// <param name="User">字段,字段值参数</param>
    public void Update(Hashtable ht)
    {
        dal.Update(ht);
    }
    /// <summary>
    ///  用户验证
    /// </summary>
    /// <param name="User">字段,字段值参数</param>
    public int UserValidate(Hashtable ht)
    {
        return dal.UserValidate(ht);
    }

}

 

 

 

 

 

 

 

 

 

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;

/// <summary>
/// UserInfo 的摘要说明
/// </summary>
public class UserInfo
{
 public UserInfo()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //
 }

    #region Model
    private int _user_id;
    private string _user_code;
    private string _user_name;
    private string _user_short_name;
    private int _user_type;
    private string _current_password;
    private DateTime _user_birthday;
    private string _pwd_question;
    private string _pwd_answer;
    private string _link_addr;
    private string _link_mobil;
    private string _link_phone;
    private string _link_name;
    private string _link_fax;
    private string _link_email;
    private string _link_bb;
    private string _link_website;
    private string _link_desc;
    private string _link_qq;
    private string _link_company;
    private DateTime _last_update_date;
    private int _last_updated_by;
    private DateTime _creation_date;
    private int _session_number;
    private DateTime _start_date;
    private DateTime _end_date;
    private string _description;
    private string _register_ip;
    private int _login_times;
    private string _attribute1;
    private string _attribute2;
    private string _attribute3;
    private string _attribute4;
    private string _attribute5;
    private string _link_post_code;
    private string _bank_num;
    private string _tax_code;
    private string _manager;
    private string _belong_to_status;
    private string _is_active;
    private int _area_id;
    private string _source_type;
    private string _is_entity;
    private int _father_user_id;
    /// <summary>
    ///
    /// </summary>
    public int USER_ID
    {
        set { _user_id = value; }
        get { return _user_id; }
    }
    /// <summary>
    ///
    /// </summary>
    public string USER_CODE
    {
        set { _user_code = value; }
        get { return _user_code; }
    }
    /// <summary>
    ///
    /// </summary>
    public string USER_NAME
    {
        set { _user_name = value; }
        get { return _user_name; }
    }
    /// <summary>
    ///
    /// </summary>
    public string USER_SHORT_NAME
    {
        set { _user_short_name = value; }
        get { return _user_short_name; }
    }
    /// <summary>
    ///
    /// </summary>
    public int USER_TYPE
    {
        set { _user_type = value; }
        get { return _user_type; }
    }
    /// <summary>
    ///
    /// </summary>
    public string CURRENT_PASSWORD
    {
        set { _current_password = value; }
        get { return _current_password; }
    }
    /// <summary>
    ///
    /// </summary>
    public DateTime USER_BIRTHDAY
    {
        set { _user_birthday = value; }
        get { return _user_birthday; }
    }
    /// <summary>
    ///
    /// </summary>
    public string PWD_QUESTION
    {
        set { _pwd_question = value; }
        get { return _pwd_question; }
    }
    /// <summary>
    ///
    /// </summary>
    public string PWD_ANSWER
    {
        set { _pwd_answer = value; }
        get { return _pwd_answer; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_ADDR
    {
        set { _link_addr = value; }
        get { return _link_addr; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_MOBIL
    {
        set { _link_mobil = value; }
        get { return _link_mobil; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_PHONE
    {
        set { _link_phone = value; }
        get { return _link_phone; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_NAME
    {
        set { _link_name = value; }
        get { return _link_name; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_FAX
    {
        set { _link_fax = value; }
        get { return _link_fax; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_EMAIL
    {
        set { _link_email = value; }
        get { return _link_email; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_BB
    {
        set { _link_bb = value; }
        get { return _link_bb; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_WEBSITE
    {
        set { _link_website = value; }
        get { return _link_website; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_DESC
    {
        set { _link_desc = value; }
        get { return _link_desc; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_QQ
    {
        set { _link_qq = value; }
        get { return _link_qq; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_COMPANY
    {
        set { _link_company = value; }
        get { return _link_company; }
    }
    /// <summary>
    ///
    /// </summary>
    public DateTime LAST_UPDATE_DATE
    {
        set { _last_update_date = value; }
        get { return _last_update_date; }
    }
    /// <summary>
    ///
    /// </summary>
    public int LAST_UPDATED_BY
    {
        set { _last_updated_by = value; }
        get { return _last_updated_by; }
    }
    /// <summary>
    ///
    /// </summary>
    public DateTime CREATION_DATE
    {
        set { _creation_date = value; }
        get { return _creation_date; }
    }
    /// <summary>
    ///
    /// </summary>
    public int SESSION_NUMBER
    {
        set { _session_number = value; }
        get { return _session_number; }
    }
    /// <summary>
    ///
    /// </summary>
    public DateTime START_DATE
    {
        set { _start_date = value; }
        get { return _start_date; }
    }
    /// <summary>
    ///
    /// </summary>
    public DateTime END_DATE
    {
        set { _end_date = value; }
        get { return _end_date; }
    }
    /// <summary>
    ///
    /// </summary>
    public string DESCRIPTION
    {
        set { _description = value; }
        get { return _description; }
    }
    /// <summary>
    ///
    /// </summary>
    public string REGISTER_IP
    {
        set { _register_ip = value; }
        get { return _register_ip; }
    }
    /// <summary>
    ///
    /// </summary>
    public int LOGIN_TIMES
    {
        set { _login_times = value; }
        get { return _login_times; }
    }
    /// <summary>
    ///
    /// </summary>
    public string ATTRIBUTE1
    {
        set { _attribute1 = value; }
        get { return _attribute1; }
    }
    /// <summary>
    ///
    /// </summary>
    public string ATTRIBUTE2
    {
        set { _attribute2 = value; }
        get { return _attribute2; }
    }
    /// <summary>
    ///
    /// </summary>
    public string ATTRIBUTE3
    {
        set { _attribute3 = value; }
        get { return _attribute3; }
    }
    /// <summary>
    ///
    /// </summary>
    public string ATTRIBUTE4
    {
        set { _attribute4 = value; }
        get { return _attribute4; }
    }
    /// <summary>
    ///
    /// </summary>
    public string ATTRIBUTE5
    {
        set { _attribute5 = value; }
        get { return _attribute5; }
    }
    /// <summary>
    ///
    /// </summary>
    public string LINK_POST_CODE
    {
        set { _link_post_code = value; }
        get { return _link_post_code; }
    }
    /// <summary>
    ///
    /// </summary>
    public string BANK_NUM
    {
        set { _bank_num = value; }
        get { return _bank_num; }
    }
    /// <summary>
    ///
    /// </summary>
    public string TAX_CODE
    {
        set { _tax_code = value; }
        get { return _tax_code; }
    }
    /// <summary>
    ///
    /// </summary>
    public string MANAGER
    {
        set { _manager = value; }
        get { return _manager; }
    }
    /// <summary>
    ///
    /// </summary>
    public string BELONG_TO_STATUS
    {
        set { _belong_to_status = value; }
        get { return _belong_to_status; }
    }
    /// <summary>
    ///
    /// </summary>
    public string IS_ACTIVE
    {
        set { _is_active = value; }
        get { return _is_active; }
    }
    /// <summary>
    ///
    /// </summary>
    public int AREA_ID
    {
        set { _area_id = value; }
        get { return _area_id; }
    }
    /// <summary>
    ///
    /// </summary>
    public string SOURCE_TYPE
    {
        set { _source_type = value; }
        get { return _source_type; }
    }
    /// <summary>
    ///
    /// </summary>
    public string IS_ENTITY
    {
        set { _is_entity = value; }
        get { return _is_entity; }
    }
    /// <summary>
    ///
    /// </summary>
    public int FATHER_USER_ID
    {
        set { _father_user_id = value; }
        get { return _father_user_id; }
    }
    #endregion Model
}

 

 

 

 

 

 

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;

/// <summary>
/// DALUser 的摘要说明
/// </summary>
public class DALUser
{
 public DALUser()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //
 }


    private const string Model_ClassName = "UserInfo"; // 用户维护实体类名

    // ============================================================== 
    // ============================列表函数=============================
    // ==============================================================

    /// <summary>
    /// 获得用户维护单页列表
    /// </summary>
    /// <param name="int_PageSize">一页显示的记录数</param>
    /// <param name="int_CurrentPageIndex">当前页码</param>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public IList GetUsers(int int_PageSize, int int_CurrentPageIndex, Hashtable ht)
    {
        return Data.GetPageList(Data.conn_Default, int_PageSize, int_CurrentPageIndex, "YT_USER", null, null, ht, Model_ClassName);
    }
    /// <summary>
    /// 获得用户维护总记录数
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public int GetUsersCount(Hashtable ht)
    {
        return Data.GetRsCount(Data.conn_Default, "YT_USER", null, ht);
    }

    /// <summary>
    /// 获得用户维护全部列表
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public IList GetUsers(Hashtable ht)
    {
        return Data.GetPageList(Data.conn_Default, 0, 0, "YT_USER", null, null, ht, Model_ClassName);
    }

    /// <summary>
    /// 获得一个用户维护详细信息
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public UserInfo GetUserDetail(Hashtable ht)
    {
        return (UserInfo)Data.GetDetail(Data.conn_Default, "YT_USER", "id=@Id", ht, Model_ClassName);
    }

    /// <summary>
    /// 通过帐号获得一个用户维护详细信息
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public UserInfo GetUserDetailByUserId(Hashtable ht)
    {
        return (UserInfo)Data.GetDetail(Data.conn_Default, "YT_USER", "USER_ID=@User_Id", ht, Model_ClassName);
    }


    // ============================================================== 
    // ============================数据操作函数===========================
    // ==============================================================

    /// <summary>
    /// 增加记录时判断帐号是否重复
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public int GetAddUsersCount(Hashtable ht)
    {
        return Data.GetRsCount(Data.conn_Default, "YT_USER", "USER_ID=@User_Id", ht);
    }
    /// <summary>
    /// 修改记录时判断帐号是否重复
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    /// <returns></returns>
    public int GetEditUsersCount(Hashtable ht)
    {
        return Data.GetRsCount(Data.conn_Default, "YT_USER", "USER_ID=@User_Id and Id<>@Id", ht);
    }

    /// <summary>
    /// 增加记录
    /// </summary>
    /// <param name="ht">字段,字段值参数</param>
    public void Insert(Hashtable ht)
    {
        // ===获得最大Id值并修改哈希表Id键值===
        ht["Id"] = Data.GetMaxId(Data.conn_Default, "Id", "YT_USER") + 1;
        // ===插入操作===
        Data.Insert(Data.conn_Default, "YT_USER", ht);
    }

    /// <summary>
    ///  修改记录
    /// </summary>
    /// <param name="User">字段,字段值参数</param>
    public void Update(Hashtable ht)
    {
        Data.Update(Data.conn_Default, "YT_USER", "Id=@Id", ht);
    }
    /// <summary>
    ///  用户验证
    /// </summary>
    /// <param name="User">字段,字段值参数</param>
    public int UserValidate(Hashtable ht)
    {
        return Data.GetRsCount(Data.conn_Default, "YT_USER", "User_Id=@User_Id and Password=@Password", ht);
    }
}

 

 

using System;
using System.Collections;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.IO;
using System.Web.UI.WebControls;
using System.Text;
using System.Security.Cryptography;
using System.Net;

/// <summary>
/// Config 的摘要说明
/// </summary>
public class Config:Page
{
 public Config()
 {
  //
  // TODO: 在此处添加构造函数逻辑
  //
 }

 

    /// <summary>
    /// Set control's mode
    /// </summary>
    /// <param name="ctrls">name of control</param>
    /// <param name="Type">type of control</param>
    public void SetCtrlMode(Control[] ctrls, string Type)
    {
        for (int i = 0; i < ctrls.Length; i++)
        {
            if (ctrls[i] is Button)
            {
                ((Button)ctrls[i]).Attributes.Add("class", Type);
            }
            if (ctrls[i] is TextBox)
            {
                ((TextBox)ctrls[i]).Attributes.Add("class", Type);
            }
        }
    }
    /// <summary>
    /// 服务器端弹出alert对话框
    /// </summary>
    /// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>
    /// <param name="page">Page类</param>
    public void Alert(string str_Message, Page page)
    {
        page.RegisterStartupScript("", "<script>alert('" + str_Message + "');</script>");
    }
    /// <summary>
    /// 服务器端弹出alert对话框
    /// </summary>
    /// <param name="str_Ctl_Name">获得焦点控件Id值,比如:txt_Name</param>
    /// <param name="str_Message">提示信息,例子:"请输入您姓名!"</param>
    /// <param name="page">Page类</param>
    public void Alert(string str_Ctl_Name, string str_Message, Page page)
    {
        page.RegisterStartupScript("", "<script>alert('" + str_Message + "');document.forms(0)." + str_Ctl_Name + ".focus(); document.forms(0)." + str_Ctl_Name + ".select();</script>");
    }
    /// <summary>
    /// 服务器端弹出confirm对话框,该函数有个弊端,必须放到响应事件的最后,目前没有妥善解决方案
    /// </summary>
    /// <param name="str_Message">提示信息,例子:"您是否确认删除!"</param>
    /// <param name="btn">隐藏Botton按钮Id值,比如:btn_Flow</param>
    /// <param name="page">Page类</param>
    public void Confirm(string str_Message, string btn, Page page)
    {
        page.RegisterStartupScript("", "<script> if (confirm('" + str_Message + "')==true){document.forms(0)." + btn + ".click();}</script>");
    }
    /// <summary>
    ///  服务器端弹出confirm对话框,询问用户准备转向相应操作,包括“确定”和“取消”时的操作
    /// </summary>
    /// <param name="str_Message">提示信息,比如:"成功增加数据,单击/"确定/"按钮填写流程,单击/"取消/"修改数据"</param>
    /// <param name="btn_Redirect_Flow">"确定"按钮id值</param>
    /// <param name="btn_Redirect_Self">"取消"按钮id值</param>
    /// <param name="page">Page类</param>
    public void Confirm(string str_Message, string btn_Redirect_Flow, string btn_Redirect_Self, Page page)
    {
        page.RegisterStartupScript("", "<script> if (confirm('" + str_Message + "')==true){document.forms(0)." + btn_Redirect_Flow + ".click();}else{document.forms(0)." + btn_Redirect_Self + ".click();}</script>");
    }
    /// <summary>
    /// 刷新某个桢
    /// </summary>
    /// <param name="Frame">桢名称</param>
    /// <param name="url">连接</param>
    /// <param name="page">page对象</param>
    public void ReloadFrame(string Frame, string url, Page page)
    {
        page.RegisterStartupScript("", "<script language=/"javascript/">parent.frames('" + Frame + "').document.location.href='" + url + "';</script>");
    }

    /// <summary>
    /// Bind the data to the control,Include control:Repeater,DataGrid,DataList
    /// </summary>
    /// <param name="PageCount">Record count</param>
    /// <param name="lst">Data source</param>
    /// <param name="ctl_Listctl">control</param>
    /// <param name="AspNetPager1">Alot page control</param>
    public void BindCtrl(int PageCount, IList lst, Control ctl_Listctl, Wuqi.Webdiyer.AspNetPager AspNetPager1)
    {
        AspNetPager1.RecordCount = PageCount;

        if (ctl_Listctl is Repeater)
        {
            ((Repeater)ctl_Listctl).DataSource = lst;
            ((Repeater)ctl_Listctl).DataBind();
        }
        if (ctl_Listctl is DataList)
        {
            ((DataList)ctl_Listctl).DataSource = lst;
            ((DataList)ctl_Listctl).DataBind();
        }
        if (ctl_Listctl is DataGrid)
        {
            ((DataGrid)ctl_Listctl).DataSource = lst;
            ((DataGrid)ctl_Listctl).DataBind();
        }
        AspNetPager1.CustomInfoText = "当前页/总页数:" + AspNetPager1.CurrentPageIndex + "/" + AspNetPager1.PageCount + ",每页记录:" + AspNetPager1.PageSize;

    }
    public void BindCtrl(IList lst, Control ctl_Listctl)
    {
        if (ctl_Listctl is Repeater)
        {
            ((Repeater)ctl_Listctl).DataSource = lst;
            ((Repeater)ctl_Listctl).DataBind();
        }
        if (ctl_Listctl is DataList)
        {
            ((DataList)ctl_Listctl).DataSource = lst;
            ((DataList)ctl_Listctl).DataBind();
        }
        if (ctl_Listctl is DataGrid)
        {
            ((DataGrid)ctl_Listctl).DataSource = lst;
            ((DataGrid)ctl_Listctl).DataBind();
        }
    }
    /// <summary>
    ///
    /// </summary>
    /// <param name="strValueField"></param>
    /// <param name="id"></param>
    /// <param name="name"></param>
    /// <param name="lst"></param>
    /// <param name="listctrl"></param>
    public void SetCtrl(string strValueField, string id, string name, IList lst, Control listctrl)
    {
        BindCtrl(id, name, lst, listctrl);

        //===DropDownList===
        if (listctrl is DropDownList)
        {
            ((DropDownList)listctrl).Items[0].Selected = false;
            for (int i = 0; i < ((DropDownList)listctrl).Items.Count; i++)
            {
                if ("," + strValueField + "," == "," + ((DropDownList)listctrl).Items[i].Value + ",")
                {
                    ((DropDownList)listctrl).Items[i].Selected = true;
                    break;
                }
            }
        }
        //===CheckBoxList===
        if (listctrl is CheckBoxList)
        {
            for (int i = 0; i < ((CheckBoxList)listctrl).Items.Count; i++)
            {
                if (("," + strValueField + ",").IndexOf("," + ((CheckBoxList)listctrl).Items[i].Value + ",") != -1)
                {
                    ((CheckBoxList)listctrl).Items[i].Selected = true;
                }
            }
        }
        //===RadioButtonList===
        if (listctrl is RadioButtonList)
        {
            ((RadioButtonList)listctrl).Items[0].Selected = false;
            for (int i = 0; i < ((RadioButtonList)listctrl).Items.Count; i++)
            {
                if ("," + strValueField + "," == "," + ((RadioButtonList)listctrl).Items[i].Value + ",")
                {
                    ((RadioButtonList)listctrl).Items[i].Selected = true;
                    break;
                }
            }
        }
        //===c===
        if (listctrl is ListBox)
        {
            for (int i = 0; i < ((ListBox)listctrl).Items.Count; i++)
            {
                if (("," + strValueField + ",").IndexOf("," + ((ListBox)listctrl).Items[i].Value + ",") != -1)
                {
                    ((ListBox)listctrl).Items[i].Selected = true;
                }
            }
        }
    }
    public void SetCtrl(string strValueField, string val, string txt, Control listctrl)
    {
        string[] arr_Val = val.Split(',');
        string[] arr_Txt = txt.Split(',');

        //===DropDownList===
        if (listctrl is DropDownList)
        {
            for (int i = 0; i < arr_Val.Length; i++)
            {
                if (strValueField == arr_Val[i].ToString())
                {
                    ListItem it = new ListItem(arr_Txt[i], arr_Val[i]);
                    ((DropDownList)listctrl).Items.Insert(0, it);
                }
                else
                {
                    ListItem it = new ListItem(arr_Txt[i], arr_Val[i]);
                    ((DropDownList)listctrl).Items.Add(it);
                }
            }
        }
        //===CheckBoxList===
        if (listctrl is CheckBoxList)
        {
            for (int i = 0; i < arr_Val.Length; i++)
            {
                if (strValueField == arr_Val.ToString())
                {
                    ListItem it = new ListItem(arr_Txt[i], arr_Val[i]);
                    it.Selected = true;
                    ((CheckBoxList)listctrl).Items.Add(it);
                }
            }
        }

        //===RadioButtonList===
        if (listctrl is RadioButtonList)
        {
            for (int i = 0; i < arr_Val.Length; i++)
            {
                if (strValueField == arr_Val.ToString())
                {
                    ListItem it = new ListItem(arr_Txt[i], arr_Val[i]);
                    it.Selected = true;
                    ((RadioButtonList)listctrl).Items.Add(it);
                }
            }
        }
        //===ListBox===
        if (listctrl is ListBox)
        {
            for (int i = 0; i < arr_Val.Length; i++)
            {
                if (strValueField == arr_Val.ToString())
                {
                    ListItem it = new ListItem(arr_Txt[i], arr_Val[i]);
                    it.Selected = true;
                    ((ListBox)listctrl).Items.Add(it);
                }
            }
        }


    }

    /// <summary>
    /// 获得CheckBoxLis,RadioButtonList,ListBox控件所有选中值并以逗号格开,形式:"2,3,4"
    /// </summary>
    /// <param name="listctrl">CheckBoxLis,RadioButtonList,ListBox控件</param>
    /// <param name="type">类型,是想获得Value还是Text值</param>
    /// <returns></returns>
    public string GetCtrlSelValue(Control listctrl)
    {
        string str_Value = "";

        //===CheckBoxList===
        if (listctrl is CheckBoxList)
        {
            for (int i = 0; i < ((CheckBoxList)listctrl).Items.Count; i++)
            {
                if (((CheckBoxList)listctrl).Items[i].Selected == true)
                {
                    str_Value = str_Value + ((CheckBoxList)listctrl).Items[i].Value + ",";
                }
            }
            if (str_Value != "")
            {
                str_Value = str_Value.Substring(0, str_Value.Length - 1);
            }
        }
        //===RadioButtonList===
        if (listctrl is RadioButtonList)
        {
            for (int i = 0; i < ((RadioButtonList)listctrl).Items.Count; i++)
            {
                if (((RadioButtonList)listctrl).Items[i].Selected == true)
                {
                    str_Value = ((RadioButtonList)listctrl).Items[i].Value;
                }
            }

        }
        //===ListBox===
        if (listctrl is ListBox)
        {

            for (int i = 0; i < ((ListBox)listctrl).Items.Count; i++)
            {
                if (((ListBox)listctrl).Items[i].Selected == true)
                {
                    str_Value = str_Value + ((ListBox)listctrl).Items[i].Value + ",";
                }
            }
            if (str_Value != "")
            {
                str_Value = str_Value.Substring(0, str_Value.Length - 1);
            }
        }
        return str_Value;
    }

    /// <summary>
    /// 绑定DropDownList等控件
    /// </summary>
    /// <param name="id">控件Value值字段</param>
    /// <param name="name">控件Text值字段</param>
    /// <param name="lst">IList数据源</param>
    /// <param name="listctrl">控件Id</param>
    public void BindCtrl(string id, string name, IList lst, Control listctrl)
    {
        //===DropDownList===
        if (listctrl is DropDownList)
        {
            ((DropDownList)listctrl).DataValueField = id;
            ((DropDownList)listctrl).DataTextField = name;
            ((DropDownList)listctrl).DataSource = lst;
            ((DropDownList)listctrl).DataBind();
        }
        if (listctrl is CheckBoxList)
        {
            ((CheckBoxList)listctrl).DataValueField = id;
            ((CheckBoxList)listctrl).DataTextField = name;
            ((CheckBoxList)listctrl).DataSource = lst;
            ((CheckBoxList)listctrl).DataBind();
        }
    }
    public void BindCtrl(string DefaultValue, string DefaultText, string id, string name, IList lst, Control listctrl)
    {
        //===DropDownList===
        if (listctrl is DropDownList)
        {
            ((DropDownList)listctrl).DataValueField = id;
            ((DropDownList)listctrl).DataTextField = name;
            ((DropDownList)listctrl).DataSource = lst;
            ((DropDownList)listctrl).DataBind();
            ListItem it = new ListItem(DefaultText, DefaultValue);
            it.Selected = true;
            ((DropDownList)listctrl).Items.Insert(0, it);
        }

    }
    public void SetCtrl(string strValueField, string DefaultValue, string DefaultText, string id, string name, IList lst, Control listctrl)
    {
        //===DropDownList===
        if (listctrl is DropDownList)
        {
            ((DropDownList)listctrl).DataValueField = id;
            ((DropDownList)listctrl).DataTextField = name;
            ((DropDownList)listctrl).DataSource = lst;
            ((DropDownList)listctrl).DataBind();
            ListItem it = new ListItem(DefaultText, DefaultValue);
            ((DropDownList)listctrl).Items.Insert(0, it);
        }

        //===DropDownList===
        if (listctrl is DropDownList)
        {
            for (int i = 0; i < ((DropDownList)listctrl).Items.Count; i++)
            {
                if (strValueField == ((DropDownList)listctrl).Items[i].Value.ToString())
                {
                    ((DropDownList)listctrl).Items[i].Selected = true;
                }
            }
        }

    }
    public void BindCtrl(string val, string txt, Control listctrl)
    {
        string[] arr_Val = val.Split(',');
        string[] arr_Txt = txt.Split(',');

        //===DropDownList===
        if (listctrl is DropDownList)
        {
            for (int i = 0; i < arr_Val.Length; i++)
            {
                ListItem it = new ListItem(arr_Txt[i], arr_Val[i]);
                ((DropDownList)listctrl).Items.Add(it);
            }
        }
    }
    public Hashtable GetHtByCtrl(Control[] ctrl)
    {
        Hashtable ht = new Hashtable();
        for (int i = 0; i < ctrl.Length; i++)
        {
            if (ctrl[i] is DropDownList)
            {
                if (((DropDownList)ctrl[i]).SelectedItem.Value.Replace(" ", "") != "")
                {
                    ht.Add(((DropDownList)ctrl[i]).ID.ToString(), ((DropDownList)ctrl[i]).SelectedItem.Value);
                }
            }
            if (ctrl[i] is TextBox)
            {
                if (((TextBox)ctrl[i]).Text != "")
                {
                    ht.Add(((TextBox)ctrl[i]).ID.ToString(), ((TextBox)ctrl[i]).Text.Replace(" ", ""));
                }
            }
        }
        if (ht.Count == 0)
        {
            return null;
        }
        else
        {
            return ht;
        }
    }

    public string GetStrByMd5Base64(string str)
    {
        String temp = str;
        ASCIIEncoding enc = new ASCIIEncoding();
        byte[] buffer = enc.GetBytes(temp);
        MD5 md5 = new MD5CryptoServiceProvider();
        byte[] hash = md5.ComputeHash(buffer);
        return Convert.ToBase64String(hash);
    }


    public string GetFirstStr(string strOriginal, string strSymbol)
    {
        int strPlace = strOriginal.IndexOf(strSymbol);
        if (strPlace != -1)
            strOriginal = strOriginal.Substring(0, strPlace);
        return strOriginal;
    }
    /// <summary>
    /// 获得某个字符串在另个字符串最后一次出现时后面所有字符
    /// </summary>
    /// <param name="strOriginal">要处理字符</param>
    /// <param name="strSymbol">符号</param>
    /// <returns>返回值</returns>
    public string GetLastStr(string strOriginal, string strSymbol)
    {
        int strPlace = strOriginal.LastIndexOf(strSymbol) + strSymbol.Length;
        strOriginal = strOriginal.Substring(strPlace);
        return strOriginal;
    }
    // Put user code to initialize the page here
    /// <summary>
    ///功  能:获取本地计算机的IP地址
    ///输入参数:无
    ///输出参数:string cIPAddresses,本地计算机的IP地址
    /// </summary>
    public string GetServerIP()
    {
        string cLocalComputerName = null;
        cLocalComputerName = Dns.GetHostName();//本地计算机的DNS主机名

        string cIPAddresses = "";//本地计算机的IP地址
        try
        {
            System.Text.ASCIIEncoding ASCII = new System.Text.ASCIIEncoding();
            IPHostEntry heLocalComputer = Dns.Resolve(cLocalComputerName);
            foreach (IPAddress curAdd in heLocalComputer.AddressList)
            {
                Byte[] bytes = curAdd.GetAddressBytes();
                for (int i = 0; i < bytes.Length; i++)
                {
                    cIPAddresses += bytes[i].ToString() + ".";
                }
            }
            cIPAddresses = cIPAddresses.Substring(0, cIPAddresses.Length - 1);
        }
        catch (Exception e)
        {
            string cErrMsg = e.ToString();
            cIPAddresses = "";
        }
        return "http://" + cIPAddresses;
    }

 

    //**********************************>> 上传文件 <<**********************************//

    public string UpFile(string path, HtmlInputFile fl_Name, Page page)
    {
        if (fl_Name.PostedFile.ToString() == "")
        {
            Alert("请先选择一个文件再上传!", page);
            throw (new Exception());
        }
        if (fl_Name.PostedFile.ContentLength > 4000000)
        {
            Alert("文件大小限定在4MB以内!", page);
            throw (new Exception());
        }
        if (File.Exists(Server.MapPath(path + Path.GetFileName(fl_Name.PostedFile.FileName))))
        {
            Alert("该文件已经存在,请改名再上传!", page);
            throw (new Exception());
        }
        string strFullPath = Server.MapPath(path + Path.GetFileName(fl_Name.PostedFile.FileName));
        fl_Name.PostedFile.SaveAs(strFullPath);
        return Path.GetFileName(fl_Name.PostedFile.FileName);
    }

    public string UpFileTypeRandom(string path, string filetype, HtmlInputFile fl_Name, Page page)
    {
        if (fl_Name.PostedFile.ToString() == "")
        {
            Alert("请先选择一个文件再上传", page);
            throw (new Exception());
        }
        if (fl_Name.PostedFile.ContentLength > 4000000)
        {
            Alert("文件大小限定在4MB以内", page);
            throw (new Exception());
        }
        string str_filetype = GetLastStr(Path.GetFileName(fl_Name.PostedFile.FileName), "."); // 获得文件类型
        string str_RandomFileName = GetId(6) + "." + str_filetype; // 获得随机文件名
        if ((filetype + ",").IndexOf(str_filetype + ",") == -1)
        {
            Alert("请选择" + filetype + "等类型文件", page);
            throw (new Exception());
        }
        if (File.Exists(Server.MapPath(path + str_RandomFileName)))
        {
            Alert("该文件已经存在,请改名再上传!", page);
            throw (new Exception());
        }
        //string strFullPath=Server.MapPath(path+Path.GetFileName(fl_Name.PostedFile.FileName));

        string strFullPath = Server.MapPath(path + str_RandomFileName);
        fl_Name.PostedFile.SaveAs(strFullPath);
        return Path.GetFileName(str_RandomFileName);
    }

    public string UpFileType(string path, string filetype, HtmlInputFile fl_Name, Page page)
    {
        if (fl_Name.PostedFile.ToString() == "")
        {
            Alert("请先选择一个文件再上传", page);
            throw (new Exception());
        }
        if (fl_Name.PostedFile.ContentLength > 4000000)
        {
            Alert("文件大小限定在4MB以内", page);
            throw (new Exception());
        }
        string str_filetype = GetLastStr(Path.GetFileName(fl_Name.PostedFile.FileName), "."); // 获得文件类型
        if ((filetype + ",").IndexOf(str_filetype + ",") == -1)
        {
            Alert("请选择" + filetype + "等类型文件", page);
            throw (new Exception());
        }
        if (File.Exists(Server.MapPath(path + Path.GetFileName(fl_Name.PostedFile.FileName))))
        {
            Alert("该文件已经存在,请改名再上传!", page);
            throw (new Exception());
        }
        string strFullPath = Server.MapPath(path + Path.GetFileName(fl_Name.PostedFile.FileName));
        fl_Name.PostedFile.SaveAs(strFullPath);
        return Path.GetFileName(fl_Name.PostedFile.FileName);
    }

    /// <summary>
    /// 获得14时间+。。。位的时间随机数
    /// </summary>
    /// <returns></returns>
    public string GetId(int count)
    {
        return GetDateRandom(count);
    }
    public string GetDateRandom(int int_Count)
    {
        string strData = DateTime.Now.ToString("yyyyMMddhhmmss");
        strData = strData.Replace(":", "");
        strData = strData.Replace("-", "");
        strData = strData.Replace(" ", "");
        strData = strData + GetRandom(int_Count);
        return strData;
    }
    public string GetRandom(int int_Count)
    {
        string str_RV = "1";
        for (int i = 0; i < int_Count - 2; i++)
        {
            str_RV = str_RV + "0";
        }
        Random r = new Random();
        str_RV = r.Next(int.Parse(str_RV)).ToString();
        int int_Count1 = int_Count - str_RV.Length;
        if (int_Count1 > 0)
        {
            for (int i = 0; i < int_Count1; i++)
            {
                str_RV = str_RV + "0";
            }
        }
        return str_RV;
    }

    /// <summary>
    /// 获得拼音
    /// </summary>
    /// <param name="str_Spell">汉字</param>
    /// <returns></returns>
    public string GetSpellByChinese(string str_Spell)
    {

        Hashtable t = hb();

        byte[] b = System.Text.Encoding.Default.GetBytes(str_Spell);
        int p;
        StringBuilder ret = new StringBuilder();
        for (int i = 0; i < b.Length; i++)
        {
            p = (int)b[i];
            if (p > 160)
            {
                p = p * 256 + b[++i] - 65536;
                ret.Append(g(t, p));
            }
            else
            {
                ret.Append((char)p);
            }
        }
        t.Clear();
        return ret.ToString();
    }
    private string g(Hashtable ht, int num)
    {
        if (num < -20319 || num > -10247)
            return "";
        while (!ht.ContainsKey(num))
            num--;
        return ht[num].ToString();
    }

    private Hashtable hb()
    {
        Hashtable ht = new Hashtable();
        ht.Add(-20319, "a");
        ht.Add(-20317, "ai"); ht.Add(-20304, "an"); ht.Add(-20295, "ang");
        ht.Add(-20292, "ao"); ht.Add(-20283, "ba"); ht.Add(-20265, "bai");
        ht.Add(-20257, "ban"); ht.Add(-20242, "bang"); ht.Add(-20230, "bao");
        ht.Add(-20051, "bei"); ht.Add(-20036, "ben"); ht.Add(-20032, "beng");
        ht.Add(-20026, "bi"); ht.Add(-20002, "bian"); ht.Add(-19990, "biao");
        ht.Add(-19986, "bie"); ht.Add(-19982, "bin"); ht.Add(-19976, "bing");
        ht.Add(-19805, "bo"); ht.Add(-19784, "bu"); ht.Add(-19775, "ca");
        ht.Add(-19774, "cai"); ht.Add(-19763, "can"); ht.Add(-19756, "cang");
        ht.Add(-19751, "cao"); ht.Add(-19746, "ce"); ht.Add(-19741, "ceng");
        ht.Add(-19739, "cha"); ht.Add(-19728, "chai"); ht.Add(-19725, "chan");
        ht.Add(-19715, "chang"); ht.Add(-19540, "chao"); ht.Add(-19531, "che");
        ht.Add(-19525, "chen"); ht.Add(-19515, "cheng"); ht.Add(-19500, "chi");
        ht.Add(-19484, "chong"); ht.Add(-19479, "chou"); ht.Add(-19467, "chu");
        ht.Add(-19289, "chuai"); ht.Add(-19288, "chuan"); ht.Add(-19281, "chuang");
        ht.Add(-19275, "chui"); ht.Add(-19270, "chun"); ht.Add(-19263, "chuo");
        ht.Add(-19261, "ci"); ht.Add(-19249, "cong"); ht.Add(-19243, "cou");
        ht.Add(-19242, "cu"); ht.Add(-19238, "cuan"); ht.Add(-19235, "cui");
        ht.Add(-19227, "cun"); ht.Add(-19224, "cuo"); ht.Add(-19218, "da");
        ht.Add(-19212, "dai"); ht.Add(-19038, "dan"); ht.Add(-19023, "dang");
        ht.Add(-19018, "dao"); ht.Add(-19006, "de"); ht.Add(-19003, "deng");
        ht.Add(-18996, "di"); ht.Add(-18977, "dian"); ht.Add(-18961, "diao");
        ht.Add(-18952, "die"); ht.Add(-18783, "ding"); ht.Add(-18774, "diu");
        ht.Add(-18773, "dong"); ht.Add(-18763, "dou"); ht.Add(-18756, "du");
        ht.Add(-18741, "duan"); ht.Add(-18735, "dui"); ht.Add(-18731, "dun");
        ht.Add(-18722, "duo"); ht.Add(-18710, "e"); ht.Add(-18697, "en");
        ht.Add(-18696, "er"); ht.Add(-18526, "fa"); ht.Add(-18518, "fan");
        ht.Add(-18501, "fang"); ht.Add(-18490, "fei"); ht.Add(-18478, "fen");
        ht.Add(-18463, "feng"); ht.Add(-18448, "fo"); ht.Add(-18447, "fou");
        ht.Add(-18446, "fu"); ht.Add(-18239, "ga"); ht.Add(-18237, "gai");
        ht.Add(-18231, "gan"); ht.Add(-18220, "gang"); ht.Add(-18211, "gao");
        ht.Add(-18201, "ge"); ht.Add(-18184, "gei"); ht.Add(-18183, "gen");
        ht.Add(-18181, "geng"); ht.Add(-18012, "gong"); ht.Add(-17997, "gou");
        ht.Add(-17988, "gu"); ht.Add(-17970, "gua"); ht.Add(-17964, "guai");
        ht.Add(-17961, "guan"); ht.Add(-17950, "guang"); ht.Add(-17947, "gui");
        ht.Add(-17931, "gun"); ht.Add(-17928, "guo"); ht.Add(-17922, "ha");
        ht.Add(-17759, "hai"); ht.Add(-17752, "han"); ht.Add(-17733, "hang");
        ht.Add(-17730, "hao"); ht.Add(-17721, "he"); ht.Add(-17703, "hei");
        ht.Add(-17701, "hen"); ht.Add(-17697, "heng"); ht.Add(-17692, "hong");
        ht.Add(-17683, "hou"); ht.Add(-17676, "hu"); ht.Add(-17496, "hua");
        ht.Add(-17487, "huai"); ht.Add(-17482, "huan"); ht.Add(-17468, "huang");
        ht.Add(-17454, "hui"); ht.Add(-17433, "hun"); ht.Add(-17427, "huo");
        ht.Add(-17417, "ji"); ht.Add(-17202, "jia"); ht.Add(-17185, "jian");
        ht.Add(-16983, "jiang"); ht.Add(-16970, "jiao"); ht.Add(-16942, "jie");
        ht.Add(-16915, "jin"); ht.Add(-16733, "jing"); ht.Add(-16708, "jiong");
        ht.Add(-16706, "jiu"); ht.Add(-16689, "ju"); ht.Add(-16664, "juan");
        ht.Add(-16657, "jue"); ht.Add(-16647, "jun"); ht.Add(-16474, "ka");
        ht.Add(-16470, "kai"); ht.Add(-16465, "kan"); ht.Add(-16459, "kang");
        ht.Add(-16452, "kao"); ht.Add(-16448, "ke"); ht.Add(-16433, "ken");
        ht.Add(-16429, "keng"); ht.Add(-16427, "kong"); ht.Add(-16423, "kou");
        ht.Add(-16419, "ku"); ht.Add(-16412, "kua"); ht.Add(-16407, "kuai");
        ht.Add(-16403, "kuan"); ht.Add(-16401, "kuang"); ht.Add(-16393, "kui");
        ht.Add(-16220, "kun"); ht.Add(-16216, "kuo"); ht.Add(-16212, "la");
        ht.Add(-16205, "lai"); ht.Add(-16202, "lan"); ht.Add(-16187, "lang");
        ht.Add(-16180, "lao"); ht.Add(-16171, "le"); ht.Add(-16169, "lei");
        ht.Add(-16158, "leng"); ht.Add(-16155, "li"); ht.Add(-15959, "lia");
        ht.Add(-15958, "lian"); ht.Add(-15944, "liang"); ht.Add(-15933, "liao");
        ht.Add(-15920, "lie"); ht.Add(-15915, "lin"); ht.Add(-15903, "ling");
        ht.Add(-15889, "liu"); ht.Add(-15878, "long"); ht.Add(-15707, "lou");
        ht.Add(-15701, "lu"); ht.Add(-15681, "lv"); ht.Add(-15667, "luan");
        ht.Add(-15661, "lue"); ht.Add(-15659, "lun"); ht.Add(-15652, "luo");
        ht.Add(-15640, "ma"); ht.Add(-15631, "mai"); ht.Add(-15625, "man");
        ht.Add(-15454, "mang"); ht.Add(-15448, "mao"); ht.Add(-15436, "me");
        ht.Add(-15435, "mei"); ht.Add(-15419, "men"); ht.Add(-15416, "meng");
        ht.Add(-15408, "mi"); ht.Add(-15394, "mian"); ht.Add(-15385, "miao");
        ht.Add(-15377, "mie"); ht.Add(-15375, "min"); ht.Add(-15369, "ming");
        ht.Add(-15363, "miu"); ht.Add(-15362, "mo"); ht.Add(-15183, "mou");
        ht.Add(-15180, "mu"); ht.Add(-15165, "na"); ht.Add(-15158, "nai");
        ht.Add(-15153, "nan"); ht.Add(-15150, "nang"); ht.Add(-15149, "nao");
        ht.Add(-15144, "ne"); ht.Add(-15143, "nei"); ht.Add(-15141, "nen");
        ht.Add(-15140, "neng"); ht.Add(-15139, "ni"); ht.Add(-15128, "nian");
        ht.Add(-15121, "niang"); ht.Add(-15119, "niao"); ht.Add(-15117, "nie");
        ht.Add(-15110, "nin"); ht.Add(-15109, "ning"); ht.Add(-14941, "niu");
        ht.Add(-14937, "nong"); ht.Add(-14933, "nu"); ht.Add(-14930, "nv");
        ht.Add(-14929, "nuan"); ht.Add(-14928, "nue"); ht.Add(-14926, "nuo");
        ht.Add(-14922, "o"); ht.Add(-14921, "ou"); ht.Add(-14914, "pa");
        ht.Add(-14908, "pai"); ht.Add(-14902, "pan"); ht.Add(-14894, "pang");
        ht.Add(-14889, "pao"); ht.Add(-14882, "pei"); ht.Add(-14873, "pen");
        ht.Add(-14871, "peng"); ht.Add(-14857, "pi"); ht.Add(-14678, "pian");
        ht.Add(-14674, "piao"); ht.Add(-14670, "pie"); ht.Add(-14668, "pin");
        ht.Add(-14663, "ping"); ht.Add(-14654, "po"); ht.Add(-14645, "pu");
        ht.Add(-14630, "qi"); ht.Add(-14594, "qia"); ht.Add(-14429, "qian");
        ht.Add(-14407, "qiang"); ht.Add(-14399, "qiao"); ht.Add(-14384, "qie");
        ht.Add(-14379, "qin"); ht.Add(-14368, "qing"); ht.Add(-14355, "qiong");
        ht.Add(-14353, "qiu"); ht.Add(-14345, "qu"); ht.Add(-14170, "quan");
        ht.Add(-14159, "que"); ht.Add(-14151, "qun"); ht.Add(-14149, "ran");
        ht.Add(-14145, "rang"); ht.Add(-14140, "rao"); ht.Add(-14137, "re");
        ht.Add(-14135, "ren"); ht.Add(-14125, "reng"); ht.Add(-14123, "ri");
        ht.Add(-14122, "rong"); ht.Add(-14112, "rou"); ht.Add(-14109, "ru");
        ht.Add(-14099, "ruan"); ht.Add(-14097, "rui"); ht.Add(-14094, "run");
        ht.Add(-14092, "ruo"); ht.Add(-14090, "sa"); ht.Add(-14087, "sai");
        ht.Add(-14083, "san"); ht.Add(-13917, "sang"); ht.Add(-13914, "sao");
        ht.Add(-13910, "se"); ht.Add(-13907, "sen"); ht.Add(-13906, "seng");
        ht.Add(-13905, "sha"); ht.Add(-13896, "shai"); ht.Add(-13894, "shan");
        ht.Add(-13878, "shang"); ht.Add(-13870, "shao"); ht.Add(-13859, "she");
        ht.Add(-13847, "shen"); ht.Add(-13831, "sheng"); ht.Add(-13658, "shi");
        ht.Add(-13611, "shou"); ht.Add(-13601, "shu"); ht.Add(-13406, "shua");
        ht.Add(-13404, "shuai"); ht.Add(-13400, "shuan"); ht.Add(-13398, "shuang");
        ht.Add(-13395, "shui"); ht.Add(-13391, "shun"); ht.Add(-13387, "shuo");
        ht.Add(-13383, "si"); ht.Add(-13367, "song"); ht.Add(-13359, "sou");
        ht.Add(-13356, "su"); ht.Add(-13343, "suan"); ht.Add(-13340, "sui");
        ht.Add(-13329, "sun"); ht.Add(-13326, "suo"); ht.Add(-13318, "ta");
        ht.Add(-13147, "tai"); ht.Add(-13138, "tan"); ht.Add(-13120, "tang");
        ht.Add(-13107, "tao"); ht.Add(-13096, "te"); ht.Add(-13095, "teng");
        ht.Add(-13091, "ti"); ht.Add(-13076, "tian"); ht.Add(-13068, "tiao");
        ht.Add(-13063, "tie"); ht.Add(-13060, "ting"); ht.Add(-12888, "tong");
        ht.Add(-12875, "tou"); ht.Add(-12871, "tu"); ht.Add(-12860, "tuan");
        ht.Add(-12858, "tui"); ht.Add(-12852, "tun"); ht.Add(-12849, "tuo");
        ht.Add(-12838, "wa"); ht.Add(-12831, "wai"); ht.Add(-12829, "wan");
        ht.Add(-12812, "wang"); ht.Add(-12802, "wei"); ht.Add(-12607, "wen");
        ht.Add(-12597, "weng"); ht.Add(-12594, "wo"); ht.Add(-12585, "wu");
        ht.Add(-12556, "xi"); ht.Add(-12359, "xia"); ht.Add(-12346, "xian");
        ht.Add(-12320, "xiang"); ht.Add(-12300, "xiao"); ht.Add(-12120, "xie");
        ht.Add(-12099, "xin"); ht.Add(-12089, "xing"); ht.Add(-12074, "xiong");
        ht.Add(-12067, "xiu"); ht.Add(-12058, "xu"); ht.Add(-12039, "xuan");
        ht.Add(-11867, "xue"); ht.Add(-11861, "xun"); ht.Add(-11847, "ya");
        ht.Add(-11831, "yan"); ht.Add(-11798, "yang"); ht.Add(-11781, "yao");
        ht.Add(-11604, "ye"); ht.Add(-11589, "yi"); ht.Add(-11536, "yin");
        ht.Add(-11358, "ying"); ht.Add(-11340, "yo"); ht.Add(-11339, "yong");
        ht.Add(-11324, "you"); ht.Add(-11303, "yu"); ht.Add(-11097, "yuan");
        ht.Add(-11077, "yue"); ht.Add(-11067, "yun"); ht.Add(-11055, "za");
        ht.Add(-11052, "zai"); ht.Add(-11045, "zan"); ht.Add(-11041, "zang");
        ht.Add(-11038, "zao"); ht.Add(-11024, "ze"); ht.Add(-11020, "zei");
        ht.Add(-11019, "zen"); ht.Add(-11018, "zeng"); ht.Add(-11014, "zha");
        ht.Add(-10838, "zhai"); ht.Add(-10832, "zhan"); ht.Add(-10815, "zhang");
        ht.Add(-10800, "zhao"); ht.Add(-10790, "zhe"); ht.Add(-10780, "zhen");
        ht.Add(-10764, "zheng"); ht.Add(-10587, "zhi"); ht.Add(-10544, "zhong");
        ht.Add(-10533, "zhou"); ht.Add(-10519, "zhu"); ht.Add(-10331, "zhua");
        ht.Add(-10329, "zhuai"); ht.Add(-10328, "zhuan"); ht.Add(-10322, "zhuang");
        ht.Add(-10315, "zhui"); ht.Add(-10309, "zhun"); ht.Add(-10307, "zhuo");
        ht.Add(-10296, "zi"); ht.Add(-10281, "zong"); ht.Add(-10274, "zou");
        ht.Add(-10270, "zu"); ht.Add(-10262, "zuan"); ht.Add(-10260, "zui");
        ht.Add(-10256, "zun"); ht.Add(-10254, "zuo"); ht.Add(-10247, "zz");
        return ht;
    }


}

 

 

 

 

 

 

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="GView.aspx.cs" Inherits="GView" %>

<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<html>
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
   
     <asp:repeater id="rpt" runat="server" EnableViewState="false">
     <headertemplate>
      <tr align="center" height="25">
       <th width="40" align="center" height="27">
        <div align="center">用户ID</div>
       </th>
       <th height="27">
        <div align="center">用户登陆帐号</div>
       </th>
       <th height="27">
        用户名称</th>
       <th height="27">
        用户昵称</th>
       <th width="170" height="27">
        1 表示企业   2  表示散客  3 表示独立导游</th>
       <th width="40" height="27">
        <div align="center">修改</div>
       </th>
       <th width="40" height="27">
        <div align="center">删除</div>
       </th>
      </tr>
     </headertemplate>
     
     <itemtemplate>
      <tr height="25">
       <td height="25" width="40" align="center">
        <%#Container.ItemIndex+1%>
       </td>
       <td height="25">
                                <asp:TextBox ID="TextBox1" runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "USER_CODE").ToString()%>>
        
        </asp:TextBox>
       </td>
       
       <td height="25">
                                <asp:TextBox ID="TextBox2" runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "USER_NAME").ToString()%>>
        
        </asp:TextBox>
       </td>
       <td height="25">
                                <asp:TextBox ID="TextBox3" runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "USER_SHORT_NAME").ToString()%>>
        </asp:TextBox>
       </td>
       <td height="25" width="170">
                                <asp:TextBox ID="TextBox4" runat="server" Text=<%# DataBinder.Eval(Container.DataItem, "USER_TYPE").ToString()%>>
        
        </asp:TextBox>
       </td>
       <td height="25" width="40">
        <div align="center"><a href='<%# "GView.aspx?Title="+Request["Title"]+"&USER_ID="+DataBinder.Eval(Container.DataItem,"USER_ID").ToString()%>'><img src="../../images/Icon/edit.jpg" width="17" height="17" border="0"></a></div>
       </td>
       <td width="40">
        <div align="center"><a onClick="return confirm('您确定删除!');"  href='<%# "../GView.aspx?Title="+Request["Title"]+"&Where=yt_User Where USER_ID="+DataBinder.Eval(Container.DataItem,"USER_ID").ToString()%>'><img src="../../images/Icon/del.jpg" width="17" height="17" border="0"></a>
        </div>
       </td>
      </tr>
     </itemtemplate>
     
    </asp:repeater>
   
   
   
   
        <asp:Button ID="btn_Add" runat="server" OnClick="btn_Add_Click" Text=" 增 加 " />
       <WEBDIYER:ASPNETPAGER id="Pg" runat="server" CustomInfoSectionWidth="50%" HorizontalAlign="Right" CssClass="mypager"
        PageSize="16" NumericButtonCount="8" FirstPageText="第一页" LastPageText="最后一页" PrevPageText="上一页" NextPageText="下一页"
        NumericButtonTextFormatString="{0}" ShowCustomInfoSection="Left" AlwaysShow="True" ShowInputBox="Never"
        Width="100%" SubmitButtonText="确定"></WEBDIYER:ASPNETPAGER>
        <br />
        <asp:GridView ID="GridView1" runat="server">
        </asp:GridView>
   
    </div>
    </form>
</body>
</html>

 

 

 

 

 

 

 

 

 

 

 

 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;

public partial class GView : System.Web.UI.Page
{
    Config conn = new Config();
    User bll_User = new User();
    protected void Page_Load(object sender, EventArgs e)
    {
        // 在此处放置用户代码以初始化页面
        if (!Page.IsPostBack)
        {
            Init_Prop(); // 初始化属性
            Init_Data(); // 初始化数据
        }
    }


    private void Init_Prop()
    {
        // ===设置控件属性===
        Control[] ctrls ={ btn_Add };
        conn.SetCtrlMode(ctrls, "htc_btn");
    }


    private void Init_Data()
    {
        // ===获得用户维护单页列表===
       conn.BindCtrl(bll_User.GetUsersCount(null), bll_User.GetUsers(Pg.PageSize, Pg.CurrentPageIndex, null), rpt, Pg);

        conn.BindCtrl(bll_User.GetUsersCount(null), bll_User.GetUsers(Pg.PageSize, Pg.CurrentPageIndex, null), GridView1, Pg);
       
    }

    protected void btn_Add_Click(object sender, EventArgs e)
    {

    }
}
 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值