Example #1
0
        public int UpdateLink(LinkInfo link)
        {
            string cmdText = @"update Loachs_Links set
                                type=@type,
                                name=@name,
                                href=@href,
                                position=@position,
                                target=@target,
                                description=@description,
                                displayorder=@displayorder,
                                status=@status,
                                createdate=@createdate
                                where linkid=@linkid";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@type",         DbType.Int32,    4, link.Type),
                SqliteHelper.MakeInParam("@name",         DbType.String, 100, link.Name),
                SqliteHelper.MakeInParam("@href",         DbType.String, 255, link.Href),
                SqliteHelper.MakeInParam("@position",     DbType.Int32,    4, link.Position),
                SqliteHelper.MakeInParam("@target",       DbType.String,  50, link.Target),
                SqliteHelper.MakeInParam("@description",  DbType.String, 255, link.Description),
                SqliteHelper.MakeInParam("@displayorder", DbType.Int32,    4, link.Displayorder),
                SqliteHelper.MakeInParam("@status",       DbType.Int32,    4, link.Status),
                SqliteHelper.MakeInParam("@createdate",   DbType.Date,     8, link.CreateDate),
                SqliteHelper.MakeInParam("@linkid",       DbType.Int32,    4, link.LinkId),
            };

            return(Convert.ToInt32(SqliteHelper.ExecuteScalar(CommandType.Text, cmdText, prams)));
        }
Example #2
0
        /// <summary>
        /// 添加分类
        /// </summary>
        /// <param name="category"></param>
        /// <returns></returns>
        public int InsertCategory(CategoryInfo category)
        {
            CheckSlug(category);

            string cmdText = @"insert into Loachs_Terms
                            (
                            Type,Name,Slug,Description,Displayorder,Count,CreateDate
                            )
                            values
                            (
                            @Type,@Name,@Slug,@Description,@Displayorder,@Count,@CreateDate
                            )";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@Type",         DbType.Int32,    1, (int)TermType.Category),
                SqliteHelper.MakeInParam("@Name",         DbType.String, 255, category.Name),
                SqliteHelper.MakeInParam("@Slug",         DbType.String, 255, category.Slug),
                SqliteHelper.MakeInParam("@Description",  DbType.String, 255, category.Description),
                SqliteHelper.MakeInParam("@Displayorder", DbType.Int32,    4, category.Displayorder),
                SqliteHelper.MakeInParam("@Count",        DbType.Int32,    4, category.Count),
                SqliteHelper.MakeInParam("@CreateDate",   DbType.Date,     8, category.CreateDate)
            };
            SqliteHelper.ExecuteScalar(CommandType.Text, cmdText, prams);

            //int newId = Convert.ToInt32(SqliteHelper.ExecuteScalar("select top 1 [termid] from [Loachs_Terms] order by [termid] desc"));
            int newId = Convert.ToInt32(SqliteHelper.ExecuteScalar("select termid from Loachs_Terms order by termid desc limit 0,1"));


            return(newId);
        }
Example #3
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public int UpdateComment(CommentInfo comment)
        {
            string cmdText = @"update Loachs_Comments set 
                            PostId=@PostId,                            
                            ParentId=@ParentId,
                            UserId=@UserId,
                            Name=@Name,
                            Email=@Email,
                            SiteUrl=@SiteUrl,
                            Content=@Content,
                            EmailNotify=@EmailNotify,
                            IpAddress=@IpAddress,
                            CreateDate=@CreateDate,
                            Approved=@Approved
                            where CommentId=@CommentId ";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@PostId",      DbType.Int32,    4, comment.PostId),
                SqliteHelper.MakeInParam("@ParentId",    DbType.Int32,    4, comment.ParentId),
                SqliteHelper.MakeInParam("@UserId",      DbType.Int32,    4, comment.UserId),
                SqliteHelper.MakeInParam("@Name",        DbType.String, 255, comment.Name),
                SqliteHelper.MakeInParam("@Email",       DbType.String, 255, comment.Email),
                SqliteHelper.MakeInParam("@SiteUrl",     DbType.String, 255, comment.SiteUrl),
                SqliteHelper.MakeInParam("@Content",     DbType.String, 255, comment.Content),
                SqliteHelper.MakeInParam("@EmailNotify", DbType.Int32,    4, comment.EmailNotify),
                SqliteHelper.MakeInParam("@IpAddress",   DbType.String, 255, comment.IpAddress),
                SqliteHelper.MakeInParam("@CreateDate",  DbType.Date,     8, comment.CreateDate),
                SqliteHelper.MakeInParam("@Approved",    DbType.Int32,    4, comment.Approved),
                SqliteHelper.MakeInParam("@CommentId",   DbType.Int32,    4, comment.CommentId),
            };
            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams));
        }
Example #4
0
        public int UpdateCategory(CategoryInfo category)
        {
            CheckSlug(category);

            string cmdText = @"update Loachs_Terms set
                                Type=@Type,
                                Name=@Name,
                                Slug=@Slug,
                                Description=@Description,
                                Displayorder=@Displayorder,
                                Count=@Count,
                                CreateDate=@CreateDate
                                where termid=@termid";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@Type",         DbType.Int32,    1, (int)TermType.Category),
                SqliteHelper.MakeInParam("@Name",         DbType.String, 255, category.Name),
                SqliteHelper.MakeInParam("@Slug",         DbType.String, 255, category.Slug),
                SqliteHelper.MakeInParam("@Description",  DbType.String, 255, category.Description),
                SqliteHelper.MakeInParam("@Displayorder", DbType.Int32,    4, category.Displayorder),
                SqliteHelper.MakeInParam("@Count",        DbType.Int32,    4, category.Count),
                SqliteHelper.MakeInParam("@CreateDate",   DbType.Date,     8, category.CreateDate),
                SqliteHelper.MakeInParam("@termid",       DbType.Int32,    1, category.CategoryId),
            };
            return(Convert.ToInt32(SqliteHelper.ExecuteScalar(CommandType.Text, cmdText, prams)));
        }
Example #5
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="_userinfo"></param>
        /// <returns></returns>
        public int InsertUser(UserInfo _userinfo)
        {
            string cmdText = @" insert into Loachs_Users(
                                Type,UserName,Name,Password,Email,SiteUrl,AvatarUrl,Description,displayorder,Status,PostCount,CommentCount,CreateDate)
                                values (
                                @Type,@UserName,@Name,@Password,@Email,@SiteUrl,@AvatarUrl,@Description,@Displayorder,@Status, @PostCount,@CommentCount,@CreateDate )";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@Type",         DbType.Int32,    4, _userinfo.Type),
                SqliteHelper.MakeInParam("@UserName",     DbType.String,  50, _userinfo.UserName),
                SqliteHelper.MakeInParam("@Name",         DbType.String,  50, _userinfo.Name),
                SqliteHelper.MakeInParam("@Password",     DbType.String,  50, _userinfo.Password),
                SqliteHelper.MakeInParam("@Email",        DbType.String,  50, _userinfo.Email),
                SqliteHelper.MakeInParam("@SiteUrl",      DbType.String, 255, _userinfo.SiteUrl),
                SqliteHelper.MakeInParam("@AvatarUrl",    DbType.String, 255, _userinfo.AvatarUrl),
                SqliteHelper.MakeInParam("@description",  DbType.String, 255, _userinfo.Description),
                SqliteHelper.MakeInParam("@Displayorder", DbType.Int32,    4, _userinfo.Displayorder),
                SqliteHelper.MakeInParam("@Status",       DbType.Int32,    4, _userinfo.Status),
                SqliteHelper.MakeInParam("@PostCount",    DbType.Int32,    4, _userinfo.PostCount),
                SqliteHelper.MakeInParam("@CommentCount", DbType.Int32,    4, _userinfo.CommentCount),
                SqliteHelper.MakeInParam("@CreateDate",   DbType.Date,     8, _userinfo.CreateDate),
            };
            int r = SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);

            if (r > 0)
            {
                //return Convert.ToInt32(SqliteHelper.ExecuteScalar("select top 1 UserId from Loachs_Users  order by UserId desc"));
                return(Convert.ToInt32(SqliteHelper.ExecuteScalar("select UserId from Loachs_Users  order by UserId desc limit 0,1")));
            }
            return(0);
        }
Example #6
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="comment"></param>
        /// <returns></returns>
        public int InsertComment(CommentInfo comment)
        {
            string cmdText = @"insert into Loachs_Comments(
                            PostId, ParentId,UserId,Name,Email,SiteUrl,Content,EmailNotify,IpAddress,CreateDate,Approved)
                             values (
                            @PostId, @ParentId,@UserId,@Name,@Email,@SiteUrl,@Content,@EmailNotify,@IpAddress,@CreateDate,@Approved)";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@PostId",      DbType.Int32,    4, comment.PostId),
                SqliteHelper.MakeInParam("@ParentId",    DbType.Int32,    4, comment.ParentId),
                SqliteHelper.MakeInParam("@UserId",      DbType.Int32,    4, comment.UserId),
                SqliteHelper.MakeInParam("@Name",        DbType.String, 255, comment.Name),
                SqliteHelper.MakeInParam("@Email",       DbType.String, 255, comment.Email),
                SqliteHelper.MakeInParam("@SiteUrl",     DbType.String, 255, comment.SiteUrl),
                SqliteHelper.MakeInParam("@Content",     DbType.String, 255, comment.Content),
                SqliteHelper.MakeInParam("@EmailNotify", DbType.Int32,    4, comment.EmailNotify),
                SqliteHelper.MakeInParam("@IpAddress",   DbType.String, 255, comment.IpAddress),
                SqliteHelper.MakeInParam("@CreateDate",  DbType.Date,     8, comment.CreateDate),
                SqliteHelper.MakeInParam("@Approved",    DbType.Int32,    4, comment.Approved),
            };
            SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);

            int newId = Convert.ToInt32(SqliteHelper.ExecuteScalar("select  CommentId from Loachs_Comments  order by CommentId desc limit 0,1"));

            return(newId);
        }
Example #7
0
        public int InsertLink(LinkInfo link)
        {
            string cmdText = @"insert into Loachs_Links
                            (
                            type,name,href,position,target,description,displayorder,status,createdate
                            )
                            values
                            (
                            @type,@name,@href,@position,@target,@description,@displayorder,@status,@createdate
                            )";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@type",         DbType.Int32,    4, link.Type),
                SqliteHelper.MakeInParam("@name",         DbType.String, 100, link.Name),
                SqliteHelper.MakeInParam("@href",         DbType.String, 255, link.Href),
                SqliteHelper.MakeInParam("@position",     DbType.Int32,    4, link.Position),
                SqliteHelper.MakeInParam("@target",       DbType.String,  50, link.Target),
                SqliteHelper.MakeInParam("@description",  DbType.String, 255, link.Description),
                SqliteHelper.MakeInParam("@displayorder", DbType.Int32,    4, link.Displayorder),
                SqliteHelper.MakeInParam("@status",       DbType.Int32,    4, link.Status),
                SqliteHelper.MakeInParam("@createdate",   DbType.Date,     8, link.CreateDate),
            };

            int r = SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);

            if (r > 0)
            {
                return(Convert.ToInt32(SqliteHelper.ExecuteScalar("select linkid from Loachs_Links  order by linkid desc limit 0,1")));
            }
            return(0);
        }
Example #8
0
        public int DeleteLink(int linkId)
        {
            string cmdText = "delete from Loachs_Links where linkid = @linkid";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@linkid", DbType.Int32, 4, linkId)
            };
            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams));
        }
Example #9
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="userid"></param>
        /// <returns></returns>
        public int DeleteUser(int userid)
        {
            string cmdText = "delete from Loachs_Users where userid = @userid";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@userid", DbType.Int32, 4, userid)
            };
            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams));
        }
Example #10
0
        public int DeleteCategory(int categoryId)
        {
            string cmdText = "delete from Loachs_Terms where termid = @termid";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@termid", DbType.Int32, 4, categoryId)
            };
            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams));
        }
Example #11
0
        /// <summary>
        /// 是否存在
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public bool ExistsUserName(string userName)
        {
            string cmdText = "select count(1) from Loachs_Users where userName = @userName ";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@userName", DbType.String, 50, userName),
            };
            return(Convert.ToInt32(SqliteHelper.ExecuteScalar(CommandType.Text, cmdText, prams)) > 0);
        }
Example #12
0
        public int UpdatePostViewCount(int postId, int addCount)
        {
            string cmdText = "update Loachs_Posts set viewcount = viewcount + @addcount where postid=@postid";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@addcount", DbType.Int32, 4, addCount),
                SqliteHelper.MakeInParam("@postid",   DbType.Int32, 4, postId),
            };
            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams));
        }
Example #13
0
        public bool UpdateSetting(SettingInfo setting)
        {
            string cmdText = @"update Loachs_Sites set setting=@setting";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@setting", DbType.String, 0, Serialize(setting)),
            };

            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams) == 1);
        }
Example #14
0
        /// <summary>
        /// 根据日志ID删除评论
        /// </summary>
        /// <param name="postId">日志ID</param>
        /// <returns></returns>
        public int DeleteCommentByPost(int postId)
        {
            string cmdText = "delete from Loachs_Comments where postId = @postId";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@postId", DbType.Int32, 4, postId)
            };
            int result = SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);

            return(result);
        }
Example #15
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="commentId"></param>
        /// <returns></returns>
        public CommentInfo GetComment(int commentId)
        {
            string cmdText = "select * from Loachs_Comments where commentId = @commentId";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@commentId", DbType.Int32, 4, commentId)
            };
            List <CommentInfo> list = DataReaderToCommentList(SqliteHelper.ExecuteReader(cmdText, prams));

            return(list.Count > 0 ? list[0] : null);
        }
Example #16
0
        public CategoryInfo GetCategory(int categoryId)
        {
            string cmdText = "select * from Loachs_Terms where termid = @termid";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@termid", DbType.Int32, 4, categoryId)
            };

            List <CategoryInfo> list = DataReaderToList(SqliteHelper.ExecuteReader(CommandType.Text, cmdText, prams));

            return(list.Count > 0 ? list[0] : null);
        }
Example #17
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="PostId">主键</param>
        /// <returns></returns>
        public PostInfo GetPost(int postid)
        {
            //string cmdText = "select top 1 * from [Loachs_Posts] where [PostId] = @PostId";
            string cmdText = "select * from Loachs_Posts where PostId = @PostId limit 0,1";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@PostId", DbType.Int32, 4, postid)
            };


            List <PostInfo> list = DataReaderToCommentList(SqliteHelper.ExecuteReader(cmdText, prams));

            return(list.Count > 0 ? list[0] : null);
        }
Example #18
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="commentId"></param>
        /// <returns></returns>
        public int DeleteComment(int commentId)
        {
            CommentInfo comment = GetComment(commentId);        //删除前

            string cmdText = "delete from Loachs_Comments where commentId = @commentId";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@commentId", DbType.Int32, 4, commentId)
            };

            int result = SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);

            return(result);
        }
Example #19
0
        /// <summary>
        /// 获取实体
        /// </summary>
        /// <param name="slug"></param>
        /// <returns></returns>
        public PostInfo GetPost(string slug)
        {
            //string cmdText = "select top 1 * from [Loachs_Posts] where [slug] = @slug";
            string cmdText = "select * from Loachs_Posts where slug = @slug limit 0,1";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@slug", DbType.String, 200, slug)
            };


            List <PostInfo> list = DataReaderToCommentList(SqliteHelper.ExecuteReader(cmdText, prams));

            return(list.Count > 0 ? list[0] : null);
        }
Example #20
0
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="postinfo">实体</param>
        /// <returns>成功返回新记录的ID,失败返回 0</returns>
        public int InsertPost(PostInfo postinfo)
        {
            CheckSlug(postinfo);
            string cmdText = @"insert into Loachs_Posts
                                (
                               CategoryId,Title,Summary,Content,Slug,UserId,CommentStatus,CommentCount,ViewCount,Tag,UrlFormat,Template,Recommend,Status,TopStatus,HideStatus,CreateDate,UpdateDate
                                )
                                values
                                (
                                @CategoryId,@Title,@Summary,@Content,@Slug,@UserId,@CommentStatus,@CommentCount,@ViewCount,@Tag,@UrlFormat,@Template,@Recommend,@Status,@TopStatus,@HideStatus,@CreateDate,@UpdateDate
                                )";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@CategoryId",    DbType.Int32,    4, postinfo.CategoryId),
                SqliteHelper.MakeInParam("@Title",         DbType.String, 255, postinfo.Title),
                SqliteHelper.MakeInParam("@Summary",       DbType.String,   0, postinfo.Summary),
                SqliteHelper.MakeInParam("@Content",       DbType.String,   0, postinfo.Content),
                SqliteHelper.MakeInParam("@Slug",          DbType.String, 255, postinfo.Slug),
                SqliteHelper.MakeInParam("@UserId",        DbType.Int32,    4, postinfo.UserId),
                SqliteHelper.MakeInParam("@CommentStatus", DbType.Int32,    1, postinfo.CommentStatus),
                SqliteHelper.MakeInParam("@CommentCount",  DbType.Int32,    4, postinfo.CommentCount),
                SqliteHelper.MakeInParam("@ViewCount",     DbType.Int32,    4, postinfo.ViewCount),
                SqliteHelper.MakeInParam("@Tag",           DbType.String, 255, postinfo.Tag),
                SqliteHelper.MakeInParam("@UrlFormat",     DbType.Int32,    1, postinfo.UrlFormat),
                SqliteHelper.MakeInParam("@Template",      DbType.String,  50, postinfo.Template),
                SqliteHelper.MakeInParam("@Recommend",     DbType.Int32,    1, postinfo.Recommend),
                SqliteHelper.MakeInParam("@Status",        DbType.Int32,    1, postinfo.Status),
                SqliteHelper.MakeInParam("@TopStatus",     DbType.Int32,    1, postinfo.TopStatus),
                SqliteHelper.MakeInParam("@HideStatus",    DbType.Int32,    1, postinfo.HideStatus),
                SqliteHelper.MakeInParam("@CreateDate",    DbType.Date,     8, postinfo.CreateDate),
                SqliteHelper.MakeInParam("@UpdateDate",    DbType.Date,     8, postinfo.UpdateDate)
            };
            SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);
            //int newId = StringHelper.ObjectToInt(SqliteHelper.ExecuteScalar("select top 1 PostId from Loachs_Posts order by PostId desc"));
            int newId = StringHelper.ObjectToInt(SqliteHelper.ExecuteScalar("select PostId from Loachs_Posts order by PostId desc limit 0,1"));

            //if (newId > 0)
            //{
            //    SqliteHelper.ExecuteNonQuery(string.Format("update [Loachs_Users] set [postcount]=[postcount]+1 where [userid]={0}", postinfo.UserId));
            //    SqliteHelper.ExecuteNonQuery("update [Loachs_Sites] set [postcount]=[postcount]+1");
            //    SqliteHelper.ExecuteNonQuery(string.Format("update [Loachs_Terms] set [count]=[count]+1 where [termid]={0}", postinfo.CategoryId));
            //}
            return(newId);
        }
Example #21
0
        public bool UpdateStatistics(StatisticsInfo statistics)
        {
            string cmdText = @"update Loachs_Sites set 
                                PostCount=@PostCount,
                                CommentCount=@CommentCount,
                                VisitCount=@VisitCount,
                                TagCount=@TagCount";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@PostCount",    DbType.Int32, 4, statistics.PostCount),
                SqliteHelper.MakeInParam("@CommentCount", DbType.Int32, 4, statistics.CommentCount),
                SqliteHelper.MakeInParam("@VisitCount",   DbType.Int32, 4, statistics.VisitCount),
                SqliteHelper.MakeInParam("@TagCount",     DbType.Int32, 4, statistics.TagCount),
            };

            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams) == 1);
        }
Example #22
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="postinfo">实体</param>
        /// <returns>修改的行数</returns>
        public int UpdatePost(PostInfo postinfo)
        {
            CheckSlug(postinfo);

            //PostInfo oldPost = GetPost(postinfo.PostId);        //修改前

            //if (oldPost.CategoryId != postinfo.CategoryId)
            //{

            //    SqliteHelper.ExecuteNonQuery(string.Format("update [Loachs_Terms] set [count]=[count]-1 where [termid]={0}", oldPost.CategoryId));

            //    SqliteHelper.ExecuteNonQuery(string.Format("update [Loachs_Terms] set [count]=[count]+1 where [termid]={0}", postinfo.CategoryId));

            //}


            string cmdText = "update Loachs_Posts set  CategoryId=@CategoryId,Title=@Title,Summary=@Summary,Content=@Content,Slug=@Slug,UserId=@UserId,CommentStatus=@CommentStatus,CommentCount=@CommentCount,ViewCount=@ViewCount,Tag=@Tag,UrlFormat=@UrlFormat,Template=@Template,Recommend=@Recommend,Status=@Status,TopStatus=@TopStatus,HideStatus=@HideStatus,CreateDate=@CreateDate,UpdateDate=@UpdateDate where PostId=@PostId";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@CategoryId",    DbType.Int32,    4, postinfo.CategoryId),
                SqliteHelper.MakeInParam("@Title",         DbType.String, 255, postinfo.Title),
                SqliteHelper.MakeInParam("@Summary",       DbType.String,   0, postinfo.Summary),
                SqliteHelper.MakeInParam("@Content",       DbType.String,   0, postinfo.Content),
                SqliteHelper.MakeInParam("@Slug",          DbType.String, 255, postinfo.Slug),
                SqliteHelper.MakeInParam("@UserId",        DbType.Int32,    4, postinfo.UserId),
                SqliteHelper.MakeInParam("@CommentStatus", DbType.Int32,    1, postinfo.CommentStatus),
                SqliteHelper.MakeInParam("@CommentCount",  DbType.Int32,    4, postinfo.CommentCount),
                SqliteHelper.MakeInParam("@ViewCount",     DbType.Int32,    4, postinfo.ViewCount),
                SqliteHelper.MakeInParam("@Tag",           DbType.String, 255, postinfo.Tag),
                SqliteHelper.MakeInParam("@UrlFormat",     DbType.Int32,    1, postinfo.UrlFormat),
                SqliteHelper.MakeInParam("@Template",      DbType.String,  50, postinfo.Template),
                SqliteHelper.MakeInParam("@Recommend",     DbType.Int32,    1, postinfo.Recommend),
                SqliteHelper.MakeInParam("@Status",        DbType.Int32,    1, postinfo.Status),
                SqliteHelper.MakeInParam("@TopStatus",     DbType.Int32,    1, postinfo.TopStatus),
                SqliteHelper.MakeInParam("@HideStatus",    DbType.Int32,    1, postinfo.HideStatus),
                SqliteHelper.MakeInParam("@CreateDate",    DbType.Date,     8, postinfo.CreateDate),
                SqliteHelper.MakeInParam("@UpdateDate",    DbType.Date,     8, postinfo.UpdateDate),
                SqliteHelper.MakeInParam("@PostId",        DbType.Int32,    4, postinfo.PostId),
            };
            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams));
        }
Example #23
0
        /// <summary>
        /// 删除
        /// </summary>
        /// <param name="PostId">主键</param>
        /// <returns>删除的行数</returns>
        public int DeletePost(int postid)
        {
            PostInfo oldPost = GetPost(postid);        //删除前

            string cmdText = "delete from Loachs_Posts where PostId = @PostId";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@PostId", DbType.Int32, 4, postid)
            };
            int result = SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams);



            //if (oldPost != null)
            //{
            //    SqliteHelper.ExecuteNonQuery(string.Format("update [Loachs_Users] set [postcount]=[postcount]-1 where [userid]={0}", oldPost.UserId));
            //    SqliteHelper.ExecuteNonQuery("update [Loachs_Sites] set [postcount]=[postcount]-1");
            //    SqliteHelper.ExecuteNonQuery(string.Format("update [Loachs_Terms] set [count]=[count]-1 where [termid]={0}", oldPost.CategoryId));
            //}

            return(result);
        }
Example #24
0
        /// <summary>
        /// 更新
        /// </summary>
        /// <param name="_userinfo"></param>
        /// <returns></returns>
        public int UpdateUser(UserInfo _userinfo)
        {
            string cmdText = @"update Loachs_Users set
                                Type=@Type,
                                UserName=@UserName,
                                Name=@Name,
                                Password=@Password,
                                Email=@Email,
                                SiteUrl=@SiteUrl,
                                AvatarUrl=@AvatarUrl,
                                Description=@Description,
                                Displayorder=@Displayorder,
                                Status=@Status,
                                PostCount=@PostCount,
                                CommentCount=@CommentCount,
                                CreateDate=@CreateDate
                                where UserId=@UserId";

            SQLiteParameter[] prams =
            {
                SqliteHelper.MakeInParam("@Type",         DbType.Int32,    4, _userinfo.Type),
                SqliteHelper.MakeInParam("@UserName",     DbType.String,  50, _userinfo.UserName),
                SqliteHelper.MakeInParam("@Name",         DbType.String,  50, _userinfo.Name),
                SqliteHelper.MakeInParam("@Password",     DbType.String,  50, _userinfo.Password),
                SqliteHelper.MakeInParam("@Email",        DbType.String,  50, _userinfo.Email),
                SqliteHelper.MakeInParam("@SiteUrl",      DbType.String, 255, _userinfo.SiteUrl),
                SqliteHelper.MakeInParam("@AvatarUrl",    DbType.String, 255, _userinfo.AvatarUrl),
                SqliteHelper.MakeInParam("@Description",  DbType.String, 255, _userinfo.Description),
                SqliteHelper.MakeInParam("@Displayorder", DbType.String, 255, _userinfo.Displayorder),
                SqliteHelper.MakeInParam("@Status",       DbType.Int32,    4, _userinfo.Status),
                SqliteHelper.MakeInParam("@PostCount",    DbType.Int32,    4, _userinfo.PostCount),
                SqliteHelper.MakeInParam("@CommentCount", DbType.Int32,    4, _userinfo.CommentCount),
                SqliteHelper.MakeInParam("@CreateDate",   DbType.Date,     8, _userinfo.CreateDate),
                SqliteHelper.MakeInParam("@UserId",       DbType.Int32,    4, _userinfo.UserId),
            };
            return(SqliteHelper.ExecuteNonQuery(CommandType.Text, cmdText, prams));
        }