Esempio n. 1
0
  @BeforeClass
  public static void setUpBeforeClass() throws Exception {
    con.addCustomer(
        "Buddy", "Bear", "1520 Garnet Ave", "", "San Diego", "CA", "92109", "4766666656");
    con.addPublication("Runner Magazine", "Sports", 9.80, "Monthly", 5);

    ResultSet r = con.searchCustomer(0, "Buddy", "");
    try {
      while (r.next()) {
        testCustID = r.getInt("CustomerID");
      }
      r.close();

    } catch (Exception e) {
      e.printStackTrace();
    }

    ResultSet rs = con.searchPublication(0, "", "Runner Magazine");

    try {
      while (rs.next()) {
        testPubID = rs.getInt("PublicationID");
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    subscriptions newSub = new subscriptions(testCustID, testPubID);
  }
Esempio n. 2
0
 @Test
 public void addSubcriptionTest() {
   ResultSet r = con.getSubscriptions(testCustID, testPubID);
   assertNotNull(r);
 }
Esempio n. 3
0
  public void initLines() {
    try {

      connect c1 = new connect();

      c1.rs =
          c1.st.executeQuery(
              "select count(b.asn) from basic b, payment p where b.asn=p.asn  and (b.dist='By Post' or b.dist='By Hand') and ( p.endm>"
                  + (m1 - 1)
                  + " and p.endy="
                  + y1
                  + ")  and (p.endm <"
                  + (m2 + 1)
                  + " and p.endy="
                  + y2
                  + ")");
      while (c1.rs.next()) {
        x = c1.rs.getInt(1);
      }
      c1.st.close();
      c1.con.close();

      numLines = x * 9;

      textLines = new String[numLines][7];
      asn = new int[x];

      connect c2 = new connect();
      c2.rs =
          c2.st.executeQuery(
              "select b.asn from basic b, payment p where b.asn=p.asn and (b.dist='By Post' or b.dist='By Hand') and ( p.endm>"
                  + (m1 - 1)
                  + " and p.endy="
                  + y1
                  + ")  and (p.endm <"
                  + (m2 + 1)
                  + " and p.endy="
                  + y2
                  + ") order by p.endm asc, p.endy asc, b.subnos, b.subno");
      while (c2.rs.next()) {
        asn[i] = c2.rs.getInt(1);

        i++;
      }

      i = 0;
      for (i = 0; i < x; i++) {
        connect c10 = new connect();
        c10.rs = c10.st.executeQuery("select * from basic where asn=" + asn[i]);
        c10.rs.next();
        textLines[i][0] = "SUB # " + c10.rs.getString(2) + " " + c10.rs.getString(3) + " / REMI ";
      }

      c2.st.close();
      c2.con.close();

      i = 0;

      connect c3 = new connect();
      for (i = 0; i < x; i++) {
        c3.rs = c3.st.executeQuery("select * from payment where asn=" + asn[i]);
        c3.rs.next();
        textLines[i][0] += "   " + c3.rs.getInt(10) + "/" + c3.rs.getInt(11);
      }

      c3.st.close();
      c3.con.close();

      i = 0;
      connect c4 = new connect();
      for (i = 0; i < x; i++) {

        c4.rs = c4.st.executeQuery("select * from subdetails where asn=" + asn[i]);
        c4.rs.next();

        String s1, s2, s3, s4, s5, s6, s7;

        s1 = c4.rs.getString(3);
        s2 = c4.rs.getString(4);
        s3 = c4.rs.getString(5);
        s4 = c4.rs.getString(6);
        s5 = c4.rs.getString(7);
        s6 = c4.rs.getString(8);
        s7 = c4.rs.getString(9);

        textLines[i][1] = "";
        textLines[i][2] = "";
        textLines[i][3] = "";
        textLines[i][4] = "";
        textLines[i][5] = "";
        textLines[i][6] = "";

        if (s1 != null) textLines[i][1] = s1 + " ";

        if (s2 != null) textLines[i][1] += s2;

        if (s3 != null) textLines[i][2] = s3;

        if (s4 != null) textLines[i][3] = s4;

        if (s5 != null) textLines[i][4] = s5;

        if (s6 != null) textLines[i][5] = s6;

        if (s7 != null) textLines[i][6] = s7;

        int c = Integer.parseInt(c4.rs.getString(10));
        if (c > 0) {
          textLines[i][6] += " - " + c;
        }
      }

      c4.st.close();
      c4.con.close();

      i = 0;

    } catch (Exception e) {
      System.out.println(e);
      e.printStackTrace();
    }
  }