📄 default.aspx.cs
字号:
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>
/// 根据相片ID获取相片信息
/// </summary>
/// <param name="PhotoId">相片ID</param>
/// <returns>相片信息</returns>
[AjaxPro.AjaxMethod()]
public DataSet GetPhotoInfo(int PhotoId)
{
// 创建数据集
DataSet ds = new DataSet();
// 创建数据连接
DataAccess db = new DataAccess();
// 创建 SQL 命令对象
OleDbCommand oleComm = new OleDbCommand();
oleComm.Connection = db.getConn();
try
{
// 设置存储过程参数
oleComm.CommandText = "GetPhotoInfo";
oleComm.CommandType = CommandType.StoredProcedure;
oleComm.Parameters.Add("@PhotoID", OleDbType.Integer, 4);
oleComm.Parameters["@PhotoID"].Value = PhotoId;
// 创建适配器
OleDbDataAdapter da = new OleDbDataAdapter(oleComm);
// 填充数据到 DataSet
da.Fill(ds);
}
catch { }
finally
{
// 关闭数据连接
db.Close();
}
// 返回相片信息
return ds;
}
/// <summary>
/// 获取子类别数据
/// </summary>
/// <param name="intCateID">类别ID</param>
/// <param name="intUserID">用户ID</param>
/// <returns>类别信息</returns>
[AjaxPro.AjaxMethod()]
public DataSet GetSubCategorys(int intCateID, int intUserID)
{
// 创建数据集
DataSet ds = new DataSet();
// 创建数据连接
DataAccess db = new DataAccess();
// 创建 SQL 命令对象
OleDbCommand oleComm = new OleDbCommand();
oleComm.Connection = db.getConn();
try
{
// 设置存储过程参数
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;
// 创建适配器
OleDbDataAdapter da = new OleDbDataAdapter(oleComm);
// 填充数据到 DataSet
da.Fill(ds);
}
catch { }
finally
{
// 关闭数据连接
db.Close();
}
// 返回相片信息
return ds;
}
/// <summary>
/// 获取某一类别下相片信息
/// </summary>
/// <param name="intCateID">类别ID</param>
/// <returns>相片信息</returns>
[AjaxPro.AjaxMethod()]
public DataSet GetSubPhotos(int intCateID, int intUserID)
{
// 创建数据集
DataSet ds = new DataSet();
// 创建数据连接
DataAccess db = new DataAccess();
// 创建 SQL 命令对象
OleDbCommand oleComm = new OleDbCommand();
oleComm.Connection = db.getConn();
try
{
// 设置存储过程参数
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;
// 创建适配器
OleDbDataAdapter da = new OleDbDataAdapter(oleComm);
// 填充数据到 DataSet
da.Fill(ds);
}
catch { }
finally
{
// 关闭数据连接
db.Close();
}
// 返回相片信息
return ds;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -