Esempio n. 1
0
        //注册
        public bool Register(Model.User user)
        {
            string  SQL = "select * from news_user where username='******'";
            DataSet ds  = DBHelper.GetDataSet(SQL);

            if (ds.Tables[0].Rows.Count > 0)  //存在该记录时
            {
                HttpContext.Current.Response.Write("<script>alert('用户名已存在,请更换用户名!');</script>");
                return(false);
            }
            else
            {
                string SQL2 = "insert into news_user values('" + user.username + "','" + user.password + "','" + user.email + "','" + user.realname + "')";
                bool   iRet = DBHelper.ExecSql(SQL2);
                if (iRet)
                {
                    HttpContext.Current.Response.Write("<script>alert('注册成功');location.href='login.aspx'</script>");
                    return(true);
                }
                else
                {
                    HttpContext.Current.Response.Write("<script>alert('注册失败');</script>");
                    return(false);
                }
            }
        }
Esempio n. 2
0
        //更新点击
        public bool UpdateClick(Model.News news)
        {
            string SQL  = "update news set click=click+1 where id ='" + news.id + "'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 3
0
        //更新用户信息
        public bool Updateinfo(Model.User user)
        {
            string SQL  = "update news_user set email='" + user.email + "',realname='" + user.realname + "' where username='******'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('修改信息失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 4
0
        //用户更新密码
        public bool Updatepwd(Model.User user)
        {
            string SQL  = "update news_user set password='******' where username='******'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('修改密码失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 5
0
        //删除举报
        public bool DelReport(Model.Report report)
        {
            string SQL  = "DELETE from report where newsid='" + report.newsid + "'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                HttpContext.Current.Response.Write("<script>alert('删除成功');location.href='report_check.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('删除失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 6
0
        //添加举报
        public bool AddReport(Model.Report report)
        {
            string SQL  = "insert into report values('" + report.newsid + "','" + report.title + "','" + report.contents + "','" + report.reportTime + "')";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                HttpContext.Current.Response.Write("<script>alert('匿名举报成功!');location.href='../../../main.aspx';</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('举报失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 7
0
        //删除分类
        public bool DelCategory(Model.Category category)
        {
            string SQL  = "DELETE from news_categore where id='" + category.id + "'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                HttpContext.Current.Response.Write("<script>alert('删除成功');location.href='categore.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('删除失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 8
0
        //添加分类
        public bool AddCategory(Model.Category category)
        {
            string SQL  = "insert into news_categore values('" + category.name + "')";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                HttpContext.Current.Response.Write("<script>alert('添加成功');location.href='categore.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('添加失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 9
0
        //添加新闻
        public bool AddNews(Model.News news)
        {
            string SQL  = "insert into news values('" + news.category + "','" + news.title + "','" + news.author + "','" + news.contents + "','" + news.createTime + "','" + news.click + "')";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                HttpContext.Current.Response.Write("<script>alert('添加成功');location.href='choose.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('添加失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 10
0
        //删除新闻
        public bool DelNews(Model.News news)
        {
            string SQL  = "DELETE from news where id='" + news.id + "'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                // HttpContext.Current.Response.Write("<script>alert('删除成功');location.href='choose.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('删除失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 11
0
        //更新新闻
        public bool UpdateNews(Model.News news)
        {
            string SQL  = "update news set category='" + news.category + "',title='" + news.title + "',author='" + news.author + "',contents='" + news.contents + "',createTime='" + news.createTime + "' where id='" + news.id + "'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                HttpContext.Current.Response.Write("<script>alert('更新成功');location.href='choose.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('更新失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 12
0
        //重置用户密码
        public bool UpdateUser(Model.User user)
        {
            string SQL  = "update news_user set password='******' where id='" + user.id + "'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                //  HttpContext.Current.Response.Write("<script>alert('重置密码成功,新密码为:123456');location.href='user_management.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('重置密码失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 13
0
        //删除用户
        public bool DelUser(Model.User user)
        {
            string SQL  = "DELETE from news_user where id='" + user.id + "'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                HttpContext.Current.Response.Write("<script>alert('删除成功');location.href='user_management.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('删除失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 14
0
        //添加投稿
        public bool AddContribute(Model.Contribute contribute)
        {
            string SQL  = "insert into contribute values('" + contribute.username + "','" + contribute.category + "','" + contribute.title + "','" + contribute.author + "','" + contribute.contents + "','" + contribute.createTime + "')";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                HttpContext.Current.Response.Write("<script>alert('投稿成功');location.href='contributes.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('投稿失败,请重试');</script>");
                return(false);
            }
        }
Esempio n. 15
0
        //删除投稿
        public bool DelContribute(Model.Contribute contribute)
        {
            string SQL  = "DELETE from contribute where id='" + contribute.id + "'";
            bool   iRet = DBHelper.ExecSql(SQL);

            if (iRet)
            {
                // HttpContext.Current.Response.Write("<script>alert('删除成功');location.href='contributes.aspx'</script>");
                return(true);
            }
            else
            {
                HttpContext.Current.Response.Write("<script>alert('删除失败,请重试');</script>");
                return(false);
            }
        }