19年期末考试答案

<%@ page contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>用户登录</title>
</head>
    <form id="1" action ="denlv.jsp" method="get">   
   <p style="text-align:center;color:black;font-family:楷体; font-size:20px">    
                <br>
                身份:
                <select size ="1"name="calss">
                <option value ="顾客" selected>顾客</option>
                <option value ="房产经纪" >房产经纪</option>
                <option value ="系统管理员" >系统管理员</option>
                </select>
                <br><br>
                用户:             
                    <input type="text" name="num"size="15"/>
                <br><br>                
                密码:               
                    <input type="password" name="pass"size="16"/>                       
                <br><br>                  
                <br><br>
                     <input type="button" value="登录" onclick="location.href='gongneng.jsp'" />                             
                     <input type="button" value="注册" onclick="location.href='zhuce.jsp'" />   
                
                   
                       
    </p>
    </form>  

</html>
<%@ page contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>录入</title>   
</head>
   <form id="1" action ="zhuce-backstage.jsp" method="get">   
   <p style="text-align:center;color:black;font-family:楷体; font-size:20px">    
                <br>                        
                身份证号码:             
                    <input type="text" name="sfnum"size="15"/>
                       <br><br> 
                姓名:             
                    <input type="text" name="name"size="3"/>
                <br><br>                
                性别:               
                     <input type="radio" name="sex" value="男" />男
                     <input type="radio" name="sex" value="女" />女
                手机号码:             
                    <input type="text" name="sjnum"size="10"/>
                <br><br>                
                家庭住址:               
                    <input type="text" name="home"size="10"/>
                <br><br>  
                密码:
                     <input type="text" name="home"size="10"/>
                <br><br>            
                    <input type="submit" value="登记"/>
                    <input type="reset" value="重置"/>     
    </p>
    </form>   
</body>
</html>
<%@ page contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>处理</title>
</head>

<body>
<jsp:useBean id="util" class="jb.AbbC"/>
<%
String sfnum= request.getParameter("sfnum");
String name= request.getParameter("name");
String sex= request.getParameter("sex");
String sjnum= request.getParameter("sjnum");
String home= request.getParameter("home");
String mima= request.getParameter("mima");

if(util.queryEmpty(sfnum,name,sex,sjnum,home,mima)){
    out.print("<script language ='javaScript'> alert('输入不能为空,请完成填写');window.history.back(-1); </script>");
}else if(util.sfzhm(sfnum)){
    out.print("<script language ='javaScript'> alert('身份证必须为18位,且只能最后一位为X或数字');window.history.back(-1); </script>");
}else if(util.chachong(sfnum)){
    out.print("<script language ='javaScript'> alert('录入身份证号码重复');window.history.back(-1); </script>");      
}else{
    util.input(sfnum,name,sex,sjnum,home,mima);
    out.print("<script language='javaScript'> alert('录入成功');</script>");
    response.setHeader("refresh", "0;url=main.jsp");
}
%>
</body>
</html>

<%@ page language="java" import="java.sql.*" pageEncoding="utf-8"%>
<html>
<head>
<title>修改</title>
</head>
<body>
<table border="1"style="text-align:center">
<caption>修改密码</caption>
<tr>
<td align="center" width=4%>密码</td>

</tr>
<jsp:useBean id="util" class="jb.AbbC" scope="page" />
<%
String num=session.getAttribute("num").toString();
try{
    Connection connect = util.sjk();
    Statement stmt = connect.createStatement();
    ResultSet rs = stmt.executeQuery("select * from guke");
    while(rs.next()){    
       if(num.equals(rs.getObject(2).toString()))
       {
           %>
          <tr>
          <td width=4% align="center"><%=rs.getObject(6) %></td>                
    
          </tr>
            <%
       }
   }
   rs.close();
   connect.close();
   stmt.close();
}catch (SQLException e) {
   e.printStackTrace();            
}
%>
</table> 
</body>
<form id="1" action ="teacher-reviseback.jsp" method="get">   
   <p style="text-align:center;color:black;font-family:楷体; font-size:20px">    
                <br>
                密码:             
                    <input type="text" name="mima"size="10"/>
                           
                                   
                <br><br>            
                <input type="button" value="返回上一页" onclick="location.href='gongneng.jsp" /> 
                <br><br>
                    <input type="submit" value="修改"/>
                    <input type="reset" value="重置"/>     
    </p>
    </form>  
</html>
<%@ page contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>修改密码</title>
</head>
<body>
<jsp:useBean id="util" class="jb.AbbC" scope="page" />
<%
String mima=session.getAttribute("mima").toString();

if(util.queryTeacherxiu(mima)){
      out.print("<script language ='javaScript'> alert('输入不能为空');window.history.back(-1); </script>");
}else{
    util.teacherXiugai(mima);
    out.print("<script language='javaScript'> alert('修改成功');</script>");
    response.setHeader("refresh", "0;url=teacher.jsp");   
}
%>
</body>
</html>>
<%@ page contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>房产经纪</title>
<body background="BACKGROUNG/1.jpg">
</head>
    <p style="text-align:center;color:black;font-family:宋体,serif; font-size:20px">
            <br> 
            <input type="button" value="查看个人信息" onclick="location.href='watchjinngji.jsp'" />
            <br><br>
            <input type="button" value="修改个人密码" onclick="location.href='revisejingji.jsp'" />
            <br><br>
            <input type="button" value="浏览房产信息" onclick="location.href='watchhouse.jsp'" />
            <br><br>
            <input type="button" value="查询房产" onclick="location.href='wacthfang.jsp'" />
            <br><br>
            <input type="button" value="房产交易" onclick="location.href='buyhouse1.jsp'" />    
            
            
            
            
                 <br><br>            
                <input type="button" value="主页面" onclick="location.href='main.jsp'" />   
    </p>

</html>
<%@ page contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>录入</title>   
</head>
   <form id="1" action ="jjzhuce-backstage.jsp" method="get">   
   <p style="text-align:center;color:black;font-family:楷体; font-size:20px">    
                <br>                        
                工号:             
                    <input type="text" name="gonghao"size="15"/>
                       <br><br> 
                姓名:             
                    <input type="text" name="jjname"size="3"/>
                <br><br>                
                家庭住址:               
                    <input type="text" name="jjhome"size="10"/>
                <br><br> 
                手机号码:             
                    <input type="text" name="sjhm"size="10"/>
                               
    
             
                  <br><br>            
                    <input type="submit" value="登记"/>
                    <input type="reset" value="重置"/>     
    </p>
    </form>   
</body>
</html>ml>
<%@ page contentType="text/html; charset=utf-8"
         pageEncoding="utf-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>处理</title>
</head>

<body>
<jsp:useBean id="util" class="jb.AbbC"/>
<%
String gonghao= request.getParameter("gonghao");
String jjname= request.getParameter("jjname");
String jjhome= request.getParameter("jjhome");
String sjhm= request.getParameter("sjhm");

if(util.queryEmpty2(gonghao,jjname,jjhome,sjhm)){
    out.print("<script language ='javaScript'> alert('输入不能为空,请完成填写');window.history.back(-1); </script>");
  
}else{
    util.input1(gonghao,jjname,jjhome,sjhm);

    out.print("<script language='javaScript'> alert('录入成功');</script>");
    response.setHeader("refresh", "0;url=main.jsp");
}
%>
</body>
</html>


ADDC
package jb;
import java.sql.*;
public class AbbC {
    public Connection sjk()
    {
        Connection connect;
        try {
            connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");
            return connect;
        }catch(Exception e)
        {
            e.printStackTrace();  
        }
        return null;        
    }
    public boolean queryEmpty(String sfnum,String name,String sex,String sjnum,String home,String mima)
    {
        boolean flag=false;
        if(sfnum==null||"".equals((sfnum))&&name==null||"".equals(name)&&sex==null||"".equals(sex)&&sjnum==null||"".equals(sjnum)&&home==null||"".equals(home)&&mima==null||"".equals(mima))
        {
            flag=true;
        }
        return flag;
    }
    public Connection sj()
    {
        Connection connect;
        try {
            connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");
            return connect;
        }catch(Exception e)
        {
            e.printStackTrace();  
        }
        return null;        
    }
    public boolean queryEmpty2(String gonghao,String jjname,String jjhome,String sjhm)
    {
        boolean flag=false;
        if(gonghao==null||"".equals((gonghao))&&jjname==null||"".equals(jjname)&&jjhome==null||"".equals(jjhome)&&sjhm==null||"".equals(sjhm))
        {
            flag=true;
        }
        return flag;
    }
    public boolean pinji(String sfnum,String sjnum)
    {
        boolean flag=true;
        try {  
            double a=Integer.valueOf(sfnum);
            double b=Integer.valueOf(sjnum);
            if(a%1==0&&b%1==0)
            {
                flag=false;
            }
            return flag; 
        } catch (Exception e) {  
            return flag;   
        }  
    }
    public boolean queryTeacherxiu(String mima)//查空
    {
        boolean flag=false;
        if(mima==null||"".equals((mima)))
        {
            flag=true;
        }
        return flag;
    }
    public void teacherXiugai(String mima)
    {
        try {
            PreparedStatement preparedStatement=null;
            Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");           
            preparedStatement=connect.prepareStatement("Update guke set mima=?, ");
            preparedStatement.setString(6,mima);           
            preparedStatement.executeUpdate();  
            preparedStatement.execute();
            connect.close();                      
        }catch(SQLException e){
            e.printStackTrace();  
        }
    }
    public void input(String sfnum,String name,String sex,String sjnum,String home,String mima)
    {
        try {
            PreparedStatement preparedStatement=null;
            Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");           
            preparedStatement=connect.prepareStatement("insert into guke (sfnum,name,sex,sjnum,home,mima) values (?,?,?,?,?,?)");
            preparedStatement.setString(1,sfnum);
            preparedStatement.setString(2,name);
            preparedStatement.setString(3,sex);
            preparedStatement.setString(4,sjnum);
            preparedStatement.setString(5,home);
            preparedStatement.setString(6,mima);
          
            preparedStatement.executeUpdate();  
            connect.close();
            preparedStatement.close();           
        }catch(SQLException e){
            e.printStackTrace();  
        }
    }
    public void input1(String gonghao,String jjname,String jjhome,String sjhm)
    {
        try {
            PreparedStatement preparedStatement=null;
            Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");           
            preparedStatement=connect.prepareStatement("insert into jingji (gonghao,jjname,jjhome,sjhm) values (?,?,?,?)");
            preparedStatement.setString(1,gonghao);
            preparedStatement.setString(2,jjname);
        
            preparedStatement.setString(3,jjhome);
            preparedStatement.setString(4,sjhm);
          
            preparedStatement.executeUpdate();  
            connect.close();
            preparedStatement.close();           
        }catch(SQLException e){
            e.printStackTrace();  
        }
    }
    public void xiugai(String sfnum,String name,String sex,String sjnum,String home,String mima,String sf1)
    {
        try {
            PreparedStatement preparedStatement=null;
            Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");           
            preparedStatement=connect.prepareStatement("Update guke set sfnum=?,name=?,sex=?,sjnum=?,home=?,miam=? where sfnum=?");
            preparedStatement.setString(1,sfnum);
            preparedStatement.setString(2,name);
            preparedStatement.setString(3,sex);
            preparedStatement.setString(4,sjnum);
            preparedStatement.setString(5,home);
            preparedStatement.setString(6,mima);
            preparedStatement.setString(7,sf1);
            preparedStatement.executeUpdate();  
            preparedStatement.execute();
            connect.close();                      
        }catch(SQLException e){
            e.printStackTrace();  
        }
    }
    public void deletedata(String sfnum)
    {
        try {
            PreparedStatement preparedStatement=null;
            Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");           
            preparedStatement=connect.prepareStatement("delete from guke where sfnum = ?");
            preparedStatement.setString(1,sfnum);
            preparedStatement.executeUpdate();  
            connect.close();
            preparedStatement.close();           
        }catch(SQLException e){
            e.printStackTrace();  
        }
    }
    public boolean queryEmpty1(String name)
    {
        boolean flag=false;
        if(name==null||"".equals((name)))
        {
            flag=true;
        }
        return flag;
    }
    public boolean inquiryCurriculum(String name)
    {       
        boolean flag=true;     
        try {
            Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");
            Statement stmt = connect.createStatement();
            ResultSet rs = stmt.executeQuery("select * from guke");
            while(rs.next())
            {
                if(name.equals(rs.getString("name")))
                {                                           
                    flag=false;                  
                } 
            }                                                          
            rs.close();
            connect.close();
            stmt.close();
        }catch (SQLException e) {
            e.printStackTrace();            
        }
        return  flag;
    }
    public boolean chachong(String sfnum)
    {
        boolean flag=false;
        try {
            Connection connect = DriverManager.getConnection("jdbc:mysql://localhost:3306/test?&useSSL=false&serverTimezone=UTC","root","root");
            Statement stmt = connect.createStatement();
            ResultSet rs = stmt.executeQuery("select * from guke");
            while(rs.next())
            {                 
                if(sfnum.equals(rs.getString("sfnum")))
                {
                    flag=true; 
                }                 
            }                                                          
            rs.close();
            connect.close();
            stmt.close();
        }catch (SQLException e) {
            e.printStackTrace();            
        }
        return flag;
    }
    public boolean sfzhm(String sfnum)
    {
        boolean flag=true;     
        if(sfnum.length()==18)
        {
            for(int i=0;i<sfnum.length()-1;i++)
            {
                char k=sfnum.charAt(i);
                if(k=='0'||k=='1'||k=='2'||k=='3'||k=='4'||k=='5'||k=='6'||k=='7'||k=='8'||k=='9') continue;
                else return flag;
            }
            char k=sfnum.charAt(sfnum.length()-1);
            if(k=='0'||k=='1'||k=='2'||k=='3'||k=='4'||k=='5'||k=='6'||k=='7'||k=='8'||k=='9'||k=='X') flag=false;
        }
        return  flag;
    }
    public static void main(String[] args) {
        AbbC a=new AbbC(); 
posted @   意い十三章  阅读(22)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· C#/.NET/.NET Core优秀项目和框架2025年2月简报
· DeepSeek在M芯片Mac上本地化部署
点击右上角即可分享
微信分享提示