📄 allmethod.java
字号:
pf.setPatient_num(rs.getInt(1));
pf.setPatient_id(rs.getString(2));
pf.setPatient_name(rs.getString(3));
pf.setPatient_sex(rs.getString(4));
pf.setPatient_birth(rs.getString(5));
pf.setPatient_address(rs.getString(6));
pf.setPatient_jiguan(rs.getString(7));
pf.setPatient_state(rs.getString(8));
pf.setPay_money(rs.getInt(9));
pf.setIsdelete(rs.getString(10));
patientList.add(pf);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closeStatement(stmt);
MySQLDAOFactory.closeConnection(conn);
}
return patientList;
}
public ArrayList selectPatient(String selectType,String selectMess){
ArrayList patientList = new ArrayList();
String sql = "select * from patient_message where "+selectType+" like'%"+selectMess+"%'";
conn = MySQLDAOFactory.getConnection();
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()){
PatientForm pf = new PatientForm();
pf.setPatient_num(rs.getInt(1));
pf.setPatient_id(rs.getString(2));
pf.setPatient_name(rs.getString(3));
pf.setPatient_sex(rs.getString(4));
pf.setPatient_birth(rs.getString(5));
pf.setPatient_address(rs.getString(6));
pf.setPatient_jiguan(rs.getString(7));
pf.setPatient_state(rs.getString(8));
pf.setPay_money(rs.getInt(9));
pf.setIsdelete(rs.getString(10));
patientList.add(pf);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closeStatement(stmt);
MySQLDAOFactory.closeConnection(conn);
}
return patientList;
}
public int deletePatient(String patient_id){
int row = 0;
String sql = "update patient_message set isdelete='Y' where patient_id=?";
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
ps.setString(1, patient_id);
row = ps.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return row;
}
public int updatePatient(PatientForm form){
int row = 0;
String sql = "update patient_message set patient_name=?,patient_sex=?," +
"patient_birth=?,patient_address=?,patient_jiguan=?,patient_state=?,pay_money=? " +
"where patient_id=?";
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
ps.setString(1, form.getPatient_name());
ps.setString(2, form.getPatient_sex());
ps.setString(3, form.getPatient_birth());
ps.setString(4, form.getPatient_address());
ps.setString(5, form.getPatient_jiguan());
ps.setString(6, form.getPatient_state());
ps.setInt(7,form.getPay_money());
ps.setString(8, form.getPatient_id());
row = ps.executeUpdate();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally{
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return row;
}
public int selectPatient(String patient_id){
ArrayList patientList = new ArrayList();
String sql = "select count(*) from patient_message where patient_id='"+patient_id+"'";
int row = 0;
conn = MySQLDAOFactory.getConnection();
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if(rs.next()){
row = rs.getInt(1);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closeStatement(stmt);
MySQLDAOFactory.closeConnection(conn);
}
return row;
}
public String[][] selectMedicine_type_list(){
String[][] ss = null;
String sql = "select * from medicine_type_list";
conn = MySQLDAOFactory.getConnection();
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
rs.last();
ss = new String[rs.getRow()][2];
rs.beforeFirst();
int i =0;
while(rs.next()){
ss[i][0]=rs.getString(1);
ss[i][1]=rs.getString(2);
i++;
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closeStatement(stmt);
MySQLDAOFactory.closeConnection(conn);
}
return ss;
}
public String[][] selectPrice_management(String type_id){
String[][] ss = null;
String sql = "select medicine_id,medicine_name from price_management where type_id='"+type_id+"' and isdelete='N'";
conn = MySQLDAOFactory.getConnection();
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
rs.last();
ss = new String[rs.getRow()][2];
rs.beforeFirst();
int i =0;
while(rs.next()){
ss[i][0]=rs.getString(1);
ss[i][1]=rs.getString(2);
i++;
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closeStatement(stmt);
MySQLDAOFactory.closeConnection(conn);
}
return ss;
}
//对see_doctor_message表插入数据
public boolean insertSee_doctor_message(See_doctor_messageForm sdmForm){
boolean boo = false;
String sql = "insert into see_doctor_message(patient_id,department,doctor_id,sickness_reason,medicine_list,isdelete) values(?,?,?,?,?,?)";
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
ps.setString(1, sdmForm.getPatient_id());
ps.setString(2, sdmForm.getDepartment());
ps.setString(3, sdmForm.getDoctor_id());
ps.setString(4, sdmForm.getSickness_reason());
ps.setString(5, sdmForm.getMedicine_list());
ps.setString(6, "N");
int i = ps.executeUpdate();
if(i==1){
boo = true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return boo;
}
//分页查询病人就医信息
public ArrayList selectSee_doctor_message(int pagerows,int strdata ){
ArrayList list = new ArrayList();
String sql = "select d.doctor_id,d.doctor_name,p.patient_id,p.patient_name,s.list_number,s.department,s.sickness_reason,s.medicine_list " +
"from see_doctor_message s " +
"left join patient_message p on p.patient_id=s.patient_id " +
"left join doctor_message d on d.doctor_id=s.doctor_id " +
"where s.isdelete='N' limit "+strdata+","+pagerows;
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
while(rs.next()){
See_doctor_messageForm sdmForm = new See_doctor_messageForm();
sdmForm.setDoctor_id(rs.getString(1));
sdmForm.setDoctor_name(rs.getString(2));
sdmForm.setPatient_id(rs.getString(3));
sdmForm.setPatient_name(rs.getString(4));
sdmForm.setList_number(rs.getInt(5));
sdmForm.setDepartment(rs.getString(6));
sdmForm.setSickness_reason(rs.getString(7));
sdmForm.setMedicine_list(rs.getString(8));
sdmForm.setSstr_medicine_id(splitStr(sdmForm.getMedicine_list()));
sdmForm.setSstr_medicine_name(selectMedicine_name(sdmForm.getSstr_medicine_id()));
sdmForm.setMedicine_name_list(hcStr(sdmForm.getSstr_medicine_name()));
list.add(sdmForm);
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return list;
}
//根据medicine_id查询medicine_name,返回medicine_name数组
public String[] selectMedicine_name(String[] str){
String[] sstr = new String[str.length];
PreparedStatement ps1 = null;
ResultSet rs1 = null;
Connection conn1 = MySQLDAOFactory.getConnection();
try {
for(int i=0;i<str.length;i++){
String sql = "select medicine_name from price_management where medicine_id='";
sql=sql+str[i]+"'";
ps1 = conn1.prepareStatement(sql);
rs1 = ps1.executeQuery();
if(rs1.next()){
sstr[i]=rs1.getString(1);
}
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closeResultSet(rs1);
MySQLDAOFactory.closePreparedStatement(ps1);
MySQLDAOFactory.closeConnection(conn1);
}
return sstr;
}
//查询就医表的记录数
public int contSee_doctor_message(){
Integer count = null;
String sql = "select count(*) from see_doctor_message where isdelete!='Y'";
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
rs = ps.executeQuery();
if(rs.next()){
count = rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return count;
}
//根据list_number删除病人就医档案
public boolean delectSee_doctor_message(int list_number){
boolean boo = false;
String sql = "update see_doctor_message set isdelete='Y' where list_number="+list_number;
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
int i = ps.executeUpdate();
if(i==1){
boo = true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return boo;
}
//根据list_number查询see_doctor_message,返回See_doctor_messageForm
public See_doctor_messageForm selectSee_doctor_message(int list_number){
See_doctor_messageForm sdmForm = new See_doctor_messageForm();
String sql = "select * from see_doctor_message";
conn = MySQLDAOFactory.getConnection();
try {
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if(rs.next()){
sdmForm.setList_number(rs.getInt(1));
sdmForm.setPatient_id(rs.getString(2));
sdmForm.setDepartment(rs.getString(3));
sdmForm.setDoctor_id(rs.getString(4));
sdmForm.setSickness_reason(rs.getString(5));
sdmForm.setMedicine_list(rs.getString(6));
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closeStatement(stmt);
MySQLDAOFactory.closeConnection(conn);
}
return sdmForm;
}
//根据list_number更新see_doctor_message
public boolean updateSee_doctor_message(See_doctor_messageForm sdmForm){
boolean boo = false;
String sql = "update see_doctor_message set department=?,doctor_id=?,sickness_reason=?,medicine_list=? where list_number=?";
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
ps.setString(1, sdmForm.getDepartment());
ps.setString(2, sdmForm.getDoctor_id());
ps.setString(3, sdmForm.getSickness_reason());
ps.setString(4, sdmForm.getMedicine_list());
ps.setInt(5, sdmForm.getList_number());
int i = ps.executeUpdate();
if(i==1){
boo = true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return boo;
}
//查询是否存在该病人patient_id
public boolean isExsitPatient_id(String patient_id){
boolean boo = false;
String sql = "select * from patient_message where patient_id=? and isdelete='N'";
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
ps.setString(1, patient_id);
rs = ps.executeQuery();
if(rs.next()){
boo = true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return boo;
}
//根据doctor_id查询是否存在该医生
public boolean isExsitDoctor_id(String doctor_id){
boolean boo = false;
String sql = "select * from doctor_message where doctor_id=? and isdelete='N'";
conn = MySQLDAOFactory.getConnection();
try {
ps = conn.prepareStatement(sql);
ps.setString(1, doctor_id);
rs = ps.executeQuery();
if(rs.next()){
boo = true;
}
} catch (SQLException e) {
e.printStackTrace();
} finally{
MySQLDAOFactory.closeResultSet(rs);
MySQLDAOFactory.closePreparedStatement(ps);
MySQLDAOFactory.closeConnection(conn);
}
return boo;
}
//将传来的String数组以"、"合成为一个String
public String hcStr(String[] sstr){
String str = "";
if(sstr.length==0){
}else{
for(int i=0;i<sstr.length;i++){
if(i==0){
str+=sstr[i];
}else{
str+="、"+sstr[i];
}
}
}
return str;
}
//将String按“、”折开为数组
public String[] splitStr(String str){
String[] sstr = null;
sstr = str.split("、");
return sstr;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -