Пример #1
0
 public String GetAccountName(int id) {
   for (Account a : accounts) {
     if (a.getAccountID() == id) {
       return a.getAccountName();
     }
   }
   return null;
 }
Пример #2
0
 public int GetAccoutID(String user) {
   for (Account a : accounts) {
     if (a.getAccountName().equals(user)) {
       return a.getAccountID();
     }
   }
   return 0;
 }
Пример #3
0
  // create account (account name, account password, account email)
  public boolean CreateAccount(Account a) throws NoSuchAlgorithmException {
    String name = a.getAccountName();

    if (!CheckUserExist(name)) {
      String pass = new MD5().createMD5(a.getAccountPassword());
      String email = a.getAccountMail();
      int type = 2;
      String cmd2 =
          "insert into Account values('" + name + "','" + pass + "','" + email + "'," + type + ")";
      boolean result = new SQLUtil().execute(cmd2);
      if (result) {
        JOptionPane.showMessageDialog(Accounts, "Register Successfully");
        return true;
      } else {
        JOptionPane.showMessageDialog(Accounts, "Create Account faild");
        return false;
      }

    } else {
      JOptionPane.showMessageDialog(Accounts, "Username already exist");
      return false;
    }
  }