📄 see_doctor_messageaction.java
字号:
/*
* Generated by MyEclipse Struts
* Template path: templates/java/JavaClass.vtl
*/
package com.nitpro.action;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.nitpro.dao.DAOFactory;
import com.nitpro.form.PageForm;
import com.nitpro.form.See_doctor_messageForm;
/**
* MyEclipse Struts
* Creation date: 12-25-2007
*
* XDoclet definition:
* @struts.action path="/see_doctor_message" name="see_doctor_messageForm" parameter="see_doctor_message" scope="request"
*/
public class See_doctor_messageAction extends DispatchAction {
/*
* Generated Methods
*/
public ActionForward selectSDMList(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
String tar = request.getParameter("tar");
String tag1 = request.getParameter("tag1");
if(tar!=null){
PageForm pf = new PageForm();
pf.setCont(dao.getAllMethodDAO().contSee_doctor_message());
pf.setPagerows(10);
pf.setCpage(1);
pf.setAllpage(pf.getCont(),pf.getPagerows());
pf.setStrdata(pf.getPagerows(), pf.getCpage());
ArrayList pList = new ArrayList();
pList.add(pf);
request.setAttribute("pList", pList);
ArrayList list = new ArrayList();
list = dao.getAllMethodDAO().selectSee_doctor_message(pf.getPagerows(), pf.getStrdata());
request.setAttribute("list", list);
}else{
PageForm pf = new PageForm();
pf.setCont(dao.getAllMethodDAO().contSee_doctor_message());
if(tag1==null){
//点击了按钮GO
pf.setPagerows(strToint(request.getParameter("Pagerows")));
pf.setAllpage(pf.getCont(),pf.getPagerows());
pf.setPpage(strToint(request.getParameter("ppage")));
if(pf.getPpage()>pf.getAllpage()){
pf.setCpage(pf.getAllpage());
}else{
if(pf.getPpage()<1){
pf.setCpage(1);
}else{
pf.setCpage(pf.getPpage());
}
}
pf.setAllpage(pf.getCont(),pf.getPagerows());
pf.setStrdata(pf.getPagerows(), pf.getCpage());
}else{
//点超链接时
pf.setPagerows(strToint(request.getParameter("pagerows")));
pf.setAllpage(pf.getCont(),pf.getPagerows());
if(tag1.equals("SY")){
pf.setCpage(1);
pf.setStrdata(pf.getPagerows(), pf.getCpage());
}
if(tag1.equals("SYY")){
String strPP = request.getParameter("cpage");
Integer intPP = Integer.parseInt(strPP);
pf.setCpage(intPP-1);
pf.setStrdata(pf.getPagerows(), pf.getCpage());
}
if(tag1.equals("XYY")){
String strPP = request.getParameter("cpage");
Integer intPP = Integer.parseInt(strPP);
pf.setCpage(intPP+1);
pf.setStrdata(pf.getPagerows(), pf.getCpage());
}
if(tag1.equals("MY")){
pf.setCpage(pf.getAllpage());
pf.setStrdata(pf.getPagerows(), pf.getCpage());
}
}
ArrayList list = dao.getAllMethodDAO().selectSee_doctor_message(pf.getPagerows(), pf.getStrdata());
ArrayList pList = new ArrayList();
pList.add(pf);
request.setAttribute("pList", pList);
request.setAttribute("list", list);
}
return mapping.findForward("selectMain");
}
public ActionForward addAccess(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
See_doctor_messageForm see_doctor_messageForm = (See_doctor_messageForm) form;// TODO Auto-generated method stub
//System.out.println(see_doctor_messageForm.getPatient_id());
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
boolean boo = dao.getAllMethodDAO().isExsitPatient_id(see_doctor_messageForm.getPatient_id());
if(!boo){
request.setAttribute("tar", "不存在此<font color=red>"+see_doctor_messageForm.getPatient_id()+"</font>病人ID!");
return mapping.findForward("mained");
}
String[][] ssMTL = dao.getAllMethodDAO().selectMedicine_type_list();
ArrayList list = new ArrayList();
for(int i=0;i<ssMTL.length;i++){
String[][] ssPM = dao.getAllMethodDAO().selectPrice_management(ssMTL[i][0]);
String[] sstr = new String[1+ssPM.length*2];
sstr[0]=ssMTL[i][1];
int j=1;
for(int k=0;k<ssPM.length;k++,j++){
sstr[j]=ssPM[k][0];
j+=1;
sstr[j]=ssPM[k][1];
}
list.add(sstr);
request.setAttribute("patient_id", see_doctor_messageForm.getPatient_id());
request.setAttribute("list", list);
}
return mapping.findForward("addMassage");
}
public ActionForward insertSDM(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
try {
request.setCharacterEncoding("GBK");
response.setCharacterEncoding("GBK");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
See_doctor_messageForm see_doctor_messageForm = (See_doctor_messageForm) form;// TODO Auto-generated method stub
try {
see_doctor_messageForm.setDepartment(new String(see_doctor_messageForm.getDepartment().getBytes("ISO-8859-1"),"GBK"));
see_doctor_messageForm.setMedicine_list(new String(see_doctor_messageForm.getMedicine_list().getBytes("ISO-8859-1"),"GBK"));
see_doctor_messageForm.setSickness_reason(new String(see_doctor_messageForm.getSickness_reason().getBytes("ISO-8859-1"),"GBK"));
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
boolean isExist = dao.getAllMethodDAO().isExsitDoctor_id(see_doctor_messageForm.getDoctor_id());
if(!isExist){
request.setAttribute("tar", "不存在该<font color=red>"+see_doctor_messageForm.getDoctor_id()+"</font>医生ID!");
return mapping.findForward("mained");
}
String list_number = request.getParameter("list_number");
if(list_number==null){
boolean boo = dao.getAllMethodDAO().insertSee_doctor_message(see_doctor_messageForm);
if(boo){
request.setAttribute("tar", "插入成功!");
}else{
request.setAttribute("tar", "插入失败!");
}
}else{
see_doctor_messageForm.setList_number(strToint(list_number));
boolean boo = dao.getAllMethodDAO().updateSee_doctor_message(see_doctor_messageForm);
if(boo){
request.setAttribute("tar", "更新成功!");
}else{
request.setAttribute("tar", "更新失败!");
}
}
return mapping.findForward("mained");
}
public ActionForward deleteSDM(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//See_doctor_messageForm see_doctor_messageForm = (See_doctor_messageForm) form;// TODO Auto-generated method stub
int list_number = strToint(request.getParameter("list_number"));
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
boolean boo = dao.getAllMethodDAO().delectSee_doctor_message(list_number);
if(boo){
request.setAttribute("tar", "删除成功");
}else{
request.setAttribute("tar", "删除失败");
}
return mapping.findForward("mained");
}
public ActionForward updateSDM(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//See_doctor_messageForm see_doctor_messageForm = (See_doctor_messageForm) form;// TODO Auto-generated method stub
DAOFactory dao = DAOFactory.getDAOFactory(DAOFactory.MYSQL);
int list_number = strToint(request.getParameter("list_number"));
See_doctor_messageForm sdmForm = new See_doctor_messageForm();
sdmForm = dao.getAllMethodDAO().selectSee_doctor_message(list_number);
String[][] ssMTL = dao.getAllMethodDAO().selectMedicine_type_list();
ArrayList list = new ArrayList();
for(int i=0;i<ssMTL.length;i++){
String[][] ssPM = dao.getAllMethodDAO().selectPrice_management(ssMTL[i][0]);
String[] sstr = new String[1+ssPM.length*2];
sstr[0]=ssMTL[i][1];
int j=1;
for(int k=0;k<ssPM.length;k++,j++){
sstr[j]=ssPM[k][0];
j+=1;
sstr[j]=ssPM[k][1];
}
list.add(sstr);
request.setAttribute("list_number", sdmForm.getList_number()+"");
request.setAttribute("patient_id", sdmForm.getPatient_id());
request.setAttribute("department", sdmForm.getDepartment());
request.setAttribute("doctor_id", sdmForm.getDoctor_id());
request.setAttribute("sickness_reason", sdmForm.getSickness_reason());
request.setAttribute("medicine_list", sdmForm.getMedicine_list());
request.setAttribute("list", list);
}
return mapping.findForward("addMassage");
}
public ActionForward selectSDMList1(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
//See_doctor_messageForm see_doctor_messageForm = (See_doctor_messageForm) form;// TODO Auto-generated method stub
return null;
}
//把字符串(String)转化为整形(Integer)
public static Integer strToint(String str){
Integer i = null;
i = Integer.valueOf(str);
return i;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -