zoukankan      html  css  js  c++  java
  • 进度十一(10.29)

     

    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    
    <title></title>
    </head>
    <body>
        <div align="center">    
            <h1 style="color: red;">权限信息总览</h1>
            <h6>(“1”表示拥有此项权限;“0”表示未拥有此项权限)</h6>    
            <table class="table table-hover table-striped table-bordered table-sm" id="resultshow">
                <tr>
                    <td>角色名称</td>
                    <td>需求征集</td>
                    <td>需求管理</td>
                    <td>用户信息</td>
                    <td>修改密码</td>
                    <td>统计需求</td>
                    <td>形式审核</td>        
                    <td>部门审核</td>            
                    <td>修改</td>
                </tr>
                <c:forEach items="${power}" var="item">
                    <tr>
                        <td>${item.joker}</td>
                        <td>${item.xqzj_qx}</td>
                        <td>${item.xqgl_qx}</td>
                        <td>${item.yhxx_qx}</td>
                        <td>${item.xgmm_qx}</td>
                        <td>${item.tjxq_qx}</td>    
                        <td>${item.xssh_qx}</td>
                        <td>${item.bmsh_qx}</td>    
                        <td><a href="AdminServlet?method=changeThePowerByJoker&joker=${item.joker}">修改</a></td>
                    </tr>
                </c:forEach>
            </table>
        </div>
    </body>
    </html>
    View Code
    <%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/css/bootstrap.min.css">
    <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://cdn.staticfile.org/popper.js/1.15.0/umd/popper.min.js"></script>
    <script src="https://cdn.staticfile.org/twitter-bootstrap/4.3.1/js/bootstrap.min.js"></script>
    <%
             Object power = request.getAttribute("power");
             if(power!=null && !"".equals(power)){} 
    %>
    <title></title>
    </head>
    <body>
        <div align="center">    
            <h1 style="color: red;">修改<a>${power.joker}</a>权限</h1>
            <h6>(“1”表示拥有此项权限;“0”表示未拥有此项权限)</h6>    
            <div hidden="true"><input id="joker" value="${power.joker}"></div>
            <table class="table table-hover table-striped table-bordered table-sm" id="resultshow">
                <tr>
                    <td>权限名称</td>
                    <td>权限状态</td>
                    <td>修改状态</td>
                </tr>
                <tr>
                    <td>需求征集</td>
                    <td>${power.xqzj_qx}</td>
                    <td>
                        <select id="xqzj_qx">
                            <option value="${power.xqzj_qx}"></option>
                            <option value='1'>1</option>
                            <option value='0'>0</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>需求管理</td>
                    <td>${power.xqgl_qx}</td>
                    <td>
                        <select id="xqgl_qx">
                            <option value="${power.xqgl_qx}"></option>
                            <option value='1'>1</option>
                            <option value='0'>0</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>用户信息</td>
                    <td>${power.yhxx_qx}</td>
                    <td>
                        <select id="yhxx_qx">
                            <option value="${power.yhxx_qx}"></option>
                            <option value='1'>1</option>
                            <option value='0'>0</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>修改密码</td>
                    <td>${power.xgmm_qx}</td>
                    <td>
                        <select id="xgmm_qx">
                            <option value="${power.xgmm_qx}"></option>
                            <option value='1'>1</option>
                            <option value='0'>0</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>统计需求</td>
                    <td>${power.tjxq_qx}</td>
                    <td>
                        <select id="tjxq_qx">
                            <option value="${power.tjxq_qx}"></option>
                            <option value='1'>1</option>
                            <option value='0'>0</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>形式审核</td>
                    <td>${power.xssh_qx}</td>
                    <td>
                        <select id="xssh_qx">
                            <option value="${power.xssh_qx}"></option>
                            <option value='1'>1</option>
                            <option value='0'>0</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>部门审核</td>
                    <td>${power.bmsh_qx}</td>
                    <td>
                        <select id="bmsh_qx">
                            <option value="${power.bmsh_qx}"></option>
                            <option value='1'>1</option>
                            <option value='0'>0</option>
                        </select>
                    </td>
                </tr>
            </table>
            <div align="center"><input type="button" value="保存" onclick="change('${power.joker}')"></div>
        </div>
    </body>
    <script type="text/javascript">
            function change(joker) {    
                
                var joker = document.getElementById("joker").value;
                var xqzj_qx = document.getElementById("xqzj_qx").value;
                var xqgl_qx = document.getElementById("xqgl_qx").value;
                var yhxx_qx = document.getElementById("yhxx_qx").value;
                var xgmm_qx = document.getElementById("xgmm_qx").value;
                var tjxq_qx = document.getElementById("tjxq_qx").value;
                var xssh_qx = document.getElementById("xssh_qx").value;
                var bmsh_qx = document.getElementById("bmsh_qx").value;
                
                var url = "AdminServlet?method=changeThePower&joker=" + joker + "&xqzj_qx=" + xqzj_qx + "&xqgl_qx=" + xqgl_qx + "&yhxx_qx=" + yhxx_qx + "&xgmm_qx=" + xgmm_qx + "&tjxq_qx=" + tjxq_qx + "&xssh_qx=" + xssh_qx + "&bmsh_qx=" + bmsh_qx;
    
                if (confirm("确定要修改吗?")){
                    window.location.href = url;
                }else{
                    return false;
                }
            }
        </script>
    </html>
    View Code
    package servlet;
    
    import java.io.IOException;
    import java.util.List;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import bean.Power;
    import dao.AdminDao;
    
    @WebServlet("/AllPowerServlet")
    public class AllPowerServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
           
        public AllPowerServlet() {
            super();
            // TODO Auto-generated constructor stub
        }
    
        protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            request.setCharacterEncoding("utf-8");
            List<Power> power = AdminDao.listpower();
            request.setAttribute("power", power);
            request.getRequestDispatcher("admin/allpower.jsp").forward(request,response);
        }
    
        protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            // TODO Auto-generated method stub
            doGet(request, response);
        }
    
    }
    View Code
    package servlet;
    
    import java.io.IOException;
    import java.util.Arrays;
    
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import bean.Power;
    import bean.Table;
    import bean.User;
    import dao.AdminDao;
    
    @WebServlet("/AdminServlet")
    public class AdminServlet extends HttpServlet {
        private static final long serialVersionUID = 1L;
           
        public AdminServlet() {
            super();
            // TODO Auto-generated constructor stub
        }
        
        protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
            request.setCharacterEncoding("utf-8");
            String method = request.getParameter("method");
            if ("getTheTableById".equals(method)) {
                getTheTableById(request, response);
            }
            else if ("changeTheTableById".equals(method)) {
                changeTheTableById(request, response);
            }
            else if ("changeTheTable".equals(method)) {
                changeTheTable(request, response);
            }
            else if ("deleteTheTableById".equals(method)) {
                deleteTheTableById(request, response);
            }
            else if ("getTheUserById".equals(method)) {
                getTheUserById(request, response);
            }
            else if ("changeTheUserById".equals(method)) {
                changeTheUserById(request, response);
            }
            else if ("changeTheUser".equals(method)) {
                changeTheUser(request, response);
            }
            else if ("deleteTheUserById".equals(method)) {
                deleteTheUserById(request, response);
            }
            else if ("changeTheJoker".equals(method)) {
                changeTheJoker(request, response);
            }
            else if ("changeThePowerByJoker".equals(method)) {
                changeThePowerByJoker(request, response);
            }
            else if ("changeThePower".equals(method)) {
                changeThePower(request, response);
            }
        }
        
        private void getTheTableById(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            int id = Integer.parseInt(request.getParameter("id"));
            Table table = AdminDao.getTheTableById(id);
            request.setAttribute("table", table);
            request.getRequestDispatcher("table/thetable.jsp").forward(request,response);
        }
        
        private void changeTheTableById(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            int id = Integer.parseInt(request.getParameter("id"));
            Table table = AdminDao.getTheTableById(id);
            request.setAttribute("table", table);
            request.getRequestDispatcher("table/changetable.jsp").forward(request,response);
        }
        
        private void changeTheTable(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            response.setContentType("text/html;charset=utf-8");
            
            String wjid1=request.getParameter("wjid");
            int wjid=Integer.parseInt(wjid1);
            String jgqc=request.getParameter("jgqc");
            String gkglbm=request.getParameter("gkglbm");
            String txdz=request.getParameter("txdz");
            String szdy=request.getParameter("szdy");
            String wz=request.getParameter("wz");
            String dzxx=request.getParameter("dzxx");
            String frdb=request.getParameter("frdb");
            String yzbm=request.getParameter("yzbm");
            String lxr=request.getParameter("lxr");
            String gddh=request.getParameter("gddh");
            String sj=request.getParameter("sj");
            String cz=request.getParameter("cz");
            String jgsx=request.getParameter("jgsx");
            String jgjj=request.getParameter("jgjj");
            String jsxqmc=request.getParameter("jsxqmc");
            String qsxqsx=request.getParameter("qsxqsx");
            String jzxqsx=request.getParameter("jzxqsx");
            String jsxqgs=request.getParameter("jsxqgs");
            String gjza=request.getParameter("gjza");
            String gjzb=request.getParameter("gjzb");
            String gjzc=request.getParameter("gjzc");
            String gjzd=request.getParameter("gjzd");
            String gjze=request.getParameter("gjze");
            String gjz=gjza+" "+gjzb+" "+gjzc+" "+gjzd+" "+gjze;
            String ntrjeze1=request.getParameter("ntrjeze");
            int ntrjeze=Integer.parseInt(ntrjeze1);
            String jsxqjjfs=request.getParameter("jsxqjjfs");
            String hzyxdw=request.getParameter("hzyxdw");
            String kjhdlx=request.getParameter("kjhdlx");
            String xkfl=request.getParameter("xkfl");
            String [] a = request.getParameterValues("xqjsssly");
            String xqjsssly=Arrays.toString(a);
            xqjsssly=xqjsssly.substring(1,xqjsssly.length()-1);
            String xqjsyyhy=request.getParameter("xqjsyyhy");
            String qtjs=request.getParameter("qtjs");
            String xssh=request.getParameter("xssh");
            String glcs=request.getParameter("glcs");
            String xsyj=request.getParameter("xsyj");
            String bmsh=request.getParameter("bmsh");
            String bmyj=request.getParameter("bmyj");
            
            Table tbwork =new Table();
            tbwork.setWjid(wjid);
            tbwork.setJgqc(jgqc);
            tbwork.setGkglbm(gkglbm);
            tbwork.setTxdz(txdz);
            tbwork.setSzdy(szdy);
            tbwork.setWz(wz);
            tbwork.setDzxx(dzxx);
            tbwork.setFrdb(frdb);
            tbwork.setYzbm(yzbm);
            tbwork.setLxr(lxr);
            tbwork.setGddh(gddh);
            tbwork.setSj(sj);
            tbwork.setCz(cz);
            tbwork.setJgsx(jgsx);
            tbwork.setJgjj(jgjj);
            tbwork.setJsxqmc(jsxqmc);
            tbwork.setQsxqsx(qsxqsx);
            tbwork.setJzxqsx(jzxqsx);
            tbwork.setJsxqgs(jsxqgs);
            tbwork.setGjz(gjz);
            tbwork.setNtrjeze(ntrjeze);
            tbwork.setJsxqjjfs(jsxqjjfs);
            tbwork.setHzyxdw(hzyxdw);
            tbwork.setKjhdlx(kjhdlx);
            tbwork.setXkfl(xkfl);
            tbwork.setXqjsssly(xqjsssly);
            tbwork.setXqjsyyhy(xqjsyyhy);
            tbwork.setQtjs(qtjs);
            tbwork.setXssh(xssh);
            tbwork.setXsyj(xsyj);
            tbwork.setGlcs(glcs);
            tbwork.setBmsh(bmsh);
            tbwork.setBmyj(bmyj);
            
            try{
                AdminDao.changeTheTableById(tbwork);  
                request.setAttribute("message", "修改成功");
                request.getRequestDispatcher("AllTableServlet").forward(request,response);
    
            }catch(Exception e){
                System.out.println("保存失败");
                e.printStackTrace();
            }
    
        }
        
        private void getTheUserById(final HttpServletRequest request, final HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            int id = Integer.parseInt(request.getParameter("id"));
            User user = AdminDao.getTheUserById(id);
            request.setAttribute("user", user);
            request.getRequestDispatcher("user/theuser.jsp").forward(request,response);
        }
        
        private void changeTheUserById(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            int id = Integer.parseInt(request.getParameter("id"));
            User user = AdminDao.getTheUserById(id);
            request.setAttribute("user", user);
            request.getRequestDispatcher("user/changeuser.jsp").forward(request,response);
        }
        
        private void changeTheUser(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            response.setContentType("text/html;charset=utf-8");
            
            String id1=request.getParameter("id");
            int id=Integer.parseInt(id1);
            String username=request.getParameter("username");
            String password=request.getParameter("password");
            String jgmc=request.getParameter("jgmc");
            String zzjgdm=request.getParameter("zzjgdm");
            String name=request.getParameter("name");
            String ssz=request.getParameter("ssz");
            String yzbm=request.getParameter("yzbm");
            String sex=request.getParameter("sex");
            String sheng=request.getParameter("sheng");
            String shi=request.getParameter("shi");
            String zyfx=request.getParameter("zyfx");
            String szhy=request.getParameter("szhy");
            String jycd=request.getParameter("jycd");
            String zc=request.getParameter("zc");
            String txdz=request.getParameter("txdz");
            String sj=request.getParameter("sj");
            String gddh=request.getParameter("gddh");
            String yx=request.getParameter("yx");
            String qq=request.getParameter("qq");
            String joker=request.getParameter("joker");
            
            User Subject =new User();
            Subject.setId(id);
            Subject.setUsername(username);
            Subject.setPassword(password);
            Subject.setJgmc(jgmc);
            Subject.setZzjgdm(zzjgdm);
            Subject.setName(name);
            Subject.setSsz(ssz);
            Subject.setYzbm(yzbm);
            Subject.setSex(sex);
            Subject.setSheng(sheng);
            Subject.setShi(shi);
            Subject.setZyfx(zyfx);
            Subject.setSzhy(szhy);
            Subject.setJycd(jycd);
            Subject.setZc(zc);
            Subject.setTxdz(txdz);
            Subject.setSj(sj);
            Subject.setGddh(gddh);
            Subject.setYx(yx);
            Subject.setQq(qq);
            Subject.setJoker(joker);
            
            try{
                AdminDao.changeTheUserById(Subject);  
                request.setAttribute("message", "修改成功");
                request.getRequestDispatcher("AllUserServlet").forward(request,response);
    
            }catch(Exception e){
                System.out.println("保存失败");
                e.printStackTrace();
            }
    
        }
    
        private void deleteTheTableById(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            int id = Integer.parseInt(request.getParameter("id"));
            
            try{
                AdminDao.deleteTheTableById(id);
                request.setAttribute("message", "删除成功");
                request.getRequestDispatcher("AllTableServlet").forward(request,response);
    
            }catch(Exception e){
                System.out.println("删除失败");
                e.printStackTrace();
            }
        }
        
        private void deleteTheUserById(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            int id = Integer.parseInt(request.getParameter("id"));
            
            try{
                AdminDao.deleteTheUserById(id);
                request.setAttribute("message", "删除成功");
                request.getRequestDispatcher("AllUserServlet").forward(request,response);
    
            }catch(Exception e){
                System.out.println("删除失败");
                e.printStackTrace();
            }
        }
        
        private void changeTheJoker(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            
            String username = request.getParameter("username");
            String joker = request.getParameter("joker");
        
            try{
                AdminDao.changeTheJoker(username,joker);
                request.setAttribute("message", "保存成功");
                request.getRequestDispatcher("AllJokerServlet").forward(request,response);
    
            }catch(Exception e){
                System.out.println("保存失败");
                e.printStackTrace();
            }
        }
        
        private void changeThePowerByJoker(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            
            String joker = request.getParameter("joker");    
            Power power = new Power();
            power = AdminDao.getThePowerByJoker(joker);
            
            request.setAttribute("power", power);
            request.getRequestDispatcher("admin/changepower.jsp").forward(request,response);
    
            
        }
        
        private void changeThePower(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException{
            request.setCharacterEncoding("utf-8");
            
            String joker = request.getParameter("joker");
            String xqzj_qx1 = request.getParameter("xqzj_qx");
            int xqzj_qx = Integer.parseInt(xqzj_qx1);
            String xqgl_qx1 = request.getParameter("xqgl_qx");
            int xqgl_qx = Integer.parseInt(xqgl_qx1);
            String yhxx_qx1 = request.getParameter("yhxx_qx");
            int yhxx_qx = Integer.parseInt(yhxx_qx1);
            String xgmm_qx1 = request.getParameter("xgmm_qx");
            int xgmm_qx = Integer.parseInt(xgmm_qx1);
            String tjxq_qx1 = request.getParameter("tjxq_qx");
            int tjxq_qx = Integer.parseInt(tjxq_qx1);
            String xssh_qx1 = request.getParameter("xssh_qx");
            int xssh_qx = Integer.parseInt(xssh_qx1);
            String bmsh_qx1 = request.getParameter("bmsh_qx");
            int bmsh_qx = Integer.parseInt(bmsh_qx1);
        
            try{
                AdminDao.changeThePower(joker,xqzj_qx,xqgl_qx,yhxx_qx,xgmm_qx,tjxq_qx,xssh_qx,bmsh_qx);
                request.setAttribute("message", "保存成功");
                request.getRequestDispatcher("AllPowerServlet").forward(request,response);
    
            }catch(Exception e){
                System.out.println("保存失败");
                e.printStackTrace();
            }
        }
        
    }
    View Code
    package dao;
    
    import java.sql.Connection;
    import java.sql.PreparedStatement;
    import java.sql.ResultSet;
    import java.sql.SQLException;
    import java.sql.Statement;
    import java.util.ArrayList;
    import java.util.List;
    
    import bean.Power;
    import bean.Table;
    import bean.User;
    import util.DBUtil;
    
    public class AdminDao {
        
        public static List<User> listuser() {
            String sql = "select * from t_user";
            List<User> list = new ArrayList<>();
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            ResultSet rs = null;
            try {
                state = conn.createStatement();
                rs = state.executeQuery(sql);            
                while (rs.next()) {
                    User user = new User();
                    int id = rs.getInt("id");
                    String username = rs.getString("username");
                    String name = rs.getString("name");
                    String sex = rs.getString("sex");
                    String jgmc = rs.getString("jgmc");
                    String joker = rs.getString("joker");
                    
                    user.setId(id);
                    user.setUsername(username);
                    user.setName(name);
                    user.setSex(sex);
                    user.setJgmc(jgmc);
                    user.setJoker(joker);
                    list.add(user);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(rs, state, conn);
            }    
            return list;
        }
        
        public static List<Power> listpower() {
            String sql = "select * from t_power";
            List<Power> list = new ArrayList<>();
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            ResultSet rs = null;
            try {
                state = conn.createStatement();
                rs = state.executeQuery(sql);            
                while (rs.next()) {
                    Power power = new Power();
    
                    String joker = rs.getString("joker");
                    int xqzj_qx = rs.getInt("xqzj_qx");
                    int xqgl_qx = rs.getInt("xqgl_qx");
                    int yhxx_qx = rs.getInt("yhxx_qx");
                    int xgmm_qx = rs.getInt("xgmm_qx");
                    int xssh_qx = rs.getInt("xssh_qx");
                    int bmsh_qx = rs.getInt("bmsh_qx");
                    int tjxq_qx = rs.getInt("tjxq_qx");
                    
                    power.setJoker(joker);
                    power.setXqzj_qx(xqzj_qx);
                    power.setXqgl_qx(xqgl_qx);
                    power.setYhxx_qx(yhxx_qx);
                    power.setXgmm_qx(xgmm_qx);
                    power.setXssh_qx(xssh_qx);
                    power.setBmsh_qx(bmsh_qx);
                    power.setTjxq_qx(tjxq_qx);
                    list.add(power);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(rs, state, conn);
            }    
            return list;
        }
        
        public static List<Table> listtable() {
            String sql = "select * from t_table";
            List<Table> list2 = new ArrayList<>();
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            ResultSet rs = null;
            try {
                state = conn.createStatement();
                rs = state.executeQuery(sql);            
                while (rs.next()) {
                    
                    Table table = new Table();
                    
                    int wjid = rs.getInt("wjid");
                    String jsxqmc = rs.getString("jsxqmc");
                    String jgqc = rs.getString("jgqc");
                    String gkglbm = rs.getString("gkglbm");
                    String szdy = rs.getString("szdy");
                    String frdb = rs.getString("frdb");
                    String lxr = rs.getString("lxr");
                    String jgsx = rs.getString("jgsx");
                    int ntrjeze = rs.getInt("ntrjeze");            
                    String jsxqjjfs = rs.getString("jsxqjjfs");                
                    String kjhdlx = rs.getString("kjhdlx");                                        
                    String xkfl = rs.getString("xkfl");            
                    String xqjsssly = rs.getString("xqjsssly");
                    String xqjsyyhy = rs.getString("xqjsyyhy");
                    String glcs = rs.getString("glcs");
                    String xssh = rs.getString("xssh");
                    String bmsh = rs.getString("bmsh");
                    
                    table.setWjid(wjid);
                    table.setJsxqmc(jsxqmc);
                    table.setJsxqjjfs(jsxqjjfs);
                    table.setKjhdlx(kjhdlx);
                    table.setGkglbm(gkglbm);
                    table.setJgqc(jgqc);
                    table.setLxr(lxr);
                    table.setSzdy(szdy);
                    table.setFrdb(frdb);
                    table.setJgsx(jgsx);
                    table.setNtrjeze(ntrjeze);
                    table.setXkfl(xkfl);
                    table.setXqjsssly(xqjsssly);
                    table.setXqjsyyhy(xqjsyyhy);
                    table.setGlcs(glcs);
                    table.setXssh(xssh);
                    table.setBmsh(bmsh);
                    
                    list2.add(table);
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(rs, state, conn);
            }    
            return list2;
        }
        
        public static Table getTheTableById(int id) {
            String sql = "select * from t_table where wjid ="+id;
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            ResultSet rs = null;
            Table table = new Table();
            try {
                state = conn.createStatement();
                rs = state.executeQuery(sql);            
                while (rs.next()) {
                    
                    int wjid = rs.getInt("wjid");
                    String jsxqmc = rs.getString("jsxqmc");
                    String jgqc = rs.getString("jgqc");
                    String gkglbm = rs.getString("gkglbm");
                    String txdz = rs.getString("txdz");
                    String szdy = rs.getString("szdy");
                    String wz = rs.getString("wz");
                    String dzxx = rs.getString("dzxx");
                    String frdb = rs.getString("frdb");
                    String yzbm = rs.getString("yzbm");
                    String lxr = rs.getString("lxr");
                    String gddh = rs.getString("gddh");
                    String sj = rs.getString("sj");
                    String cz = rs.getString("cz");
                    String jgsx = rs.getString("jgsx");
                    String jgjj = rs.getString("jgjj");
                    String qsxqsx = rs.getString("qsxqsx");
                    String jzxqsx = rs.getString("jzxqsx");
                    String jsxqgs = rs.getString("jsxqgs");
                    String gjz = rs.getString("gjz");
                    int ntrjeze = rs.getInt("ntrjeze");            
                    String jsxqjjfs = rs.getString("jsxqjjfs");
                    String hzyxdw = rs.getString("hzyxdw");
                    String kjhdlx = rs.getString("kjhdlx");                                        
                    String xkfl = rs.getString("xkfl");            
                    String xqjsssly = rs.getString("xqjsssly");
                    String xqjsyyhy = rs.getString("xqjsyyhy");
                    String qtjs = rs.getString("qtjs");
                    String glcs = rs.getString("glcs");
                    String xssh = rs.getString("xssh");
                    String bmsh = rs.getString("bmsh");
                    String xsyj = rs.getString("xsyj");
                    String bmyj = rs.getString("bmyj");
                    
                    table.setWjid(wjid);
                    table.setJgqc(jgqc);
                    table.setGkglbm(gkglbm);
                    table.setTxdz(txdz);
                    table.setSzdy(szdy);
                    table.setWz(wz);
                    table.setDzxx(dzxx);
                    table.setFrdb(frdb);
                    table.setYzbm(yzbm);
                    table.setLxr(lxr);
                    table.setGddh(gddh);
                    table.setSj(sj);
                    table.setCz(cz);
                    table.setJgsx(jgsx);
                    table.setJgjj(jgjj);
                    table.setJsxqmc(jsxqmc);
                    table.setQsxqsx(qsxqsx);
                    table.setJzxqsx(jzxqsx);
                    table.setJsxqgs(jsxqgs);
                    table.setGjz(gjz);
                    table.setNtrjeze(ntrjeze);
                    table.setJsxqjjfs(jsxqjjfs);
                    table.setHzyxdw(hzyxdw);
                    table.setKjhdlx(kjhdlx);
                    table.setXkfl(xkfl);
                    table.setXqjsssly(xqjsssly);
                    table.setXqjsyyhy(xqjsyyhy);
                    table.setQtjs(qtjs);
                    table.setXssh(xssh);
                    table.setBmsh(bmsh);
                    table.setGlcs(glcs);
                    table.setXsyj(xsyj);
                    table.setBmyj(bmyj);
                    
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(rs, state, conn);
            }    
            return table;
        }
        
        public static User getTheUserById(int id1) {
            String sql = "select * from t_user where id ="+id1;
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            ResultSet rs = null;
            User user = new User();
            try {
                state = conn.createStatement();
                rs = state.executeQuery(sql);            
                while (rs.next()) {
                    
                    int id = rs.getInt("id");
                    String username = rs.getString("username");
                    String password = rs.getString("password");
                    String jgmc = rs.getString("jgmc");
                    String zzjgdm = rs.getString("zzjgdm");
                    String name = rs.getString("name");
                    String ssz = rs.getString("ssz");
                    String yzbm = rs.getString("yzbm");
                    String sex = rs.getString("sex");
                    String sheng = rs.getString("sheng");
                    String shi = rs.getString("shi");
                    String zyfx = rs.getString("zyfx");
                    String szhy = rs.getString("szhy");
                    String jycd = rs.getString("jycd");
                    String zc = rs.getString("zc");
                    String txdz = rs.getString("txdz");
                    String sj = rs.getString("sj");
                    String gddh = rs.getString("gddh");
                    String yx = rs.getString("yx");
                    String qq = rs.getString("qq");        
                    String joker = rs.getString("joker");
                    
                    user.setId(id);
                    user.setUsername(username);
                    user.setPassword(password);
                    user.setJgmc(jgmc);
                    user.setZzjgdm(zzjgdm);
                    user.setName(name);
                    user.setSsz(ssz);
                    user.setYzbm(yzbm);
                    user.setSex(sex);
                    user.setSheng(sheng);
                    user.setShi(shi);
                    user.setZyfx(zyfx);
                    user.setSzhy(szhy);
                    user.setJycd(jycd);
                    user.setZc(zc);
                    user.setTxdz(txdz);
                    user.setSj(sj);
                    user.setGddh(gddh);
                    user.setYx(yx);
                    user.setQq(qq);
                    user.setJoker(joker);
                    
                }
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(rs, state, conn);
            }    
            return user;
        }
        
        public static boolean changeTheTableById(Table table) {
            
            Connection conn = DBUtil.getConnection();
            boolean flag = false;
            try {
                String sql = "update t_table set jgqc = '"+table.getJgqc()
                + "', gkglbm = '"+table.getGkglbm()
                + "', txdz = '"+table.getTxdz()
                + "', szdy = '"+table.getSzdy()
                + "', wz = '"+table.getWz()
                + "', dzxx = '"+table.getDzxx()
                + "', frdb = '"+table.getFrdb()
                + "', yzbm = '"+table.getYzbm()
                + "', lxr = '"+table.getLxr()
                + "', gddh = '"+table.getGddh()
                + "', sj = '"+table.getSj()
                + "', cz = '"+table.getCz()
                + "', jgsx = '"+table.getJgsx()
                + "', jgjj = '"+table.getJgjj()
                + "', jsxqmc = '"+table.getJsxqmc()
                + "', qsxqsx = '"+table.getQsxqsx()
                + "', jzxqsx = '"+table.getJzxqsx()
                + "', jsxqgs = '"+table.getJsxqgs()
                + "', gjz = '"+table.getGjz()
                + "', ntrjeze = '"+table.getNtrjeze()
                + "', jsxqjjfs = '"+table.getJsxqjjfs()
                + "', hzyxdw = '"+table.getHzyxdw()
                + "', kjhdlx = '"+table.getKjhdlx()
                + "', xkfl = '"+table.getXkfl()
                + "', xqjsssly = '"+table.getXqjsssly()
                + "', xqjsyyhy = '"+table.getXqjsyyhy()
                + "', qtjs = '"+table.getQtjs()
                + "', xssh = '"+table.getXssh()
                + "', xsyj = '"+table.getXsyj()
                + "', glcs = '"+table.getGlcs()
                + "', bmsh = '"+table.getBmsh()
                + "', bmyj = '"+table.getBmyj()
                + "' where wjid = '"+table.getWjid()+"'";
        
                System.out.println(sql);
                PreparedStatement pstmt = conn.prepareStatement(sql);
                int i = pstmt.executeUpdate();
                pstmt.close();
                conn.close();
                if(i>0) {
                    flag = true;
                }
    
            } catch (SQLException e) {
                e.printStackTrace();
            } 
            
            return flag;
        }
        
    public static boolean changeTheUserById(User user) {
            
            Connection conn = DBUtil.getConnection();
            boolean flag = false;
            try {
                String sql = "update t_user set username = '"+user.getUsername()
                + "', password = '"+user.getPassword()
                + "', jgmc = '"+user.getJgmc()
                + "', zzjgdm = '"+user.getZzjgdm()
                + "', name = '"+user.getName()
                + "', ssz = '"+user.getSsz()
                + "', yzbm = '"+user.getYzbm()
                + "', sex = '"+user.getSex()
                + "', sheng = '"+user.getSheng()
                + "', shi = '"+user.getShi()
                + "', zyfx = '"+user.getZyfx()
                + "', szhy = '"+user.getSzhy()
                + "', jycd = '"+user.getJycd()
                + "', zc = '"+user.getZc()
                + "', txdz = '"+user.getTxdz()
                + "', sj = '"+user.getSj()
                + "', gddh = '"+user.getGddh()
                + "', yx = '"+user.getYx()
                + "', qq = '"+user.getQq()
                + "', joker = '"+user.getJoker()
                + "' where id = '"+user.getId()+"'";
        
                System.out.println(sql);
                PreparedStatement pstmt = conn.prepareStatement(sql);
                int i = pstmt.executeUpdate();
                pstmt.close();
                conn.close();
                if(i>0) {
                    flag = true;
                }
    
            } catch (SQLException e) {
                e.printStackTrace();
            } 
            
            return flag;
        }
    
        public static boolean deleteTheTableById (int id) {
            boolean f = false;
            String sql = "delete from t_table where wjid='" + id + "'";
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            int a = 0;
            
            try {
                state = conn.createStatement();
                a = state.executeUpdate(sql);
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(state, conn);
            }    
            if (a > 0) {
                f = true;
            }
            return f;
        }
        
        public static boolean deleteTheUserById (int id) {
            boolean f = false;
            String sql = "delete from t_user where id='" + id + "'";
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            int a = 0;
            
            try {
                state = conn.createStatement();
                a = state.executeUpdate(sql);
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(state, conn);
            }    
            if (a > 0) {
                f = true;
            }
            return f;
        }
        
        public static boolean changeTheJoker (String username,String joker) {
            boolean f = false;
            String sql = "update t_user set joker = '"+joker+"' where username='" + username + "'";
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            int a = 0;
            
            try {
                state = conn.createStatement();
                a = state.executeUpdate(sql);
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(state, conn);
            }    
            if (a > 0) {
                f = true;
            }
            return f;
        }
        
        public static Power getThePowerByJoker(String joker) {
            String sql = "select * from t_power where joker = '"+joker+"'";
            Power power = new Power();
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            ResultSet rs = null;
            try {
                state = conn.createStatement();
                rs = state.executeQuery(sql);    
                while(rs.next()) {
                    int xqzj_qx = rs.getInt("xqzj_qx");
                    int xqgl_qx = rs.getInt("xqgl_qx");
                    int yhxx_qx = rs.getInt("yhxx_qx");
                    int xgmm_qx = rs.getInt("xgmm_qx");
                    int xssh_qx = rs.getInt("xssh_qx");
                    int bmsh_qx = rs.getInt("bmsh_qx");
                    int tjxq_qx = rs.getInt("tjxq_qx");
                        
                    power.setJoker(joker);
                    power.setXqzj_qx(xqzj_qx);
                    power.setXqgl_qx(xqgl_qx);
                    power.setYhxx_qx(yhxx_qx);
                    power.setXgmm_qx(xgmm_qx);
                    power.setXssh_qx(xssh_qx);
                    power.setBmsh_qx(bmsh_qx);
                    power.setTjxq_qx(tjxq_qx);
                }
                    
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(rs, state, conn);
            }    
            return power;
        } 
        
        public static boolean changeThePower (String joker, int xqzj_qx, int xqgl_qx, int yhxx_qx, int xgmm_qx, int tjxq_qx, int xssh_qx, int bmsh_qx) {
            boolean f = false;
            String sql = "update t_power set xqzj_qx = '"+xqzj_qx
                    +"', xqgl_qx = '"+xqgl_qx
                    +"', yhxx_qx = '"+yhxx_qx
                    +"', xgmm_qx = '"+xgmm_qx
                    +"', tjxq_qx = '"+tjxq_qx
                    +"', xssh_qx = '"+xssh_qx
                    +"', bmsh_qx = '"+bmsh_qx
                    +"' where joker='" + joker + "'";
            Connection conn = DBUtil.getConnection();
            Statement state = null;
            int a = 0;
            
            try {
                state = conn.createStatement();
                a = state.executeUpdate(sql);
            } catch (SQLException e) {
                e.printStackTrace();
            } finally {
                DBUtil.close(state, conn);
            }    
            if (a > 0) {
                f = true;
            }
            return f;
        }
        
    }
    View Code
  • 相关阅读:
    8086 CPU 寄存器
    python中 * 的用法
    字典的相应操作
    tesseract学习记录
    C学习之路2012.8.28
    函数库管理
    2013.3.19C++浏览记录。。。
    自动生成makefile文件学习
    整理做过的东西(电子警察)
    基于zed的tesseract移植过程记录
  • 原文地址:https://www.cnblogs.com/vvxvv/p/14021023.html
Copyright © 2011-2022 走看看