第八篇

MyHospital08

UserDao.java

package com.chinasofti.hospital.user.dao;

import java.io.IOException;
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.chinasofti.hospital.user.sql.UserSql;
import com.chinasofti.hospital.user.vo.Department;
import com.chinasofti.hospital.user.vo.Doctor;
import com.chinasofti.hospital.user.vo.GuaHao;
import com.chinasofti.hospital.user.vo.Notice;
import com.chinasofti.hospital.user.vo.Patient;
import com.chinasofti.hospital.util.JDBCDao;
import com.chinasofti.hospital.util.JDBCUtil;
import com.chinasofti.hospital.util.PageHelper;






public class UserDao {

	public boolean findNameDao(String name) {
		// TODO Auto-generated method stub		
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		boolean bn=false;
		String patientName = null;
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.FIND_NAME);
			pstmt.setString(1, name);
			rs = pstmt.executeQuery();
			while(rs.next()){
				patientName = rs.getString(1);
				if (patientName!=null) {
					bn=true;
				} 
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {				
				e.printStackTrace();
			}
		}
		
		return bn;
	}

	public int registerDao(Patient patient) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.REGISTER);
			pstmt.setString(1, patient.getPATIENT_NAME());
			pstmt.setString(2, patient.getAccount());
			pstmt.setString(3, patient.getUserPwd());
			pstmt.setString(4, patient.getSex());
			pstmt.setString(5, patient.getAge());
			pstmt.setString(6, patient.getTelphone());
			pstmt.setString(7, patient.getMail());
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public String patientLoginDao(String userName) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;	
		String pwd = null;
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.PATIENT_LOGIN);
			pstmt.setString(1, userName);
			rs = pstmt.executeQuery();
			while(rs.next()){
				pwd = rs.getString(1);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {				
				e.printStackTrace();
			}
		}
		
		return pwd;
	}

	public String adminLoginDao(String adminName) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;	
		String apwd = null;
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.ADMIN_LOGIN);
			pstmt.setString(1, adminName);
			rs = pstmt.executeQuery();
			while(rs.next()){
				apwd = rs.getString(1);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {				
				e.printStackTrace();
			}
		}
		
		return apwd;
	}

	public String doctoLoginDao(String doctorName) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;	
		String dpwd = null;
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.DOCTOR_LOGIN);
			pstmt.setString(1, doctorName);
			rs = pstmt.executeQuery();
			while(rs.next()){
				dpwd = rs.getString(1);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {				
				e.printStackTrace();
			}
		}
		
		return dpwd;
	}

	public Doctor queryDoctorDao(String DOCTOR_NAME){
		// TODO Auto-generated method stub
		List<Doctor> doctor = JDBCDao.queryAll(Doctor.class, UserSql.SQL_QUERY_DOCTOR_BYNAME, DOCTOR_NAME);
		if(doctor.size()>0){
			return doctor.get(0);
		}
		return null;
	}

	public Department queryDepartmentDao(String DEPARTMENT_NAME) {
		// TODO Auto-generated method stub
		List<Department> department = JDBCDao.queryAll(Department.class, UserSql.SQL_QUERY_DEPARTMENT_BYNAME, DEPARTMENT_NAME);
		if(department.size()>0){
			return department.get(0);
		}
		return null;
	}

	public int getCountDao() {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		int result=0;
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.QUERY_DEPARTMENT_COUNT);
			rs=pstmt.executeQuery();
			while(rs.next()){
				result=rs.getInt(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return result;
	}

	public List<Department> queryDepartmentDao(PageHelper helper) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<Department> list = new ArrayList<>();
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.QUERY_DEPARTMENT_FENYE);
			pstmt.setInt(1, helper.getEnd());
			pstmt.setInt(2, helper.getStart());
			rs=pstmt.executeQuery();
			while(rs.next()){
				Department department =new Department();
				department.setDEPARTMENT_ID(rs.getString("DEPARTMENT_ID"));
				department.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				department.setDEPARTMENT_SYNOPSIS(rs.getString("DEPARTMENT_SYNOPSIS"));
				department.setDEPARTMENT_NOTICE_HEAD(rs.getString("DEPARTMENT_NOTICE_HEAD"));
				department.setDEPARTMENT_NOTICE_CONTENT(rs.getString("DEPARTMENT_NOTICE_CONTENT"));
				list.add(department);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return list;
	}

	public List<Doctor> queryDoctorDao(PageHelper helper) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<Doctor> list = new ArrayList<>();
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.QUERY_DOCTOR_FENYE);
			pstmt.setInt(1, helper.getEnd());
			pstmt.setInt(2, helper.getStart());
			rs=pstmt.executeQuery();
			while(rs.next()){
				Doctor doctor =new Doctor();
				doctor.setDOCTOR_ID(rs.getString("DOCTOR_ID"));
				doctor.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				doctor.setDOCTOR_NAME(rs.getString("DOCTOR_NAME"));
				doctor.setJOB_TITLE(rs.getString("JOB_TITLE"));
				doctor.setGOOD_JOB(rs.getString("GOOD_JOB"));
				list.add(doctor);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return list;
	}

	public int getCountDoctorDao() {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		int result=0;
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.QUERY_DOCTOR_COUNT);
			rs=pstmt.executeQuery();
			while(rs.next()){
				result=rs.getInt(1);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return result;
	}

	public boolean queryBySnameDao(String sname) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		boolean bn=false;
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.QUERY_DEPARTMENT_BY_NAME);
			pstmt.setString(1, sname);
			rs=pstmt.executeQuery();
			String sName = null;
			
			while(rs.next()){
				Department department =new Department();
				sName = rs.getString(1);
				System.out.println(sName);
				if (sName!=null) {
					bn=true;
				} 
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return bn;
	}

	public int registerGuaHaoDao(GuaHao guaHao) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.GUAHAOREGISTER);
			pstmt.setString(1, guaHao.getDEPARTMENT_NAME());
			pstmt.setString(2, guaHao.getWORK_TIME());
			pstmt.setString(3, guaHao.getDOCTOR_NAME());
			pstmt.setString(4, guaHao.getPATIENT_NAME());
			pstmt.setString(5, guaHao.getSEX());
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public List<Patient> patientQueryDao(String account) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<Patient> list =new ArrayList<Patient>();
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.PATIENT_QUERY_BY_ACCOUNT);
			pstmt.setString(1, account);
			rs = pstmt.executeQuery();
			while(rs.next()){
				Patient patient = new Patient();
				patient.setPATIENT_ID(rs.getString("PATIENT_ID"));
				patient.setPATIENT_NAME(rs.getString("PATIENT_NAME"));
				patient.setAccount(rs.getString("ACCOUNT"));
				patient.setUserPwd(rs.getString("USERPWD"));
				patient.setSex(rs.getString("SEX"));
				patient.setAge(rs.getString("AGE"));
				patient.setTelphone(rs.getString("TELPHONE"));
				patient.setMail(rs.getString("MAIL"));
				list.add(patient);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {
				e.printStackTrace();
			}
			
		}
		
		return list;
	}

	public List<GuaHao> guaHaoQueryDao(String PATIENT_NAME) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<GuaHao> list =new ArrayList<GuaHao>();
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.GuaHao_QUERY_BY_PATIENT_NAME);
			pstmt.setString(1, PATIENT_NAME);
			rs = pstmt.executeQuery();
			while(rs.next()){
				GuaHao guaHao = new GuaHao();
				guaHao.setGUAHAO_ID(rs.getString("GUAHAO_ID"));
				guaHao.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				guaHao.setWORK_TIME(rs.getString("WORK_TIME"));
				guaHao.setDOCTOR_NAME(rs.getString("DOCTOR_NAME"));
				guaHao.setMONEY(rs.getString("MONEY"));
				guaHao.setPATIENT_NAME(rs.getString("PATIENT_NAME"));
				guaHao.setSEX(rs.getString("SEX"));
				list.add(guaHao);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {
				e.printStackTrace();
			}
			
		}
		
		return list;
	}

	public int updatePatientDao(String account,Patient patient) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
		/*	Patient patient=new Patient()*/
			pstmt=conn.prepareStatement(UserSql.UPDATE_PATIENT_BY_ACCOUNT);
			pstmt.setString(1, patient.getUserPwd());
			pstmt.setString(2, patient.getSex());
			pstmt.setString(3, patient.getAge());
			pstmt.setString(4, patient.getTelphone());
			pstmt.setString(5, patient.getMail());
			pstmt.setString(6, account);
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public List<Doctor> doctorQueryDao(String DOCTOR_NAME) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<Doctor> list =new ArrayList<Doctor>();
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.DOCTOR_QUERY_BY_DOCTOR_NAME);
			pstmt.setString(1, DOCTOR_NAME);
			rs = pstmt.executeQuery();
			while(rs.next()){
				Doctor doctor =new Doctor();
				doctor.setDOCTOR_ID(rs.getString("DOCTOR_ID"));
				doctor.setPASSWORD(rs.getString("PASSWORD"));
				doctor.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				doctor.setDOCTOR_NAME(rs.getString("DOCTOR_NAME"));
				doctor.setJOB_TITLE(rs.getString("JOB_TITLE"));
				doctor.setGOOD_JOB(rs.getString("GOOD_JOB"));
				doctor.setJOB_SYNOPSIS(rs.getString("JOB_SYNOPSIS"));
				doctor.setINTRODUCTION(rs.getString("INTRODUCTION"));
				list.add(doctor);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {
				e.printStackTrace();
			}
			
		}
		
		return list;
	}

	public List<GuaHao> guaHaoQueryByDoctorNameDao(String DOCTOR_NAME) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<GuaHao> list =new ArrayList<GuaHao>();
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.GuaHao_QUERY_BY_DOCTOR_NAME);
			pstmt.setString(1, DOCTOR_NAME);
			rs = pstmt.executeQuery();
			while(rs.next()){
				GuaHao guaHao = new GuaHao();
				guaHao.setGUAHAO_ID(rs.getString("GUAHAO_ID"));
				guaHao.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				guaHao.setWORK_TIME(rs.getString("WORK_TIME"));
				guaHao.setDOCTOR_NAME(rs.getString("DOCTOR_NAME"));
				guaHao.setMONEY(rs.getString("MONEY"));
				guaHao.setPATIENT_NAME(rs.getString("PATIENT_NAME"));
				guaHao.setSEX(rs.getString("SEX"));
				list.add(guaHao);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {
				e.printStackTrace();
			}
			
		}
		
		return list;
	}

	public List<Doctor> queryAllDoctorDao() {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<Doctor> list =new ArrayList<Doctor>();
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.DOCTOR_QUERY_ALL);
			rs = pstmt.executeQuery();
			while(rs.next()){
				Doctor doctor =new Doctor();
				doctor.setDOCTOR_ID(rs.getString("DOCTOR_ID"));
				doctor.setPASSWORD(rs.getString("PASSWORD"));
				doctor.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				doctor.setDOCTOR_NAME(rs.getString("DOCTOR_NAME"));
				doctor.setJOB_TITLE(rs.getString("JOB_TITLE"));
				doctor.setGOOD_JOB(rs.getString("GOOD_JOB"));
				doctor.setJOB_SYNOPSIS(rs.getString("JOB_SYNOPSIS"));
				doctor.setINTRODUCTION(rs.getString("INTRODUCTION"));
				list.add(doctor);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {
				e.printStackTrace();
			}
			
		}
		
		return list;
	}

	public List<GuaHao> queryAllGuaHaoDao() {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<GuaHao> list =new ArrayList<GuaHao>();
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.GuaHao_QUERY_ALL);
			rs = pstmt.executeQuery();
			while(rs.next()){
				GuaHao guaHao = new GuaHao();
				guaHao.setGUAHAO_ID(rs.getString("GUAHAO_ID"));
				guaHao.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				guaHao.setWORK_TIME(rs.getString("WORK_TIME"));
				guaHao.setDOCTOR_NAME(rs.getString("DOCTOR_NAME"));
				guaHao.setMONEY(rs.getString("MONEY"));
				guaHao.setPATIENT_NAME(rs.getString("PATIENT_NAME"));
				guaHao.setSEX(rs.getString("SEX"));
				list.add(guaHao);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {
				e.printStackTrace();
			}
			
		}
		
		return list;
	}

	public List<Department> queryAllDepartmentDao() {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<Department> list = new ArrayList<>();
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.QUERY_DEPARTMENT_ALL);
			rs=pstmt.executeQuery();
			while(rs.next()){
				Department department =new Department();
				department.setDEPARTMENT_ID(rs.getString("DEPARTMENT_ID"));
				department.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				department.setDEPARTMENT_SYNOPSIS(rs.getString("DEPARTMENT_SYNOPSIS"));
				department.setDEPARTMENT_NOTICE_HEAD(rs.getString("DEPARTMENT_NOTICE_HEAD"));
				department.setDEPARTMENT_NOTICE_CONTENT(rs.getString("DEPARTMENT_NOTICE_CONTENT"));
				list.add(department);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return list;
	}

	public String queryPatientByNameDao(String PATIENT_NAME) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		String account = null;
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.QUERY_ACCOUNT_BY_PATIENT_NAME);
			pstmt.setString(1, PATIENT_NAME);
			rs = pstmt.executeQuery();
			while(rs.next()){
				account = rs.getString(1);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {				
				e.printStackTrace();
			}
		}
		
		return account;
	}

	public int updateDoctortDao(String DOCTOR_ID, Doctor doctor) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
		/*	Patient patient=new Patient()*/
			pstmt=conn.prepareStatement(UserSql.UPDATE_DOCTOR_BY_DOCTOR_ID);
			pstmt.setString(1, doctor.getDOCTOR_NAME());
			pstmt.setString(2, doctor.getPASSWORD());
			pstmt.setString(3, doctor.getDEPARTMENT_NAME());
			pstmt.setString(4, doctor.getJOB_TITLE());
			pstmt.setString(5, doctor.getGOOD_JOB());
			pstmt.setString(6, doctor.getJOB_SYNOPSIS());
			pstmt.setString(7, doctor.getINTRODUCTION());
			pstmt.setString(8,DOCTOR_ID);
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public int deleteDoctortDao(String DOCTOR_ID) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
		/*	Patient patient=new Patient()*/
			pstmt=conn.prepareStatement(UserSql.DELETE_DOCTOR_BY_DOCTOR_ID);
			pstmt.setString(1, DOCTOR_ID);
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public int updateDepartmentDao(String DEPARTMENT_ID, Department department) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
		/*	Patient patient=new Patient()*/
			pstmt=conn.prepareStatement(UserSql.UPDATE_DEPARTMENT_BY_DEPARTMENT_ID);
			pstmt.setString(1, department.getDEPARTMENT_SYNOPSIS());
			pstmt.setString(2, department.getDEPARTMENT_NOTICE_CONTENT());
			pstmt.setString(3, department.getDEPARTMENT_NOTICE_HEAD());
			pstmt.setString(4,DEPARTMENT_ID);
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public int deleteDepartmentDao(String DEPARTMENT_ID) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
		/*	Patient patient=new Patient()*/
			pstmt=conn.prepareStatement(UserSql.DELETE_DEPARTMENT_BY_DEPARTMENT_ID);
			pstmt.setString(1, DEPARTMENT_ID);
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public int addDoctortDao(Doctor doctor) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
		/*	Patient patient=new Patient()*/
			pstmt=conn.prepareStatement(UserSql.ADD_DOCTOR);
			pstmt.setString(1, doctor.getDOCTOR_ID());
			pstmt.setString(2, doctor.getDOCTOR_NAME());
			pstmt.setString(3, doctor.getPASSWORD());
			pstmt.setString(4, doctor.getDEPARTMENT_NAME());
			pstmt.setString(5, doctor.getJOB_TITLE());
			pstmt.setString(6, doctor.getGOOD_JOB());
			pstmt.setString(7, doctor.getJOB_SYNOPSIS());
			pstmt.setString(8, doctor.getINTRODUCTION());
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public int addDepartmentDao(Department department) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
		/*	Patient patient=new Patient()*/
			pstmt=conn.prepareStatement(UserSql.ADD_DEPARTMENT);
			pstmt.setString(1, department.getDEPARTMENT_NAME());
			pstmt.setString(2, department.getDEPARTMENT_SYNOPSIS());
			pstmt.setString(3, department.getDEPARTMENT_NOTICE_CONTENT());
			pstmt.setString(4, department.getDEPARTMENT_NOTICE_HEAD());
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public int addNoticeDao(Notice notice) {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt=null;
		int num=0;
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.ADD_NOTICE);
			pstmt.setString(1, notice.getNOTICE_HEAD());
			pstmt.setString(2, notice.getNOTICE_CONTENT());
			num=pstmt.executeUpdate();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return num;
	}

	public List<Notice> noticeQueryDao() {
		// TODO Auto-generated method stub
		Connection conn=null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<Notice> list = new ArrayList<>();
		try {
			conn=JDBCUtil.getConn();
			pstmt=conn.prepareStatement(UserSql.QUERY_NOTICE_ALL);
			rs=pstmt.executeQuery();
			while(rs.next()){
				Notice notice =new Notice();
				notice.setNOTICE_HEAD(rs.getString("NOTICE_HEAD"));
				notice.setNOTICE_CONTENT(rs.getString("NOTICE_CONTENT"));
				list.add(notice);
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally{
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			} catch (SQLException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		
		return list;
	}

	public List<Doctor> queryDoctorByDepartmentNameDao(String DEPARTMENT_NAME) {
		// TODO Auto-generated method stub
		Connection conn = null;
		PreparedStatement pstmt = null;
		ResultSet rs = null;
		List<Doctor> list =new ArrayList<Doctor>();
		try {
			conn = JDBCUtil.getConn();
			pstmt = conn.prepareStatement(UserSql.DOCTOR_QUERY_BY_DEPARTMENT_NAME);
			pstmt.setString(1, DEPARTMENT_NAME);
			rs = pstmt.executeQuery();
			while(rs.next()){
				Doctor doctor =new Doctor();
				doctor.setDOCTOR_ID(rs.getString("DOCTOR_ID"));
				doctor.setPASSWORD(rs.getString("PASSWORD"));
				doctor.setDEPARTMENT_NAME(rs.getString("DEPARTMENT_NAME"));
				doctor.setDOCTOR_NAME(rs.getString("DOCTOR_NAME"));
				doctor.setJOB_TITLE(rs.getString("JOB_TITLE"));
				doctor.setGOOD_JOB(rs.getString("GOOD_JOB"));
				doctor.setJOB_SYNOPSIS(rs.getString("JOB_SYNOPSIS"));
				doctor.setINTRODUCTION(rs.getString("INTRODUCTION"));
				list.add(doctor);
			}
		}
		catch (SQLException e) {
			e.printStackTrace();
		}finally {
			try {
				JDBCUtil.CloseAll(conn, pstmt, rs);
			}
			catch (SQLException e) {
				e.printStackTrace();
			}
			
		}
		
		return list;
	}
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
孙子兵法的第七篇至第十三篇,分别是兵势、军争、九变、行军、地形、九地、虚实,这些篇章是关于作战策略和战术的进一步讲解。 第七篇《兵势篇》论述的是军队的优劣势和制胜的方法。孙子认为,战争中最重要的是兵势,即军队的整体态势和形势,只有充分利用兵势,才能制胜于敌。这篇篇章主要包括了以下几个方面的内容: 1. 分析兵势的形式:孙子在这里提出了九种不同的兵势形式,包括势均力敌、攻其不备、出奇制胜、以逸待劳、以进为退、虚实相生、形如棋局、变化莫测、水能载舟,亦能覆舟。 2. 论述兵势的变化:孙子认为,兵势不断变化,战场上的胜利者往往是能够适应变化的人。他提出了“势生因变化,变化因乘势”的观点,强调了灵活应对变化的重要性。 3. 论述兵势的利用:孙子认为,兵势的利用需要在多方面考虑,包括战争的时间、地点、人员等。他提出了“知己知彼,百战不殆”的观点,强调了充分了解自己和敌人的重要性。 第八篇《军争篇》主要论述了战争的规模、作战的目标和策略,以及如何应对各种情况。这篇篇章主要包括了以下几个方面的内容: 1. 论述作战的目标:孙子认为,战争的目标不应该仅仅是摧毁敌人的军队,而应该是达到一定的政治目的。他提出了“战争的终极目标是和平”这一观点。 2. 论述如何取胜:孙子提出了“攻其无备,出其不意”这一战争策略,强调了在作战中利用敌人的弱点和意外性的重要性。 3. 论述军队的规模和组织:孙子认为,军队的规模不是唯一的决定性因素,重要的是军队的组织和指挥。他

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值