温馨提示:代码在线浏览功能只能做为源码浏览参考,如果想更进一步了解该代码请下载:多层文章管理系统源码
当前文件:
MultiLayerArticle/Web/Controls/AdminArticle.ascx.cs,打开代码结构图
MultiLayerArticle/Web/Controls/AdminArticle.ascx.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 SqlServerBLL; 12
using System.Collections.Generic; 13
14
public partial class Controls_AdminArticle : System.Web.UI.UserControl 15
{ 16
Admins adminBLL = new Admins(); 17
protected void Page_Load(object sender, EventArgs e) 18
{ 19
if (!IsPostBack) 20
{ 21
DataBindPage(); 22
} 23
} 24
public void DataBindPage() 25
{ 26
string sUrl = ""; 27
int iPageIndex = 0; 28
int iPageSize = 20; 29
int iType = 0; 30
int iUserID = 0; 31
string sName = HttpUtility.UrlDecode(Request.QueryString["title"]); 32
string sSummary = HttpUtility.UrlDecode(Request.QueryString["summary"]); 33
string sType = Request.QueryString["type"]; 34
string sPageIndex = Request.QueryString["PageIndex"]; 35
if (!string.IsNullOrEmpty(sName)) 36
{ 37
sUrl += "&title=" + HttpUtility.UrlEncode(sName); 38
} 39
if (!string.IsNullOrEmpty(sSummary)) 40
{ 41
sUrl += "&summary=" + HttpUtility.UrlEncode(sSummary); 42
} 43
if (!string.IsNullOrEmpty(sType)) 44
{ 45
sUrl += "&type=" + sType; 46
int.TryParse(sType, out iType); 47
} 48
if (!string.IsNullOrEmpty(sPageIndex)) 49
{ 50
int.TryParse(sPageIndex, out iPageIndex); 51
} 52
53
DataSet dsArticle = adminBLL.GetArticle(iPageIndex, iPageSize, iType, sName, sSummary); 54
if (dsArticle != null && dsArticle.Tables.Count == 2) 55
{ 56
repeaterArticle.DataSource = dsArticle.Tables[0]; 57
repeaterArticle.DataBind(); 58
int iCount = Convert.ToInt32(dsArticle.Tables[1].Rows[0][0]); 59
spTop.PageCount = iCount; 60
spTop.PageIndex = iPageIndex; 61
spTop.PageSize = iPageSize; 62
spTop.Parameter = sUrl; 63
spBottom.PageCount = iCount; 64
spBottom.PageIndex = iPageIndex; 65
spBottom.PageSize = iPageSize; 66
spBottom.Parameter = sUrl; 67
dsArticle.Dispose(); 68
} 69
} 70
71
protected void lBtnDelete_Click(object sender, EventArgs e) 72
{ 73
string sid = hf_id.Value; 74
if (adminBLL.DeleteArticleByIds(sid)) 75
{ 76
Page.ClientScript.RegisterClientScriptBlock(GetType(), "delete", "alert('删除成功');window.location.href='AdminArticle.aspx';", true); 77
} 78
else 79
{ 80
Page.ClientScript.RegisterClientScriptBlock(GetType(), "deleteError", "alert('删除出现错误');", true); 81
} 82
} 83
84
85
} 86




Admins adminBLL 
}
}