c#写的学生管理系统的心得1

1.html文件中引入另一个html文件,用 #parse("../include/header.htm"),最好不要用这种形式的

2.需要连接数据库和导入sqlhelper(数据库里边的一些方法)和引用Nvelocity(渲染html页面)

连接数据库需要在web.config中配置:


            --stuentsystem数据库名称
 

3.可以往Data存多个数据:

                    DataTable dt = SqlHelper.ExecuteDataTable("select * from class where CLASS_ID=@CLASS_ID", new SqlParameter("@CLASS_ID", id));
                    DataTable dts = SqlHelper.ExecuteDataTable("select * from teacher");
                    var Data = new { team = dt.Rows[0], teachers=dts.Rows};
                    string html = CommonHelper.RenderHtml("editteam.html", Data);
                    context.Response.Write(html);

相应的前台可以通过$Data.team和$Data.teachers调用

4.比如班级(班级表中)里边得到所有的班主任老师名称(在另一个数据表teacher中)  添加页面

相当于遍历老师表:

前台:
               
             

后台(需要得到teachers):

              DataTable dt = SqlHelper.ExecuteDataTable("select * from teacher");
                var Data = new { teachers = dt.Rows };
                string html = CommonHelper.RenderHtml("addteam.html", Data);
                context.Response.Write(html);

5.编辑页面    显示已经选择的老师名称,并且遍历

前台:

          
              班主任老师
             
               
             
           

后台:需要得到当前编辑的班级和教师列表

                  DataTable dt = SqlHelper.ExecuteDataTable("select * from class where CLASS_ID=@CLASS_ID", new SqlParameter("@CLASS_ID", id));
                    DataTable dts = SqlHelper.ExecuteDataTable("select * from teacher");
                    var Data = new { team = dt.Rows[0], teachers=dts.Rows};
                    string html = CommonHelper.RenderHtml("editteam.html", Data);
                    context.Response.Write(html);

6.模糊查询:

 DataTable dt = SqlHelper.ExecuteDataTable("select * from class_teacher where C_NAME like @C_NAME", new SqlParameter("@C_NAME", "%" + searchText + "%"));                                                                                                                                                                                                     --searchText为输入框的name


好了,现在就这么多吧,别的问题暂时还没怎么遇到呢

你可能感兴趣的:(c#写的学生管理系统的心得1)