Esempio n. 1
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "{}";
            string action = context.Request.Form["Action"];

            if (action == "Show")
            {
                BLL.BBSTopic bll = new BLL.BBSTopic();
                DataSet      ds  = bll.GetList(20);                      //调用业务逻辑层的方法
                ds.Tables[0].TableName = "Admin";                        //为数据表改名
                                                                         //返回列表
                json = WEB.DataConvertJson.DataTable2Json(ds.Tables[0]); //调用把datatable转为json的方法
            }
            context.Response.Write(json);
        }
Esempio n. 2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "{'info':'数据失败'}";
            string action = context.Request.Form["Action"];

            if (action == "Show")//显示数据页
            {
                BLL.BBSTopic bll = new BLL.BBSTopic();
                // Model.Admin前必须加 [Serializable]
                DataSet ds = bll.GetModels();                            //调用业务逻辑层的方法
                ds.Tables[0].TableName = "Admin";                        //为数据表改名
                                                                         //返回列表
                json = WEB.DataConvertJson.DataTable2Json(ds.Tables[0]); //调用把datatable转为json的方法
                context.Response.Write(json);
            }
        }
Esempio n. 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            string json = "{'info':'增加数据失败'}";
            //获取动作的类型
            string action = context.Request.Form["Action"];

            if (action == "add")
            {
                //获取GET方法传递参数:Request.QueryString["参数名称"];
                //获取POST方法传递参数:Request.Form["参数名称"];
                //保存文本框对象,提高效率
                string ttopic    = context.Request.Form["ttopic"];    //帖子标题
                string tcontents = context.Request.Form["tcontents"]; //帖子内容
                string rsid      = context.Request.Form["rsid"];      //帖子所属板块
                //string

                Model.BBSTopic model = new Model.BBSTopic();
                model.TTopic      = ttopic;
                model.TContents   = tcontents;
                model.Tsid        = int.Parse(rsid);
                model.TTime       = DateTime.Now;//发帖时间
                model.Tuid        = Convert.ToInt32(context.Session["ID"]);
                model.Treplycount = 0;
                model.TLastClickT = DateTime.Now;
                model.TClickCount = 0;

                BLL.BBSTopic bll = new BLL.BBSTopic();
                int          n   = bll.add(model);
                //返回单个文字信息
                if (n > 0)
                {
                    json = "{'info':'增加数据成功,编号是:" + n + "'}";
                }
            }
            context.Response.Write(json);
        }
Esempio n. 4
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "";
            string action = context.Request.Form["Action"];

            if (action == "Show")//显示
            {
                if (context.Session["ID"] == null)
                {
                    json = "{}";//未登录
                }
                else
                {
                    BLL.BBSTopic bll = new BLL.BBSTopic();
                    DataSet      ds  = bll.GetList("");
                    ds.Tables[0].TableName = "TopicTable";
                    //返回列表
                    json = WEB.DataConvertJson.DataTable2Json(ds.Tables[0]);
                }
            }
            else if (action == "Del")                                   //删除操作
            {
                string       DelNumS = context.Request.Form["DelNumS"]; //获取批量删除的编号
                BLL.BBSTopic bll     = new BLL.BBSTopic();
                if (bll.DeleteList(DelNumS))
                {
                    json = "{'info':'删除成功'}";
                }
                else
                {
                    json = "{'info':'删除失败'}";
                }
            }
            context.Response.Write(json);
        }
Esempio n. 5
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "{'info':'增加数据失败'}";
            string action = context.Request.Form["Action"];

            if (action == "Show")//显示数据页
            {
                string       UserID = context.Request.Form["UserID"];
                BLL.BBSTopic bll    = new BLL.BBSTopic();
                // Model.Admin前必须加 [Serializable]
                Model.BBSTopic model = bll.GetModel(int.Parse(UserID));
                //返回一个类的对象
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                string jsonString = serializer.Serialize(model);
                context.Response.Write(jsonString);
            }
            else if (action == "Load")//检查是否已经登录
            {
                if (context.Session["ID"] == null)
                {
                    json = "{'info':'no'}";
                }
                context.Response.Write(json);
            }
            else if (action == "reply")                               //回帖操作
            {
                int id = int.Parse(context.Session["ID"].ToString()); //获取当前用户的ID
                context.Response.ContentType = "text/plain";

                json = "{'info':'回帖失败','ID':-1}";

                string txtReply = context.Request.Form["txtreply"];       //回帖内容
                string txtTitle = context.Request.Form["txttitle"];       //回帖标题
                int    tid      = int.Parse(context.Request.Form["tid"]); //主贴编号
                int    sid      = int.Parse(context.Request.Form["sid"]); //板块编号

                BLL.BBSReply bll = new BLL.BBSReply();
                int          n   = bll.add(txtReply, txtTitle, tid, sid, id);
                //返回单个文字信息;
                if (n > 0)
                {
                    json = "{'info':'回帖成功!'}";
                }
                context.Response.Write(json);
            }
            else if (action == "good")
            {
                BLL.BBSTopic bll = new BLL.BBSTopic();
                int          tid = int.Parse(context.Request.Form["tid"]);
                if (bll.changegood(tid))
                {
                    json = "{'info':'点赞成功!'}";
                }
                else
                {
                    json = "{'info':'点赞失败!'}";
                }
            }
            else if (action == "ShowReply")
            {
                BLL.BBSReply bll = new BLL.BBSReply();
                int          tid = int.Parse(context.Request.Form["TID"]);
                DataSet      ds  = bll.GetList(tid, 3);                  //调用业务逻辑层的方法
                ds.Tables[0].TableName = "Admin";                        //为数据表改名
                                                                         //返回列表
                json = WEB.DataConvertJson.DataTable2Json(ds.Tables[0]); //调用把datatable转为json的方法
                context.Response.Write(json);
            }
        }