package com.cxd.hospital.dao.imp;
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.cxd.hospital.dao.BuildDao;
import com.cxd.hospital.db.DB;
import com.cxd.hospital.jopo.Bed;
import com.cxd.hospital.jopo.Building;
import com.cxd.hospital.jopo.Floor;
import com.cxd.hospital.jopo.Room;
import com.cxd.hospital.jopo.Sicker;
public class BuildDaoImp implements BuildDao {
private Connection conn;
private PreparedStatement pstmt;
private ResultSet rs;
public List<Building> getAllBuilding() {
List<Building> list = new ArrayList<Building>();
conn = DB.getConnection();
String sql = "select id,name from building";
try {
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()){
Building b = new Building();
b.setId(rs.getInt(1));
b.setName(rs.getString(2));
list.add(b);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
return list;
}
public List<Floor> getFloorByBuildingId(int id) {
List<Floor> list = new ArrayList<Floor>();
conn = DB.getConnection();
String sql = "select id,name from floors where building_id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
rs = pstmt.executeQuery();
while(rs.next()){
Floor f = new Floor();
f.setId(rs.getInt(1));
f.setName(rs.getString(2));
list.add(f);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
return list;
}
public List<Room> getRoomByFloorId(int id) {
List<Room> list = new ArrayList<Room>();
conn = DB.getConnection();
String sql = "select id,name from room where f_id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
rs = pstmt.executeQuery();
while(rs.next()){
Room r = new Room();
r.setId(rs.getInt(1));
r.setName(rs.getString(2));
list.add(r);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
return list;
}
public List<Bed> getBedByRoomId(int id) {
List<Bed> list = new ArrayList<Bed>();
conn = DB.getConnection();
String sql = "select b.id,b.name,b.price,b.descr,b.stat,s.id,s.name,s.age,s.sex,s.workplace from bed b,sicker s where s.id=b.s_id and r_id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
rs = pstmt.executeQuery();
while(rs.next()){
Bed bed = new Bed();
Sicker sicker = new Sicker();
bed.setSicker(sicker);
bed.setId(rs.getInt(1));
bed.setName(rs.getString(2));
bed.setPrice(rs.getFloat(3));
bed.setDesc(rs.getString(4));
bed.setState(rs.getInt(5));
sicker.setId(rs.getInt(6));
sicker.setName(rs.getString(7));
sicker.setAge(rs.getInt(8));
sicker.setSex(rs.getInt(9));
sicker.setWorkPlace(rs.getString(10));
list.add(bed);
}
sql = "select id,name,price,descr,stat from bed where r_id=? and s_id is null";
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
rs = pstmt.executeQuery();
while(rs.next()){
Bed bed = new Bed();
Sicker sicker = new Sicker();
bed.setSicker(sicker);
bed.setId(rs.getInt(1));
bed.setName(rs.getString(2));
bed.setPrice(rs.getFloat(3));
bed.setDesc(rs.getString(4));
bed.setState(rs.getInt(5));
list.add(bed);
}
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
return list;
}
public void addRoom(String name, int floor) {
conn = DB.getConnection();
String sql = "insert into room(name,f_id) values(?,?)";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setInt(2, floor);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void addFloor(String name, int building) {
conn = DB.getConnection();
String sql = "insert into floors(name,building_id) values(?,?)";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setInt(2, building);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void addBuilding(String name) {
conn = DB.getConnection();
String sql = "insert into building(name) values(?)";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void deleteBuilding(int id) {
conn = DB.getConnection();
String sql = "delete from building where id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void deleteFloor(int id) {
conn = DB.getConnection();
String sql = "delete from floors where id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void deleteRoom(int id) {
conn = DB.getConnection();
String sql = "delete from room where id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void deleteBed(int id) {
conn = DB.getConnection();
String sql = "delete from bed where id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setInt(1, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void updateBuilding(int id, String name) {
conn = DB.getConnection();
String sql = "update building set name=? where id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setInt(2, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void updateFloor(int id, String name) {
conn = DB.getConnection();
String sql = "update floors set name=? where id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setInt(2, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void updateRoom(int id, String name) {
conn = DB.getConnection();
String sql = "update room set name=? where id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setInt(2, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
public void updateBed(int id, String name, float price) {
conn = DB.getConnection();
String sql = "update bed set name=?,price=? where id=?";
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, name);
pstmt.setFloat(2, price);
pstmt.setInt(3, id);
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}finally{
DB.close(rs, pstmt, conn);
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
社区医院信息管理系统的设计
共297个文件
class:68个
java:68个
htm:54个
需积分: 50 18 下载量 12 浏览量
2015-04-26
22:16:07
上传
评论 1
收藏 1.64MB RAR 举报
温馨提示
在此社区医院管理系统中,技术路线前期采用servlet为主,同时使用了ajax技术,后期的编写中,除了servlet和ajax技术之外,用到了一些jsp在页面中处理的技术,提供了系统页面的丰富度和完整度。
资源推荐
资源详情
资源评论
收起资源包目录
社区医院信息管理系统的设计 (297个子文件)
BuildDaoImp.class 9KB
MedctionDaoImp.class 8KB
BedDaoImp.class 7KB
UserDaoImp.class 6KB
RecordDaoImp.class 6KB
DeptDaoImp.class 5KB
Register.class 4KB
Bed.class 3KB
MedTypeDaoImp.class 3KB
Build.class 3KB
SickerDaoImp.class 3KB
Sicker_add.class 2KB
User_update.class 2KB
Record.class 2KB
User_add.class 2KB
CheckLoginFilter.class 2KB
User_changePwd.class 2KB
Record_register.class 2KB
Medction_add.class 2KB
Bed_add.class 2KB
Dept_upd.class 2KB
Dept_add.class 2KB
User_login.class 2KB
Sicker_register.class 2KB
User_reset.class 2KB
MedType_update.class 2KB
Bed_live.class 2KB
Room_add.class 2KB
Bed_update.class 2KB
Bed_update2.class 2KB
User.class 2KB
Floor.class 2KB
DB.class 2KB
Room.class 2KB
Building_update.class 2KB
Bed_xf.class 2KB
Floor_add.class 2KB
Floor_update.class 2KB
Room_update.class 2KB
Medction_changeNum.class 2KB
Dept_update.class 2KB
Medction_getOk.class 2KB
EncodingFilter.class 2KB
Bed_liveOut.class 2KB
Building_add.class 2KB
MedType_add.class 2KB
Medction.class 2KB
Dept_del.class 2KB
Building_delete.class 2KB
Medction_delete.class 2KB
MedType_delete.class 1KB
Floor_delete.class 1KB
Room_delete.class 1KB
Sicker.class 1KB
Bed_delete.class 1KB
User_del.class 1KB
Bed_out.class 1KB
Building.class 1KB
Dept.class 1KB
BuildDao.class 866B
MedType.class 733B
MedctionDao.class 597B
UserDao.class 555B
BedDao.class 496B
RecordDao.class 493B
DeptDao.class 378B
MedTypeDao.class 352B
SickerDao.class 230B
css.css 16KB
style.css 11KB
head.css 6KB
control.css 5KB
common1.css 4KB
style0.css 1KB
welcome.gif 164KB
top03.gif 15KB
ico15.gif 8KB
ico14.gif 8KB
ico16.gif 8KB
ico13.gif 7KB
logo.gif 6KB
pic05.gif 5KB
nav03.gif 4KB
nav01.gif 4KB
shape01.gif 3KB
ico02.gif 2KB
ico24.gif 1KB
nav02.gif 1KB
ico07.gif 1KB
line01.gif 935B
navbutton04.gif 662B
ico01.gif 654B
navbutton02.gif 635B
navbutton03.gif 576B
top02.gif 559B
navbutton01.gif 547B
loadon.gif 538B
dhbutton02.gif 499B
dhbutton04.gif 499B
dhbutton03.gif 499B
共 297 条
- 1
- 2
- 3
资源评论
s278190002
- 粉丝: 1
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- #P0015. 全排列 超级简单
- pta题库答案c语言之排序4统计工龄.zip
- pta题库答案c语言之树结构7堆中的路径.zip
- pta题库答案c语言之树结构3TreeTraversalsAgain.zip
- pta题库答案c语言之树结构2ListLeaves.zip
- pta题库答案c语言之树结构1树的同构.zip
- 基于C++实现民航飞行与地图简易管理系统可执行程序+说明+详细注释.zip
- pta题库答案c语言之复杂度1最大子列和问题.zip
- 三维装箱问题(Three-Dimensional Bin Packing Problem,3D-BPP)是一个经典的组合优化问题
- 以下是一些关于Linux线程同步的基本概念和方法.txt
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功