Package net.sourceforge.wampum.finance.entities

Examples of net.sourceforge.wampum.finance.entities.BudgetDAO


    DAOSQLImpl dao = null;
   
    if (name.equalsIgnoreCase("account"))
      dao = new AccountDAO();
    else if (name.equalsIgnoreCase("budget"))
      dao = new BudgetDAO();
    else if (name.equalsIgnoreCase("transaction"))
      dao = new TransactionDAO();
    else if (name.equalsIgnoreCase("transSplit"))
      dao = new TransSplitDAO();
    else if (name.equalsIgnoreCase("payee"))
View Full Code Here


  }
 
  private static String[] columnNames = {"Month", "Year", "Amount", "Balance", "Status"};
  public void updateBudgetTableData() {
    if (this.currentAccount != null) {
      BudgetDAO budgetDAO = (BudgetDAO)daoFactory.getDAO("budget");
      budgetList = budgetDAO.load("WHERE ACCOUNT_ID = '" + this.currentAccount.getAccountID() + "'", "ORDER BY YEAR, MONTH", true);
     
      RegisterDAO registerDAO = (RegisterDAO)daoFactory.getDAO("register");
      balanceList = registerDAO.loadBalancesForAccount(this.currentAccount.getAccountID());
    }

    TableModel dataModel = new AbstractTableModel() {
      private static final long serialVersionUID = 1;
     
      public int getColumnCount() { return 5; }
     
      public String getColumnName(int columnIndex) {
        return columnNames[columnIndex];
      }
     
      public int getRowCount() {
        if (currentAccount != null)
          return 25;
        else
          return 0;
      }
     
      public boolean isCellEditable(int row, int column) {
        if (column == 2)
          return true;
        else
          return false;
      }
     
      public Object getValueAt(int row, int col) {
        Calendar tempCal = Calendar.getInstance();
        tempCal.add(Calendar.MONTH, (row-12));
        int year = tempCal.get(Calendar.YEAR);
        int month = tempCal.get(Calendar.MONTH);
       
        if (col == 0) {
          return new Integer(month);
        }
        else if (col == 1)
          return new Integer(year);
        else if (col == 2) {
          Double amount = new Double(0.0);
          boolean found = false;
          int count = 0;
          Budget budget = null;
          while (!found && count<budgetList.size()) {
            budget = (Budget)budgetList.get(count);
            if (budget.getYear().intValue() == year && budget.getMonth().intValue() == month) {
              amount = budget.getAmount();
            }
            count++;
          }
          return amount;
        }
        else if (col == 3) {
          Double amount = new Double(0.0);
          boolean found = false;
          int count = 0;
          while (!found && count<balanceList.size()) {
            double[] record = (double[])balanceList.get(count);
            if (year == record[0] && month == record[1]) {
              amount = new Double(record[2]);
              found = true;
            }
            count++;
          }
          return amount;
        }
        else if (col == 4) {
          Double[] retVal = new Double[2];
          retVal[0] = (Double)getValueAt(row, 2);
          retVal[1] = (Double)getValueAt(row, 3);
          return retVal;
        }
        else
          return null;
      }
     
      public void setValueAt(Object value, int row, int column) {
        Integer month = (Integer)getValueAt(row, 0);
        Integer year = (Integer)getValueAt(row, 1);
        Budget budget = null;
        boolean found = false;
        int count = 0;
        while (!found && count < budgetList.size()) {
          budget = (Budget)budgetList.get(count);
          if (budget.getYear().intValue() == year.intValue() &&
              budget.getMonth().intValue() == month.intValue()) {
            found = true;
          }
          count++;
        }
        if (!found) {
          budget = new Budget();
          budget.setAccountID(currentAccount);
          budget.setYear(year);
          budget.setMonth(month);
          budget.setActive(new Boolean(true));
          budgetList.add(budget);
        }
        budget.setAmount((Double)value);
       
        BudgetDAO budgetDAO = (BudgetDAO)daoFactory.getDAO("budget");
        budgetDAO.store(budget, false);
      }
     
    };
    budgetTable.setModel(dataModel);
   
View Full Code Here

TOP

Related Classes of net.sourceforge.wampum.finance.entities.BudgetDAO

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.