简单评论系统开发过程(五)
这次把类后代码也贴上,上次太匆忙。
default.aspx.cs
1
using System;
2
using System.Data;
3
using System.Configuration;
4
using System.Collections;
5
using System.Web;
6
using System.Web.Security;
7
using System.Web.UI;
8
using System.Web.UI.WebControls;
9
using System.Web.UI.WebControls.WebParts;
10
using System.Web.UI.HtmlControls;
11
using System.Data.SqlClient;
12
using System.Text;
13
using Model;
14
using BLL;
15
16
namespace UL
17
{
18
public partial class _Default : System.Web.UI.Page
19
{
20
comment comm = new comment();
21
BllComm bll = new BllComm();
22
com c = new com();
23
string conditions = "";
24
protected void Page_Load(object sender, EventArgs e)
25
{
26
if(!IsPostBack){
27
string act = Request.QueryString["act"] != null ? Request.QueryString["act"] : "";
28
string id = Request.QueryString["id"] != null ? Request.QueryString["id"] : "";
29
try
30
{
31
if (act!=null&&act == "agree")
32
{
33
this.Comment_Num("comm_agree",int.Parse(id));
34
}
35
else if (act == "against")
36
{
37
this.Comment_Num("comm_against",int.Parse(id));
38
}
39
else if (act == "report")
40
{
41
42
}
43
pager.RecordCount = bll.Total("comment", "*", conditions);
44
this.Comment_List();
45
}
46
catch(Exception ex){
47
new Exception(ex.Message);
48
}
49
}
50
}
51
/// <summary>
52
/// 添加评论
53
/// </summary>
54
/// <param name="sender"></param>
55
/// <param name="e"></param>
56
protected void btn_Click(object sender, EventArgs e)
57
{
58
comm.Comm_name = this.announce.Checked==false?this.name.Text:"本站网友";
59
comm.Comm_content = this.content.Text;
60
comm.Comm_time = DateTime.Parse(DateTime.Now.ToString());
61
comm.Comm_ip = c.GetClientIP();
62
bll.Add(comm);
63
Response.Redirect("default.aspx");
64
}
65
/// <summary>
66
/// 评论列表
67
/// </summary>
68
protected void Comment_List()
69
{
70
this.dl.DataSource = bll.CommList("comment",(pager.CurrentPageIndex-1)*pager.PageSize,pager.PageSize,"");
71
this.dl.DataBind();
72
}
73
/// <summary>
74
/// 更新评论功能
75
/// </summary>
76
/// <param name="str"></param>
77
/// <param name="val"></param>
78
/// <param name="id"></param>
79
protected void Comment_Update(string str,int val,int id)
80
{
81
bll.Deal(str,val,id);
82
Response.Redirect("default.aspx");
83
}
84
public string Comment_Name(string str,int id)
85
{
86
return bll.str_name(str,id);
87
}
88
/// <summary>
89
/// 叠加
90
/// </summary>
91
/// <param name="str"></param>
92
/// <param name="id"></param>
93
/// <returns></returns>
94
protected int Comment_Num(string str, int id)
95
{
96
return bll.Hits(str,id);
97
}
98
/// <summary>
99
/// 评论分页事件
100
/// </summary>
101
/// <param name="sender"></param>
102
/// <param name="e"></param>
103
protected void pager_PageChanged(object sender, EventArgs e)
104
{
105
this.Comment_List();
106
}
107
}
108
}
109
using System;2
using System.Data;3
using System.Configuration;4
using System.Collections;5
using System.Web;6
using System.Web.Security;7
using System.Web.UI;8
using System.Web.UI.WebControls;9
using System.Web.UI.WebControls.WebParts;10
using System.Web.UI.HtmlControls;11
using System.Data.SqlClient;12
using System.Text;13
using Model;14
using BLL;15

16
namespace UL17
{18
public partial class _Default : System.Web.UI.Page19
{20
comment comm = new comment();21
BllComm bll = new BllComm();22
com c = new com();23
string conditions = "";24
protected void Page_Load(object sender, EventArgs e)25
{26
if(!IsPostBack){27
string act = Request.QueryString["act"] != null ? Request.QueryString["act"] : "";28
string id = Request.QueryString["id"] != null ? Request.QueryString["id"] : "";29
try30
{31
if (act!=null&&act == "agree")32
{33
this.Comment_Num("comm_agree",int.Parse(id));34
}35
else if (act == "against")36
{37
this.Comment_Num("comm_against",int.Parse(id));38
}39
else if (act == "report")40
{41
42
}43
pager.RecordCount = bll.Total("comment", "*", conditions);44
this.Comment_List();45
}46
catch(Exception ex){47
new Exception(ex.Message);48
}49
}50
}51
/// <summary>52
/// 添加评论53
/// </summary>54
/// <param name="sender"></param>55
/// <param name="e"></param>56
protected void btn_Click(object sender, EventArgs e)57
{58
comm.Comm_name = this.announce.Checked==false?this.name.Text:"本站网友";59
comm.Comm_content = this.content.Text;60
comm.Comm_time = DateTime.Parse(DateTime.Now.ToString());61
comm.Comm_ip = c.GetClientIP();62
bll.Add(comm);63
Response.Redirect("default.aspx");64
}65
/// <summary>66
/// 评论列表67
/// </summary>68
protected void Comment_List()69
{70
this.dl.DataSource = bll.CommList("comment",(pager.CurrentPageIndex-1)*pager.PageSize,pager.PageSize,"");71
this.dl.DataBind();72
}73
/// <summary>74
/// 更新评论功能75
/// </summary>76
/// <param name="str"></param>77
/// <param name="val"></param>78
/// <param name="id"></param>79
protected void Comment_Update(string str,int val,int id)80
{81
bll.Deal(str,val,id);82
Response.Redirect("default.aspx");83
}84
public string Comment_Name(string str,int id)85
{86
return bll.str_name(str,id);87
}88
/// <summary>89
/// 叠加90
/// </summary>91
/// <param name="str"></param>92
/// <param name="id"></param>93
/// <returns></returns>94
protected int Comment_Num(string str, int id)95
{96
return bll.Hits(str,id);97
}98
/// <summary>99
/// 评论分页事件100
/// </summary>101
/// <param name="sender"></param>102
/// <param name="e"></param>103
protected void pager_PageChanged(object sender, EventArgs e)104
{105
this.Comment_List();106
}107
}108
}109

待续……


浙公网安备 33010602011771号