📄 listeachcoursestudent.ascx.cs
字号:
namespace Park.Statisitics
{
using System;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Collections;
using Park.Common;
/// <summary>
/// ListEachCourseStudent 的摘要说明。
/// </summary>
public abstract class ListEachCourseStudent : System.Web.UI.UserControl
{
protected System.Web.UI.WebControls.Repeater CourseList;
protected System.Web.UI.WebControls.DataList QuartersList;
protected System.Web.UI.WebControls.DataGrid StudentList;
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
loadList();
string currentcourseid=Request["CurrentCourseID"];
if(currentcourseid==null|| currentcourseid.Equals(""))
{
QuartersList.Visible = false;
return;
}
BindList(currentcourseid);
//loadData(currentcourseid);
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN:该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// 设计器支持所需的方法 - 不要使用
/// 代码编辑器修改此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void loadList()
{
SqlConnection myConnection=Utils.GetConnection();
SqlCommand myCommand = new SqlCommand("Statisitics_Get_Course", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader();
CourseList.DataSource = result;
CourseList.DataBind();
result.Close();
myCommand.Dispose();
myConnection.Dispose();
}
public ArrayList loadData(string classid)
{
SqlConnection myConnection=Utils.GetConnection();
SqlCommand myCommand = new SqlCommand("Statisitics_Get_StudentByClassID", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter CourseID = new SqlParameter("@classid", SqlDbType.VarChar,30);
CourseID.Value = classid;
myCommand.Parameters.Add(CourseID);
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader();
ArrayList list = new ArrayList();
while(result.Read())
{
Student st = new Student();
st.ID = result["StudentID"].ToString();
st.Name = result["Name"].ToString();
st.BelongingClass = result["BelongingClass"].ToString();
list.Add(st);
}
//EachClassStudentList.DataSource = result;
//EachClassStudentList.DataBind();
result.Close();
myCommand.Dispose();
myConnection.Dispose();
return list;
}
private void BindList(string courseid)
{
SqlConnection myConnection=Utils.GetConnection();
SqlCommand myCommand = new SqlCommand("Statisitics_Get_ClassByCourseID", myConnection);
// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;
// Add Parameters to SPROC
SqlParameter CourseID = new SqlParameter("@courseid", SqlDbType.VarChar,30);
CourseID.Value = courseid;
myCommand.Parameters.Add(CourseID);
myConnection.Open();
SqlDataReader result = myCommand.ExecuteReader();
QuartersList.DataSource = result;
/*if(!result.Read())
{
Response.Write("asdfasdfasd");
}*/
QuartersList.DataBind();
result.Close();
myCommand.Dispose();
myConnection.Dispose();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -