First, to re-name registration of Chinese characters and in line with the format:
// new users join request public void NewHuman () { System.out.println ( "======== ======== new members apply to join the page" ); Scanner sc = new Scanner(System.in); String Pname = ""; while (true) { System.out.println ( "Please enter your name of the game:" ); Pname = sc.next (); // verify same name int COUNT = newHumanController.selectPname (pname); // verify compliance with the format Character String REG = "^ [\ u4e00- \ u9fa5] {0,} $" ; Boolean In Flag = Pname.matches (REG); IF (COUNT == 0 && In Flag) { System.out.println ( "Your name of the game is available !!" ); BREAK ; } else { System.out.println ( "Sorry, your game name is incorrect or has been registered, please re-enter Chinese characters !!" ); } } System.out.println ( "Please enter your profession:" ); Pprofession String = sc.next (); // application layer call NewHumanController join process to join the Association int count1 is = newHumanController.join (pname, Pprofession); IF (count1 is> 0 ) { System.out.println ( "You have to complete the application, has informed the relevant staff, please wait!" ); } else { System.out.println ( "Sorry you entered is incorrect, please re-enter:!!" ); } }
Second, change your password:
// change the password public void updatepwd () { System.out.println ( "Please enter your name of the game:" ); Scanner sc = new Scanner(System.in); String Pname = sc.next(); System.out.println ( "Please enter your password to be modified:" ); String pwd1 = sc.next(); System.out.println ( "Please enter the password you want to edit again:" ); String pwd2 = sc.next(); while (!pwd1.equals(pwd2)) { System.out.println ( "Sorry, passwords do not match, please re-enter" ); System.out.println ( "Please re-enter your password" ); pwd1 = sc.next(); System.out.println ( "Please confirm your password again" ); pwd2 = sc.next (); } int row = newHumanController.updatePwd(pwd2, Pname); if (row > 0) { System.out.println ( "modified successfully!" ); } else { System.out.println ( "modification failed!" ); } }
Three, then graded into the respective interface
// guild members to log public void the Login () { System.out.println ( "======== ======== guild members login page" ); System.out.println ( "Please enter your game name:" ); Scanner sc = new Scanner(System.in); String Pname = sc.next(); System.out.println ( "Please enter your password:" ); Pwd String = sc.next (); // call to the login method of UserController log int COUNT = userController.login (pname, Pwd); IF (COUNT> 0 ) { System.out.println ( "Login successful!" ); // search for the name of the members of its level judge and then enter the next interface int pcount = userController.plogin (PNAME); IF (pcount == 1 ) { // president level masterView.show1 (); } The else IF (Pcount == 2 ) { // head level leaderView.show2 (); } The else IF (Pcount ==. 3 ) { // occupational supervisor level mentorView.show3 (); } The else IF (Pcount ==. 4 ) { // the DKP level manager dkperView.show4 (); } The else IF (Pcount ==. 5 ) { // official members level regularView.show5 (); } The else IF (Pcount ==. 6 ) { // substitutes level alternateView.show6 (); } The else IF (Pcount ==. 7 ) { // new membership level memberView.show7 (); } } else { System.out.println ( "user name or password is incorrect, please log in again!" ); } }
Fourth, add the query results in Table 1 to Table 2,
// the name of the state of the equipment in an application form, and it takes integral ID added to human acquired equipment allocation table // 1. query public the ArrayList <ApplyforClo> applyforClo () throws SQLException { // Get the connection object Connection = conn JDBCUtils.getConn (); // get the statement execution platform String SQL = "the SELECT Cclothes, Pid, Cscore from ApplyforClo the WHERE astate = 1" ; PreparedStatement pst = conn.prepareStatement(sql); // 执行sql ResultSet rs = pst.executeQuery(); // 处理结果集 ArrayList<ApplyforClo> arr = new ArrayList<ApplyforClo>(); while (rs.next()) { ApplyforClo applyforClo = new ApplyforClo(); applyforClo.setCclothes(rs.getString("Cclothes")); applyforClo.setPid(rs.getInt("pid")); applyforClo.setCscore(rs.getInt("cscore")); arr.add(applyforClo); } // release resources JDBCUtils.close (conn, PST, rs); return arr; } // 2. Increase public int addClothes (String Cclothes, int the Pid, int Cscore) throws SQLException { // Get connection object Connection Conn = JDBCUtils.getConn (); // get the statement execution platform String sql = "insert into Clothes ( Cclothes , Pid, Cscore) values (,,) "??? ; PreparedStatement pst = conn.prepareStatement(sql); // 执行sql pst.setString(1, Cclothes); pst.setInt(2, Pid); pst.setInt(3, Cscore); int rs = pst.executeUpdate(); // 释放资源 JDBCUtils.close(conn, pst); return rs; }
// query results (traverse) the application form is added to the member information table: public int addClothes () { ArrayList<ApplyforClo> arr = null; int row = 0; try { arr = getClothesDao.applyforClo(); for (ApplyforClo a : arr) { row = getClothesDao.addClothes(a.getCclothes(), a.getPid(), a.getCscore()); } } catch (SQLException e) { e.printStackTrace (); } return row; }