Esempio n. 1
0
  // Reports
  public ArrayList<Customer> getAllCustomers() {
    con = new DBConnection();
    ArrayList<Customer> customers = new ArrayList<Customer>();
    try {
      cstmt = con.connection.prepareCall("{call getAllCustomer()}");
      ResultSet rs = cstmt.executeQuery();
      while (rs.next()) {
        Customer objCustomer = new Customer();
        Area objArea = new Area();
        objCustomer.setFirstName(rs.getString("FirstName"));
        objCustomer.setLastName(rs.getString("LastName"));
        objArea.setAreaName(rs.getString("AreaName"));
        objCustomer.setArea(objArea);
        objCustomer.setUserName(rs.getString("UserName"));
        objCustomer.setLane(rs.getString("Lane"));
        objCustomer.setMobileNo(rs.getString("MobileNo"));
        objCustomer.setEmailID(rs.getString("EmailID"));
        objCustomer.setStatus(rs.getBoolean("Status"));
        customers.add(objCustomer);
      }
      rs.close();
    } catch (Exception ex) {
      ex.getMessage();
    } finally {

      con.closeConnection();
    }
    return customers;
  }
Esempio n. 2
0
  private Customer insertCustomerNoContacts(String name) {

    Customer c = createCustomer("Roger", "15 Kumera Way", "Bos town", 1, "2010-04-10");
    c.setName(name);
    c.setStatus(Customer.Status.ACTIVE);

    Ebean.save(c);
    return c;
  }
Esempio n. 3
0
  private Customer insertCustomerNoAddress() {

    Customer c = new Customer();
    c.setName("Cust NoAddress");
    c.setStatus(Customer.Status.NEW);
    c.addContact(createContact("Jack", "Black"));

    Ebean.save(c);
    return c;
  }
Esempio n. 4
0
  private Customer insertCustomerFiona() {

    Customer c = createCustomer("Fiona", "12 Apple St", "West Coast Rd", 1, "2009-08-31");
    c.setStatus(Customer.Status.ACTIVE);

    c.addContact(createContact("Fiona", "Black"));
    c.addContact(createContact("Tracy", "Red"));

    Ebean.save(c);
    return c;
  }
Esempio n. 5
0
  public static Customer createCustomer(
      String name, String shippingStreet, String billingStreet, int contactSuffix, String annDate) {

    Customer c = new Customer();
    c.setName(name);
    c.setStatus(Customer.Status.NEW);
    if (annDate == null) {
      annDate = "2010-04-14";
    }
    c.setAnniversary(Date.valueOf(annDate));
    if (contactSuffix > 0) {
      Contact jim = new Contact("Jim" + contactSuffix, "Cricket");
      jim.getNotes().add(new ContactNote("ORM Lives", "And it is cool!"));
      c.addContact(jim);
      c.addContact(new Contact("Fred" + contactSuffix, "Blue"));
      c.addContact(new Contact("Bugs" + contactSuffix, "Bunny"));
    }

    if (shippingStreet != null) {
      Address shippingAddr = new Address();
      shippingAddr.setLine1(shippingStreet);
      shippingAddr.setLine2("Sandringham");
      shippingAddr.setCity("Auckland");
      shippingAddr.setCountry(Ebean.getReference(Country.class, "NZ"));

      c.setShippingAddress(shippingAddr);
    }

    if (billingStreet != null) {
      Address billingAddr = new Address();
      billingAddr.setLine1(billingStreet);
      billingAddr.setLine2("St Lukes");
      billingAddr.setCity("Auckland");
      billingAddr.setCountry(Ebean.getReference(Country.class, "NZ"));

      c.setBillingAddress(billingAddr);
    }

    return c;
  }