📄 patientaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.nitpro.action;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.sql.Array;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.apache.struts.action.ActionError;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.action.DynaActionForm;
import org.apache.struts.actions.DispatchAction;
import com.nitpro.dao.DAOFactory;
import com.nitpro.form.PatientForm;
/**
* MyEclipse Struts
* Creation date: 12-25-2007
*
* XDoclet definition:
* @struts.action path="/patient" name="patient" input="/index.jsp" parameter="methods" scope="request" validate="true"
*/
public class PatientAction extends DispatchAction {
/*
* Generated Methods
*/
/**
* Method execute
* @param mapping
* @param form
* @param request
* @param response
* @return ActionForward
*/
public ActionForward addPatient1(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
response.setContentType("text/html");
PatientForm patient = (PatientForm) form;
try {
patient.setPatient_id(new String(patient.getPatient_id().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_name(new String(patient.getPatient_name().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_sex(new String(patient.getPatient_sex().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_birth(new String(patient.getPatient_birth().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_address(new String(patient.getPatient_address().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_jiguan(new String(patient.getPatient_jiguan().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_state(new String(patient.getPatient_state().getBytes("ISO8859-1"),"GBK"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
int row = dao.getAllMethodDAO().addPatient(patient);
if(row==1){
request.setAttribute("onePatient", patient);
return mapping.findForward("insertSuccess");
}
else{
return null;
}
}
public ActionForward listPatient(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ArrayList patientList = new ArrayList();
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
patientList = dao.getAllMethodDAO().listPatient();
request.getSession().setAttribute("listPatient", patientList);
return mapping.findForward("listPatient");
}
public ActionForward selectPatient(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
request.setCharacterEncoding("gb2312");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.setContentType("text/xml;charset=GB2312");
response.setHeader("Cache-Control","no-cache");
String selectType = request.getParameter("selectType");
String selectMess = request.getParameter("selectMess");
try {
selectMess = new String(selectMess.getBytes("ISO8859-1"),"GBK");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
ArrayList patientList = new ArrayList();
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
patientList = dao.getAllMethodDAO().selectPatient(selectType, selectMess);
try {
response.getWriter().println("<?xml version='1.0' encoding='GB2312' ?>");
response.getWriter().println("<patient>");
Object[] object = (Object[]) patientList.toArray();
for(int i = 0;i<object.length;i++){
PatientForm patient = (PatientForm) object[i];
response.getWriter().println("<patientMess>");
response.getWriter().println("<id>");
response.getWriter().println(patient.getPatient_id());
response.getWriter().println("</id>");
response.getWriter().println("<name>");
response.getWriter().println(patient.getPatient_name());
response.getWriter().println("</name>");
response.getWriter().println("<sex>");
response.getWriter().println(patient.getPatient_sex());
response.getWriter().println("</sex>");
response.getWriter().println("<birth>");
response.getWriter().println(patient.getPatient_birth());
response.getWriter().println("</birth>");
response.getWriter().println("<address>");
response.getWriter().println(patient.getPatient_address());
response.getWriter().println("</address>");
response.getWriter().println("<jiguan>");
response.getWriter().println(patient.getPatient_jiguan());
response.getWriter().println("</jiguan>");
response.getWriter().println("<state>");
response.getWriter().println(patient.getPatient_state());
response.getWriter().println("</state>");
response.getWriter().println("<money>");
response.getWriter().println(patient.getPay_money());
response.getWriter().println("</money>");
response.getWriter().println("</patientMess>");
}
response.getWriter().println("</patient>");
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
public ActionForward deletePatient(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String patient_id = request.getParameter("patient_id");
System.out.println(patient_id);
ArrayList patientList = new ArrayList();
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
int row = dao.getAllMethodDAO().deletePatient(patient_id);
if(row==1){
patientList = dao.getAllMethodDAO().listPatient();
request.getSession().setAttribute("listPatient", patientList);
return mapping.findForward("listPatient");
}
return null;
}
public ActionForward updatePatient(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
PatientForm patient = (PatientForm) form;// TODO Auto-generated method stub
try {
patient.setPatient_id(new String(patient.getPatient_id().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_name(new String(patient.getPatient_name().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_sex(new String(patient.getPatient_sex().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_birth(new String(patient.getPatient_birth().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_address(new String(patient.getPatient_address().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_jiguan(new String(patient.getPatient_jiguan().getBytes("ISO8859-1"),"GBK"));
patient.setPatient_state(new String(patient.getPatient_state().getBytes("ISO8859-1"),"GBK"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
ArrayList patientList = new ArrayList();
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
int row = dao.getAllMethodDAO().updatePatient(patient);
if(row==1){
patientList = dao.getAllMethodDAO().listPatient();
request.getSession().setAttribute("listPatient", patientList);
return mapping.findForward("listPatient");
}
return null;
}
public ActionForward checkPatient(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
request.setCharacterEncoding("gb2312");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
response.setContentType("text/xml;charset=GB2312");
response.setHeader("Cache-Control","no-cache");
String patient_id = request.getParameter("patient_id");
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
int row = dao.getAllMethodDAO().selectPatient(patient_id);
System.out.println(row);
try {
response.getWriter().println(row);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -