温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:唐唐企业管理网站源码
当前文件:
TangCompany/liulianban.aspx.cs,打开代码结构图
TangCompany/liulianban.aspx.cs,打开代码结构图1using 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
14
public partial class liulianban : System.Web.UI.Page 15
{ 16
private int txtPageId; 17
private string txtName = string.Empty; 18
private int txtTypes; 19
private int txtSex; 20
private string txtEmail = string.Empty; 21
private Int32 txtQQ; 22
private string txtHomePage = string.Empty; 23
private string txtContent = string.Empty; 24
protected int num; 25
protected void Page_Load(object sender, EventArgs e) 26
{ 27
if (!Page.IsPostBack) { 28
29
BindPs(); 30
BindPage(); 31
IsPage(); 32
33
} 34
35
} 36
protected void IsPage() { 37
38
int txtItem; 39
if (Request.QueryString["page"] == null) 40
{ 41
txtItem = RepeaterMessage.Items.Count; 42
if (txtItem > 1) 43
{ 44
for (int i = 0; i < 2; i++) 45
{ 46
Label laText = (Label)RepeaterMessage.Items[i].FindControl("LabelNum"); 47
laText.Text = Convert.ToString(i + 1); 48
49
} 50
} 51
else { 52
53
Label laText = (Label)RepeaterMessage.Items[0].FindControl("LabelNum"); 54
laText.Text = "1"; 55
56
} 57
} 58
else { 59
60
txtPageId = int.Parse(Request.QueryString["page"].ToString()); 61
txtItem = RepeaterMessage.Items.Count; 62
if (txtItem > 1) 63
{ 64
for (int i = 0; i < 2; i++) 65
{ 66
if (txtPageId >= 3) 67
{ 68
Label laText = (Label)RepeaterMessage.Items[i].FindControl("LabelNum"); 69
laText.Text = Convert.ToString(txtPageId + i + 2); 70
} 71
else { 72
73
Label laText = (Label)RepeaterMessage.Items[i].FindControl("LabelNum"); 74
laText.Text = Convert.ToString(txtPageId + i + 1); 75
76
} 77
} 78
} 79
else 80
{ 81
if (txtPageId >= 3) 82
{ 83
Label laText = (Label)RepeaterMessage.Items[0].FindControl("LabelNum"); 84
laText.Text = Convert.ToString(txtPageId + 2); 85
} 86
else { 87
88
Label laText = (Label)RepeaterMessage.Items[0].FindControl("LabelNum"); 89
laText.Text = Convert.ToString(txtPageId + 1); 90
91
} 92
} 93
94
} 95
} 96
protected string IsFace(string txtBool) 97
{ 98
99
string txtImg = string.Empty; 100
if (txtBool.ToLower() == "true") 101
{ 102
103
txtImg = "flpicture\\man.gif"; 104
105
} 106
else { 107
108
txtImg = "flpicture\\girl.gif"; 109
110
} 111
return txtImg; 112
} 113
protected string IsSex(string txtBool) 114
{ 115
116
string txtSex = string.Empty; 117
if (txtBool.ToLower() == "true") 118
{ 119
120
txtSex = "先生"; 121
122
} 123
else 124
{ 125
126
txtSex = "女士"; 127
128
} 129
return txtSex; 130
} 131
protected PagedDataSource BindPs() { 132
133
string txtPage=string.Empty; 134
PagedDataSource ps = new PagedDataSource(); 135
ps.AllowPaging = true; 136
ps.PageSize = 2; 137
if (Request.QueryString["page"] != null) 138
{ 139
txtPage = Request.QueryString["page"].ToString(); 140
ps.CurrentPageIndex = int.Parse(txtPage) - 1; 141
142
} 143
else { 144
145
ps.CurrentPageIndex = 0; 146
147
} 148
149
ps.DataSource = SqlHelper.ExcuteReadApdater("sys_SelectByVisMessage", CommandType.StoredProcedure, null).Tables[0].DefaultView; 150
RepeaterMessage.DataSource = ps; 151
RepeaterMessage.DataBind(); 152
return ps; 153
} 154
protected void BindPage() { 155
156
int nPage = BindPs().PageCount; 157
StringBuilder builder = new StringBuilder(); 158
builder.Append(" 第 "); 159
if (nPage > 1) 160
{ 161
for (int i = 1; i <= nPage; i++) 162
{ 163
if (i==(BindPs().CurrentPageIndex + 1)) 164
{ 165
166
builder.Append("<span class=\"STYLE7\"> " + i.ToString() + " </span>"); 167
168
} 169
else 170
{ 171
builder.Append(" <a href=\"?page=" + i + "\">" + i + "</a> "); 172
} 173
} 174
} 175
else { 176
177
builder.Append("<span class=\"STYLE7\"> 1 </span>"); 178
179
} 180
181
builder.Append(" 页 "); 182
ShowPage.InnerHtml = builder.ToString(); 183
} 184
protected void bntAdd_ServerClick(object sender, EventArgs e) 185
{ 186
txtName = Server.HtmlEncode(inputName.Value.ToString()); 187
txtTypes = int.Parse(RadioTypes.SelectedValue.ToString()); 188
txtSex = int.Parse(SelectSex.SelectedValue.ToString()); 189
txtEmail = Server.HtmlEncode(inputEmail.Value.ToString()); 190
if (string.IsNullOrEmpty(inputQQ.Value)) 191
{ 192
txtQQ = 0; 193
} 194
else { 195
196
txtQQ = Int32.Parse(inputQQ.Value.ToString()); 197
198
} 199
txtHomePage = inputHomePage.Value.ToString(); 200
txtContent = TextContent.Value.ToString(); 201
SqlParameter[] paras ={ new SqlParameter("@Name", SqlDbType.NVarChar, 30), new SqlParameter("@Sex", SqlDbType.Bit), new SqlParameter("@Email", SqlDbType.NVarChar, 50), new SqlParameter("@QQ", SqlDbType.BigInt, 10), new SqlParameter("@HomePage", SqlDbType.NVarChar, 50), new SqlParameter("@Content", SqlDbType.NVarChar, 200), new SqlParameter("@Types", SqlDbType.Bit) }; 202
paras[0].Value = txtName; 203
paras[1].Value = txtSex; 204
paras[2].Value = txtEmail; 205
paras[3].Value = txtQQ; 206
paras[4].Value = txtHomePage; 207
paras[5].Value = txtContent; 208
paras[6].Value = txtTypes; 209
SqlHelper.ExcuteNonQurey("INSERT INTO [Message] (Name,Sex,Email,QQ,HomePage,Content,Types) Values(@Name,@Sex,@Email,@QQ,@HomePage,@Content,@Types)", CommandType.Text, paras); 210
Response.Redirect("liulianban.aspx"); 211
212
} 213
214
215
} 216





}
}