一,添加查询对象的实体类,数据访问类,业务逻辑类
实体类
数据访问类
namespace DAL
{
public class StudentService
{
/// <summary>
/// 根据班级名称查询学员信息
/// </summary>
/// <param name="className">班级名称</param>
/// <returns>学员信息列表</returns>
public List<Student> GetStudentByClass(string className)
{
string sql = "select StudentId, StudentName, Gender, Birthday, StudentIdNo, CardNo, PhoneNumber, StudentAddress, Students.ClassId from Students";
sql += " inner join StudentClass on Students.ClassId=StudentClass.ClassId";//内连接
sql += " where ClassName like '%{0}%'";//模糊查询
sql = string.Format(sql, className);
SqlDataReader objReader = SQLHelper.GetReader(sql);
List<Student> list = new List<Student>();
while (objReader.Read())
{
list.Add(new Student()
{
StudentId = Convert.ToInt32(objReader["StudentId"]),
StudentName = objReader["StudentName"].ToString(),
Gender = objReader["Gender"].ToString(),
Birthday = Convert.ToDateTime(objReader["Birthday"])
});
}
objReader.Close();
return list;
}
}
}
业务逻辑类
二,添加对应的控制器和视图
控制器添加(都大同小异)
视图添加
获取当前用户名
@{
string adminName = ((Models.SysAdmin)Session["CurrentAdmin"]).AdminName;
添加简单样式表
<link href="../../Styles/stuManage.css" rel="stylesheet" />
三,显示结果