基于javaweb+mysql的jsp+servlet私人牙科诊所病历管理系统(java+jsp+css+javascript+mysql)

这是一个利用JavaWeb技术结合MySQL数据库实现的JSP和Servlet私人牙科诊所病历管理系统。系统分为前后台,包含管理员、病人、挂号人员等多个角色,实现了预约挂号、信息查询、收费管理等功能。开发环境包括Java8、MySQL5.7、Tomcat8,使用Eclipse等IDE进行开发。
摘要由CSDN通过智能技术生成

基于javaweb+mysql的jsp+servlet私人牙科诊所病历管理系统(java+jsp+css+javascript+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明


前台病人:

user1   123456

user2   123456

后台:

管理员账号/密码:admin/123456

挂号人员账号/密码:gh/123456

医生人员账号/密码:doctor/123456

收费人员账号/密码:sf/123456

药房人员账号/密码:yf/123456

预约挂号的操作流程:

1 前台user1:预约挂号

2 后台gh:受理

3 后台doctor:问诊

4 后台sf:收费

5 后台yf:确认取药

6 前台user1:查询病历(就诊信息)

基于javaweb+mysql的JSP+Servlet私人牙科诊所病历管理系统(java+jsp+css+javascript+mysql)

项目介绍

本系统分为前后台,包括管理员、病人、挂号人员、收费人员、药房人员、医生人员等角色,其中前台只能由病人角色登录,其它角色可通过后台登录; 管理员角色包含以下功能: 登录页面,增加公告,公告管理,留言管理,增加用户,用户管理,增加科室,科室管理,药品管理,收费统计,挂号统计等功能。

病人角色包含以下功能: 注册账号,用户登录,用户登录后首页,预约挂号,个人信息修改,提交留言等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:否;

技术栈

1.后端技术:Servlet 2.前端技术:JSP+CSS+JavaScript

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中dbconnection.properties配置文件中的数据库配置改为自己的配置; 将项目中src/dao/CommDAO.java中第71行的数据库配置用户名密码改为自己的配置; 4. 运行项目,输入http://localhost:8080/srykzsblmis/ 登录 注:Tomcat中配置路径必须为srykzsblmis 管理员账号/密码:admin/123 病人账号/密码: xm/123 挂号人员账号/密码:gh/123 收费人员账号/密码:sf/123 药房人员账号/密码:yf/123 医生人员账号/密码:doctor1/123
				}    
	             //下面开始添加单元格  
				int i=1;
	            for(List t:list){  
	            	try {
	            		
	            	Iterator it = t.iterator();
	            	int jj=0;
	            		while(it.hasNext())
	            		{
	            	Label label1 = new Label(jj, i,"");
	            	String a = it.next().toString();
		            label1.setString(a);
		            ws.addCell(label1);
		            jj++;
	            		}
		            
		            i++;
	            } catch (RowsExceededException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (WriteException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}    
	            }    
	   
	            try {    
	                //从内存中写入文件中    
	                wwb.write();    
	                //关闭资源,释放内存    
	                wwb.close();    
	            } catch (IOException e) {    
	                e.printStackTrace();    
	            } catch (Exception e) {    
	                e.printStackTrace();    
	            }    
	        }
	        try {
				response.sendRedirect("/srykzsblmis/upload?filename="+fileName.substring(fileName.lastIndexOf("/")+1));
			} catch (IOException e) {
				e.printStackTrace();
			}
	        
	    }    

		public static void main(String[] args) {
			String a = "A020$A004$";
		return new PageManager(path, pageSize, request);

	}

	/**
	 * 
	 * 
	 * @param hql语句
	 * 
	 */
	public void doList(String hql) {
        //String sql = "select count(*)  "+hql.substring(hql.indexOf("from"));
        //sql = sql.substring(0,sql.indexOf("order"));
		this.count = this.dao.select(hql).size();
		if (this.count != 0) {
			this.pageNumber = count % this.pageSize == 0 ? this.count
					/ this.pageSize : this.count / this.pageSize + 1;
			if (this.currentPage > this.pageNumber)
				this.currentPage = (int) this.pageNumber;

		}
		this.request.getSession().setAttribute("currentPage",
				String.valueOf(this.currentPage));
		this.collection = this.dao.select(hql,
				this.currentPage , this.pageSize);

		this.refreshUrl();
	}

	/**
	 * 
	 * @param 查询条件集合
	 *            如没有条件只是列表就不使用这个方法
	 */
	public void addParameter(List parameter) {

		StringBuffer para = new StringBuffer("");
		if (parameter != null && parameter.size() != 0) {
			Iterator iterator = parameter.iterator();
			while (iterator.hasNext()) {
				para.append("&").append(iterator.next().toString());
			}
		}
		this.parameter = para.toString();

	 *
	 * This method is called when a form has its tag value method equals to post.
	 * 
	 * @param request the request send by the client to the server
	 * @param response the response send by the server to the client
	 * @throws ServletException if an error occurred
	 * @throws IOException if an error occurred
	 */
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		StringBuffer   sb   =   new   StringBuffer(50);   
		 response.setContentType("application/x-msdownload;charset=GB2312");   
        try {
			response.setHeader("Content-Disposition",   new   String(sb.toString()   
			         .getBytes(),   "ISO8859-1"));
		} catch (UnsupportedEncodingException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
		 String filename = request.getParameter("filename");
		  if (request.getHeader("User-Agent").toLowerCase().indexOf("firefox") > 0){
		     try {
				filename = new String(filename.getBytes("UTF-8"), "ISO8859-1");
			} catch (UnsupportedEncodingException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		 }
		 else 
		      if (request.getHeader("User-Agent").toUpperCase().indexOf("MSIE") > 0){
		           try {
					filename = URLEncoder.encode(filename, "UTF-8");
				} catch (UnsupportedEncodingException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
		      }
		 response.setContentType("text/plain");
		 response.setHeader("Location",filename);
		 response.reset();
		 response.setHeader("Cache-Control", "max-age=0" );
		 response.setHeader("Content-Disposition", "attachment; filename=" + filename);

	        String sourceLowcase=source.toLowerCase();
	        String sub1,sub2,subLowcase1,subLowcase2;
	        sub1=sub2=subLowcase1=subLowcase2="";
	        int start=0,end;
	        boolean done=true;
	        if(source==null) return null;
	        if(from==null||from.equals("")||to==null||to.equals("")) 
	         return source;
	        while(done){
	         start=sourceLowcase.indexOf(from,start);
	         if(start==-1) {
	          break;
	         }
	         subLowcase1=sourceLowcase.substring(0,start);
	         sub1=source.substring(0,start);
	         end=sourceLowcase.indexOf(to,start);
	         if(end==-1){
	          end=sourceLowcase.indexOf("/>",start); 
	          if(end==-1) {
	           done=false;
	          }
	         }
	         else{
	          end=end+to.length();
	          subLowcase2=sourceLowcase.substring(end,source.length());
	          sub2=source.substring(end,source.length());
	          sourceLowcase=subLowcase1+subLowcase2;
	          source=sub1+sub2;
	         }
	         //System.out.println(start+" "+end);
	        }
	        return source;
	   }
	    
	    public static String tform(HashMap map)
		{
	    	String jscode = "";
	    	try{
	    	jscode+="<script type=\"text/javascript\">\n";
	    	jscode+="function getPvalue()\n";
	    	jscode+="{\n";
	    	
	    	 Set set = map.entrySet();
	    	 Iterator it = set.iterator();
	    	 while(it.hasNext())
	    	 {
	    	  String pm=((Object)it.next()).toString();
	    	  String str1 = "";
	    	  String str2 = "";
	    	  String[] strs = pm.split("=");
	    	  str1 = strs[0];
	    	  if(strs.length==1)str2="";
	              
	                return "small";
	            } else {
	                return "den";
	            }
	        } catch (Exception exception) {
	            exception.printStackTrace();
	        }
	        return "den";
	    }
	    
	    /**
	 	 * 过滤html代码
	 	 * 
	 	 */
	    public static String filterStrIgnoreCase(String source, String from, String to){
	        String sourceLowcase=source.toLowerCase();
	        String sub1,sub2,subLowcase1,subLowcase2;
	        sub1=sub2=subLowcase1=subLowcase2="";
	        int start=0,end;
	        boolean done=true;
	        if(source==null) return null;
	        if(from==null||from.equals("")||to==null||to.equals("")) 
	         return source;
	        while(done){
	         start=sourceLowcase.indexOf(from,start);
	         if(start==-1) {
	          break;
	         }
	         subLowcase1=sourceLowcase.substring(0,start);
	         sub1=source.substring(0,start);
	         end=sourceLowcase.indexOf(to,start);
	         if(end==-1){
	          end=sourceLowcase.indexOf("/>",start); 
	          if(end==-1) {
	           done=false;
	          }
	         }
	         else{
	          end=end+to.length();
	          subLowcase2=sourceLowcase.substring(end,source.length());
	          sub2=source.substring(end,source.length());
	          sourceLowcase=subLowcase1+subLowcase2;
	          source=sub1+sub2;
	         }
        //登录
        if (ac.equals("login")) {
            String utype = request.getParameter("utype");
            String username = request.getParameter("uname");
            String password = request.getParameter("upass");
            String sql = "select * from sysuser where uname='" + username + "' and upass='" + password + "' ";
            List<HashMap> userlist = dao.select(sql);
            if (userlist.size() != 1) {
                request.setAttribute("error", "");
                go("/admin/login.jsp", request, response);
            } else {
                request.getSession().setAttribute("admin", userlist.get(0));
                gor("/srykzsblmis/admin/index.jsp", request, response);
            }
        }

        //添加用户
        if (ac.equals("sysuseradd")) {
            String uname = request.getParameter("uname");
            String cksql = "select * from sysuser where uname='" + uname + "'";
            ArrayList cklist = (ArrayList) dao.select(cksql);
            if (cklist.size() != 0) {
                request.getParameter("no");
                go("/admin/sysuseradd.jsp", request, response);
            } else {
                String upass = request.getParameter("upass");
                String tname = request.getParameter("tname");
                String utype = request.getParameter("utype");
                String sex = request.getParameter("sex");
                String birth = request.getParameter("birth");
                String tel = request.getParameter("tel");
                String ismarage = request.getParameter("ismarage");
                String addr = request.getParameter("addr");
                String email = request.getParameter("email");
                String idcard = request.getParameter("idcard");
                String byschool = request.getParameter("byschool");
                String dept = request.getParameter("dept");
                if (!utype.equals("医生")) {
                    dept = "";
                }
                String sql = "insert into sysuser (uname,upass,tname,utype,sex,dept,birth,tel,ismarage,addr,email,idcard,byschool)values" +
                        " ('" + uname + "','" + upass + "','" + tname + "','" + utype + "','" + sex + "','" + dept + "','" + birth + "','" + tel + "','" + ismarage + "'" +
                        " ,'" + addr + "','" + email + "','" + idcard + "','" + byschool + "')";
                dao.commOper(sql);
                request.setAttribute("suc", "");
	 	 */
	    public static String filterStrIgnoreCase(String source, String from, String to){
	        String sourceLowcase=source.toLowerCase();
	        String sub1,sub2,subLowcase1,subLowcase2;
	        sub1=sub2=subLowcase1=subLowcase2="";
	        int start=0,end;
	        boolean done=true;
	        if(source==null) return null;
	        if(from==null||from.equals("")||to==null||to.equals("")) 
	         return source;
	        while(done){
	         start=sourceLowcase.indexOf(from,start);
	         if(start==-1) {
	          break;
	         }
	         subLowcase1=sourceLowcase.substring(0,start);
	         sub1=source.substring(0,start);
	         end=sourceLowcase.indexOf(to,start);
	         if(end==-1){
	          end=sourceLowcase.indexOf("/>",start); 
	          if(end==-1) {
	           done=false;
	          }
	         }
	         else{
	          end=end+to.length();
	          subLowcase2=sourceLowcase.substring(end,source.length());
	          sub2=source.substring(end,source.length());
	          sourceLowcase=subLowcase1+subLowcase2;
	          source=sub1+sub2;
	         }
	         //System.out.println(start+" "+end);
	        }
	        return source;
	   }
	    
	    public static String tform(HashMap map)
		{
	    	String jscode = "";
	    	try{
	    	jscode+="<script type=\"text/javascript\">\n";
	    	jscode+="function getPvalue()\n";
	    	jscode+="{\n";
	    	
	    	 Set set = map.entrySet();
				 {
			  File file1=new File(path + "/" + img); 
		       if(file1.exists() ) {
		    	file1.deleteOnExit();
		         file1.delete(); 
		       }}}
		}
	    
	    
	    public static void writeExcel(String fileName,String[] pros,java.util.List<List> list,HttpServletRequest request, HttpServletResponse response){    
	        WritableWorkbook  wwb = null;    
	        try {    
	            //首先要使用Workbook类的工厂方法创建一个可写入的工作薄(Workbook)对象    
	            wwb = Workbook.createWorkbook(new File(fileName));    
	        } catch (IOException e) {    
	            e.printStackTrace();    
	        }    
	        if(wwb!=null){    
	            //创建一个可写入的工作表    
	            //Workbook的createSheet方法有两个参数,第一个是工作表的名称,第二个是工作表在工作薄中的位置    
	            WritableSheet ws = wwb.createSheet("sheet1", 0);    
	            ws.setColumnView(0,20);
	            ws.setColumnView(1,20);
	            ws.setColumnView(2,20);
	            ws.setColumnView(3,20);
	            ws.setColumnView(4,20);
	            ws.setColumnView(5,20);

	            try {
	            	
	            for(int i=0;i<pros.length;i++)
	            {
	            Label label1 = new Label(i, 0,"");
	            
	            label1.setString(pros[i]);
	            ws.addCell(label1);
	            }
	            
	            } catch (RowsExceededException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (WriteException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}    
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/stuinfo.jsp", request, response);
        }

        //添加科室
        if (ac.equals("deptadd")) {
            String deptname = request.getParameter("deptname");
            String tel = request.getParameter("tel");
            String addr = request.getParameter("addr");
            String delstatus = "0";
            String sql = "insert into dept (deptname,tel,addr,delstatus) values('" + deptname + "','" + tel + "','" + addr + "','" + delstatus + "')";
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/deptadd.jsp", request, response);
        }
        //修改科室
        if (ac.equals("deptedit")) {
            String id = request.getParameter("id");
            String tel = request.getParameter("tel");
            String addr = request.getParameter("addr");
            String deptname = request.getParameter("deptname");

            String sql = "update dept set deptname='" + deptname + "',tel='" + tel + "',addr='" + addr + "' where id= " + id;
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/deptadd.jsp", request, response);
        }
        //添加药品、处置
        if (ac.equals("ypcfadd")) {
            String yno = request.getParameter("yno");
            String cksql = "select * from ypcf where yno='" + yno + "'";
            ArrayList cklist = (ArrayList) dao.select(cksql);
            if (cklist.size() != 0) {
                request.getParameter("no");
                go("/admin/ypcfadd.jsp", request, response);
            } else {
                String yname = request.getParameter("yname");
                String price = request.getParameter("price");
                String type = request.getParameter("type");
                String gg = request.getParameter("gg");
                String company = request.getParameter("company");
                if (!type.equals("药品")) {
                    gg = "";
                    company = "";
                }
                String delstatus = "0";
                String sql = "insert into ypcf (yno,yname,gg,price,company,delstatus,type)values('" + yno + "','" + yname + "','" + gg + "','" + price + "','" + company + "','" + delstatus + "','" + type + "')";
		this.request = request;
		this.path = path;

		request.setAttribute("page", this);

		try {
			this.currentPage = Integer.parseInt(request
					.getParameter("currentPage")) <= 0 ? 1 : Integer
					.parseInt(request.getParameter("currentPage"));

		} catch (Exception e) {

			try {
				this.currentPage = Integer.parseInt((String) request
						.getSession().getAttribute("currentPage"));

			} catch (Exception e1) {
				this.currentPage = 1;

			}

		}

	}
	
	
	
	

	
	

	/**
	 * 
	 * @param 下一页的分页链接
	 * @param 一页最大记录数
	 * @param 当前HttpServletRequest对象
	 * @param 数据库操作对象
	 */
	public static PageManager getPage(String path, int pageSize,
			HttpServletRequest request) {
		return new PageManager(path, pageSize, request);

	}

	/**
            List<List> rlist = new ArrayList();
            DecimalFormat decimal = new DecimalFormat("#.#");
            for (HashMap map : list) {
                List mlist = new ArrayList();
                mlist.add(map.get("ghno"));
                mlist.add(decimal.format(Double.valueOf(map.get("price").toString())) + "元");
                HashMap dm = dao.select("select * from dept where id=" + map.get("ghdept")).get(0);
                mlist.add(dm.get("deptname"));
                mlist.add(map.get("oper"));
                mlist.add(map.get("savetime"));

                rlist.add(mlist);
            }
            String[] pros = {"挂号编号", "挂号金额", "挂号科室", "操作人", "操作时间"};
            Info.writeExcel(request.getRealPath("/upfile/") + "/ghexport.xls", pros, rlist, request, response);
        }

        if (ac.equals("test")) {
            String str = request.getParameter("str");
            String sql = "select * from sysuser where uname like '%" + str + "%' or tname like '%" + str + "%' ";
            if (str.equals("")) {
                sql = "select * from sysuser";
            }
            System.out.println(sql);
            String returnStr = "";
            ArrayList<HashMap> list = (ArrayList<HashMap>) dao.select(sql);
            System.out.println("aa-=" + list.size());
            if (list.size() != 0) {
                for (HashMap map : list) {
                    returnStr += map.get("uname") + "-" + map.get("tname") + "$";
                }
                out.println(returnStr);
            } else {
                out.println("");
            }
        }
        if (ac.equals("testadd")) {
            String Hidden1 = request.getParameter("Hidden1");
            //String str[] = Hidden1.split("\\$");
            String cfno = "czd001";
            //for(int i=0;i<str.length;i++){
            //	System.out.println("aaa="+str[i]);
            //}
            System.out.println("Hidden1==" + Hidden1);
            String sql = "update czd set info='" + Hidden1 + "' where cfno='" + cfno + "' ";
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/testadd1.jsp?cfno=" + cfno, request, response);
        }
        //自动补全药品
        if (ac.equals("ajaxsearch")) {
            String str = request.getParameter("str");

        if (ac.equals("ghexport")) {

            String sql = "select * from ghinfo where 1=1 and delstatus='0'";
            sql += "order by id desc";
            ArrayList<HashMap> list = (ArrayList) dao.select(sql);
            List<List> rlist = new ArrayList();
            DecimalFormat decimal = new DecimalFormat("#.#");
            for (HashMap map : list) {
                List mlist = new ArrayList();
                mlist.add(map.get("ghno"));
                mlist.add(decimal.format(Double.valueOf(map.get("price").toString())) + "元");
                HashMap dm = dao.select("select * from dept where id=" + map.get("ghdept")).get(0);
                mlist.add(dm.get("deptname"));
                mlist.add(map.get("oper"));
                mlist.add(map.get("savetime"));

                rlist.add(mlist);
            }
            String[] pros = {"挂号编号", "挂号金额", "挂号科室", "操作人", "操作时间"};
            Info.writeExcel(request.getRealPath("/upfile/") + "/ghexport.xls", pros, rlist, request, response);
        }

        if (ac.equals("test")) {
            String str = request.getParameter("str");
            String sql = "select * from sysuser where uname like '%" + str + "%' or tname like '%" + str + "%' ";
            if (str.equals("")) {
                sql = "select * from sysuser";
            }
            System.out.println(sql);
            String returnStr = "";
            ArrayList<HashMap> list = (ArrayList<HashMap>) dao.select(sql);
            System.out.println("aa-=" + list.size());
            if (list.size() != 0) {
                for (HashMap map : list) {
                    returnStr += map.get("uname") + "-" + map.get("tname") + "$";
                }
                out.println(returnStr);
            } else {
                out.println("");
            }
        }
        }
        //患者修改个人信息
        if (ac.equals("userinfo")) {
            String id = request.getParameter("id");
            String upass = request.getParameter("upass");
            String tname = request.getParameter("tname");
            String sex = request.getParameter("sex");
            String age = request.getParameter("age");
            String idcard = request.getParameter("idcard");
            String tel = request.getParameter("tel");
            String addr = request.getParameter("addr");
            dao.commOper("update patient set upass='" + upass + "',tname='" + tname + "',sex='" + sex + "',age='" + age + "'," +
                    " idcard='" + idcard + "',tel='" + tel + "',addr='" + addr + "' where id=" + id);
            request.setAttribute("suc", "");
            go("/userinfo.jsp", request, response);
        }

        //用户登陆
        if (ac.equals("plogin")) {
            String uname = request.getParameter("uname");
            String upass = request.getParameter("upass");
            ArrayList list = (ArrayList) dao.select("select * from patient where uname='" + uname + "' and upass='" + upass + "' and delstatus='0' ");
            if (list.size() == 1) {
                session.setAttribute("user", list.get(0));
                request.setAttribute("suc", "");
                gor("index.jsp", request, response);
            } else {
                request.setAttribute("no", "");
                go("index.jsp", request, response);
            }

        }

        //预约
        if (ac.equals("yy")) {
            String uid = user.get("id").toString();
            String type = request.getParameter("type");
            String dept = request.getParameter("id");
            String savetime = Info.getDateStr();
            dao.commOper("insert into yy (uid,type,dept,ghno,savetime) values ('" + uid + "','" + type + "','" + dept + "','','" + savetime + "') ");
            request.setAttribute("suc", "");
            go("yy.jsp?id=" + dept, request, response);
        }
        //挂号受理
        if (ac.equals("yysl")) {
            System.out.println("aa");

        //添加公告
        if (ac.equals("noticeadd")) {
            String title = request.getParameter("title");
            String note = request.getParameter("note");
            String savetime = Info.getDateStr();
            String sql = "insert into notice (title,note,savetime) values('" + title + "','" + note + "','" + savetime + "')";
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/noticeadd.jsp", request, response);
        }
        //修改公告
        if (ac.equals("noticeedit")) {
            String id = request.getParameter("id");
            String title = request.getParameter("title");
            String note = request.getParameter("note");
            String sql = "update notice set title='" + title + "',note='" + note + "' where id= " + id;
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/noticeadd.jsp", request, response);
        }

        //添加留言
        if (ac.equals("chatadd")) {
            String msg = request.getParameter("msg");
            String hfmsg = "";
            String savetime = Info.getDateStr();
            String uid = user.get("id").toString();
            String sql = "insert into chat (msg,hfmsg,savetime,uid) values('" + msg + "','" + hfmsg + "','" + savetime + "','" + uid + "')";
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("chat.jsp", request, response);
        }
        //回复留言
        if (ac.equals("chathf")) {
            String id = request.getParameter("id");
            String hfmsg = request.getParameter("hfmsg");
            String sql = "update chat set hfmsg='" + hfmsg + "' where id= " + id;
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/chathf.jsp?id=" + id, request, response);
        }

        dao.close();
					.append("</a>");
		} else {
			buf.append("上页");

		}
		buf.append("&nbsp;&nbsp;");

		int currentSegment = this.currentPage % segment == 0 ? this.currentPage
				/ segment : this.currentPage / segment + 1;

		/*for (int i = 1; i <= this.pageNumber; i++) {
			if (this.currentPage == i)
				buf.append("<font color='red'>").append(i).append("</font>");

			else
				buf.append("<a href='").append(this.path).append(
						"&currentPage=").append(i).append(parameter).append(
						"' class='ls'>[").append(i).append(
						"]</a>");
		}*/

		buf.append("&nbsp;&nbsp;");
		if (this.currentPage < this.pageNumber) {
			buf.append("<a href='").append(this.path).append("&currentPage=")
					.append(currentPage + 1).append(parameter).append(
							"' class='ls'>").append("下页")
					.append("</a>");
		} else {

			buf.append("下页");

		}

		buf.append("&nbsp;&nbsp;&nbsp;&nbsp;");
		if (this.currentPage == this.pageNumber)
			buf.append("末页&nbsp;&nbsp;");
		else
			buf.append("<a href='").append(this.path).append("&currentPage=")
					.append(this.pageNumber).append(parameter).append(
							"' class='ls'>").append("末页")
					.append("</a></font>&nbsp;&nbsp;");
	 }

	 
	 /**
		 * @param String date
		 * @param int day
		 * @return
		 */
		public static String getDay(String date,int day) {
			String b = date.substring(0,10);
			String c = b.substring(0,4);
			String d = b.substring(5,7);
			String f = b.substring(8,10);
			String aa = c+"/"+d+"/"+f;
			String a = "";
			DateFormat dateFormat =  DateFormat.getDateInstance(DateFormat.MEDIUM);
				GregorianCalendar grc=new GregorianCalendar();
				grc.setTime(new Date(aa));
	            grc.add(GregorianCalendar.DAY_OF_MONTH,day);
	            String resu = dateFormat.format(grc.getTime());
	        String t[]= resu.split("-");
	        String sesuu = "";
	        for(int i=0;i<t.length;i++)
	        {
	        	if(t[i].length()==1)
	        	{
	        		t[i]="0"+t[i];
	        	}
	        	sesuu += t[i]+"-";
	        }
	        
			return sesuu.substring(0,10);
		}
		

	    
	    
	    /**
	 	 * 计算两个时期之间的天数
	 	 * 
	 	 */
	    public static int dayToday(String DATE1, String DATE2) {
                for (int i = 0; i < a.length; i++) {
                    String ynos[] = a[i].split("\\-");
                    ArrayList amlist = (ArrayList) dao.select("select * from ypcf where yno='" + ynos[0] + "' and type='药品' ");
                    if (amlist.size() != 0) {
                        HashMap am = dao.select("select * from ypcf where yno='" + ynos[0] + "' and type='药品' ").get(0);
                        String yno = am.get("yno").toString();//药品编号
                        int num = Integer.parseInt(b[i]);//购买药品数量
                        //查药品数量
                        HashMap inmap = dao.select("select sum(num) as innum from kcrecord where type='in' and yno='" + ynos[0] + "' ").get(0);
                        HashMap outmap = dao.select("select sum(num) as outnum from kcrecord where type='out' and yno='" + ynos[0] + "' ").get(0);
                        int innum = 0;
                        int outnum = 0;
                        if (inmap.get("innum") != null) {
                            innum = Integer.parseInt(inmap.get("innum").toString());
                        }
                        if (outmap.get("outnum") != null) {
                            outnum = Integer.parseInt(outmap.get("outnum").toString());
                        }
                        int kc = innum - outnum;

                        dao.commOper("insert into kcrecord (yno,num,type,savetime,oper) values ('" + yno + "','" + num + "','out','" + Info.getDateStr() + "','" + admin.get("uname") + "') ");
                    }
                }
                dao.commOper("update zd set fyoper='" + admin.get("uname") + "',fysavetime='" + Info.getDateStr() + "',qystatus='已取药'  where ghno='" + ghno + "'");
                request.setAttribute("suc", "");
                go("/admin/dfy.jsp", request, response);
            } else {
                request.setAttribute("no", "");
                go("/admin/dfy.jsp", request, response);
            }
        }

        //注册
        if (ac.equals("regedit")) {
            System.out.println("123123");
            String uname = request.getParameter("uname");
            String upass = request.getParameter("upass");
            String tname = request.getParameter("tname");
            String sex = request.getParameter("sex");
            String age = request.getParameter("age");
            String idcard = request.getParameter("idcard");
            String tel = request.getParameter("tel");
            String addr = request.getParameter("addr");
            String delstatus = "0";
            ArrayList cklist = (ArrayList) dao.select("select * from patient where delstatus='0' and uname='" + uname + "' ");
            if (cklist.size() > 0) {
		}
		

	    
	    
	    /**
	 	 * 计算两个时期之间的天数
	 	 * 
	 	 */
	    public static int dayToday(String DATE1, String DATE2) {
	       int i = 0;
	       DATE1 = DATE1.substring(0,DATE1.indexOf(" "));
	       DATE2 = DATE2.substring(0,DATE2.indexOf(" "));
	       
	       String[] d1 = DATE1.split("-");
	       if(d1[1].length()==1)
	       {
	    	   DATE1 = d1[0]+"-0"+d1[1];
	       }else{
	    	   DATE1 = d1[0]+"-"+d1[1];
	       }
	       
	       if(d1[2].length()==1)
	       {
	    	   DATE1 = DATE1+"-0"+d1[2];
	       }else{
	    	   DATE1 = DATE1+"-"+d1[2];
	       }
	       
	       String[] d2 = DATE2.split("-");
	       if(d2[1].length()==1)
	       {
	    	   DATE2 = d2[0]+"-0"+d2[1];
	       }else{
	    	   DATE2 = d2[0]+"-"+d2[1];
	       }
	       
	       if(d2[2].length()==1)
	       {
	    	   DATE2 = DATE2+"-0"+d2[2];
	       }else{
            dao.commOper("insert into ghinfo (ghno,tname,sex,age,idcard,tel,addr,ghdept,price,status,delstatus,oper,savetime) " +
                    " values('" + ghno + "','" + tname + "','" + sex + "','" + age + "','" + idcard + "','" + tel + "','" + addr + "','" + ghdept + "','" + price + "','" + status + "','" + delstatus + "','" + oper + "','" + savetime + "')  ");
            request.setAttribute("suc", "");
            go("admin/yy.jsp", request, response);
        }
        //前台退出
        if (ac.equals("frontexit")) {
            session.removeAttribute("user");
            go("index.jsp", request, response);
        }

        //添加公告
        if (ac.equals("noticeadd")) {
            String title = request.getParameter("title");
            String note = request.getParameter("note");
            String savetime = Info.getDateStr();
            String sql = "insert into notice (title,note,savetime) values('" + title + "','" + note + "','" + savetime + "')";
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/noticeadd.jsp", request, response);
        }
        //修改公告
        if (ac.equals("noticeedit")) {
            String id = request.getParameter("id");
            String title = request.getParameter("title");
            String note = request.getParameter("note");
            String sql = "update notice set title='" + title + "',note='" + note + "' where id= " + id;
            dao.commOper(sql);
            request.setAttribute("suc", "");
            go("/admin/noticeadd.jsp", request, response);
        }

        //添加留言
        if (ac.equals("chatadd")) {
            String msg = request.getParameter("msg");
            String hfmsg = "";
            String savetime = Info.getDateStr();
            String uid = user.get("id").toString();
            String sql = "insert into chat (msg,hfmsg,savetime,uid) values('" + msg + "','" + hfmsg + "','" + savetime + "','" + uid + "')";
            dao.commOper(sql);
                        int kc = innum - outnum;

                        dao.commOper("insert into kcrecord (yno,num,type,savetime,oper) values ('" + yno + "','" + num + "','out','" + Info.getDateStr() + "','" + admin.get("uname") + "') ");
                    }
                }
                dao.commOper("update zd set fyoper='" + admin.get("uname") + "',fysavetime='" + Info.getDateStr() + "',qystatus='已取药'  where ghno='" + ghno + "'");
                request.setAttribute("suc", "");
                go("/admin/dfy.jsp", request, response);
            } else {
                request.setAttribute("no", "");
                go("/admin/dfy.jsp", request, response);
            }
        }

        //注册
        if (ac.equals("regedit")) {
            System.out.println("123123");
            String uname = request.getParameter("uname");
            String upass = request.getParameter("upass");
            String tname = request.getParameter("tname");
            String sex = request.getParameter("sex");
            String age = request.getParameter("age");
            String idcard = request.getParameter("idcard");
            String tel = request.getParameter("tel");
            String addr = request.getParameter("addr");
            String delstatus = "0";
            ArrayList cklist = (ArrayList) dao.select("select * from patient where delstatus='0' and uname='" + uname + "' ");
            if (cklist.size() > 0) {
                request.setAttribute("no", "");
            } else {
                dao.commOper("insert into patient (uname,upass,tname,sex,age,idcard,tel,addr,delstatus) values " +
                        "('" + uname + "','" + upass + "','" + tname + "','" + sex + "','" + age + "','" + idcard + "','" + tel + "','" + addr + "','" + delstatus + "') ");
                request.setAttribute("suc", "");
                go("/regedit.jsp", request, response);
            }
        }
        //患者修改个人信息
        if (ac.equals("userinfo")) {
            String id = request.getParameter("id");
            String upass = request.getParameter("upass");
            String tname = request.getParameter("tname");
            String sex = request.getParameter("sex");
            String age = request.getParameter("age");
            String idcard = request.getParameter("idcard");
            String tel = request.getParameter("tel");
            String addr = request.getParameter("addr");
            dao.commOper("update patient set upass='" + upass + "',tname='" + tname + "',sex='" + sex + "',age='" + age + "'," +
                    " idcard='" + idcard + "',tel='" + tel + "',addr='" + addr + "' where id=" + id);
            request.setAttribute("suc", "");
            go("/userinfo.jsp", request, response);
        }

        //用户登陆
        if (ac.equals("plogin")) {
		 } 
	public static String AutoID(){
		String dateString="";
		try{//yyyyMMddHHmmss
		java.text.SimpleDateFormat formatter=new java.text.SimpleDateFormat("yyyyMMddhhmmss");
		java.util.Date currentTime_1=new java.util.Date();
		dateString=formatter.format(currentTime_1);
		}catch(Exception e){
		     }
		 return dateString;
		 } 

	 public static String getUTFStr(String str) {
		 if(str==null){
			 return "";
		 }
		 
		 try {
			str =  new String(str.getBytes("ISO-8859-1"),"utf-8");
		} catch (UnsupportedEncodingException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return str;
	 }
	 
	 public static String getGBKStr(String str) throws UnsupportedEncodingException{
		 if(str==null){
			 return "";
		 }
		 return  new String(str.getBytes("ISO-8859-1"),"GBK");
	 }
	 
	 public static String getGB2312Str(String str) throws UnsupportedEncodingException{
		 if(str==null){
			 return "";
		 }
		 return  new String(str.getBytes("ISO-8859-1"),"gb2312");
	 }

	 
	 /**
		 * @param String date
		 * @param int day
				int i=1;
	            for(List t:list){  
	            	try {
	            		
	            	Iterator it = t.iterator();
	            	int jj=0;
	            		while(it.hasNext())
	            		{
	            	Label label1 = new Label(jj, i,"");
	            	String a = it.next().toString();
		            label1.setString(a);
		            ws.addCell(label1);
		            jj++;
	            		}
		            
		            i++;
	            } catch (RowsExceededException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				} catch (WriteException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
				}    
	            }    
	   
	            try {    
	                //从内存中写入文件中    
	                wwb.write();    
	                //关闭资源,释放内存    
	                wwb.close();    
	            } catch (IOException e) {    
	                e.printStackTrace();    
	            } catch (Exception e) {    
	                e.printStackTrace();    
	            }    
	        }
	        try {
				response.sendRedirect("/srykzsblmis/upload?filename="+fileName.substring(fileName.lastIndexOf("/")+1));
			} catch (IOException e) {
				e.printStackTrace();
			}
	        
	    }    

		public static void main(String[] args) {
			String a = "A020$A004$";
			String[] aa = a.split("\\$");
			for(int i=0;i<aa.length;i++){
				System.out.println(aa[i]);
			}
			
		}
					.append(currentPage - 1).append(parameter).append(
							"' class='ls'>").append("上页")
					.append("</a>");
		} else {
			buf.append("上页");

		}
		buf.append("&nbsp;&nbsp;");

		int currentSegment = this.currentPage % segment == 0 ? this.currentPage
				/ segment : this.currentPage / segment + 1;

		/*for (int i = 1; i <= this.pageNumber; i++) {
			if (this.currentPage == i)
				buf.append("<font color='red'>").append(i).append("</font>");

			else
				buf.append("<a href='").append(this.path).append(
						"&currentPage=").append(i).append(parameter).append(
						"' class='ls'>[").append(i).append(
						"]</a>");
		}*/

		buf.append("&nbsp;&nbsp;");
		if (this.currentPage < this.pageNumber) {
			buf.append("<a href='").append(this.path).append("&currentPage=")
					.append(currentPage + 1).append(parameter).append(
							"' class='ls'>").append("下页")
					.append("</a>");
		} else {

			buf.append("下页");

		}

		buf.append("&nbsp;&nbsp;&nbsp;&nbsp;");
		if (this.currentPage == this.pageNumber)
			buf.append("末页&nbsp;&nbsp;");
		else
			buf.append("<a href='").append(this.path).append("&currentPage=")
					.append(this.pageNumber).append(parameter).append(
							"' class='ls'>").append("末页")
					.append("</a></font>&nbsp;&nbsp;");
		// 
		// for (int i = 0; i < this.pageNumber; i++) {
		// if (this.currentPage == i + 1) {
		// buf.append("<font color=red>[" + (i + 1) + "]</font>").append(
		// "&nbsp;");
		// } else {
		// buf.append("<a href='").append(this.path).append(
		// "&currentPage=").append(i + 1).append(parameter)
		// .append("' style='TEXT-DECORATION:none'>").append(
		// "[" + (i + 1) + "]").append("</a>&nbsp;");
        if (ac.equals("yprk")) {
            String yno = request.getParameter("yno");
            String num = request.getParameter("num");
            String type = "in";
            String oper = admin.get("uname").toString();
            String savetime = Info.getDateStr();
            dao.commOper("insert into kcrecord (yno,num,type,savetime,oper) values ('" + yno + "','" + num + "','" + type + "','" + savetime + "','" + oper + "') ");
            request.setAttribute("suc", "");
            go("/admin/yprk.jsp", request, response);
        }

        if (ac.equals("export")) {

            String sql = "select * from zd where fkstatus='已付款' ";
            sql += "order by ghno desc";
            ArrayList<HashMap> list = (ArrayList) dao.select(sql);
            List<List> rlist = new ArrayList();
            DecimalFormat decimal = new DecimalFormat("#.#");
            for (HashMap map : list) {

                HashMap am = dao.select("select * from ghinfo where ghno='" + map.get("ghno") + "'").get(0);
                HashMap mstu = dao.select("select * from zd where ghno='" + map.get("ghno") + "'").get(0);
                String info = mstu.get("info").toString();
                String numinfo = mstu.get("numinfo").toString();
                String yinfo = "";
                String a[] = info.split("\\$");
                String b[] = numinfo.split("\\$");
                for (int i = 0; i < a.length; i++) {
                    yinfo += a[i] + "&nbsp;&nbsp;数量:" + b[i] + "<br/>";
                }
                List mlist = new ArrayList();
                mlist.add(map.get("ghno"));
                mlist.add(am.get("tname"));
                mlist.add(am.get("sex"));
                mlist.add(am.get("age"));
                mlist.add(mstu.get("bq"));
                mlist.add(mstu.get("zd"));
                mlist.add(yinfo);
                mlist.add(decimal.format(Double.valueOf(map.get("totalprice").toString())) + "元");
                mlist.add(map.get("sfoper"));
                mlist.add(map.get("sfsavetime"));
			 {
				 if(!img.equals(""))
				 {
			  File file1=new File(path + "/" + img); 
		       if(file1.exists() ) {
		    	file1.deleteOnExit();
		         file1.delete(); 
		       }}}
		}
	    
	    
	    public static void writeExcel(String fileName,String[] pros,java.util.List<List> list,HttpServletRequest request, HttpServletResponse response){    
	        WritableWorkbook  wwb = null;    
	        try {    
	            //首先要使用Workbook类的工厂方法创建一个可写入的工作薄(Workbook)对象    
	            wwb = Workbook.createWorkbook(new File(fileName));    
	        } catch (IOException e) {    
	            e.printStackTrace();    
	        }    
	        if(wwb!=null){    
	            //创建一个可写入的工作表    
	            //Workbook的createSheet方法有两个参数,第一个是工作表的名称,第二个是工作表在工作薄中的位置    
	            WritableSheet ws = wwb.createSheet("sheet1", 0);    
	            ws.setColumnView(0,20);
	            ws.setColumnView(1,20);
	            ws.setColumnView(2,20);
	            ws.setColumnView(3,20);
	            ws.setColumnView(4,20);
	            ws.setColumnView(5,20);

	            try {
	            	
	            for(int i=0;i<pros.length;i++)
	            {
	            Label label1 = new Label(i, 0,"");
	            
	            label1.setString(pros[i]);
	            ws.addCell(label1);
	            }
	            
	            } catch (RowsExceededException e1) {
					// TODO Auto-generated catch block
					e1.printStackTrace();
	 	 */
	    public static int dayToday(String DATE1, String DATE2) {
	       int i = 0;
	       DATE1 = DATE1.substring(0,DATE1.indexOf(" "));
	       DATE2 = DATE2.substring(0,DATE2.indexOf(" "));
	       
	       String[] d1 = DATE1.split("-");
	       if(d1[1].length()==1)
	       {
	    	   DATE1 = d1[0]+"-0"+d1[1];
	       }else{
	    	   DATE1 = d1[0]+"-"+d1[1];
	       }
	       
	       if(d1[2].length()==1)
	       {
	    	   DATE1 = DATE1+"-0"+d1[2];
	       }else{
	    	   DATE1 = DATE1+"-"+d1[2];
	       }
	       
	       String[] d2 = DATE2.split("-");
	       if(d2[1].length()==1)
	       {
	    	   DATE2 = d2[0]+"-0"+d2[1];
	       }else{
	    	   DATE2 = d2[0]+"-"+d2[1];
	       }
	       
	       if(d2[2].length()==1)
	       {
	    	   DATE2 = DATE2+"-0"+d2[2];
	       }else{
	    	   DATE2 = DATE2+"-"+d2[2];
	       }
	       
	       
	       for(int j=0;j<10000;j++)
	       {
	    	i=j;
	    	String gday = Info.getDay(DATE1, j);
	    	if(gday.equals(DATE2))
	    	{
	    		break;
	    	}
	       }
	        return i;
	    }
	    
	   
	    

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值