⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forumsqldataprovider.cs

📁 Dos 以功能个性化和人性化为基础
💻 CS
📖 第 1 页 / 共 3 页
字号:
//===============================================
//          \\\|///                      
//          \\ - - //                   
//            ( @ @ )                    
//┏━━━━━━━━━oOOo-(_)-oOOo━━━┓          
//┃                                     ┃
//┃             东 网 原 创!           ┃
//┃      lenlong 作品,请保留此信息!   ┃
//┃      ** lenlenlong@hotmail.com **   ┃
//┃                                     ┃
//┃             Dooo      ┃
//┗━━━━━━━━━ oooD━-(  )━━━┛
//           (  )   ) /
//           \ (  (_/
//            \_)
//===============================================
using System;
using System.Text;
using System.Data;
using System.Collections;
using System.Web;
namespace DataProviders
{
    public class ForumSqlDataProvider : ForumDataProvider
    {
        private string MySql;
        /// <summary>
        /// 根据论坛ID,取论坛信息
        /// </summary>
        /// <param name="boardID">论坛ID</param>
        /// <param name="Cach">是否缓冲</param>
        /// <returns>返回该论坛信息</returns>
        public override DataRow SetBoard(int boardID, bool Cach)
        {
            MySql = "select * from DoNetBbs_Board where BoardID=" + boardID.ToString() + "";
            DataTable dt;
            if (Cach)
            {
                string key = "WebSite-Board" + boardID.ToString();
                DataTable _cachetable = Components.CsCache.Get(key) as DataTable;
                if (_cachetable == null)
                {
                    dt = DataConnectionHepler.Instance().DataAdapter(MySql, 0, 1, "DoNetBbs_Board");
                    Components.CsCache.Insert(key, dt, null);
                }
                else
                {
                    dt = _cachetable;
                }
            }
            else
            {
                dt = DataConnectionHepler.Instance().DataAdapter(MySql, 0, 1, "DoNetBbs_Board");
            }

            if (dt.Rows.Count > 0)
            {
                return dt.Rows[0];
            }
            else
            {
                return null;
            }

        }//
        public override ArrayList SetBoardList(int boardID, bool Cach)
        {
            Components.Components.Board Rs = new Components.Components.Board();
            DataTable dt;
            MySql = "select * from DoNetBbs_Board order by BoardParentID asc,BoardOrders asc";
            if (Cach)
            {
                string key = "DoNetBbs-Board-List-" + boardID.ToString();
                DataTable _cachetable = Components.CsCache.Get(key) as DataTable;
                if (_cachetable == null)
                {
                    dt = DataConnectionHepler.Instance().DataAdapter(MySql, 0, 0, "DoNetBbs_Board");
                    Components.CsCache.Insert(key, dt, null);
                }
                else
                {
                    dt = _cachetable;
                }
            }
            else
            {
                dt = DataConnectionHepler.Instance().DataAdapter(MySql, 0, 0, "DoNetBbs_Board");
            }
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    if (boardID == 0)
                    {
                        if (int.Parse(row["BoardParentID"].ToString()) == 0)
                        {
                            Components.Components.Board _Arraylist = new Components.Components.Board();
                            _Arraylist.SetDataProviders(row);
                            Rs.Arraylist.Add(_Arraylist);
                            _Arraylist.Length = 0;
                            SetBoardList(dt, int.Parse(row["BoardID"].ToString()), 1,Rs);
                        }
                    }
                    else
                    {
                        if (boardID == int.Parse(row["BoardID"].ToString()))
                        {
                            Components.Components.Board _Arraylist = new Components.Components.Board();
                            _Arraylist.SetDataProviders(row);
                            _Arraylist.Length = 0;
                            Rs.Arraylist.Add(_Arraylist);
                            SetBoardList(dt, int.Parse(row["BoardID"].ToString()), 1,Rs);
                            return Rs.Arraylist;
                        }
                    }
                }
            }
            return Rs.Arraylist;
        }



        private void SetBoardList(DataTable de, int id, int length, Components.Components.Board Rs)
        {
            DataRow[] rows = de.Select("BoardParentID='" + id + "'", "BoardOrders asc,BoardID asc");//取出id子节点进行绑定
            for (int i = 0; i < rows.Length; i++)
            {
                Components.Components.Board _Arraylist = new Components.Components.Board();
                _Arraylist.SetDataProviders(rows[i]);
                _Arraylist.Length = length;
                Rs.Arraylist.Add(_Arraylist);
                SetBoardList(de, int.Parse(rows[i]["BoardID"].ToString()), length + 1, Rs);
            }

        }//

        public override ArrayList SetBoardParentList(int boardID, bool Cach)
        {
            Components.Components.Board Rs = new Components.Components.Board();
            DataTable dt;
            MySql = "select * from DoNetBbs_Board order by BoardParentID asc,BoardOrders asc";
            if (Cach)
            {
                string key = "DoNetBbs-Board-Parent-" + boardID.ToString();
                DataTable _cachetable = Components.CsCache.Get(key) as DataTable;
                if (_cachetable == null)
                {
                    dt = DataConnectionHepler.Instance().DataAdapter(MySql, 0, 0, "DoNetBbs_Board");
                    Components.CsCache.Insert(key, dt, null);
                }
                else
                {
                    dt = _cachetable;
                }
            }
            else
            {
                dt = DataConnectionHepler.Instance().DataAdapter(MySql, 0, 0, "DoNetBbs_Board");
            }
            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    if (boardID == int.Parse(row["BoardID"].ToString()))
                    {
                        Components.Components.Board _Arraylist = new Components.Components.Board();
                        _Arraylist.SetDataProviders(row);
                        _Arraylist.Length = 0;
                        Rs.Arraylist.Add(_Arraylist);
                        SetBoardParentList(dt, int.Parse(row["BoardParentID"].ToString()), 1, Rs);
                        Rs.Arraylist.Reverse();
                        return Rs.Arraylist;
                    }
                }
            }
            return Rs.Arraylist;
        }
        private void SetBoardParentList(DataTable de, int id, int length, Components.Components.Board Rs)
        {
            DataRow[] rows = de.Select("BoardID='" + id + "'", "BoardOrders asc,BoardID asc");//取出id子节点进行绑定
            for (int i = 0; i < rows.Length; i++)
            {
                Components.Components.Board _Arraylist = new Components.Components.Board();
                _Arraylist.SetDataProviders(rows[i]);
                _Arraylist.Length = length;
                Rs.Arraylist.Add(_Arraylist);
                SetBoardParentList(de, int.Parse(rows[i]["BoardParentID"].ToString()), length + 1, Rs);
            }

        }//

        public override void UpdateBoardInfo(Components.Components.Board board)
        {
            MySql = "update DoNetBbs_Board set ";
            MySql += "BoardParentID='" + board.BoardParentID + "',";
            MySql += "BoardName ='" + board.BoardName + "',";
            MySql += "BoardTypeID ='" + board.BoardTypeID + "',";
            MySql += "BoardSubject ='" + board.BoardSubject + "',";
            MySql += "BoardOrders ='" + board.BoardOrders + "',";
            MySql += "BoardMaster ='" + board.BoardMaster + "',";
            MySql += "BoardLastTopicTitle ='" + board.BoardLastTopicTitle + "',";
            MySql += "BoardLastTopicID ='" + board.BoardLastTopicID + "',";
            MySql += "BoardLastTopicTime ='" + board.BoardLastTopicTime.ToString() + "',";
            MySql += "BoardLastTopicUserNickName ='" + board.BoardLastTopicUserNickName + "',";
            MySql += "BoardLastTopicUserID ='" + board.BoardLastTopicUserID + "',";
            MySql += "BoardFalse ='" + board.BoardFalse + "',";
            MySql += "BoardImages ='" + board.BoardImages + "',";
            MySql += "BoardAbout ='" + board.BoardAbout + "',";
            MySql += "BoardPostNumber = '" + board.BoardPostNumber + "',";
            MySql += "BoardTodayPostNumber ='" + board.BoardTodayPostNumber + "',";
            MySql += "BoardTopicNumber ='" + board.BoardTopicNumber + "',";
            MySql += "BoardDelPoint ='" + board.BoardDelPoint + "',";
            MySql += "BoardPostRole ='" + board.BoardPostRole + "',";
            MySql += "BoardRePostRole ='" + board.BoardRePostRole + "',";
            MySql += "BoardViewRole ='" + board.BoardViewRole + "'";
            MySql += " where BoardID=" + board.BoardID + "";
            //HttpContext.Current.Response.Write(MySql);
            DataConnectionHepler.Instance().ExceCuteSql(MySql);
        }

        public override void DeleteBoard(int boardID)
        {
            DataConnectionHepler.Instance().ExceCuteSql("delete from DoNetBbs_Board where BoardID = " + boardID + "");
        }

        public override ArrayList SetBoardTopic(int boardID, bool Cach)
        {
            MySql = "select * from DoNetBbs_Topic where TopicBoardID=" + boardID.ToString() + "";
            Components.Components.Topic Rs = new Components.Components.Topic();
            DataTable dt;
            if (Cach)
            {
                string key = "WebSite-BoardTopic-List" + boardID.ToString();
                DataTable _cachetable = Components.CsCache.Get(key) as DataTable;
                if (_cachetable == null)
                {
                    dt = DataConnectionHepler.Instance().DataAdapter(MySql, 0, 0, "DoNetBbs_Topic");
                    Components.CsCache.Insert(key, dt, null);
                }
                else
                {
                    dt = _cachetable;
                }
            }
            else
            {
                dt = DataConnectionHepler.Instance().DataAdapter(MySql, 0, 0, "DoNetBbs_Topic");
            }

            if (dt.Rows.Count > 0)
            {
                foreach (DataRow row in dt.Rows)
                {
                    Components.Components.Topic _Arraylist = new Components.Components.Topic();
                    _Arraylist.SetDataProviders(row);
                    Rs.Arraylist.Add(_Arraylist);
                }
            }
            return Rs.Arraylist;
        }

        public override void InsertBoardInfo(Components.Components.Board board)
        {
            string sql = string.Empty;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -