예제 #1
0
 protected void btnCommit_Click(object sender, EventArgs e)
 {
     BbsForum forum = new BbsForum
     {
         forumTitle = txtTitle.Text,
         userNo=this.userNo.Value,
         userType=int.Parse(this.userType.Value),
         forumType=int.Parse(this.ddltforunType.SelectedValue)
     };
     DalOperationAboutBbsManage DalOperationAboutBbsManage = new DalOperationAboutBbsManage();
     DalOperationAboutBbsManage.AddForumInfo(forum);
     Javascript.AlertAndRedirect("添加成功!","BbsManage.aspx",Page);
 }
예제 #2
0
        /// <summary>
        /// 添加自定义版块
        /// </summary>
        /// <param name="bbsForum">版块对象</param>
        /// <returns>添加记录的行数</returns>
        public int AddForumInfo(BbsForum bbsForum)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@forumTitle", SqlDbType.NChar,50),
                    new SqlParameter("@userNo", SqlDbType.NChar,10),
                    new SqlParameter("@userType", SqlDbType.Int,4),
                    new SqlParameter("@forumType", SqlDbType.Int,4)
                    };
            parameters[0].Value = bbsForum.forumTitle;
            parameters[1].Value = bbsForum.userNo;
            parameters[2].Value = bbsForum.userType;
            parameters[3].Value = bbsForum.forumType;

            return SqlHelper.ExecuteNonQuery(conn, CommandType.Text,
                "INSERT INTO [usta_BbsForum]([forumTitle],[userNo],[userType],[forumType]) VALUES (@forumTitle,@userNo,@userType,@forumType)", parameters);
        }
예제 #3
0
        /// <summary>
        /// 修改版块的信息
        /// </summary>
        /// <param name="bbsForum">版块对象</param>
        public void UpdateBbsForum(BbsForum bbsForum)
        {
            try
            {
                string sql = "UPDATE usta_BbsForum SET forumTitle=@forumTitle,lastUpdateTime=@lastUpdateTime,lastTopicTitle=@lastTopicTitle,lastTopicId=@lastTopicId,bbsEmailAddress=@bbsEmailAddress WHERE forumId=@forumId";

                SqlParameter[] parameters = {
                    new SqlParameter("@forumId", SqlDbType.Int,4),
                    new SqlParameter("@forumTitle", SqlDbType.NChar,50),
                    new SqlParameter("@lastUpdateTime", SqlDbType.DateTime),
                    new SqlParameter("@lastTopicTitle", SqlDbType.NChar,50),
                    new SqlParameter("@lastTopicId", SqlDbType.Int,4),
                    new SqlParameter("@bbsEmailAddress", SqlDbType.NVarChar,500)};
                parameters[0].Value = bbsForum.forumId;
                parameters[1].Value = bbsForum.forumTitle;
                parameters[2].Value = bbsForum.lastUpdateTime;
                parameters[3].Value = bbsForum.lastTopicTitle;
                parameters[4].Value = bbsForum.lastTopicId;
                parameters[5].Value = bbsForum.bbsEmaiAddress;
                SqlHelper.ExecuteNonQuery(conn, CommandType.Text, sql, parameters);
            }
            catch (Exception ex)
            {
               MongoDBLog.LogRecord(ex);
                CommonUtility.RedirectUrl();
            }
            finally
            {
                conn.Close();
            }
        }
예제 #4
0
        /// <summary>
        /// 以主键获得版面
        /// </summary>
        /// <param name="forumId">版块编号</param>
        /// <returns>版块对象</returns>
        public BbsForum GetForumById(string forumId)
        {
            string sql = "SELECT [forumId],[forumTitle],[lastUpdateTime],[lastTopicTitle],[lastTopicId] FROM [USTA].[dbo].[usta_BbsForum] WHERE forumId=@forumId";
            SqlParameter[] parameters = {
                    new SqlParameter("@forumId",forumId)};
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql,parameters);
            BbsForum bbsForum = null;

            if (dr.Read())
            {
                bbsForum = new BbsForum
                {
                    forumId=int.Parse(dr["forumId"].ToString().Trim()),
                    forumTitle=dr["forumTitle"].ToString().Trim()
                };

            }

            dr.Close();
            conn.Close();
            return bbsForum;
        }
예제 #5
0
        /// <summary>
        /// 获取版块的信息
        /// </summary>
        /// <param name="forumId">版块编号</param>
        /// <returns>版块对象</returns>
        public BbsForum FindBbsForum(int forumId)
        {
            BbsForum bbsForum = null;
            string sql = "SELECT [forumId],[forumTitle],[lastUpdateTime],[lastTopicTitle],[lastTopicId],[bbsEmailAddress] FROM usta_BbsForum WHERE forumId=@forumId";
            SqlParameter[] parameters = new SqlParameter[1]{
                 new SqlParameter("@forumId",forumId)
            };
            SqlDataReader dr = SqlHelper.ExecuteReader(conn, CommandType.Text, sql, parameters);

            while (dr.Read())
            {
                bbsForum = new BbsForum();
                bbsForum.forumId = int.Parse(dr["forumId"].ToString().Trim());
                bbsForum.forumTitle = dr["forumTitle"].ToString().Trim();
                bbsForum.lastUpdateTime = DateTime.Parse(dr["lastUpdateTime"].ToString().Trim());
                bbsForum.lastTopicTitle = dr["lastTopicTitle"].ToString().Trim();
                bbsForum.lastTopicId = dr["lastTopicId"].ToString().Trim().Length > 0 ? int.Parse(dr["lastTopicId"].ToString().Trim()) : 0;
                bbsForum.bbsEmaiAddress = dr["bbsEmailAddress"].ToString().Trim();
            }
            dr.Close();
            conn.Close();
            return bbsForum;
        }
예제 #6
0
        /// <summary>
        /// 编辑自定义版块
        /// </summary>
        /// <param name="bbsForum">版块对象</param>
        /// <returns>数据库中受影响的记录行数</returns>
        public int EditForumInfo(BbsForum bbsForum)
        {
            SqlParameter[] parameters = {
                    new SqlParameter("@forumId", SqlDbType.Int,4),
                    new SqlParameter("@forumTitle", SqlDbType.NChar,50)
                    };
            parameters[0].Value = bbsForum.forumId;
            parameters[1].Value = bbsForum.forumTitle;

            return SqlHelper.ExecuteNonQuery(conn, CommandType.Text,
                "UPDATE [usta_BbsForum] SET [forumTitle] = @forumTitle WHERE [forumId]=@forumId", parameters);
        }