示例#1
0
  public static synchronized void update(String array[]) {

    int index, count;
    Date date;
    Person person;
    SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy", Locale.ENGLISH);

    for (int i = 1; i < array.length; i++) {
      if (array[i].equals("м")) {

        count = i - 2;
        index = Integer.parseInt(array[count]);
        if (index < allPeople.size()) {
          person = allPeople.get(index);
        } else return;

        count = i - 1;
        person.setName(array[count]);

        person.setSex(Sex.MALE);

        try {
          count = i + 1;
          date = format.parse(array[count]);
          person.setBirthDay(date);
        } catch (Exception e) {
        }
      }

      if (array[i].equals("ж")) {

        count = i - 2;
        index = Integer.parseInt(array[count]);
        if (index < allPeople.size()) {
          person = allPeople.get(index);
        } else return;

        count = i - 1;
        person.setName(array[count]);

        person.setSex(Sex.FEMALE);

        try {
          count = i + 1;
          date = format.parse(array[count]);
          person.setBirthDay(date);
        } catch (Exception e) {
        }
      }
    }
  }
示例#2
0
 public static synchronized void DeleteAll(String[] arg) {
   Person per;
   for (int i = 0; i < arg.length; i++) {
     per = allPeople.get(Integer.parseInt(arg[i]));
     per.setBirthDay(null);
   }
 }
示例#3
0
  public static synchronized void delete(String array[]) {

    int index;
    Person person;

    for (int i = 1; i < array.length; i++) {
      index = Integer.parseInt(array[i]);
      if (index < allPeople.size()) {
        person = allPeople.get(index);
        person.setName(null);
        person.setSex(null);
        person.setBirthDay(null);
      }
    }
  }
示例#4
0
 public void savePerson() {
   Session session = HibernateUtils.getSessionFactory().getCurrentSession();
   Transaction tx = null;
   try {
     tx = session.beginTransaction();
     Person person = new Person();
     person.setName("linchunfeng");
     person.setAge(26);
     person.setBirthDay(new Date(1988, 11, 25));
     IdCard idCard = new IdCard();
     idCard.setNum("linchunfeng8387");
     person.setIdCard(idCard);
     Email email1 = new Email();
     email1.setEmail("*****@*****.**");
     Email email2 = new Email();
     email2.setEmail("*****@*****.**");
     Email email3 = new Email();
     email3.setEmail("*****@*****.**");
     Email email4 = new Email();
     email4.setEmail("*****@*****.**");
     Email email5 = new Email();
     email5.setEmail("*****@*****.**");
     Email email6 = new Email();
     email6.setEmail("*****@*****.**");
     Email email7 = new Email();
     email7.setEmail("*****@*****.**");
     Email email8 = new Email();
     email8.setEmail("*****@*****.**");
     person.setEmails(
         new HashSet<Email>(
             Arrays.asList(email1, email2, email3, email4, email5, email6, email7, email8)));
     session.save(person);
     tx.commit();
   } catch (Exception e) {
     if (tx != null) {
       tx.rollback();
     }
     throw new RuntimeException(e);
   }
 }
示例#5
0
 public static synchronized void UpdatePerson(int id, Person person) {
   Person per = allPeople.get(id);
   per.setName(person.getName());
   per.setSex(person.getSex());
   per.setBirthDay(person.getBirthDay());
 }