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

📄 bbstopicdao.cs

📁 小型ERP系统源码,修改版本
💻 CS
字号:
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.Text;
using DLOA.DALFactory;

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

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(DLOA.Model.BBSTopic model)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append("insert into BBSTopic(");
            strSql.Append("topicUser,topicTitle,topicContent,topicDate)");
            strSql.Append(" values (");
            strSql.Append("@topicUser,@topicTitle,@topicContent,@topicDate)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters = {
					new SqlParameter("@topicUser", SqlDbType.Int,4),
					new SqlParameter("@topicTitle", SqlDbType.VarChar,500),
					new SqlParameter("@topicContent", SqlDbType.VarChar,8000),
					new SqlParameter("@topicDate", SqlDbType.DateTime)};
            parameters[0].Value = model.topicUser;
            parameters[1].Value = model.topicTitle;
            parameters[2].Value = model.topicContent;
            parameters[3].Value = model.topicDate;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);
            if (obj == null)
            {
                return 1;
            }
            else
            {
                return Convert.ToInt32(obj);
            }
        }
        /// <summary>
        /// 删除一条数据
        /// </summary>
        public void Delete(int id)
        {
            StringBuilder strSql = new StringBuilder();
            System.Collections.Hashtable ht = new System.Collections.Hashtable();
            strSql.Append(" delete BBSReply where topicId = @id");
            SqlParameter[] replyParameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
				};
            replyParameters[0].Value = id;
            ht.Add(strSql, replyParameters);

            strSql = new StringBuilder();
            strSql.Append("delete BBSTopic ");
            strSql.Append(" where id=@id");
            SqlParameter[] topicParameters = {
					new SqlParameter("@id", SqlDbType.Int,4)
				};
            topicParameters[0].Value = id;
            ht.Add(strSql, topicParameters);
            DbHelperSQL.ExecuteSqlTran(ht);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataTable GetList(string strWhere)
        {
            StringBuilder strSql = new StringBuilder();
            strSql.Append(" SELECT BBSTopic.topicTitle, BBSTopic.topicContent, BBSTopic.topicUser, ");
            strSql.Append(" BBSTopic.id, BBSTopic.topicDate,Personnel.name as topicUserName");
            strSql.Append(" FROM BBSTopic INNER JOIN ");
            strSql.Append(" Personnel ON BBSTopic.topicUser = Personnel.id ");
            if (strWhere.Trim() != "")
            {
                strSql.Append(" where " + strWhere);
            }
            return DbHelperSQL.QueryBySql(strSql.ToString());
        }
    }
}

⌨️ 快捷键说明

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