6.删除收费供求信息
DeleteLeaguerInfo()方法主要用于删除收费供求信息。实现代码如下:
例程14 代码位置:光盘\TM\01\SIS\ App_Code \ Operation.cs
#region 删除收费供求信息
/// <summary>
/// 删除收费供求信息
/// </summary>
/// <param name="id">要删除信息的ID</param>
public void DeleteLeaguerInfo(string id)
{
int d = data.RunProc("Delete from tb_LeaguerInfo where id='" + id + "'");
}
#endregion
7.查询收费供求信息
SelectLeaguerInfo()方法为可重载方法,用于根据不同的条件查询收费供求信息。实现代码如下:
例程15 代码位置:光盘\TM\01\SIS\ App_Code \ Operation.cs
#region 查询收费供求信息
/// <summary>
/// 显示所有的收费信息
/// </summary>
/// <returns>返回DataSet结果集</returns>
public DataSet SelectLeaguerInfo()
{
return data.RunProcReturn("Select * from tb_LeaguerInfo order by date desc", "tb_LeaguerInfo");
}
/// <summary>
/// 查询收费到期和未到期供求信息
/// </summary>
/// <param name="All">True显示未到期信息,False显示到期信息</param>
/// <returns>返回DataSet结果集</returns>
public DataSet SelectLeaguerInfo(bool All)
{
if (All) //显示有效收费信息
return data.RunProcReturn("Select * from tb_LeaguerInfo where showday >= getdate() order by date desc", "tb_LeaguerInfo");
else //显示过期收费信息
return data.RunProcReturn("select * from tb_LeaguerInfo where showday<getdate() order by date desc", "tb_LeaguerInfo");
}
/// <summary>
/// 查询同类型收费到期和未到期供求信息
/// </summary>
/// <param name="all">True显示未到期信息,False显示到期信息</param>
/// <param name="infoType">信息类型</param>
/// <returns>返回DataSet结果集</returns>
public DataSet SelectLeaguerInfo(bool All, string infoType)
{
if (All) //显示有效收费信息
return data.RunProcReturn("Select * from tb_LeaguerInfo where type='" + infoType + "' and showday >= getdate() order by date desc", "tb_LeaguerInfo");
else //显示过期收费信息
return data.RunProcReturn("select * from tb_LeaguerInfo where type='" + infoType + "' and showday<getdate() order by date desc", "tb_LeaguerInfo");
}
/// <summary>
/// 查询显示“按类型未过期推荐信息”或“所有的未过期推荐信息”
/// </summary>
/// <param name="infoType">信息类型</param>
/// <param name="checkState">True按类型显示未过期推荐信息 False显示所有未过期推荐信息</param>
/// <returns></returns>
public DataSet SelectLeaguerInfo(string infoType,bool checkState)
{
if (checkState) //按类型未过期推荐信息
return data.RunProcReturn("SELECT top 20 * FROM tb_LeaguerInfo WHERE (type = '" + infoType + "') AND (showday >= GETDATE()) AND (CheckState = '" + checkState + "') ORDER BY date DESC", "tb_LeaguerInfo");
else //显示未过期推荐信息
return data.RunProcReturn("SELECT top 10 * FROM tb_LeaguerInfo WHERE (showday >=GETDATE()) AND (CheckState = '" + !checkState + "') ORDER BY date DESC", "tb_LeaguerInfo");
}
/// <summary>
/// 查询同类型收费到期和未到期供求信息(前N条信息)
/// </summary>
/// <param name="all">True显示未到期信息,False显示到期信息</param>
/// <param name="infoType">信息类型</param>
/// <param name="top">获取前N条信息</param>
/// <returns></returns>
public DataSet SelectLeaguerInfo(bool All, string infoType, int top)
{
if (All) //显示有效收费信息
return data.RunProcReturn("Select top(" + top + ") * from tb_LeaguerInfo where type='" + infoType + "' and showday >= getdate() order by date desc", "tb_LeaguerInfo");
else //显示过期收费信息
return data.RunProcReturn("select top(" + top + ") * from tb_LeaguerInfo where type='" + infoType + "' and showday<getdate() order by date desc", "tb_LeaguerInfo");
}
/// <summary>
/// 根据ID查询收费供求信息
/// </summary>
/// <param name="id">供求信息ID</param>
/// <returns></returns>
public DataSet SelectLeaguerInfo(string id)
{
return data.RunProcReturn("Select * from tb_LeaguerInfo where id='" + id + "' order by date desc", "tb_LeaguerInfo");
}
#endregion
8.DataList分页设置绑定
PageDataListBind()方法主要用于实现DataList绑定分页功能。实现代码如下:
例程16 代码位置:光盘\TM\01\SIS\ App_Code \ Operation.Cs
#region 分页设置绑定
/// <summary>
/// 绑定DataList控件,并且设置分页
/// </summary>
/// <param name="infoType">信息类型</param>
/// <param name="infoKey">查询的关键字(如果为空,则查询所有)</param>
/// <param name="currentPage">当前页</param>
/// <param name="PageSize">每页显示数量</param>
/// <returns>返回PagedDataSource对象</returns>
public PagedDataSource PageDataListBind(string infoType, string infoKey, int currentPage,int PageSize)
{
PagedDataSource pds = new PagedDataSource();
pds.DataSource = SelectInfo(infoType, infoKey).Tables[0].DefaultView; //将查询结果绑定到分页数据源上
pds.AllowPaging = true; //允许分页
pds.PageSize = PageSize; //设置每页显示的页数
pds.CurrentPageIndex = currentPage - 1; //设置当前页
return pds;
}
#endregion
9.后台登录
Logon()方法主要用于实现网站后台验证用户登录功能。实现代码如下:
例程17 代码位置:光盘\TM\01\SIS\ App_Code \ Operation.cs
#region 后台登录
public DataSet Logon(string user, string pwd)
{
SqlParameter[] parms ={
data.MakeInParam("@sysName",SqlDbType.VarChar,20,user),
data.MakeInParam("@sysPwd",SqlDbType.VarChar,20,pwd)
};
return data.RunProcReturn("Select * from tb_Power where sysName=@sysName and
sysPwd=@sysPwd",parms, "tb_Power");
}
#endregion