Exemplo n.º 1
0
        /// <summary>
        /// 登录判断
        /// </summary>
        /// <param name="Admin">接收Admin类</param>
        /// <returns>返回是否登录成功</returns>
        public static bool Login(Admin_M Admin)
        {
            SqlParameter paramAdminName = new SqlParameter();

            paramAdminName.ParameterName = "@AdminName";
            paramAdminName.DbType        = DbType.String;
            paramAdminName.Value         = Admin.Adminlogin;
            SqlParameter paramAdminPwd = new SqlParameter();

            paramAdminPwd.ParameterName = "@AdminPwd";
            paramAdminPwd.DbType        = DbType.String;
            paramAdminPwd.Value         = Admin.Adminpassword;
            SqlDataReader dr = SQLDBHelper.ExecuteReader("proc_Login", paramAdminName, paramAdminPwd);

            if (dr.HasRows)
            {
                dr.Close();
                return(true);
            }
            else
            {
                dr.Close();
                return(false);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageSize">每页数据行数</param>
        /// <param name="pageIndex">页码</param>
        /// <returns>返回集合</returns>
        public static List <Taxonomy_M> TaxListPager(string pageSize, string pageIndex)
        {
            List <Taxonomy_M> list = new List <Taxonomy_M>();
            string            sql  = string.Format("select top ({0}) *from Taxonomy where TaxonomyId not in(select top (({1}-1)*{0}) TaxonomyId from Taxonomy order by TaxonomyId) order by TaxonomyId", pageSize, pageIndex);
            SqlDataReader     dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Taxonomy_M tax = new Taxonomy_M();
                    if (dr["TaxonomyId"] != DBNull.Value)
                    {
                        tax.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                    }
                    if (dr["TaxonomyName"] != DBNull.Value)
                    {
                        tax.TaxonomyName = dr["TaxonomyName"].ToString();
                    }
                    if (dr["Taxonomydesc"] != DBNull.Value)
                    {
                        tax.Taxonomydesc = dr["Taxonomydesc"].ToString();
                    }
                    list.Add(tax);
                }
            }
            dr.Close();
            return(list);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 根据ID查访客
        /// </summary>
        /// <param name="id">访客ID</param>
        /// <returns>返回类</returns>
        public static Users_M UserByID(string id)
        {
            Users_M       user = new Users_M();
            string        sql  = "select * from Users where UserId=" + id;
            SqlDataReader dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                dr.Read();
                if (dr["UserId"] != DBNull.Value)
                {
                    user.UserId = Convert.ToInt32(dr["UserId"]);
                }
                if (dr["Username"] != DBNull.Value)
                {
                    user.Username = Convert.ToString(dr["Username"]);
                }
                if (dr["UserEmail"] != DBNull.Value)
                {
                    user.UserEmail = Convert.ToString(dr["UserEmail"]);
                }
                if (dr["UserIP"] != DBNull.Value)
                {
                    user.UserIP = Convert.ToString(dr["UserIP"]);
                }
            }
            dr.Close();
            return(user);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 根据ID查找帖子
        /// </summary>
        /// <param name="PostID">获取PostID</param>
        /// <returns>返回一个对象</returns>
        public static Posts_M PostByID(string PostID)
        {
            Posts_M       Post = new Posts_M();
            string        sql  = "select * from Posts where PostId=" + PostID;
            SqlDataReader dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                dr.Read();
                if (dr["PostId"] != DBNull.Value)
                {
                    Post.PostId = Convert.ToInt32(dr["PostId"]);
                }
                if (dr["TaxonomyId"] != DBNull.Value)
                {
                    Post.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                }
                if (dr["Title"] != DBNull.Value)
                {
                    Post.Title = Convert.ToString(dr["Title"]);
                }
                if (dr["Post"] != DBNull.Value)
                {
                    Post.Post = Convert.ToString(dr["Post"]);
                }
                if (dr["PublishTime"] != DBNull.Value)
                {
                    Post.PublishTime = Convert.ToDateTime(dr["PublishTime"]);
                }
            }
            dr.Close();
            return(Post);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 查询所有类型
        /// </summary>
        /// <returns>返回集合</returns>
        public static List <Taxonomy_M> TaxList()
        {
            List <Taxonomy_M> list = new List <Taxonomy_M>();
            string            sql  = "select * from Taxonomy";
            SqlDataReader     dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Taxonomy_M tax = new Taxonomy_M();
                    if (dr["TaxonomyId"] != DBNull.Value)
                    {
                        tax.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                    }
                    if (dr["TaxonomyName"] != DBNull.Value)
                    {
                        tax.TaxonomyName = dr["TaxonomyName"].ToString();
                    }
                    if (dr["Taxonomydesc"] != DBNull.Value)
                    {
                        tax.Taxonomydesc = dr["Taxonomydesc"].ToString();
                    }
                    list.Add(tax);
                }
            }
            dr.Close();
            return(list);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 添加访客及其评论
        /// </summary>
        /// <param name="PostId">帖子id</param>
        /// <param name="UserName">访客姓名</param>
        /// <param name="UserEmail">访客邮箱</param>
        /// <param name="CommentMeta">评论内容</param>
        /// <param name="UserIP">访客IP</param>
        /// <returns>返回是否添加成功</returns>
        public static bool AddComment(string PostId, string UserName, string UserEmail, string CommentMeta, string UserIP)
        {
            SqlParameter paramPostId = new SqlParameter();

            paramPostId.ParameterName = "@PostId";
            paramPostId.DbType        = DbType.String;
            paramPostId.Value         = PostId;
            SqlParameter paramUserName = new SqlParameter();

            paramUserName.ParameterName = "@Username";
            paramUserName.DbType        = DbType.String;
            paramUserName.Value         = UserName;
            SqlParameter paramUserEmail = new SqlParameter();

            paramUserEmail.ParameterName = "@UserEmail";
            paramUserEmail.DbType        = DbType.String;
            paramUserEmail.Value         = UserEmail;
            SqlParameter paramCommentMeta = new SqlParameter();

            paramCommentMeta.ParameterName = "@Commentsmeta";
            paramCommentMeta.DbType        = DbType.String;
            paramCommentMeta.Value         = CommentMeta;
            SqlParameter paramUserIP = new SqlParameter();

            paramUserIP.ParameterName = "@UserIP";
            paramUserIP.DbType        = DbType.String;
            paramUserIP.Value         = UserIP;
            return(SQLDBHelper.ExecuteNonQuery("proc_Insert_Comment", paramPostId, paramUserName, paramUserEmail, paramCommentMeta, paramUserIP));
        }
Exemplo n.º 7
0
        /// <summary>
        /// 增
        /// </summary>
        /// <param name="tax"></param>
        /// <returns></returns>
        public static bool addTax(Taxonomy_M tax)
        {
            SqlParameter paramTaxName = new SqlParameter();

            paramTaxName.ParameterName = "@TaxonomyName";
            paramTaxName.DbType        = DbType.String;
            paramTaxName.Value         = tax.TaxonomyName;
            SqlParameter paramTaxdesc = new SqlParameter();

            paramTaxdesc.ParameterName = "@Taxonomydesc";
            paramTaxdesc.DbType        = DbType.String;
            paramTaxdesc.Value         = tax.Taxonomydesc;
            return(SQLDBHelper.ExecuteNonQuery("proc_Insert_Tax", paramTaxName, paramTaxdesc));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 注册
        /// </summary>
        /// <param name="Admin">接收Admin类</param>
        /// <returns>返回是否注册成功</returns>
        public static bool Register(Admin_M Admin)
        {
            SqlParameter paramAdminName = new SqlParameter();

            paramAdminName.ParameterName = "@AdminName";
            paramAdminName.DbType        = DbType.String;
            paramAdminName.Value         = Admin.Adminlogin;
            SqlParameter paramAdminPwd = new SqlParameter();

            paramAdminPwd.ParameterName = "@AdminPwd";
            paramAdminPwd.DbType        = DbType.String;
            paramAdminPwd.Value         = Admin.Adminpassword;
            return(SQLDBHelper.ExecuteNonQuery("proc_Register", paramAdminName, paramAdminPwd));
        }
Exemplo n.º 9
0
        /// <summary>
        /// 改
        /// </summary>
        /// <param name="tax"></param>
        /// <returns></returns>
        public static bool updateTax(Taxonomy_M tax)
        {
            SqlParameter paramTaxName = new SqlParameter();

            paramTaxName.ParameterName = "@TaxonomyName";
            paramTaxName.DbType        = DbType.String;
            paramTaxName.Value         = tax.TaxonomyName;
            SqlParameter paramTaxdesc = new SqlParameter();

            paramTaxdesc.ParameterName = "@Taxonomydesc";
            paramTaxdesc.DbType        = DbType.String;
            paramTaxdesc.Value         = tax.Taxonomydesc;
            SqlParameter paramTaxId = new SqlParameter();

            paramTaxId.ParameterName = "@TaxonomyId";
            paramTaxId.DbType        = DbType.String;
            paramTaxId.Value         = tax.TaxonomyId;
            return(SQLDBHelper.ExecuteNonQuery("proc_Update_Tax", paramTaxName, paramTaxdesc, paramTaxId));
        }
Exemplo n.º 10
0
        /// <summary>
        /// 添加帖子
        /// </summary>
        /// <param name="post">接收类</param>
        /// <returns>返回影响行数是否大于0</returns>
        public static bool addPost(Posts_M post)
        {
            SqlParameter paramTaxID = new SqlParameter();

            paramTaxID.ParameterName = "@TaxonomyId";
            paramTaxID.DbType        = DbType.String;
            paramTaxID.Value         = post.TaxonomyId;
            SqlParameter paramTitle = new SqlParameter();

            paramTitle.ParameterName = "@Title";
            paramTitle.DbType        = DbType.String;
            paramTitle.Value         = post.Title;
            SqlParameter paramPost = new SqlParameter();

            paramPost.ParameterName = "@Post";
            paramPost.DbType        = DbType.String;
            paramPost.Value         = post.Post;
            return(SQLDBHelper.ExecuteNonQuery("proc_Insert_Post", paramTaxID, paramTitle, paramPost));
        }
Exemplo n.º 11
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageSize">每页数据</param>
        /// <param name="pageIndex">页码</param>
        /// <returns>返回集合</returns>
        public static List <Comments_M> CommentsListPager(string pageSize, string pageIndex)
        {
            List <Comments_M> list = new List <Comments_M>();
            string            sql  = string.Format("select top ({0}) *from Comments where CommentId not in(select top (({1}-1)*{0}) CommentId from Comments order by CommentId)order by CommentId", pageSize, pageIndex);
            SqlDataReader     dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Comments_M comment = new Comments_M();
                    if (dr["CommentId"] != DBNull.Value)
                    {
                        comment.CommentId = Convert.ToInt32(dr["CommentId"]);
                    }
                    if (dr["PostId"] != DBNull.Value)
                    {
                        comment.PostId = Convert.ToInt32(dr["PostId"]);
                    }
                    if (dr["UserId"] != DBNull.Value)
                    {
                        comment.UserId = Convert.ToInt32(dr["UserId"]);
                    }
                    if (dr["Commentsmeta"] != DBNull.Value)
                    {
                        comment.Commentsmeta = Convert.ToString(dr["Commentsmeta"]);
                    }
                    if (dr["CommentsTime"] != DBNull.Value)
                    {
                        comment.CommentsTime = Convert.ToDateTime(dr["CommentsTime"]);
                    }
                    list.Add(comment);
                }
            }
            dr.Close();
            return(list);
        }
Exemplo n.º 12
0
        /// <summary>
        /// 查询所有评论
        /// </summary>
        /// <returns>返回集合</returns>
        public static List <Comments_M> CommentsList()
        {
            List <Comments_M> list = new List <Comments_M>();
            string            sql  = "select * from Comments";
            SqlDataReader     dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Comments_M comment = new Comments_M();
                    if (dr["CommentId"] != DBNull.Value)
                    {
                        comment.CommentId = Convert.ToInt32(dr["CommentId"]);
                    }
                    if (dr["PostId"] != DBNull.Value)
                    {
                        comment.PostId = Convert.ToInt32(dr["PostId"]);
                    }
                    if (dr["UserId"] != DBNull.Value)
                    {
                        comment.UserId = Convert.ToInt32(dr["UserId"]);
                    }
                    if (dr["Commentsmeta"] != DBNull.Value)
                    {
                        comment.Commentsmeta = Convert.ToString(dr["Commentsmeta"]);
                    }
                    if (dr["CommentsTime"] != DBNull.Value)
                    {
                        comment.CommentsTime = Convert.ToDateTime(dr["CommentsTime"]);
                    }
                    list.Add(comment);
                }
            }
            dr.Close();
            return(list);
        }
Exemplo n.º 13
0
        /// <summary>
        /// 分页查询
        /// </summary>
        /// <param name="pageSize">页数大小</param>
        /// <param name="pageIndex">页码</param>
        /// <returns>返回集合</returns>
        public static List <Posts_M> PostListPager(string pageSize, string pageIndex)
        {
            List <Posts_M> list = new List <Posts_M>();
            string         sql  = string.Format("select top ({0}) *from Posts where PostId not in (select top (({1}-1)*{0}) PostId from Posts order by PostId) order by PostId", pageSize, pageIndex);
            SqlDataReader  dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Posts_M post = new Posts_M();
                    if (dr["PostId"] != DBNull.Value)
                    {
                        post.PostId = Convert.ToInt32(dr["PostId"]);
                    }
                    if (dr["TaxonomyId"] != DBNull.Value)
                    {
                        post.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                    }
                    if (dr["Title"] != DBNull.Value)
                    {
                        post.Title = Convert.ToString(dr["Title"]);
                    }
                    if (dr["Post"] != DBNull.Value)
                    {
                        post.Post = Convert.ToString(dr["Post"]);
                    }
                    if (dr["PublishTime"] != DBNull.Value)
                    {
                        post.PublishTime = Convert.ToDateTime(dr["PublishTime"]);
                    }
                    list.Add(post);
                }
            }
            dr.Close();
            return(list);
        }
Exemplo n.º 14
0
        /// <summary>
        /// 通过类型ID查找帖子集合
        /// </summary>
        /// <param name="TaxID">获取类型ID</param>
        /// <returns>返回集合</returns>
        public static List <Posts_M> PostListByTaxID(string TaxID)
        {
            List <Posts_M> list = new List <Posts_M>();
            string         sql  = "select * from Posts  where TaxonomyId =" + TaxID;
            SqlDataReader  dr   = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Posts_M post = new Posts_M();
                    if (dr["PostId"] != DBNull.Value)
                    {
                        post.PostId = Convert.ToInt32(dr["PostId"]);
                    }
                    if (dr["TaxonomyId"] != DBNull.Value)
                    {
                        post.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                    }
                    if (dr["Title"] != DBNull.Value)
                    {
                        post.Title = Convert.ToString(dr["Title"]);
                    }
                    if (dr["Post"] != DBNull.Value)
                    {
                        post.Post = Convert.ToString(dr["Post"]);
                    }
                    if (dr["PublishTime"] != DBNull.Value)
                    {
                        post.PublishTime = Convert.ToDateTime(dr["PublishTime"]);
                    }
                    list.Add(post);
                }
            }
            dr.Close();
            return(list);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 根据类型ID获取类型
        /// </summary>
        /// <param name="id">类型id</param>
        /// <returns>返回类型对象</returns>
        public static Taxonomy_M getTaxonomyByID(string id)
        {
            Taxonomy_M    tax = new Taxonomy_M();
            string        sql = "select * from Taxonomy where TaxonomyId=" + id;
            SqlDataReader dr  = SQLDBHelper.ExecuteReader(sql);

            if (dr.HasRows)
            {
                dr.Read();
                if (dr["TaxonomyId"] != DBNull.Value)
                {
                    tax.TaxonomyId = Convert.ToInt32(dr["TaxonomyId"]);
                }
                if (dr["TaxonomyName"] != DBNull.Value)
                {
                    tax.TaxonomyName = dr["TaxonomyName"].ToString();
                }
                if (dr["Taxonomydesc"] != DBNull.Value)
                {
                    tax.Taxonomydesc = dr["Taxonomydesc"].ToString();
                }
            }
            return(tax);
        }
Exemplo n.º 16
0
        /// <summary>
        /// 删
        /// </summary>
        /// <param name="commentid">接收评论id</param>
        /// <returns>返回是否删除成功</returns>
        public static bool delcomment(string commentid)
        {
            string sql = "delete from Comments where CommentId=" + commentid;

            return(SQLDBHelper.ExecuteNonQuery(sql));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 根据帖子ID查评论数
        /// </summary>
        /// <param name="postId">接收帖子ID</param>
        /// <returns>返回评论数</returns>
        public static int commentCountByPostID(string postId)
        {
            string sql = "select count(*) from Comments where PostId=" + postId;

            return(SQLDBHelper.ExecuteScalar(sql));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 所有评论数
        /// </summary>
        /// <returns>返回评论数</returns>
        public static int commentCount()
        {
            string sql = "select count(*) from Comments";

            return(SQLDBHelper.ExecuteScalar(sql));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 所有类型数
        /// </summary>
        /// <returns>返回数量</returns>
        public static int TaxCount()
        {
            string sql = "select count(*) from Taxonomy";

            return(SQLDBHelper.ExecuteScalar(sql));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 根据帖子ID删除
        /// </summary>
        /// <param name="postID">接收帖子ID</param>
        /// <returns>返回是否删除成功</returns>
        public static bool delBypostId(string postID)
        {
            string sql = "delete from Posts where PostId=" + postID;

            return(SQLDBHelper.ExecuteNonQuery(sql));
        }
Exemplo n.º 21
0
        /// <summary>
        /// 删
        /// </summary>
        /// <param name="taxId"></param>
        /// <returns></returns>
        public static bool delTax(string taxId)
        {
            string sql = "delete from Taxonomy where TaxonomyId=" + taxId;

            return(SQLDBHelper.ExecuteNonQuery(sql));
        }