package msc.dao;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Vector;
import msc.dbc.DataBaseConnection;
import msc.vo.*;
public class ScDAO {
public Vector ScSelect(String cno,String cname,double credit,int cteachno,String clocation,String ctime,String tname)throws Exception{
Vector all=new Vector();
String sql="SELECT tc.cno, course.cname, course.credit, tc.cteachno, tc.clocation, tc.ctime, tc.cmax, tc.csel, teacher.tname FROM tc,course,teacher where tc.cno=course.cno and tc.tid=teacher.tid";
if(cno!="")
{
sql=sql+" and tc.cno LIKE '%"+cno+"%'";
}
if(cname!="")
{
sql=sql+" and course.cname LIKE '%"+cname+"%' ";
}
if(credit!=0)
{
sql=sql+" and course.credit='"+credit+"'";
}
if(cteachno!=0)
{
sql=sql+" and tc.cteachno='"+cteachno+"' ";
}
if(clocation!="")
{
sql=sql+" and tc.clocation LIKE '%"+clocation+"%' ";
}
if(ctime!="")
{
sql=sql+" and tc.ctime LIKE '%"+ctime+"%' ";
}
if(tname!="")
{
sql=sql+" and teacher.tname LIKE '%"+tname+"%' ";
}
sql=sql+";";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt = dbc.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
Tc cou=new Tc();
cou.setCno(rs.getString("tc.cno"));
cou.setCname(rs.getString("course.cname"));
cou.setCredit(rs.getDouble("course.credit"));
cou.setCteachno(rs.getInt("tc.cteachno"));
cou.setClocation(rs.getString("tc.clocation"));
cou.setCtime(rs.getString("tc.clocation"));
cou.setCtime(rs.getString("tc.ctime"));
cou.setCmax(rs.getInt("tc.cmax"));
cou.setCsel(rs.getInt("tc.csel"));
cou.setTname(rs.getString("teacher.tname"));
all.addElement(cou);
}
rs.close();
stmt.close();
} catch (Exception e) {
throw new Exception("查询中出现错误!!!");
} finally {
dbc.close();
}
return all;
}
public Vector SelectSelf(String sid)throws Exception{
Vector all=new Vector();
String sql="SELECT sc.cno, course.cname, sc.credit, tc.cteachno, tc.clocation, tc.ctime, teacher.tname FROM sc,tc,course,teacher where sc.sid='"+sid+"' and sc.cno=course.cno and sc.cno=tc.cno and sc.tid=tc.tid and tc.tid=teacher.tid;";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt = dbc.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
Tc cou=new Tc();
cou.setCno(rs.getString("sc.cno"));
cou.setCname(rs.getString("course.cname"));
cou.setCredit(rs.getDouble("sc.credit"));
cou.setCteachno(rs.getInt("tc.cteachno"));
cou.setClocation(rs.getString("tc.clocation"));
cou.setCtime(rs.getString("tc.clocation"));
cou.setCtime(rs.getString("tc.ctime"));
cou.setTname(rs.getString("teacher.tname"));
all.addElement(cou);
}
rs.close();
stmt.close();
} catch (Exception e) {
throw new Exception("查询中出现错误!!!");
} finally {
dbc.close();
}
return all;
}
public Vector SelectStudent(String cno,String tid)throws Exception{
Vector all=new Vector();
String sql="SELECT sc.sid, student.sname, sc.credit, sc.pscore, sc.lscore,sc.escore FROM sc,student where sc.cno='"+cno+"' and sc.tid='"+tid+"' and sc.sid=student.sid ORDER BY sc.escore DESC;";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt = dbc.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
Sc cou=new Sc();
cou.setSid(rs.getString("sc.sid"));
cou.setSname(rs.getString("student.sname"));
cou.setCredit(rs.getDouble("sc.credit"));
cou.setPscore(rs.getDouble("sc.pscore"));
cou.setLscore(rs.getDouble("sc.lscore"));
cou.setEscore(rs.getDouble("sc.escore"));
all.addElement(cou);
}
rs.close();
stmt.close();
} catch (Exception e) {
throw new Exception("查询中出现错误!!!");
} finally {
dbc.close();
}
return all;
}
public Vector SelectCourse(String sid)throws Exception{
Vector all=new Vector();
String sql="SELECT sc.cno,course.cname, sc.tid, sc.credit, sc.pscore, sc.lscore,sc.escore FROM sc,course where sc.sid='"+sid+"' and sc.cno=course.cno;";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt = dbc.getConnection().createStatement();
ResultSet rs = stmt.executeQuery(sql);
while(rs.next()) {
Sc cou=new Sc();
cou.setCno(rs.getString("sc.cno"));
cou.setCname(rs.getString("course.cname"));
cou.setTid(rs.getString("sc.tid"));
cou.setCredit(rs.getDouble("sc.credit"));
cou.setPscore(rs.getDouble("sc.pscore"));
cou.setLscore(rs.getDouble("sc.lscore"));
cou.setEscore(rs.getDouble("sc.escore"));
all.addElement(cou);
}
rs.close();
stmt.close();
} catch (Exception e) {
throw new Exception("查询中出现错误!!!");
} finally {
dbc.close();
}
return all;
}
public void Insert(String sid,String cno,String tid,double credit) throws Exception{
String sql="INSERT INTO sc(sid,cno,tid,credit) VALUES('"+sid+"','"+cno+"','"+tid+"','"+credit+"');";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt=dbc.getConnection().createStatement();
stmt.executeUpdate(sql);
stmt.close();
}catch (Exception e){
throw new Exception(e);
}finally {
dbc.close();
}
}
public void DeletebyID(String sid,String cno) throws Exception{
String sql="DELETE FROM sc WHERE sid='"+sid+"' and cno='"+cno+"';";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt=dbc.getConnection().createStatement();
stmt.executeUpdate(sql);
stmt.close();
}catch (Exception e){
throw new Exception("删除中出现错误!!!");
}finally {
dbc.close();
}
}
public void DeletebyTID(String tid) throws Exception{
String sql="DELETE FROM sc WHERE tid='"+tid+"';";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt=dbc.getConnection().createStatement();
stmt.executeUpdate(sql);
stmt.close();
}catch (Exception e){
throw new Exception("删除中出现错误!!!");
}finally {
dbc.close();
}
}
public void DeletebyTidCno(String tid,String cno) throws Exception{
String sql="DELETE FROM sc WHERE tid='"+tid+"' and cno='"+cno+"';";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt=dbc.getConnection().createStatement();
stmt.executeUpdate(sql);
stmt.close();
}catch (Exception e){
throw new Exception("删除中出现错误!!!");
}finally {
dbc.close();
}
}
public Score GetMaxMinAvg(String cno,String tid)throws Exception{
Score sco=new Score();
String sql="SELECT AVG(escore),MAX(escore),MIN(escore) FROM sc WHERE cno='"+cno+"' and tid='"+tid+"';";
Statement stmt=null;
DataBaseConnection dbc=null;
dbc=new DataBaseConnection();
try{
stmt=dbc.getConnection().createStatement();
ResultSet rs=stmt.executeQuery(sql);
while(rs.next()){
sco.setAvscore(rs.getDouble("AVG(escore)"));
sco.setMaxscore(rs.getDouble("MAX(escore)"));
sco.setMinscore(rs.getDouble("MIN(escore)"));
}
rs.close();
stmt.close();
}catch (Exception e){
e.getMessage();
}finally{
dbc.close();
}
return sco;
}
public void UpdateScore(String sid,String cno,String tid,double pscore,double lscore )throws Exception{
double escore=pscore*0.3+lscore*0.7;
double scorejd=calxfjd(escore);
String sql="UPDATE sc set pscore="+pscore+",lscore="+lscore+",escore="+escore+",scorejd="+scorejd+" WHERE sid='"+sid+"' and cno='"+cno+"' and tid='"+tid+"';
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
JSP+Servlet+Javabean+Mysql学生成绩管理系统 (170个子文件)
ScDAO.class 11KB
TcDAO.class 8KB
MscDAO.class 7KB
jxl_slt.class 7KB
sc_slt.class 7KB
msc_slt.class 7KB
StudentDAO.class 6KB
tc_slt.class 4KB
teacher_slt.class 4KB
TeacherDAO.class 4KB
student_slt.class 4KB
CourseDAO.class 4KB
UserDAO.class 4KB
msg_slt.class 4KB
course_slt.class 4KB
menu_slt.class 4KB
MassageDAO.class 3KB
login_conf.class 3KB
Tc.class 3KB
Student.class 3KB
Sc.class 2KB
DataBaseConnection.class 2KB
EncodingFilter.class 1KB
Massage.class 1KB
Score.class 1KB
User.class 1KB
Course.class 894B
Teacher.class 877B
.classpath 475B
org.eclipse.wst.jsdt.ui.superType.container 49B
mystyle2.css 1KB
mystyle1.css 770B
tips.gif 17KB
top.gif 6KB
login.gif 5KB
bgpicture.gif 4KB
end.gif 4KB
start.gif 3KB
tabbar_level1_slice_selected_left_bk.gif 2KB
scan.gif 2KB
bar.gif 1KB
delete.gif 1KB
tabbar_level1_slice_left_bk.gif 1000B
dibian.gif 561B
tabbar_level1_slice_right_bk2.gif 499B
tabbar_level1_slice_selected_right_bk.gif 397B
tabbar_level1_slice_right_bk.gif 372B
tabbar_level1_bk.gif 105B
jxl.jar 709KB
mysql-connector-java-5.0.5-bin.jar 501KB
ScDAO.java 9KB
jxl_slt.java 9KB
msc_slt.java 7KB
sc_slt.java 7KB
MscDAO.java 7KB
TcDAO.java 6KB
teacher_slt.java 5KB
student_slt.java 5KB
StudentDAO.java 4KB
course_slt.java 4KB
tc_slt.java 4KB
msg_slt.java 4KB
menu_slt.java 4KB
TeacherDAO.java 3KB
login_conf.java 3KB
CourseDAO.java 3KB
UserDAO.java 3KB
Tc.java 2KB
MassageDAO.java 2KB
Student.java 2KB
Sc.java 2KB
DataBaseConnection.java 1KB
Score.java 871B
Massage.java 726B
User.java 584B
EncodingFilter.java 546B
Course.java 472B
Teacher.java 466B
login3.jpg 50KB
teacher.jpg 46KB
admin.jpg 41KB
student.jpg 40KB
login4.jpg 27KB
login1.jpg 16KB
login6.jpg 15KB
login5.jpg 15KB
login2.jpg 14KB
bj_bottom.jpg 11KB
.jsdtscope 500B
student_main.jsp 4KB
teacher_sub_rs.jsp 4KB
student_cho_sub.jsp 3KB
login.jsp 3KB
admin_stu_updrs.jsp 3KB
student_cho.jsp 3KB
student_menu.jsp 3KB
teacher_cho_set.jsp 3KB
student_cho_del.jsp 3KB
teacher_main.jsp 3KB
admin_main.jsp 3KB
共 170 条
- 1
- 2
骑车骑车减肥了
- 粉丝: 45
- 资源: 19
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
- 4
- 5
- 6
前往页