/// <summary> /// �����ݵ�GridViewPostList /// </summary> protected void BindData() { ExtendBLL.Post post = new ExtendBLL.Post(); DataSet ds = new DataSet(); if (DropDownListSections.SelectedValue == "-1") // ȫ�� { ds = post.GetAllWithFullInfo(); } else { if (DropDownListPlates.SelectedValue == "-1") // �����µ�ȫ�� { ds = post.GetAllWithFullInfoInSection(int.Parse(DropDownListSections.SelectedValue)); } else // �ض���� { ds = post.GetAllWithFullInfo(int.Parse(DropDownListPlates.SelectedValue)); } } ds = HandleData(ds); GridViewPostList.DataSource = ds.Tables[0].DefaultView; GridViewPostList.DataBind(); }
/// <summary> /// 绑定数据 /// </summary> protected void BindData() { if (!string.IsNullOrEmpty(Request.QueryString["plateID"])) { int id = 0; if (!int.TryParse(Request.QueryString["plateID"], out id)) { throw new Exception("你所访问的页面不存在!"); } ExtendBLL.PostPlate pp = new ExtendBLL.PostPlate(); LabMS.Model.PostPlate ppInfo = pp.GetModel(id); if (ppInfo == null) { throw new Exception("当前版块已经在另一处被删除!"); } ExtendBLL.Post post = new ExtendBLL.Post(); DataSet dsWholePosts = post.GetAllWithFullInfo(ppInfo.ID); AspNetPager.RecordCount = dsWholePosts.Tables[0].Rows.Count; HandleData(dsWholePosts); } else { throw new Exception("你所访问的页面不存在!"); } }
/// <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';"); } }
/// <summary> /// ���������� /// </summary> protected void BindPost() { int postID = int.Parse(Request.QueryString["id"]); ExtendBLL.Post post = new ExtendBLL.Post(); LabMS.Model.Post postInfo; postInfo = post.GetModel(postID); if (postInfo == null) { throw new Exception("�Բ���,�������ʵ�ҳ�治����"); } PosterName.Text = "����"; // TBD PostTitle.Text = postInfo.PostTitle; PostTime.Text = postInfo.PostRecordTime.Value.ToString("yyyy-MM-dd HH:mm:ss"); PostContent.Text = Server.HtmlDecode(postInfo.PostContent); }
private void InitData() { ExtendBLL.Announcement notice = new ExtendBLL.Announcement(); ExtendBLL.Resource resource = new ExtendBLL.Resource(); ExtendBLL.Post post = new ExtendBLL.Post(); List<LabMS.Model.Announcement> latestNotices; List<LabMS.Model.Resource> latestResources; List<LabMS.Model.Post> latestPosts; latestNotices = notice.GetLatest(10); latestResources = resource.GetLatest(10); latestPosts = post.GetLatest(10); RepeaterNotices.DataSource = latestNotices; RepeaterNotices.DataBind(); RepeaterResources.DataSource = latestResources; RepeaterResources.DataBind(); RepeaterPosts.DataSource = latestPosts; RepeaterPosts.DataBind(); }
/// <summary> /// ɾ�� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void BtnDelete_Click(object sender, EventArgs e) { CheckBox cb; int postID; ExtendBLL.Post post = new ExtendBLL.Post(); for (int i = GridViewPostList.Rows.Count - 1; i > -1; i--) { cb = (CheckBox)GridViewPostList.Rows[i].FindControl("CBSelect"); if (cb.Checked) { postID = int.Parse(GridViewPostList.DataKeys[i].Value.ToString()); post.DeleteFullInfo(postID); } } BindData(); }
/// <summary> /// �������� /// </summary> /// <param name="ds"></param> /// <returns></returns> protected DataSet HandleData(DataSet ds) { ds.Tables[0].Columns.Add("PostUserName"); ds.Tables[0].Columns.Add("PostReplyLatestTime"); ExtendBLL.Post post = new ExtendBLL.Post(); LabMS.Model.PostReply prInfo = new LabMS.Model.PostReply(); string authorName = String.Empty; string preName = String.Empty; for (int i = ds.Tables[0].Rows.Count - 1; i > -1; i--) { prInfo = post.GetLatestReply(int.Parse(ds.Tables[0].Rows[i]["ID"].ToString())); if (prInfo != null) { ds.Tables[0].Rows[i]["PostReplyLatestTime"] = prInfo.PostReplyTime; } authorName = post.GetAuthorName(int.Parse(ds.Tables[0].Rows[i]["PosterID"].ToString()), ds.Tables[0].Rows[i]["PosterType"].ToString()); preName = post.GetAuthorNamePrefix(ds.Tables[0].Rows[i]["PosterType"].ToString()); ds.Tables[0].Rows[i]["PostUserName"] = preName + (string.IsNullOrEmpty(authorName) ? " <del>��ɾ���û�</del>" : authorName); // TBD ɾ��û��Ȩ���Ķ������� } return ds; }
/// <summary> /// 处理回复 /// </summary> /// <param name="ds"></param> /// <returns></returns> protected void HandleReply(DataSet ds) { dsReplies.Tables.Add("replies"); dsReplies.Tables[0].Columns.AddRange(new DataColumn[] { new DataColumn("ID"), new DataColumn("PostReplyContent"), new DataColumn("PosterID"), new DataColumn("PostReplyTime"), new DataColumn("ReplierID"), new DataColumn("ReplierType"), new DataColumn("ReplierName"), new DataColumn("PostReplySN") }); DataRow row; int count = ds.Tables[0].Rows.Count; int current = AspNetPager.PageSize * (AspNetPager.CurrentPageIndex - 1) + 1; ExtendBLL.Post post = new ExtendBLL.Post(); string replierName = String.Empty; for (int i = current - 1; (i < current + AspNetPager.PageSize - 1) && (i < count); i++) { row = ds.Tables[0].Rows[i]; replierName = post.GetAuthorName(int.Parse(row["ReplierID"].ToString()), row["ReplierType"].ToString()); dsReplies.Tables[0].Rows.Add( row["ID"], row["PostReplyContent"], row["PosterID"], row["PostReplyTime"], row["ReplierID"], row["ReplierType"], string.IsNullOrEmpty(replierName) ? "<del>已删除用户</del>" : replierName, i + 1 ); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { string id = Request.QueryString["postID"]; if (string.IsNullOrEmpty(id)) { throw new Exception("对不起,您所访问的页面不存在"); } try { int postID = int.Parse(id); } catch { throw new Exception("对不起,您所访问的页面不存在"); } ExtendBLL.Post p = new ExtendBLL.Post(); p.IncrementViewTimes(int.Parse(id)); GetPost(); GetReplies(); } }