?? default.aspx.cs
字號(hào):
?using System;
using System.Data;
using System.Data.OleDb;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
namespace Chp09
{
public partial class Photo : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
int intUserID = 0;
if( Session["UserID"] != null){
intUserID = Convert.ToInt32(Session["UserID"].ToString());
}
GetSubCategorys(0, intUserID);
AjaxPro.Utility.RegisterTypeForAjax(typeof(Chp09.Photo));
}
/// <summary>
/// 根據(jù)相片ID獲取相片信息
/// </summary>
/// <param name="PhotoId">相片ID</param>
/// <returns>相片信息</returns>
[AjaxPro.AjaxMethod()]
public DataSet GetPhotoInfo(int PhotoId)
{
// 創(chuàng)建數(shù)據(jù)集
DataSet ds = new DataSet();
// 創(chuàng)建數(shù)據(jù)連接
DataAccess db = new DataAccess();
// 創(chuàng)建 SQL 命令對(duì)象
OleDbCommand oleComm = new OleDbCommand();
oleComm.Connection = db.getConn();
try
{
// 設(shè)置存儲(chǔ)過程參數(shù)
oleComm.CommandText = "GetPhotoInfo";
oleComm.CommandType = CommandType.StoredProcedure;
oleComm.Parameters.Add("@PhotoID", OleDbType.Integer, 4);
oleComm.Parameters["@PhotoID"].Value = PhotoId;
// 創(chuàng)建適配器
OleDbDataAdapter da = new OleDbDataAdapter(oleComm);
// 填充數(shù)據(jù)到 DataSet
da.Fill(ds);
}
catch { }
finally
{
// 關(guān)閉數(shù)據(jù)連接
db.Close();
}
// 返回相片信息
return ds;
}
/// <summary>
/// 獲取子類別數(shù)據(jù)
/// </summary>
/// <param name="intCateID">類別ID</param>
/// <param name="intUserID">用戶ID</param>
/// <returns>類別信息</returns>
[AjaxPro.AjaxMethod()]
public DataSet GetSubCategorys(int intCateID, int intUserID)
{
// 創(chuàng)建數(shù)據(jù)集
DataSet ds = new DataSet();
// 創(chuàng)建數(shù)據(jù)連接
DataAccess db = new DataAccess();
// 創(chuàng)建 SQL 命令對(duì)象
OleDbCommand oleComm = new OleDbCommand();
oleComm.Connection = db.getConn();
try
{
// 設(shè)置存儲(chǔ)過程參數(shù)
oleComm.CommandText = "GetSubCategorys";
oleComm.CommandType = CommandType.StoredProcedure;
oleComm.Parameters.Add(new OleDbParameter("@ParentCateID", OleDbType.Integer, 4));
oleComm.Parameters.Add(new OleDbParameter("@UserID", OleDbType.Integer, 4));
oleComm.Parameters["@ParentCateID"].Value = intCateID;
oleComm.Parameters["@UserID"].Value = intUserID;
// 創(chuàng)建適配器
OleDbDataAdapter da = new OleDbDataAdapter(oleComm);
// 填充數(shù)據(jù)到 DataSet
da.Fill(ds);
}
catch { }
finally
{
// 關(guān)閉數(shù)據(jù)連接
db.Close();
}
// 返回相片信息
return ds;
}
/// <summary>
/// 獲取某一類別下相片信息
/// </summary>
/// <param name="intCateID">類別ID</param>
/// <returns>相片信息</returns>
[AjaxPro.AjaxMethod()]
public DataSet GetSubPhotos(int intCateID, int intUserID)
{
// 創(chuàng)建數(shù)據(jù)集
DataSet ds = new DataSet();
// 創(chuàng)建數(shù)據(jù)連接
DataAccess db = new DataAccess();
// 創(chuàng)建 SQL 命令對(duì)象
OleDbCommand oleComm = new OleDbCommand();
oleComm.Connection = db.getConn();
try
{
// 設(shè)置存儲(chǔ)過程參數(shù)
oleComm.CommandText = "GetSubCatePhotoInfo";
oleComm.CommandType = CommandType.StoredProcedure;
oleComm.Parameters.Add("@CateID", OleDbType.Integer, 4);
oleComm.Parameters.Add("@UserID", OleDbType.Integer, 4);
oleComm.Parameters["@CateID"].Value = intCateID;
oleComm.Parameters["@UserID"].Value = intUserID;
// 創(chuàng)建適配器
OleDbDataAdapter da = new OleDbDataAdapter(oleComm);
// 填充數(shù)據(jù)到 DataSet
da.Fill(ds);
}
catch { }
finally
{
// 關(guān)閉數(shù)據(jù)連接
db.Close();
}
// 返回相片信息
return ds;
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -