/*
*
*
*
* 对专业设置和管理员的操作
*
*
*/
package com.test2;
import java.io.Serializable;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import com.test1.ConnectionUtils;
//第一模块
public class Student_adminDao implements Serializable{
//查找管理员信息
String search_admin = "select type from adminstrator where admin_name = ? and mima = ?";
//查询专业信息
String search_major = "select zhuanye_num,zhuanye_name,yuanxi,class_num,feiyong from zhuanye limit ?,?";
//查找某个专业信息
String search_rows = "select zhuanye_num,zhuanye_name,yuanxi,class_num,feiyong from zhuanye where zhuanye_num=?";
// 2增加管理员
String add_admin = "insert into adminstrator values(?,?,?)";
// 3删除管理员
String del_admin = "delete from adminstrator where admin_name = ?";
// 4显示所有用户
String fenye_admin = "select admin_name,mima,type from adminstrator limit ?,?";
// 5显示一条管理员信息
String one_msg = "select mima,type from adminstrator where admin_name = ?";
// 6更新一条管理员信息
String xin_msg = "update adminstrator set mima=?,type=? where admin_name=?";
// 7新增一个管理员
String xinzeng = "insert into adminstrator values (?,?,?)";
// 8查找管理员信息
String chazhao = "select * from adminstrator where admin_name = ?";
public int find_admin(Adminstrator admin){ //管理员设置
int flag = -1;
Connection conn = null;
PreparedStatement state = null;
ResultSet res = null;
try {
conn = ConnectionUtils.openConnection();
state = conn.prepareStatement(search_admin);
state.setString(1, admin.getName());
state.setString(2, admin.getMima());
res = state.executeQuery();
if(res.next()){
flag =res.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
ConnectionUtils.closeConnection(conn);
}
return flag;
}
// 增加管理员
public void AddAdmin(Adminstrator admin){
Connection conn = null;
PreparedStatement state = null;
try {
conn = ConnectionUtils.openConnection();
state = conn.prepareStatement(add_admin);
state.setString(1, admin.getName());
state.setString(2, admin.getMima());
state.setInt(1, admin.getType());
state.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 删除管理员
public void DelAdmin(String name){
Connection conn = null;
PreparedStatement state = null;
try {
conn = ConnectionUtils.openConnection();
state = conn.prepareStatement(del_admin);
state.setString(1, name);
state.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
// 分页后页数
public int FenYe(int perpages){
int pages = 0;
int num = 0;
String admin_num = "select count(*) from adminstrator";
Connection conn = null;
PreparedStatement state = null;
ResultSet res = null;
try {
conn = ConnectionUtils.openConnection();
state = conn.prepareStatement(admin_num);
res = state.executeQuery();
if(res.next()){
num = res.getInt(1);
if(num%perpages == 0){
pages = num / perpages;
}else{
pages = num / perpages + 1;
}
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return pages;
}
// 查找当前页面的数据
public List<Adminstrator> fenYe_admin(int page,int perpages){
List<Adminstrator> list = new ArrayList<Adminstrator>();
Connection conn = null;
PreparedStatement state = null;
ResultSet res = null;
try {
conn = ConnectionUtils.openConnection();
state = conn.prepareStatement(fenye_admin);
state.setInt(1, (page-1)*perpages);
state.setInt(2, perpages);
res = state.executeQuery();
while(res.next()){
Adminstrator admin = new Adminstrator();
admin.setName(res.getString(1));
admin.setMima(res.getString(2));
admin.setType(res.getInt(3));
list.add(admin);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
// 显示一条管理员信息
public Adminstrator find_One(String name){
Adminstrator admin = new Adminstrator();
Connection conn = null;
PreparedStatement state = null;
ResultSet res = null;
try {
conn = ConnectionUtils.openConnection();
state = conn.prepareStatement(one_msg);
state.setString(1, name);
res = state.executeQuery();
if(res.next()){
admin.setName(name);
admin.setMima(res.getString(1));
admin.setType(res.getInt(2));
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return admin;
}
// 更新一条管理员信息
public void GengXin(Adminstrator admin){
Connection conn = null;
PreparedStatement state = null;
try {
conn = ConnectionUtils.openConnection();
state = conn.prepareStatement(xin_msg);
state.setString(1, admin.getMima());
state.setInt(2, admin.getType());
state.setString(3, admin.getName());
System.out.println(admin.getType());
state.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
// 新增一名管理员
public void XingZeng(Adminstrator admin){
Connection conn = null;
PreparedStatement state = null;
try {
conn = ConnectionUtils.openConnection();
state = conn.prepareStatement(xinzeng);
state.setString(1, admin.getName());
state.setString(2, admin.getMima());
state.setInt(3, admin.getType());
state.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
//查询所有院系
public List<yuanxi_bean> find_yuanxiall(){
List<yuanxi_bean> list=new ArrayList<yuanxi_bean>();
String sql="select yuanxi_num,yuanxi_name from yuanxi";
Connection conn = null;
PreparedStatement state = null;
ResultSet res = null;
try {
conn = ConnectionUtils.openConnection();
state=conn.prepareStatement(sql);
res=state.executeQuery();
while(res.next()){
yuanxi_bean yuanxi=new yuanxi_bean();
yuanxi.setYuanxi_num(res.getInt(1));
yuanxi.setYuanxi_name(res.getString(2));
list.add(yuanxi);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
ConnectionUtils.closeConnection(conn);
}
return list;
}
//判断专业是否存在
public int judge_zhuanye(int major_num,String major_name){
int flag=0;
int count=0;
String sql="select count(*) from zhuanye where zhuanye_num=? or zhuanye_name=?";
Connection conn = null;
PreparedStatement state = null;
ResultSet res = null;
try {
conn = ConnectionUtils.openConnection();
state=conn.prepareStatement(sql);
state.setInt(1, major_num);
state.setString(2, major_name);
res=state.executeQuery();
while(res.next()){
count=res.getInt(1);
if(count!=0){
flag=0;
}else{
flag=1;
}
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
ConnectionUtils.closeConnection(conn);
}
return flag;
}
public void insert_zhuanye(int major_num,String major_name,String yuanxi_name,double zhuanye_money){
String sql="insert into zhuanye(zhuanye_num,zhuanye_name,yuanxi,class_num,feiyong) values(?,?,?,?,?)";
Connection conn = null;
PreparedStatement state = null;
ResultSet res = null;
try {
conn = ConnectionUtils.openConnection();
state=conn.prepareStatement(sql);
state.setInt(1, major_num);
state.setString(2, major_name);
state.setString(3, yuanxi_name);
state.setInt(4, 0);
state.setDouble(5, zhuanye_money);
state.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}fina
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
新生报名管理系统 (292个子文件)
Student_adminDao.class 19KB
Domitory_liveDao.class 10KB
StudentDao.class 7KB
SuSheDao.class 6KB
Sign_doAction.class 5KB
SearchMoneyServlet2.class 4KB
Student_money.class 4KB
Adminstrator.class 4KB
Student.class 4KB
CheckCode.class 4KB
Domitory_Dao.class 4KB
SearchMoneyDao1.class 4KB
yuanxi_bean.class 4KB
MoneyDao.class 4KB
student_reportservlet_1.class 4KB
Zhuanye.class 3KB
refer_data.class 3KB
ZhuanYe.class 3KB
DoAction.class 3KB
DoAction.class 3KB
Login.class 3KB
dormitory_liveServlet.class 3KB
Sushe.class 3KB
banji_servlet.class 3KB
domitoryFenpei_servlet.class 3KB
ShowSushe.class 3KB
PayMoney.class 3KB
find_dormitoryCase.class 3KB
student_reportservlet.class 3KB
dormitory_studentNum.class 2KB
class_setup.class 2KB
find_classServlet.class 2KB
AdminServlet.class 2KB
student_servlet.class 2KB
major_setup.class 2KB
insert_zhuanyeServlet.class 2KB
referbanji_servlet.class 2KB
find_dormitoryStudent.class 2KB
ConnectionUtils.class 2KB
SearchMoneyServlet.class 2KB
LookforStu.class 2KB
idnum_reportServlet.class 2KB
SearchZhuanye.class 2KB
SearchClass.class 2KB
add_majorServlet.class 2KB
domitory_bean.class 2KB
student_bean.class 1KB
major_bean.class 1KB
class_bean.class 1KB
myfilter.class 1KB
Zhuanye.class 1KB
.classpath 529B
org.eclipse.wst.common.component 465B
org.eclipse.wst.jsdt.ui.superType.container 49B
fox.css 7KB
skin.css 4KB
login-content-bg.gif 20KB
login-wel.gif 9KB
4.gif 5KB
3.gif 4KB
menu_bg2.gif 4KB
servicezhgb2312.gif 3KB
buttom-right.gif 2KB
ershou_1.gif 2KB
ershou_2.gif 2KB
menu_bgs.gif 2KB
1.gif 2KB
title.gif 2KB
sitebackup.gif 2KB
DefaultDocs.gif 2KB
menu_bg.gif 2KB
tool-down-pic.gif 2KB
buttom-left.gif 2KB
mime.gif 2KB
password.gif 2KB
ad.gif 2KB
lminfo.gif 2KB
defind.gif 2KB
ipsecurity.gif 2KB
user-info.gif 2KB
Redirects.gif 2KB
usercontrol.gif 2KB
menu_bg1.gif 1KB
2.gif 1KB
lm.gif 1KB
Login_but.gif 1KB
pic19.gif 1KB
menu_topline.gif 1KB
pic5.gif 1KB
pic23.gif 1KB
pic18.gif 1KB
yc.gif 1018B
out.gif 859B
nav-right-bg.gif 735B
pic16.gif 651B
icon-demo.gif 648B
icon-phone.gif 633B
icon-login-seaver.gif 633B
imageedit.gif 625B
edit.gif 624B
共 292 条
- 1
- 2
- 3
资源评论
hello灬java
- 粉丝: 0
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功