示例#1
0
        /// <summary>
        /// 提交
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void BtnSubmit_Click(object sender, EventArgs e)
        {
            #region validation

            if (string.IsNullOrEmpty(PostTitle.Text.Trim())) { WriteBackScript("alert('交流主题不能为空!')"); return; }
            else if (PostTitle.Text.Trim().Length > 100) { WriteBackScript("alert('交流主题长度不能超过100字符!')"); return; }

            if (string.IsNullOrEmpty(PostContent.Text.Trim())) { WriteBackScript("alert('交流内容不能为空!')"); return; }
            else if (PostContent.Text.Length > 1000) { WriteBackScript("alert('交流内容长度不能超过1000!')"); return; }

            #endregion

            LabMS.BLL.Post post = new LabMS.BLL.Post();
            LabMS.Model.Post postInfo = new LabMS.Model.Post();

            postInfo.PostTitle = PostTitle.Text.Trim();
            postInfo.PostContent = Server.HtmlEncode(PostContent.Text);
            postInfo.PostRecordTime = DateTime.Now;
            postInfo.ViewTimes = 0;
            postInfo.PostPlateID = int.Parse(Request.QueryString["plateID"]);

            postInfo.PosterType = Base.PrivilegeManager.GetUserTypeCode();
            postInfo.PosterID = int.Parse(UserID);

            postInfo.ID = post.Add(postInfo);

            WriteBackScript("alert('发贴成功!');window.returnValue=true;window.opener.location.replace(window.opener.location);window.close();");
        }
示例#2
0
        /// <summary>
        /// 获取帖子信息
        /// </summary>
        protected void GetPost()
        {
            int postID = int.Parse(Request.QueryString["postID"]);

            ExtendBLL.Post p = new ExtendBLL.Post();

            post = p.GetModel(postID);

            if (post == null) { WriteBackScript("alert('当前主题已经被删除!');window.location.href='Index.aspx';"); }
        }
示例#3
0
文件: Post.cs 项目: dalinhuang/labms
        public List<LabMS.Model.Post> GetLatest(int counts)
        {
            List<LabMS.Model.Post> results = new List<LabMS.Model.Post>();

            StringBuilder sb = new StringBuilder();

            sb.Append("select top ");
            sb.Append(counts);
            sb.Append(" [ID],PostTitle,PosterID,PostContent,PostRecordTime,PosterType,PostPlateID,ViewTimes from Post ");
            sb.Append(" order by [id] desc ");

            LabMS.Model.Post model;

            System.Data.DataSet ds = Maticsoft.DBUtility.DbHelperSQL.Query(sb.ToString());

            foreach (System.Data.DataRow row in ds.Tables[0].Rows)
            {
                model = new LabMS.Model.Post();

                if (row["ID"].ToString() != "")
                {
                    model.ID = int.Parse(row["ID"].ToString());
                }
                model.PostTitle = row["PostTitle"].ToString();
                if (row["PosterID"].ToString() != "")
                {
                    model.PosterID = int.Parse(row["PosterID"].ToString());
                }
                model.PostContent = row["PostContent"].ToString();
                if (row["PostRecordTime"].ToString() != "")
                {
                    model.PostRecordTime = DateTime.Parse(row["PostRecordTime"].ToString());
                }
                if (row["PosterType"].ToString() != "")
                {
                    model.PosterType = int.Parse(row["PosterType"].ToString());
                }
                if (row["PostPlateID"].ToString() != "")
                {
                    model.PostPlateID = int.Parse(row["PostPlateID"].ToString());
                }
                if (row["ViewTimes"].ToString() != "")
                {
                    model.ViewTimes = int.Parse(row["ViewTimes"].ToString());
                }

                results.Add(model);
            }

            return results;
        }
示例#4
0
文件: Post.cs 项目: dalinhuang/labms
        /// <summary>
        /// �õ�һ������ʵ��
        /// </summary>
        public LabMS.Model.Post GetModel(int ID)
        {
            StringBuilder strSql=new StringBuilder();
            strSql.Append("select  top 1 [ID],PostTitle,PosterID,PostContent,PostRecordTime,PosterType,PostPlateID,ViewTimes from Post ");
            strSql.Append(" where [ID]=@ID ");
            SqlParameter[] parameters = {
                    new SqlParameter("@ID", SqlDbType.Int,4)};
            parameters[0].Value = ID;

            LabMS.Model.Post model=new LabMS.Model.Post();
            DataSet ds=DbHelperSQL.Query(strSql.ToString(),parameters);
            if(ds.Tables[0].Rows.Count>0)
            {
                if(ds.Tables[0].Rows[0]["ID"].ToString()!="")
                {
                    model.ID=int.Parse(ds.Tables[0].Rows[0]["ID"].ToString());
                }
                model.PostTitle=ds.Tables[0].Rows[0]["PostTitle"].ToString();
                if(ds.Tables[0].Rows[0]["PosterID"].ToString()!="")
                {
                    model.PosterID=int.Parse(ds.Tables[0].Rows[0]["PosterID"].ToString());
                }
                model.PostContent=ds.Tables[0].Rows[0]["PostContent"].ToString();
                if(ds.Tables[0].Rows[0]["PostRecordTime"].ToString()!="")
                {
                    model.PostRecordTime=DateTime.Parse(ds.Tables[0].Rows[0]["PostRecordTime"].ToString());
                }
                if(ds.Tables[0].Rows[0]["PosterType"].ToString()!="")
                {
                    model.PosterType=int.Parse(ds.Tables[0].Rows[0]["PosterType"].ToString());
                }
                if(ds.Tables[0].Rows[0]["PostPlateID"].ToString()!="")
                {
                    model.PostPlateID=int.Parse(ds.Tables[0].Rows[0]["PostPlateID"].ToString());
                }
                if(ds.Tables[0].Rows[0]["ViewTimes"].ToString()!="")
                {
                    model.ViewTimes=int.Parse(ds.Tables[0].Rows[0]["ViewTimes"].ToString());
                }
                return model;
            }
            else
            {
                return null;
            }
        }