c#写的学生管理系统的心得1
来源:互联网 发布:linux如何压缩文件 编辑:程序博客网 时间:2024/05/17 18:28
1.html文件中引入另一个html文件,用 #parse("../include/header.htm"),最好不要用<iframe scrolling="no" marginwidth="0" marginheight="0" width="100%" height="50" src="/include/header.htm" frameborder="0"></iframe>这种形式的
2.需要连接数据库和导入sqlhelper(数据库里边的一些方法)和引用Nvelocity(渲染html页面)
连接数据库需要在web.config中配置:
<connectionStrings>
<add name="connstr" connectionString="Data Source=.;Initial Catalog=stuentsystem;User Id=sa;Password=136156a;"/> --stuentsystem数据库名称
</connectionStrings>
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中) 添加页面
相当于遍历老师表:
前台:<td>
<select name="teacher">
<option>请选择</option>
#foreach($p in $Data.teachers)
<option value="$p.TEACHER_ID">$p.NAME</option>
#end
</select>
</td>
后台(需要得到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.编辑页面 显示已经选择的老师名称,并且遍历
前台:
<tr>
<td>班主任老师</td>
<td>
<select name="teacher">
#foreach($p in $Data.teachers)
#if($Data.team.TEACHER_ID == $p.TEACHER_ID) --班级里的老师ID和教师表里的id一致的时候,显示老师名称;否则显示所有的老师名称
<option value="$p.TEACHER_ID" selected="selected">$p.NAME</option>
#else
<option value="$p.TEACHER_ID">$p.NAME</option>
#end
#end
</select>
</td>
</tr>
后台:需要得到当前编辑的班级和教师列表
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_NAMElike @C_NAME", new SqlParameter("@C_NAME", "%" + searchText + "%")); --searchText为输入框的name
好了,现在就这么多吧,别的问题暂时还没怎么遇到呢
- c#写的学生管理系统的心得1
- c#写的学生管理系统的心得2
- 学生管理系统的心得
- 用C#写的一个 学生管理系统验证代码
- 对学生管理系统的心得
- 用C++写的“学生管理系统”
- 初学写的学生管理系统
- Python 写的学生管理系统
- C# 学生管理系统 2 实现 添加 学生的数据
- 自己也写的小的学生管理系统
- 用C语言写的学生管理系统
- 面向对象写一个简单的学生管理系统
- 想学C#做管理系统的数院学生
- C# 作业,简单的学生管理系统(控制台)
- 简单的学生管理系统
- 学生管理系统的设计
- 学生管理系统的总结
- 学生管理系统的常见问题
- Java for Web学习笔记(四七):WebSocket(4)Java Client和二进制消息
- IntelliJ IDEA 2017激活码
- 神经网络细节与训练注意事项
- 1064. 朋友数(20) python篇
- Top K算法
- c#写的学生管理系统的心得1
- 在ubuntu上安装 GNUstep 编译objective c
- Spring的log4j使用
- android surfaceview画板如何绘制背景成五颜六色
- javascript实现输入名字列表并排序显示
- poj 2451:Uyuw's Concert(半平面交模板)
- WebStorm 2017激活码
- 2017年世界500强企业排行榜【完整榜单】2017财富杂志世界五百强排名
- 非递归中序遍历---算法导论12.1-3