⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lhh_modifyingview.jsp

📁 服务器tomcat 数据库mysql Hospital Management System 为医院的门诊
💻 JSP
字号:
<%@ page language="java" import="java.sql.*" %>
<%!
	Connection con=null;
	int iBedId=0;
	int iSroomId=0;
	int iBedStatus=0;
	String sBSUpdate=null;
	int iCheckInSeqnum=0;
	int iSroomType=0;
	float fBedFee=0;
	int iBedNum=0;
	int iAttaAmount=0;
	int iBedAmount=0;
	int iStatisticBedNum=0;
	String sSelect=null;
	String sUpdate=null;
	String sSelectQuery=null;
%>
<html>
<head></head>
<body>
<!--<@ include file="head.jsp"%>
<@ include file="foot.jsp"%> -->
<jsp:include page="../head.jsp" flush="true"/>
<table width="100%" height="100%" border="1">
  <tr valign="top">
    <td width="25%"><div id="sectionLinks">
        <h3>Section Links</h3>
        <ul>
          <li><a href="#">quering</a></li>
          <li><a href="#">modifying</a></li>
          <li><a href="#">adding</a></li>
          <li><a href="#">buying</a></li>
          <li><a href="#">deleting</a></li>
        </ul>
      </div></td>
    <td width="53%"><%
	try{
			sSelect=request.getParameter("modifying");
			Class.forName("com.mysql.jdbc.Driver"); // MySQL driver to connect to MySQL database
			con=DriverManager.getConnection("jdbc:mysql:///lenovo_db?user=root&password=amethyst"); // Connectin to database by giving databasename and giving deault username and password
			
			if(sSelect.equals("abed")){
				iBedId=Integer.parseInt(request.getParameter("bedId"));
				iCheckInSeqnum=Integer.parseInt(request.getParameter("checkInSeqNum"));
				sBSUpdate=request.getParameter("bedStatus");
				if(sBSUpdate.equals("status0")){
					iBedStatus=0;
					iCheckInSeqnum=0;
				}
				else iBedStatus=1;
				//iBedStatus=Integer.parseInt(request.getParameter("bedStatus"));
				
				//sUpdate="update bed set bed_status="+iBedStatus+",check_in_seqnum"+iCheckInSeqnum+"where bed_id="+iBedId;
				sUpdate="update bed set bed_status=?,check_in_seqnum=? where bed_id="+iBedId;
				PreparedStatement ps = con.prepareStatement(sUpdate);
				ps.setInt(1,iBedStatus);
				ps.setInt(2,iCheckInSeqnum);
				ps.executeUpdate();
				//ps.close();
				if(iBedStatus==1){
					sUpdate="update storage set atta_amount=?";
					ps = con.prepareStatement(sUpdate);
					sSelectQuery="select * from Storage";
					Statement st=con.createStatement();
	    			ResultSet rs=st.executeQuery(sSelectQuery);
					while(rs.next())
        			{
            			iAttaAmount=rs.getInt(2);
        			}
					rs.close();
					st.close();
					iAttaAmount--;
					ps.setInt(1,iAttaAmount);
					ps.executeUpdate();
					//ps.close();
				}
				ps.close();
				out.println("Record Successfuly Updated");
			}
			else if(sSelect.equals("sickroom")){
				iSroomId=Integer.parseInt(request.getParameter("sroomId"));
				iSroomType=Integer.parseInt(request.getParameter("sroomType"));
				sUpdate="update sickroom set sroom_type=? where sroom_id="+iSroomId;
				PreparedStatement ps = con.prepareStatement(sUpdate);
				ps.setInt(1,iSroomType);
				ps.executeUpdate();
				ps.close();   
				out.println("Record Successfuly Updated");
			}
			else if(sSelect.equals("sroomtype")){
				iSroomType=Integer.parseInt(request.getParameter("msroomType"));
				iBedNum=Integer.parseInt(request.getParameter("bedNum"));
				fBedFee=Float.parseFloat(request.getParameter("bedFee"));
				sUpdate="update sickroomtype set bed_num=?,bed_fee=? where sroom_type="+iSroomType;
				PreparedStatement ps = con.prepareStatement(sUpdate);
				ps.setInt(1,iBedNum);
				ps.setFloat(2,fBedFee);
				ps.executeUpdate();
				ps.close();   
				out.println("Record Successfuly Updated");
			}
	}
	catch(Exception ex)
	{
		System.out.println(ex);
 	}
%>
    </td>
    <td width="22%"><div class="relatedLinks" valign="top">
        <h3>Related Link Category</h3>
        <ul>
          <li><a href="#">Related Link</a></li>
          <li><a href="#">Related Link</a></li>
          <li><a href="#">Related Link</a></li>
          <li><a href="#">Related Link</a></li>
          <li><a href="#">Related Link</a></li>
          <li><a href="#">Related Link</a></li>
        </ul>
      </div></td>
  </tr>
</table>
<jsp:include page="../foot.jsp" flush="true"/>
</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -