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

            if (action == "Show")
            {
                BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
                DataSet          ds  = bll.GetList(10, "", "TClickCount"); //获取点击率最高的
                ds.Tables[0].TableName = "hotArticles";                    //修改数据表的名字


                DataSet dstop5 = bll.GetList(10, "", "TTime"); //获取最新的

                DataTable top5 = dstop5.Tables[0].Copy();      //获取数据表
                top5.TableName = "newArticles";                //改名
                ds.Tables.Add(top5);                           //把前5个用户的数据表,加到数据集ds中

                //返回列表
                json = Web.DataConvertJson.Dataset2Json(ds);//转换
            }

            context.Response.Write(json);
        }
Exemplo n.º 2
0
        public string BindSource(int pagesize, int page, string sqlwhere)
        {
            BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
            //获取分页数据
            DataSet ds = bll.GetListByPage(sqlwhere, "", pagesize * page + 1, pagesize * (page + 1));  //获取数据源的ds会吧。

            ds.Tables[0].TableName = "List";
            return(Web.DataConvertJson.DataTable2Json(ds.Tables[0]));
        }
Exemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string sqlwhere = context.Request["sqlwhere"];
            string json     = "{'info':'0'}";

            BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
            int n = bll.GetRecordCount(sqlwhere);

            json = "{'info':'" + n + "'}";
            context.Response.Write(json);
        }
Exemplo n.º 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!Page.IsPostBack)
     {
         BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
         if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
         {
             int tid = (Convert.ToInt32(Request.Params["id"]));
             bll.Delete(tid);
             Response.Redirect("list.aspx");
         }
     }
 }
Exemplo n.º 5
0
 private void ShowInfo(int tid)
 {
     BBS.BLL.BBSTopic   bll   = new BBS.BLL.BBSTopic();
     BBS.Model.BBSTopic model = bll.GetModel(tid);
     this.lbltid.Text         = model.tid.ToString();
     this.lbltsid.Text        = model.tsid.ToString();
     this.lbltuid.Text        = model.tuid.ToString();
     this.lbltreplycount.Text = model.treplycount.ToString();
     this.lblTTopic.Text      = model.TTopic;
     this.lblTContents.Text   = model.TContents;
     this.lblTTime.Text       = model.TTime.ToString();
     this.lblTClickCount.Text = model.TClickCount.ToString();
     this.lblTLastClickT.Text = model.TLastClickT.ToString();
 }
Exemplo n.º 6
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "{}";
            string action = context.Request.Form["Action"];

            if (action == "Del")                                            //删除操作
            {
                string           DelNumS = context.Request.Form["DelNumS"]; //获取批量删除的编号
                BBS.BLL.BBSTopic bll     = new BBS.BLL.BBSTopic();
                if (bll.DeleteList(DelNumS))
                {
                    json = "{'info':'删除成功'}";
                }
                else
                {
                    json = "{'info':'删除失败'}";
                }
            }
            context.Response.Write(json);
        }
Exemplo n.º 7
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string ID = context.Request.Form["ID"];

            BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
            // Model.Admin前必须加 [Serializable]
            BBS.Model.BBSTopic model = bll.GetModel(int.Parse(ID));
            //返回一个类的对象
            string jsonString;

            if (model == null)
            {
                jsonString = "{}";
            }
            else
            {
                JavaScriptSerializer serializer = new JavaScriptSerializer();
                jsonString = serializer.Serialize(model);
            }
            context.Response.Write(jsonString);
        }
Exemplo n.º 8
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string json   = "{}";
            string action = context.Request.Form["Action"];

            int uid = int.Parse(context.Request["UID"]);

            int    displayStart  = int.Parse(context.Request["offset"]); //起始页
            int    displayLength = int.Parse(context.Request["limit"]);  //每页数量
            string strwhere      = "";

            if (uid != 0)
            {
                strwhere = "tuid=" + uid;
            }

            BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
            int     total        = bll.GetRecordCount(strwhere);
            DataSet ds           = bll.GetListByPage(strwhere, "", displayStart + 1, displayStart + displayLength);

            ds.Tables[0].TableName = "rows";
            //返回列表
            json = Web.DataConvertJson.DataTable2Json(ds.Tables[0]);

            //??服务器端返回的数据中还要包括rows,total(数据总量)两个字段,前端要根据这两个字段分页。
            json = "{\"total\":" + total + "," + json.Substring(1);

            /*
             * 返回数据格式
             * {"total":100,"rows":....}
             *
             */

            context.Response.Write(json);
        }
Exemplo n.º 9
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string strErr = "";

            if (!PageValidate.IsNumber(txttsid.Text))
            {
                strErr += "tsid格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txttuid.Text))
            {
                strErr += "tuid格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txttreplycount.Text))
            {
                strErr += "treplycount格式错误!\\n";
            }
            if (this.txtTTopic.Text.Trim().Length == 0)
            {
                strErr += "TTopic不能为空!\\n";
            }
            if (this.txtTContents.Text.Trim().Length == 0)
            {
                strErr += "TContents不能为空!\\n";
            }
            if (!PageValidate.IsDateTime(txtTTime.Text))
            {
                strErr += "TTime格式错误!\\n";
            }
            if (!PageValidate.IsNumber(txtTClickCount.Text))
            {
                strErr += "TClickCount格式错误!\\n";
            }
            if (!PageValidate.IsDateTime(txtTLastClickT.Text))
            {
                strErr += "TLastClickT格式错误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            int      tsid        = int.Parse(this.txttsid.Text);
            int      tuid        = int.Parse(this.txttuid.Text);
            int      treplycount = int.Parse(this.txttreplycount.Text);
            string   TTopic      = this.txtTTopic.Text;
            string   TContents   = this.txtTContents.Text;
            DateTime TTime       = DateTime.Parse(this.txtTTime.Text);
            int      TClickCount = int.Parse(this.txtTClickCount.Text);
            DateTime TLastClickT = DateTime.Parse(this.txtTLastClickT.Text);

            BBS.Model.BBSTopic model = new BBS.Model.BBSTopic();
            model.tsid        = tsid;
            model.tuid        = tuid;
            model.treplycount = treplycount;
            model.TTopic      = TTopic;
            model.TContents   = TContents;
            model.TTime       = TTime;
            model.TClickCount = TClickCount;
            model.TLastClickT = TLastClickT;

            BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
            bll.Add(model);
            Common.MessageBox.ShowAndRedirect(this, "保存成功!", "add.aspx");
        }
Exemplo n.º 10
0
        public void ProcessRequest(HttpContext context)
        {
            //  context.Response.ContentType = "text/plain";

            context.Response.ContentType = "text/html";
            string action = context.Request.Form["Action"];
            string json   = "{\"info\":\"已登录\"}";

            if (action == "Load")
            {
                if (context.Session["ID"] == null)
                {
                    json = "{\"info\":\"未登录\"}";
                }
                else
                {
                    BBS.BLL.BBSSection bll0 = new BBS.BLL.BBSSection();
                    DataSet            ds   = bll0.GetList("");
                    ds.Tables[0].TableName = "BBSSection";
                    string json1 = Web.DataConvertJson.DataTable2Json(ds.Tables[0]);
                    json = "{\"info\":\"已登录\"," + json1.Substring(1);
                }
            }
            else if (action == "Add")
            {
                json = "{\"info\":\"发表失败\"}";

                string content = context.Request.Form["Content"];        //保存文本框对象,提高效率
                content = HttpContext.Current.Server.UrlDecode(content); //反编码



                int      tsid        = int.Parse(context.Request.Form["section"]);
                int      tuid        = int.Parse(context.Session["ID"].ToString());
                int      treplycount = 0;
                string   TTopic      = context.Request.Form["title"];
                string   TContents   = content;
                DateTime TTime       = DateTime.Now;
                int      TClickCount = 0;
                DateTime TLastClickT = DateTime.Now;

                BBS.Model.BBSTopic model = new BBS.Model.BBSTopic();
                model.tsid        = tsid;
                model.tuid        = tuid;
                model.treplycount = treplycount;
                model.TTopic      = TTopic;
                model.TContents   = TContents;
                model.TTime       = TTime;
                model.TClickCount = TClickCount;
                model.TLastClickT = TLastClickT;

                BBS.BLL.BBSTopic bll = new BBS.BLL.BBSTopic();
                int n = bll.Add(model);
                //返回单个文字信息
                if (n > 0)
                {
                    json = "{\"info\":\"增加数据成功\",\"UID\":\"" + tuid + "\"}";
                }
            }

            context.Response.Write(json);
        }