学生管理信息系统开发经验

首先说python web不好学, 都说python web简单,按时学到一定程度,还不如去搞java, Python的表面风平浪静,里面全是大坑,摸爬滚打了一年半,最终大彻大悟先学好python再搞pythonweb吧。

开发项目的确要遵循一定的步骤,虽然自己开发过三四个小系统,每次都是特别艰辛,前端跟后台一起做,做做前端,做做后台,。只是开发过程会特别慢,更会导致开发难度变得特别大,整个项目没有步骤感,最近学到了一种开发方法,基于需求的开发,首先需要先讲前端的基础页面做好。例如下面
这是在这里插入图片描述这是后台管理员的管理页面,使用bootstrap组件,自己每次做项目都是自己手写css导致写的项目特别丑,使用bootstrap开发速度会特别快,大概两三个小时就可以把后台初步的所有的页面全部设计完

先开发前台可以明确知道需要什么数据,数据的格式,然后在创建数据库,写后台会容易很多。

视图
视图的设计尽量采用cbv模式会灵活很多,这个也取决于自己倾向把,view视图下导入django.view import View, 可是使用多个请求方法,get put post delete等,自己很喜欢这种方式。
使用xlrd模块,可以使用escle模块对数据进行批量添加
测试数据使用xlwt模块使用脚本批量添加
视图session全部没有使用到装饰器算是对于python的不忠把,写的假python
可以参阅文档修改setting中添加对seesion的控制,另外还可以自己写装饰器作为中间件,来实现session的功能。极其建议阅读 流畅的python这本书

模板
我模板是真的没有怎么好好学,就是没有django风味的前台,开发的灵活性增大,但是遵循django是会增强安全性的,建议有一定的js css基础
下面写一个ajax发送数据把
首先导入jquery.js库
<a οnclick=函数名() >提交<\a>
document 函数名(){
$.ajax({
url:’ ', 要提交的url
type:‘post/get’, 提交方式
data;form.serialize(),这个方式可以提交form表单内的信息 提交的数据,
另外可以使用json类型的数据提交例如{‘name’: wangchao, ‘age’: 18}
所以看到这里需要去学一息js从怎么从表单或者别的地方获得数据
success: function (args){
if(args==‘ok’){
你想执行的操作,这里也要去学习js的知识
}
}
这里是获得后台传过来的数据 args就是后台传的数据,所以后台采用httpresponse传递数据,
)

}
另外还要考虑异步消息的问题,就像上传一个很大的数据,此时将会卡死在一个页面,自行查看celery的文档

最后就是多做项目,尽量用Linux系统,这才能体会到编程的乐趣,强行看文档等技能都会学到,无形中遇到很多彩蛋。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
package cn.com.dao.chivementdao; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import cn.com.util.DBConnection; import cn.com.util.DBSql; import cn.com.vo.chivementvo.ChivementVo; public class ExamDao { private Connection conn = DBConnection.getConnectionOracle(); private ChivementVo examVo; public ExamDao() { } public ExamDao(ChivementVo examVo) { super(); this.examVo = examVo; } /** * 全部查询 */ public Object[][] selectAll() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_ALL); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberAll(DBSql.SELECT_ALL_COUNT)][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据学号查询 */ public Object[][] selectBySid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_S_ID); ps.setInt(1, examVo.getS_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_S_ID_COUNT, examVo .getS_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据组号查询 */ public Object[][] selectByGid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_G_ID); ps.setInt(1, examVo.getG_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_G_ID_COUNT, examVo .getG_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据课程号查询 */ public Object[][] selectByCid() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_C_ID); ps.setInt(1, examVo.getC_id()); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumber(DBSql.SELECT_BY_C_ID_COUNT, examVo .getC_id())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { // System.out.println( examVo.getG_id()); date[i][j] = rs.getObject(j+1); } i++; } // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据姓名模糊查询 * * @return */ public Object[][] selectByName() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_S_NAME); ps.setString(1, examVo.getS_name()); ps.setString(2, "%" + examVo.getS_name() + "%"); ps.setString(3, "%" + examVo.getS_name()); ps.setString(4, examVo.getS_name() + "%"); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberByName(DBSql.SELECT_BY_S_NAME_COUNT, examVo.getS_name())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 根据课程名称模糊查询 * * @return */ public Object[][] selectByClassName() { Object date[][] = null; int max = 0; int i = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.SELECT_BY_CLASS_NAME); ps.setString(1, examVo.getClass_name()); ps.setString(2, "%" + examVo.getClass_name() + "%"); ps.setString(3, "%" + examVo.getClass_name()); ps.setString(4, examVo.getClass_name() + "%"); rs = ps.executeQuery(); // 得到列数 max = rs.getMetaData().getColumnCount(); date = new Object[getnumberByName(DBSql.SELECT_BY_CLASS_COUNT, examVo.getClass_name())][max]; while (rs.next()) { for (int j = 0; j < max; j++) { date[i][j] = rs.getObject(j + 1); } i++; } } catch (SQLException e) { e.printStackTrace(); } return date; } /** * 修改选中学生的成绩 * */ public void updatSelectClass() { PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(DBSql.UPDATE_EXAM_BY_STUID); ps.setInt(1, examVo.getClassExamChivement()); ps.setInt(2, examVo.getS_id()); ps.setInt(3, examVo.getC_id()); ps.executeUpdate(); } catch (SQLException e) { e.printStackTrace(); } } /** * 得到所有课程号和课程名 * * @return */ public String[] getClassNoName() { String[] classNoName = null; PreparedStatement ps = null; ResultSet rs = null; int j = 0; try { int i = getnumberAll(DBSql.SELECT_CLASS_NAME_COUNT); classNoName = new String[i + i]; ps = conn.prepareStatement(DBSql.SELECT_CLASS_NAME); rs = ps.executeQuery(); while (rs.next()) { classNoName[j] = rs.getString(1); classNoName[j + i] = rs.getString(2); j++; } } catch (SQLException e) { e.printStackTrace(); } return classNoName; } /** * 根据科目修改成绩 查询学号 姓名 成绩 * */ public void SelectClassStuName() { int i = 0; PreparedStatement ps = null; ResultSet rs = null; int j = getnumberBySelectClassName( DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM_COUNT, examVo.getC_id()); int[] sNum = new int[j]; String[] sName = new String[j]; int[] classExam = new int[j]; try { ps = conn.prepareStatement(DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM); ps.setInt(1, examVo.getC_id()); rs = ps.executeQuery(); while (rs.next()) { sNum[i] = rs.getInt(1); sName[i] = rs.getString(2); classExam[i] = rs.getInt(3); i++; } } catch (SQLException e) { e.printStackTrace(); } examVo.setSid(sNum); examVo.setSname(sName); examVo.setClassExam(classExam); } /** * 根据科目修改成绩 查询学号 姓名 成绩 后修改成绩 * */ public void UpdateClassStuName() { // int i = 0; PreparedStatement ps = null; ResultSet rs = null; int j = getnumberBySelectClassName( DBSql.SELECT_CLASS_STU_SNO_SNAME_EXAM_COUNT, examVo.getC_id()); try { ps = conn.prepareStatement(DBSql.UPDATE_CHIVEMENT_BY_CLASS); for(int i =0;i<j;i++){ ps.setInt(1, examVo.getClassExam()[i]); ps.setInt(2, examVo.getSid()[i]); ps.setInt(3, examVo.getC_id()); ps.executeUpdate(); } } catch (SQLException e) { e.printStackTrace(); } } /** * 全部查询获得行数 * * @return */ public int getnumberAll(String str) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return number; } /** * 根据学号 根据组号 根据课程号查询 获得行数 * * @return */ public int getnumber(String str, int i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setInt(1, i); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); // rs.close(); // ps.close(); // conn.close(); } catch (SQLException e) { e.printStackTrace(); } return number; } /** * 根据姓名 课程名 查询 获得行数 * */ public int getnumberByName(String str, String i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setString(1, i); ps.setString(2, "%" + i + "%"); ps.setString(3, "%" + i); ps.setString(4, i + "%"); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); } catch (SQLException e) { e.printStackTrace(); } return number; } // /** // * 根据课程名查询 获得行数 // * // */ // // public int getnumberByClassName(String str, String i) { // int number = 0; // PreparedStatement ps = null; // ResultSet rs = null; // try { // ps = conn.prepareStatement(str); // ps.setString(1, i); // ps.setString(2, "%" + i + "%"); // ps.setString(3, "%" + i); // ps.setString(4, i + "%"); // rs = ps.executeQuery(); // rs.next(); // number = rs.getInt(1); // } catch (SQLException e) { // e.printStackTrace(); // } // return number; // } /** * * 根据课程名修改成绩获得行数 * * @param str * @param i * @return */ public int getnumberBySelectClassName(String str, int i) { int number = 0; PreparedStatement ps = null; ResultSet rs = null; try { ps = conn.prepareStatement(str); ps.setInt(1, i); rs = ps.executeQuery(); rs.next(); number = rs.getInt(1); } catch (SQLException e) { e.printStackTrace(); } return number; } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值