?? picture.aspx.cs
字號:
using System;
using System.Collections;
using System.ComponentModel;
using System.Configuration;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using Wuqi.Webdiyer;
using WesternByte.MyBlog.Core.Blog;
using WesternByte.MyBlog.Core.Category;
using WesternByte.MyBlog.Core.Picture;
namespace WesternByte.MyBlog.Blog.Admin.Picture
{
/// <summary>
/// Picture 的摘要說明。
/// </summary>
public class Picture : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataList pictureCategory;
protected System.Web.UI.WebControls.DataList pictureList;
protected Wuqi.Webdiyer.AspNetPager pager;
protected CategoryDAO cDAO = new CategoryDAO();
protected PictureDAO pDAO = new PictureDAO();
private void Page_Load(object sender, System.EventArgs e)
{
// 在此處放置用戶代碼以初始化頁面
if(Session["Blog"]!=null)
{
BlogVO bVO = (BlogVO)Session["Blog"];
if(!Page.IsPostBack)
{
string Category = Page.Request.QueryString["CategoryID"];
int CategoryID = 0;
if(Category != null) CategoryID = Convert.ToInt32(Category);
pager.RecordCount = cDAO.LoadCount(bVO.BlogID,"p");
BindData(bVO.BlogID,CategoryID);
}
}
else
{
Page.Response.Redirect("/Login.aspx");
}
}
private void BindData(int BlogID,int CategoryID)
{
//分類列表
DataSet cDs = cDAO.LoadList(BlogID,"p");
cDs.Tables[0].Columns.Add("CategoryStr");
for(int i=0;i<cDs.Tables[0].Rows.Count;i++)
{
cDs.Tables[0].Rows[i]["CategoryStr"] = "<a href=\"Picture.aspx?CategoryID="+cDs.Tables[0].Rows[i]["CategoryID"].ToString()+"\">"+cDs.Tables[0].Rows[i]["Name"].ToString()+"</a>";
}
this.pictureCategory.DataSource = cDs.Tables[0].DefaultView;
this.pictureCategory.DataBind();
//當前分類下所有圖片列表
DataSet pDs = pDAO.LoadList(BlogID,CategoryID,pager.PageSize*(pager.CurrentPageIndex-1),pager.PageSize);
pDs.Tables[0].Columns.Add("Image");
pDs.Tables[0].Columns.Add("Edit");
pDs.Tables[0].Columns.Add("Remove");
for(int i=0;i<pDs.Tables[0].Rows.Count;i++)
{
//圖片路徑
string imageWebPath = ConfigurationSettings.AppSettings["ImageWebPath"].ToString() + pDs.Tables[0].Rows[i]["BlogID"].ToString() + "/" + pDs.Tables[0].Rows[i]["CategoryID"].ToString();
pDs.Tables[0].Rows[i]["Image"] = imageWebPath + "/t_" + pDs.Tables[0].Rows[i]["ImageUrl"].ToString();
pDs.Tables[0].Rows[i]["ImageUrl"] = "View.aspx?PictureID=" + pDs.Tables[0].Rows[i]["PictureID"].ToString();
if(pDs.Tables[0].Rows[i]["Subject"].ToString().Length>8){
pDs.Tables[0].Rows[i]["Subject"] = pDs.Tables[0].Rows[i]["Subject"].ToString().Substring(0,8) + "…";
}
pDs.Tables[0].Rows[i]["Edit"] = "<a href=\"Edit.aspx?PictureID=" + pDs.Tables[0].Rows[i]["PictureID"].ToString() + "\">修改</a>";
pDs.Tables[0].Rows[i]["Remove"] = "<a href=\"Remove.aspx?PictureID=" + pDs.Tables[0].Rows[i]["PictureID"].ToString() + "\">刪除</a>";
}
pictureList.DataSource = pDs.Tables[0].DefaultView;
pictureList.DataBind();
//動態設置用戶自定義文本內容
pager.CustomInfoText="共"+pager.PageCount.ToString()+"頁,當前為第"+pager.CurrentPageIndex.ToString()+"頁";
}
protected void ChangePage(object src,PageChangedEventArgs e)
{
string Category = Page.Request.QueryString["CategoryID"];
int CategoryID = 0;
if(Category != null) CategoryID = Convert.ToInt32(Category);
pager.CurrentPageIndex=e.NewPageIndex;
BindData(((BlogVO)Session["Blog"]).BlogID,CategoryID);
}
#region Web 窗體設計器生成的代碼
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 該調用是 ASP.NET Web 窗體設計器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 設計器支持所需的方法 - 不要使用代碼編輯器修改
/// 此方法的內容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -