经营状况统计()
ST_TurnOverStatModuleascxcs的主要代码及其解释
本页面与客户信息查询页面类似当页面加载时会执行Page_Load中的代码这里执行的是一个自定义的方法Show_TurnOverList()其后台代码如程序所示
程序 ST_TurnOverStatModuleascxcs
public partial class ST_TurnOverStatModule : ST_ModuleBase
{
private void Page_Load(object sender SystemEventArgs e)
{
if(!IsPostBack)
{
//
//绑定按房间类型下拉列表框
//
//从文件WebConfig中读取连接字符串
string ST_sqldb=
ConfigurationSettingsAppSettings[ConnectionString];
//连接ST_GinShopManage数据库
SqlConnection ST_Conn= new SqlConnection (ST_sqldb)
ST_ConnOpen ()
//定义SQL语句
string ST_mysql=select ST_RCategoryIdST_Name from
ST_RoomCategory ;
SqlCommand ST_cm=new SqlCommand (ST_mysqlST_Conn)
//执行SQL语句并读出数据
SqlDataReader dr=ST_cmExecuteReader ()
while(drRead ())
{
ListItem li=new ListItem(dr[ST_Name]ToString()
dr[ST_RCategoryId]ToString())
RCategoryNameListItemsAdd (li)
}
//关闭连接
ST_ConnClose ()
Show_TurnOverList()
}
}
protected void Show_TurnOverList()
{
//从文件WebConfig中读取连接字符串
string ST_sqldb =
ConfigurationSettingsAppSettings[ConnectionString];
//连接ST_GinShopManage数据库
SqlConnection ST_Conn = new SqlConnection (ST_sqldb)
//定义sql
string ST_selsql=select hST_BeginTimehST_EndTime
hST_RoomIdcST_NamehST_CNamehST_CIdentityId
hST_CPhonehST_TotalPrice+
from ST_History hST_RoomsInfo rST_RoomCategory c where
rST_RoomId=hST_RoomId and rST_RCategoryId=cST_RCategoryId;
//创建SqlDataAdapter对象调用存储过程ST_ShowRoomsInfo
SqlDataAdapter ST_myadapter=new SqlDataAdapter
(ST_selsqlST_Conn)
//创建并填充DataSet
DataSet ds = new DataSet()
ST_myadapterFill (ds)
dg_TurnOverListDataSource =ds;
dg_TurnOverListDataBind()
ST_ConnClose()
}
protected void GridView_Page(Object sender
GridViewPageEventArgs E)
{
dg_TurnOverList PageIndex =ENewPageIndex ;
Show_TurnOverList()
}
…
【代码说明】这里的实现代码和大多数的页面一样也是从数据库中读取数据并绑定到网格控件dg_TurnOverList代码第~行是GridView控件的翻页事件其中第行是指定新页面第行是重新绑定数据
[] []