Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(BBS.Model.BBSTopic model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update BBSTopic set ");
            if (model.tsid != null)
            {
                strSql.Append("tsid=" + model.tsid + ",");
            }
            if (model.tuid != null)
            {
                strSql.Append("tuid=" + model.tuid + ",");
            }
            if (model.treplycount != null)
            {
                strSql.Append("treplycount=" + model.treplycount + ",");
            }
            if (model.TTopic != null)
            {
                strSql.Append("TTopic='" + model.TTopic + "',");
            }
            if (model.TContents != null)
            {
                strSql.Append("TContents='" + model.TContents + "',");
            }
            if (model.TTime != null)
            {
                strSql.Append("TTime='" + model.TTime + "',");
            }
            if (model.TClickCount != null)
            {
                strSql.Append("TClickCount=" + model.TClickCount + ",");
            }
            if (model.TLastClickT != null)
            {
                strSql.Append("TLastClickT='" + model.TLastClickT + "',");
            }
            int n = strSql.ToString().LastIndexOf(",");

            strSql.Remove(n, 1);
            strSql.Append(" where tid=" + model.tid + "");
            int rowsAffected = DbHelperSQL.ExecuteSql(strSql.ToString());

            if (rowsAffected > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #2
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();
 }
Beispiel #3
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public BBS.Model.BBSTopic DataRowToModel(DataRow row)
 {
     BBS.Model.BBSTopic model = new BBS.Model.BBSTopic();
     if (row != null)
     {
         if (row["tid"] != null && row["tid"].ToString() != "")
         {
             model.tid = int.Parse(row["tid"].ToString());
         }
         if (row["tsid"] != null && row["tsid"].ToString() != "")
         {
             model.tsid = int.Parse(row["tsid"].ToString());
         }
         if (row["tuid"] != null && row["tuid"].ToString() != "")
         {
             model.tuid = int.Parse(row["tuid"].ToString());
         }
         if (row["treplycount"] != null && row["treplycount"].ToString() != "")
         {
             model.treplycount = int.Parse(row["treplycount"].ToString());
         }
         if (row["TTopic"] != null)
         {
             model.TTopic = row["TTopic"].ToString();
         }
         if (row["TContents"] != null)
         {
             model.TContents = row["TContents"].ToString();
         }
         if (row["TTime"] != null && row["TTime"].ToString() != "")
         {
             model.TTime = DateTime.Parse(row["TTime"].ToString());
         }
         if (row["TClickCount"] != null && row["TClickCount"].ToString() != "")
         {
             model.TClickCount = int.Parse(row["TClickCount"].ToString());
         }
         if (row["TLastClickT"] != null && row["TLastClickT"].ToString() != "")
         {
             model.TLastClickT = DateTime.Parse(row["TLastClickT"].ToString());
         }
     }
     return(model);
 }
Beispiel #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BBS.Model.BBSTopic GetModel(int tid)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" tid,tsid,tuid,treplycount,TTopic,TContents,TTime,TClickCount,TLastClickT ");
            strSql.Append(" from BBSTopic ");
            strSql.Append(" where tid=" + tid + "");
            BBS.Model.BBSTopic model = new BBS.Model.BBSTopic();
            DataSet            ds    = DbHelperSQL.Query(strSql.ToString());

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public BBS.Model.BBSTopic GetModel(int tid)
        {
            string        sqlupdateTClickCount = string.Format("update BBSTopic set TClickCount=TClickCount+1,TLastClickT='{0}' where tid={1}", DateTime.Now, tid);
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1  ");
            strSql.Append(" tid,tsid,tuid,treplycount,TTopic,TContents,TTime,TClickCount,TLastClickT ");
            strSql.Append(" from BBSTopic ");
            strSql.Append(" where tid=" + tid + "");
            BBS.Model.BBSTopic model = new BBS.Model.BBSTopic();
            DataSet            ds    = DbHelperSQL.Query(strSql.ToString());

            DbHelperSQL.ExecuteSql(sqlupdateTClickCount);//更新点击量
            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #6
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);
        }
Beispiel #7
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


                BBS.Model.BBSTopic model = new BBS.Model.BBSTopic();
                model.TTopic      = ttopic;                                 //主题标题
                model.TContents   = tcontents;                              //主贴内容
                model.tsid        = 0;                                      //板块编号
                model.TTime       = DateTime.Now;                           //发帖时间?暂时不知道是否要删
                model.tuid        = Convert.ToInt32(context.Session["ID"]); //发帖人编号
                model.treplycount = 0;                                      //帖子回复次数
                model.TLastClickT = DateTime.Now;                           //最后点击时间?暂时不知道是否要删
                model.TClickCount = 0;                                      //点击次数

                BBSTopic bll = new BBSTopic();
                int      n   = bll.Add(model);
                //返回单个文字信息
                if (n > 0)
                {
                    json = "{'info':'增加数据成功,编号是:" + n + "'}";
                }
            }
            context.Response.Write(json);
        }
Beispiel #8
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");
        }
Beispiel #9
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BBS.Model.BBSTopic model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.tsid != null)
            {
                strSql1.Append("tsid,");
                strSql2.Append("" + model.tsid + ",");
            }
            if (model.tuid != null)
            {
                strSql1.Append("tuid,");
                strSql2.Append("" + model.tuid + ",");
            }
            if (model.treplycount != null)
            {
                strSql1.Append("treplycount,");
                strSql2.Append("" + model.treplycount + ",");
            }
            if (model.TTopic != null)
            {
                strSql1.Append("TTopic,");
                strSql2.Append("'" + model.TTopic + "',");
            }
            if (model.TContents != null)
            {
                strSql1.Append("TContents,");
                strSql2.Append("'" + model.TContents + "',");
            }
            if (model.TTime != null)
            {
                strSql1.Append("TTime,");
                strSql2.Append("'" + model.TTime + "',");
            }
            if (model.TClickCount != null)
            {
                strSql1.Append("TClickCount,");
                strSql2.Append("" + model.TClickCount + ",");
            }
            if (model.TLastClickT != null)
            {
                strSql1.Append("TLastClickT,");
                strSql2.Append("'" + model.TLastClickT + "',");
            }
            strSql.Append("insert into BBSTopic(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                //更新版块表 帖子数
                string sqlupdateTopicCount = string.Format("update BBSSection set STopicCount=STopicCount+1 where SID={0}", model.tsid);
                DbHelperSQL.ExecuteSql(sqlupdateTopicCount);//更新
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #10
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(BBS.Model.BBSTopic model)
        {
            StringBuilder strSql  = new StringBuilder();
            StringBuilder strSql1 = new StringBuilder();
            StringBuilder strSql2 = new StringBuilder();

            if (model.tsid != null)
            {
                strSql1.Append("tsid,");
                strSql2.Append("" + model.tsid + ",");
            }
            if (model.tuid != null)
            {
                strSql1.Append("tuid,");
                strSql2.Append("" + model.tuid + ",");
            }
            if (model.treplycount != null)
            {
                strSql1.Append("treplycount,");
                strSql2.Append("" + model.treplycount + ",");
            }
            if (model.TTopic != null)
            {
                strSql1.Append("TTopic,");
                strSql2.Append("'" + model.TTopic + "',");
            }
            if (model.TContents != null)
            {
                strSql1.Append("TContents,");
                strSql2.Append("'" + model.TContents + "',");
            }
            if (model.TTime != null)
            {
                strSql1.Append("TTime,");
                strSql2.Append("'" + model.TTime.ToString("yyyy-MM-dd") + "',");
            }
            if (model.TClickCount != null)
            {
                strSql1.Append("TClickCount,");
                strSql2.Append("" + model.TClickCount + ",");
            }
            if (model.TLastClickT != null)
            {
                strSql1.Append("TLastClickT,");
                strSql2.Append("'" + model.TLastClickT.ToString("yyyy-MM-dd") + "',");
            }
            strSql.Append("insert into BBSTopic(");
            strSql.Append(strSql1.ToString().Remove(strSql1.Length - 1));
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append(strSql2.ToString().Remove(strSql2.Length - 1));
            strSql.Append(")");
            strSql.Append(";select @@IDENTITY");
            object obj = DbHelperSQL.GetSingle(strSql.ToString());

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Beispiel #11
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);
        }