Examples of WorkingDialog


Examples of nu.lazy8.util.gen.WorkingDialog

     
      //{{{ Update to 2.20
      if (SetupInfo.getProperty("lazy8ledger.lastRunVersion").compareTo("2.20") < 0) {
        //lots of database changes to make
        //need a connection to the database
        WorkingDialog workDialog = new WorkingDialog(null);
        workDialog.setVisible(true);
        try {
          DataConnection dc = new DataConnection(null);
          if (dc == null || !dc.bIsConnectionMade) {
            JOptionPane.showMessageDialog(null,
                Translator.getTranslation("Could not connect to the database.  Do not attempt to continue."),
                Translator.getTranslation("Must restart"),
                JOptionPane.PLAIN_MESSAGE);
            isInStart=true;
            return;
          }
          //copy old Activity table into new Activity2 table
          //UniqNumGenerator uniqnum = new UniqNumGenerator(); // commented out since never used
          Statement st = dc.con.createStatement();
          ResultSet rsOldTrans = st.executeQuery(dc.filterSQL(
              "SELECT CompId,Act_id,RegDate,InvDate,Notes,FileInfo FROM Activity ORDER BY CompId,Act_id"));
          rsOldTrans.last();
          int numRecs=rsOldTrans.getRow();
          rsOldTrans.beforeFirst();
          while (rsOldTrans.next()) {
            PreparedStatement prepSt = dc.con.prepareStatement(
              "INSERT INTO Activity2 (CompId,Act_id,PeriodId,RegDate,InvDate,Notes,FileInfo) VALUES (?,?,?,?,?,?,?)");
            prepSt.setInt(1,rsOldTrans.getInt(1));
            prepSt.setInt(2, rsOldTrans.getInt(2));
            prepSt.setInt(3, 0);
            prepSt.setDate(4, rsOldTrans.getDate(3));
            prepSt.setDate(5, rsOldTrans.getDate(4));
            prepSt.setString(6, rsOldTrans.getString(5));
            prepSt.setString(7, rsOldTrans.getString(6));
            prepSt.executeUpdate();
            workDialog.SetProgress((rsOldTrans.getRow() * 100) / (numRecs));
          }
          //delete the old Activity table
          st = dc.con.createStatement();
          st.executeUpdate("DROP TABLE Activity");
          SystemLog.ErrorPrintln("Dropped old table Activity");
        } catch (Exception e) {
          e.printStackTrace();
          //we need to continue because otherwise this is a lock stoping proper usage of lazy8ledger forever
          //return;
        }
        workDialog.dispose();
        AdjustAllPeriodIds(0);
      }//}}}

      SetupInfo.setProperty("lazy8ledger.lastRunVersion",
          jEdit.getProperty("plugin.lazy8ledger.Lazy8LedgerPlugin.version"));
View Full Code Here

Examples of nu.lazy8.util.gen.WorkingDialog

  /**
   *  Description of the Method
   * @param inCompId the company id
   */
  public static void AdjustAllPeriodIds(int inCompId) {
    WorkingDialog workDialog = new WorkingDialog(null);
    workDialog.setVisible(true);
    try {
      DataConnection dc = new DataConnection(null);
      if (dc == null || !dc.bIsConnectionMade) {
        return;
      }
      //get rid of all uniq num posts for period ids
      dc.con.createStatement().executeQuery(dc.filterSQL(
        "DELETE FROM UniqNum WHERE UniqName LIKE 'PeriodId=%'"));
      //adjust the periodid for each activity
      UniqNumGenerator uniqnum = new UniqNumGenerator();
      ResultSet rsPeriods=null;
      String select="SELECT CompId,Act_id,InvDate FROM Activity2 ";
      if (inCompId>0)
        select+=" WHERE CompId=" + inCompId;
      select+=" ORDER BY CompId,Act_id";
      ResultSet rsOldTrans = dc.con.createStatement().executeQuery(dc.filterSQL(select));
      int lastCompId=-1;
      rsOldTrans.last();
      int numRecs=rsOldTrans.getRow();
      rsOldTrans.beforeFirst();
      while (rsOldTrans.next()) {
        if (lastCompId!=rsOldTrans.getInt(1)){
          //get all the periods for the CompId
          lastCompId=rsOldTrans.getInt(1);
          rsPeriods=dc.con.createStatement().executeQuery(dc.filterSQL(
            "SELECT StartPeriod,EndPeriod FROM AccountingPeriods WHERE CompId=" + lastCompId));
        }
        Date invoiceDate=rsOldTrans.getDate(3);
        int periodId=0;
        rsPeriods.beforeFirst();
        //find the appropriate period if it exists.
        while (rsPeriods.next()) {
          if (invoiceDate.compareTo(rsPeriods.getDate(1))>=0 && invoiceDate.compareTo(rsPeriods.getDate(2))<=0){
            //increment period id counter
            periodId=uniqnum.GetUniqueNumber("PeriodId="+ rsPeriods.getDate(1) + "-"
              + rsPeriods.getDate(2), 1, 999999999,new Integer(lastCompId));
            break; //we found the period we need
          }
        }
        dc.con.createStatement().executeQuery(dc.filterSQL(
          "UPDATE Activity2 SET PeriodId=" + periodId + " WHERE CompId=" + lastCompId + " AND Act_id=" + rsOldTrans.getInt(2)));
        workDialog.SetProgress((rsOldTrans.getRow() * 100) / (numRecs));
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    workDialog.dispose();
  }//}}}
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.