这是一个图书馆管理系统的jsp代码

源代码在线查看: booksearch.jsp~76~

软件大小: 882 K
上传用户: BEIJINGHUANYING
关键词: jsp 图书馆 代码 管理系统
下载地址: 免注册下载 普通下载 VIP

相关代码

				
				
				
				
				
				Search Book
				
								.style3 {font-size: 24px}
				.style4 {font-size: 18px}
				-->
				
				
				
				
				  
				    
				      
				        
				          
				        
				      
				    
				    
				      
				        
				          
				            
				               
				               
				            
				            
				              
				               Adduser 
				            
				            
				               
				              
				            
				            
				              
				              Modifyuser
				            
				            
				               
				              
				            
				            
				              
				              Deletuser
				            
				            
				               
				              
				            
				            
				              
				              Searchuser
				            
				            
				               
				              
				            
				            
				             
				              Addbook
				            
				            
				               
				              
				            
				            
				              
				              Deletebook
				            
				            
				               
				              
				            
				            
				              
				              Borrowsearch
				            
				            
				               
				              
				            
				            
				              
				              Search
				            
				            
				               
				              
				            
				            
				               
				               
				            
				          
				        
				        
				           
				        
				      
				      
				        
				          Search Book 
				          
				        
				          Title:
				          
				          
				          ***
				        
				        
				                      
				            
				              
				              
				            
				          
				          
				      
				    
				    
				       
				      
				    
				  
				
								
				
				  
				    
				      title
				      
				    
				    
				      
				        
				        
				
				    
				    
				      
				      
				    
				  
				-->
				
				
				
				
								//java.util.Locale locale = request.getLocale();
				//java.text.DateFormat dateFormat = java.text.DateFormat.getDateInstance(java.text.DateFormat.LONG,locale);
				
				try{
				  int flag=0,flag1=0;String studentnumber="";
				  String id=Library.getid();
				//  String title=request.getParameter("title");
				Connection conn=Library.getConn();
				Statement stmt,stmt1;
				stmt = conn.createStatement();
				stmt1 = conn.createStatement();
				ResultSet rs2 = stmt.executeQuery("select * from borrowbook where id ='" + id + "'");
				//ResultSet rs6 = pstmt1.executeQuery();
				while(rs2.next()){//判断当前用户是否已经还清欠款,在borrowbook表中,flag=1代表为还清,flag=0代表还清
				if(rs2.getString("returnmoney").equals("no")){
				flag=1;
				}
				}
				//out.println("" + request.getParameter("title") + "");
				ResultSet rs3 = stmt.executeQuery("select * from user where id ='" + id + "'");
				if(rs3.next()){
				studentnumber = rs3.getString("studentnumber");
				}
				  if(request.getParameter("enter")!=null){
				ResultSet rs = stmt.executeQuery("select * from book where title ='" + request.getParameter("title") + "'");
				  while (rs.next()){//NO data found,是指rs.getString()中出现两个相同的,例rs.getString("id")出现两次;
				
				    out.println("serialnumber = " + rs.getString("serialnumber") + "  ");
				    out.println("sortnumber = " + rs.getString("sortnumber") + "  ");
				    out.println("title = " + rs.getString("title") + "  ");
				    out.println("author1 = " + rs.getString("author1") + "  ");
				    out.println("author2 = " + rs.getString("author2") + "  ");
				    out.println("author3 = " + rs.getString("author3") + "  ");
				    out.println("cover = " + rs.getString("cover") + "  ");
				    out.println("bookconcern = " + rs.getString("bookconcern") + "  ");
				    out.println("publicday = " + rs.getString("publicday") + "  ");
				    out.println("isbn = " + rs.getString("isbn") + "  ");
				    out.println("times = " + rs.getString("times") + "  ");
				    out.println("prize = " + rs.getString("prize") + "  ");
				    out.println("innumber = " + rs.getString("innumber") + "  ");
				    out.println("outnumber = " + rs.getString("outnumber") + "  ");
				
				  }
				
				}
				else if(request.getParameter("borrow")!=null && request.getParameter("title")!=null && flag==0){
				
				//  stmt = conn.createStatement();
				ResultSet rs5 = stmt.executeQuery("select * from book where title ='" + request.getParameter("title") + "'");
				if(rs5.next()){
				  int oldinbook = Integer.parseInt(rs5.getString("innumber"));
				  int oldoutbook = Integer.parseInt(rs5.getString("outnumber"));
				  String serialnumber=rs5.getString("serialnumber");
				  String sortnumber=rs5.getString("sortnumber");
				  if(oldinbook>0){//判断该书有没有库存
				
				  String newinbook = "update book set innumber ='" + (oldinbook-1) +"' where title ='" + request.getParameter("title") + "'";
				
				
				// stmt =conn .createStatement();
				  stmt1.executeUpdate(newinbook);
				
				  String newoutbook = "update book set outnumber ='" + (oldoutbook+1) +"' where title ='" + request.getParameter("title") + "'";
				
				
				// stmt=conn.createStatement();
				  stmt1.executeUpdate(newoutbook);
				  out.println("You succeed in borrowing this book.");}else{response.sendRedirect("fail.jsp");
				  }
				//out.println("" + request.getParameter("title") + "");
				//Statement stmt = conn.createStatement();
				//ResultSet rs1 = stmt.executeQuery("select * from book where title ='" + request.getParameter("title") + "'");
				
				//stmt = conn.createStatement();
				ResultSet rs7 = stmt.executeQuery("select * from administrator");
				int nowtrailnumber=0;
				while(rs7.next()){//从administrator表中获得borrowbook中的关键字trailnumber,他不因为程序结束而重新复值;
				nowtrailnumber=Integer.parseInt(rs7.getString("nowtrailnumber"));}
				  String insertborrowbook = "insert into borrowbook(trailnumber,serialnumber,sortnumber,title,id,studentnumber,borrowdata,shouldreturndata,returndata,overdata,fee,returnmoney) values('" + nowtrailnumber + "','" + serialnumber + "','" + sortnumber +
				   "','" + request.getParameter("title") + "','" + id + "','" + studentnumber + "','" + (new java.util.Date().getYear()*365 + new java.util.Date().getMonth()*31 + new java.util.Date().getDay()) + "','" +  (new java.util.Date().getYear()*365 + new java.util.Date().getMonth()*31 + new java.util.Date().getDay() + 6) + "','0','0','0.00','yes')";
				stmt1.execute("update administrator set nowtrailnumber ='"+(nowtrailnumber+1)+"'");//修改nowtrailnumber在administrator表中的值
				//stmt=conn.createStatement();
				   stmt1.execute(insertborrowbook);
				}
				  }else if(request.getParameter("return")!=null){
				
				//stmt = conn.createStatement();
				ResultSet rs4 = stmt.executeQuery("select * from borrowbook where id ='" + id + "' and title ='" + request.getParameter("title") + "' and returndata = '0'");
				
				if(rs4.next()){//判断在borrowbook表中是否有当前用户指定书名的书的未还记录,即returndata="0"
				 // int returndata=Integer.parseInt(rs4.getString("returndata"));
				  /*  rs4.getString("title").equals(request.getParameter("title"));
				    flag1=1;
				    }
				    if(flag1==1 && request.getParameter("title")!=null){*/
				//  if(returndata==)
				
				//stmt=conn.createStatement();
				  stmt1.executeUpdate("update borrowbook set returndata = '" +  (new java.util.Date().getYear()*365 + new java.util.Date().getMonth()*31 + new java.util.Date().getDay()) + "' where title ='" + request.getParameter("title") + "'and id ='" + id + "' and returndata = '0'");
				//一个用户不会有病到在一本书还没还的情况下,再借一本相同的书吧
				
				//stmt = conn.createStatement();
				ResultSet rs6 = stmt.executeQuery("select * from book where title ='" + request.getParameter("title") + "'");
				 while(rs6.next()){
				  int oldinbook = Integer.parseInt(rs6.getString("innumber"));
				  int oldoutbook = Integer.parseInt(rs6.getString("outnumber"));
				  String newinbook = "update book set innumber ='" + (oldinbook+1) +"' where title ='" + request.getParameter("title") + "'";
				
				
				
				  stmt1.executeUpdate(newinbook);
				
				  String newoutbook = "update book set outnumber ='" + (oldoutbook-1) +"' where title ='" + request.getParameter("title") + "'";
				
				
				
				  stmt1.executeUpdate(newoutbook);
				  out.println("You succeed in returning this book.");
				 }
				    }
				  }
				}catch (Exception ex) {
				  response.sendRedirect("fail.jsp");
				ex.printStackTrace();}
				
				%>
				
				
				
							

相关资源