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;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using System.Text;
using BaseProject.Classes.Util;
using BaseProject.Data;
namespace BaseProject.Classes.UtilPage
{
    public enum EnumListTypeName
    {
        dropdownlist,
        listbox,
        radiobuttonlist,
        checkboxlist,

    }
    public class BasePage:Page
    {
        private string[] listTypeName ={ "dropdownlist","listbox","radiobuttonlist","checkboxlist"};
        //数据库操作类
        private BaseProject.Data.DbAccess _db;
        //网站路径
        private string _WebPath;
        private string _JSMessage;
        private string _JSScript;
        //字符串操作
        private StringOperate _so;
        private  DownLoadFile _downloadfile;
        /// <summary>
        /// 索引配置文件信息
        /// </summary>
        /// <param name="configName"></param>
        /// <returns></returns>
        public string this[string configName]
        {
            get
            {
                return System.Configuration.ConfigurationManager.AppSettings[configName];
            }

        }
        public  DownLoadFile Downloadfile
        {
            get
            {
                if (_downloadfile == null)
                {
                    _downloadfile = new DownLoadFile();
                }
                return _downloadfile;
            }

        }
        private UpLoad _up;
        public UpLoad Up
        {
            get
            {
                if (_up == null)
                {
                    _up = new UpLoad();
                }
                return _up;
            }


        }
        #region "数据库"
        /// <summary>
        /// 数据库链接类
        /// </summary>
        public DbAccess Db
        {
            get
            {
                if (_db == null)
                {
                    this._db = new DbAccess();
                }

                return _db;
            }
        }
        public StringOperate So
        {
            get {
                if (_so == null)
                {
                    _so = new StringOperate();

                }
                return _so;
            }
        }
        #endregion
        #region "配置"
        public string WebPath
        {
            set { this._WebPath = value; }
            get
            {
                _WebPath = this.Request.PhysicalApplicationPath;
                return this._WebPath;
            }
        }   
        /// <summary>
        /// 信息
        /// </summary>
        public string JSMessage
        {
            set
            {
                _JSMessage = value;

            }
            get
            {

                return _JSMessage;

            }

        }
        /// <summary>
        /// 脚本
        /// </summary>
        public string JSScript
        {
            set
            {
                _JSScript = value;

            }
            get
            {

                return _JSScript;

            }

        }
        #endregion
        #region "控件绑定"
        /// <summary>
        /// 绑定列表控件
        /// </summary>
        /// <param name="lc"></param>
        /// <param name="dt"></param>
        /// <param name="text"></param>
        /// <param name="value"></param>
        public void BindList(ListControl lc, DataTable dt, string text, string value)
        {
            lc.DataSource = dt;
            lc.DataTextField = text;
            lc.DataValueField = value;
            lc.DataBind();
    
        }
  
        /// <summary>
        /// 绑定gridview数据
        /// </summary>
        /// <param name="ddl"></param>
        /// <param name="dt"></param>
        /// <param name="text"></param>
        /// <param name="value"></param>
        public void BindGridView(GridView gv, DataTable dt)
        {     
            gv.DataSource = dt;
            gv.DataBind();
        }
        /// <summary>
        /// 绑定DataList数据
        /// </summary>
        /// <param name="dl"></param>
        /// <param name="dt"></param>
        public void BindDataList(DataList dl, DataTable dt)
        {
            dl.DataSource = dt;
            dl.DataBind();
        }
     /// <summary>
        /// 绑定Repeater数据
     /// </summary>
     /// <param name="rp"></param>
     /// <param name="dt"></param>
        public void BindRepeater(Repeater rp, DataTable dt)
        {
            rp.DataSource = dt;
            rp.DataBind();
        }
        /////////////////////     ////////数据绑定方法------------------------------------------------------------------
        /// <summary>
        /// 获取参数值
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string GetRequest(string key)
        {
            //if (Request.HttpMethod.ToUpper().ToString() == "GET")
            //{
            //    return Convert.ToString(Request.QueryString[key] ?? "").Replace("'", "''");
            //}
            //else
            //{
            //    return Convert.ToString(Request.Form[key] ?? "").Replace("'", "''");
            //}
            return this.So.GetNoNullString((HttpContext.Current.Request[key] ?? "").Replace("'", "''"));
        }
       #endregion
        #region "获取控件选中值"
        //选中选项
        public string SelectListValue(ListControl lc, bool isText)
        {
            string tempvalue = "";
            if (isText)
            tempvalue = lc.SelectedIndex == -1 ? ("") : lc.SelectedItem.Text.TrimStart().Trim();
            else
            tempvalue = lc.SelectedIndex == -1 ? ("") : lc.SelectedValue.TrimStart().Trim();
            return tempvalue;
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="wc"></param>
        /// <param name="textOrValue"></param>
        /// <param name="isText"></param>
        //public string SelectListValue(DropDownList wc, string textOrValue, bool isText)
        //{
        //    ListControl lc = wc;
        //    return this.SelectListValue(lc, textOrValue, isText);
        //    // SelectListValue(ref ListControl wc, string textOrValue, bool isText);
        //}
      
        #endregion
        #region "选中列表控件项"
     /// <summary>
        /// 选中列表控件项
     /// </summary>
     /// <param name="lc">控件变量</param>
     /// <param name="textOrValue"></param>
     /// <param name="isText"></param>
        public void SelectListIndex(ListControl lc, string textOrValue, bool isText)
        {
            if (isText)
                lc.SelectedIndex = lc.Items.IndexOf(lc.Items.FindByText(textOrValue));
            else
                lc.SelectedIndex = lc.Items.IndexOf(lc.Items.FindByValue(textOrValue));
        }
        #endregion

       


    }
}

///后台管理页面父类

 

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;

namespace BaseProject.Classes.UtilPage
{
    public class ManagePage:BasePage
    {
        private string _U_Account;
        /// <summary>
        /// 用户名
        /// </summary>
        public string U_Account
        {
            get
            {
                try
                {
                    _U_Account = Convert.ToString(HttpContext.Current.Request.Cookies["adminusers"]["name"] ?? "");
                }
                catch
                {
                    _U_Account = "";

                }
                return _U_Account;

            }

        }
        public ManagePage()
        {
            if (!IsAdminLogin())
            {
                HttpContext.Current.Response.Redirect(this.So.GetNoNullString(System.Configuration.ConfigurationManager.AppSettings["LoginPage"]));
            }
        }
        /// <summary>
        /// 查看是否管理员是否登陆
        /// </summary>
        /// <returns></returns>
        public bool IsAdminLogin()
        {
            string tempLoginPage = System.Configuration.ConfigurationManager.AppSettings["LoginPage"];
            string tempSite = HttpContext.Current.Request.Path.ToString();
            bool state = false;
            string username = "";
            string userpass = "";
            try
            {
                username = Convert.ToString(HttpContext.Current.Request.Cookies["adminusers"]["name"] ?? "");

                userpass = Convert.ToString(HttpContext.Current.Request.Cookies["adminusers"]["pass"] ?? "");
            }
            catch
            {

                state = false;
            }
            /////用户名或密码为空或者不是登录页面
            if (username.Length < 1 || userpass.Length < 1 || tempSite != tempLoginPage)
            {

            }
            else
            {
                state = true;
            }
            return state;
        }

    }
}

//页面管理父类列表

 

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.Text.RegularExpressions;
namespace BaseProject.Classes.UtilPage
{
    public class ManagePageList : ManagePage
    {
        private int _PageSize;
        private string _Columns;
        private string _TableName;
        private string _Where;
        private string _Order;
        private string _Pid;
        private string _Gid;
        private DataTable _PageData;
        private string _checkbox;
        /// <summary>
        /// 页面大小
        /// </summary>
        public int PageSize
        {

            set
            {
                if (Regex.IsMatch(Convert.ToString(value), "^\\d+$"))
                {
                    this._PageSize = Convert.ToInt32(value);
                }
                else
                {
                    this._PageSize = 1;
                }
            }
            get
            {
                return this._PageSize;
            }

        }
        /// <summary>
        /// 当前页
        /// </summary>
        public int CurrentPage
        {
            get
            {
                return (Convert.ToInt32(Convert.ToInt32(Request["page"] ?? "1")));
            }
        }
        /// <summary>
        /// 显示的字段
        /// </summary>
        public string Columns
        {
            set
            {
                _Columns = value;
            }
            get
            {
                return _Columns;
            }
        }
        /// <summary>
        /// 表明
        /// </summary>
        public string TableName
        {
            set
            {
                _TableName = value;
            }
            get
            {
                return _TableName;
            }
        }
        /// <summary>
        /// 条件
        /// </summary>
        public string Where
        {
            set
            {
                _Where = value;
            }
            get
            {
                return _Where;
            }
        }
        /// <summary>
        /// 排序
        /// </summary>
        public string Order
        {
            set
            {
                _Order = value;
            }
            get
            {
                return _Order;
            }
        }
        /// <summary>
        /// 逐渐字段
        /// </summary>
        public string Pid
        {
            set
            {
                _Pid = value;
            }
            get
            {
                return _Pid;
            }
        }
        /// <summary>
        /// 分页数据
        /// </summary>
        public DataTable PageData
        {

            get
            {
                _PageData =Db.GetProcAdminData(this.CurrentPage, PageSize, Columns, TableName, Pid, Where, Order, "500", "");
                _PageData = _PageData == null ? (new DataTable()) : (_PageData);
                return _PageData;

            }
        }
        /// <summary>
        /// 多选框的模板
        /// </summary>
        public string CheckBoxString
        {
            get
            {
                if (_checkbox == null || _checkbox.Length < 1)
                {
                    return "<input type=\"checkbox\" name=\"action\" value=\"{0}\"/>";
                }
                else
                {
                    return _checkbox;
                }
            }
            set
            {
                this._checkbox = value;
            }
        }
        /// <summary>
        /// 条件设置字符串 and [{0}] like '%{0}%'
        /// </summary>
        /// <param name="whereName"></param>
        /// <returns></returns>
        public string GetWhereString(string whereName)
        {
            string whereValue = this.GetRequest(whereName);
            return whereValue.Length > 0 ? (string.Format(" and [{0}] like '%{1}%'", whereName, whereValue)) : ("");
        }
    }
}

///后台管理页面

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 BaseProject.Classes.Util;
namespace BaseProject.Classes.UtilPage
{
    public class ManagePageEdit:BasePage
    {
   
    }
}
//前台显示父类

 

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;
using System.Text.RegularExpressions;
using System.Data.SqlClient;
using System.Text;
using BaseProject.Classes.Util;
namespace BaseProject.Classes.UtilPage
{
    public class ShowPage:BasePage
    {
        private string _U_Account;
        /// <summary>
        /// 用户名
        /// </summary>
        public  string U_Account
        {
            get
            {
                try
                {
                    _U_Account = Convert.ToString(HttpContext.Current.Request.Cookies["officesers"]["name"] ?? "");
                }
                catch
                {
                    _U_Account = "";

                }
                return _U_Account;

            }

        }
     
    }
}

///前台信息显示父类

 

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 BaseProject.Classes.Util;
namespace BaseProject.Classes.UtilPage
{
    public class ShowPageDisplay:ShowPage
    {
        private DownLoadFile _downloadfile;
        public DownLoadFile Downloadfile
        {
            get
            {
                if (_downloadfile == null)
                {
                    _downloadfile = new DownLoadFile();
                }
                return _downloadfile;
            }
     
        }

        /// <summary>
        /// 绑定数据函数
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="Model"></param>
        /// <param name="columns"></param>
        /// <returns></returns>
        public string getTableData(DataTable dt, string Model, params string[] columns)
        {

            System.Text.StringBuilder tempSb = new System.Text.StringBuilder("");
            if (dt == null)
            {
                return "";
            }
            else
            {
                foreach (DataRow dr in dt.Rows)
                {
                    string[] tempStr = new string[columns.Length];
                    for (int i = 0; i < tempStr.Length; i++)
                    {
                        tempStr[i] = Convert.ToString(dr[columns[i]]);
                    }

                    tempSb.AppendFormat(Model, tempStr);
                }
            }
            return tempSb.ToString();

        }
    }
}

//会员管理父类

 

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 BaseProject.Classes.Util;
namespace BaseProject.Classes.UtilPage
{
    public class ShowPageOffice:ShowPage
    {
     
        public ShowPageOffice()
        {
            if (!IsAdminLogin())
            {
                HttpContext.Current.Response.Redirect(this.So.GetNoNullString(System.Configuration.ConfigurationManager.AppSettings["LoginPageOffice"]));
            }
        }
        public bool IsAdminLogin()
        {
            string tempLoginPage = System.Configuration.ConfigurationManager.AppSettings["LoginPageOffice"];
            string tempSite = HttpContext.Current.Request.Path.ToString();
            bool state = false;
            string username = this.U_Account;
            string userpass = "";
          
            /////用户名或密码为空或者不是登录页面
            if (username.Length < 1  || tempSite != tempLoginPage)
            {

            }
            else
            {
                state = true;
            }
            return state;
        }
    }
}

posted on 2009-04-02 18:31  bestsaler  阅读(249)  评论(0编辑  收藏  举报