/**
   * This Method returns the 2D Array which is the list of the Items for the selected WorkOrder of
   * the Customer.
   *
   * @param workorderId - WorkOrder Id Foreign Key of WRK_ORDR_DETS table
   * @return Object[][] - 2D Array which is List of the Items for the WorkOrder
   */
  public Object[][] getWorkOrderItems(long workorderId) throws RemoteException {

    WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn);

    RHCCBlgKeys blgkeys_obj = new RHCCBlgKeys(conn);

    Vector workorderdetList = wrkordrdts_obj.getProductList(workorderId);

    // Hashtable BSysList = (Hashtable) USFEnv.getBillSystems();
    BlgSys blgsys = new BlgSys();

    Hashtable BSysList = (Hashtable) blgsys.searchBlgSys();

    Enumeration BSys = BSysList.keys();

    // The 2-Dimensional array to hold the Items Billing System wise.
    Object[][] prodList = new Object[BSysList.size()][workorderdetList.size() + 1];

    // The Number of Billing Systems are assumed to be equal to the
    // Static Load Billing Systems Hashtable size. The Billing Systems will
    // be in order starting from 1 and incrementing by one.
    for (int i = 0; i < BSysList.size(); i++) {
      // Set the 2D array to store the Billing System as the first element
      // of each row.
      prodList[i][0] = String.valueOf(i + 1);
    }

    // Loop throught the WorkOrder Items List and place them in the appropriate
    // positions in the 2D array.
    for (int j = 0; j < workorderdetList.size(); j++) {
      // Determine the Billing System of the Product
      Vector tmpVector = new Vector();

      WrkOrdrDets workorderObj = (WrkOrdrDets) workorderdetList.elementAt(j);

      RHCCBlgKeys bkObj =
          blgkeys_obj.searchRHCCBlgKeys(((WrkOrdrDets) workorderdetList.elementAt(j)).getRBKID());
      int bsid = (new Long(bkObj.getBsId())).intValue();

      tmpVector.addElement(bkObj);
      tmpVector.addElement(workorderObj);

      // Based on the Billing System Id retreived place the Product Object
      // in the 2D array.
      int k = 1;
      while (prodList[bsid - 1][k] != null) {
        k = k + 1;
      }
      prodList[bsid - 1][k] = tmpVector;
    }

    // Return the 2D array
    return prodList;
  }
  /**
   * This Method checks if the passed product key has any credits. returns a boolean value based on
   * the check Result.
   *
   * @param wodId - Product Key WOD_ID of the WRK_ORDR_DETS table
   * @return boolean - TRUE ( If product has credits) FALSE (If product has no credits)
   */
  public boolean hasCredits(long wodId) throws RemoteException {

    WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn);

    // Check if the Product credit is greater than zero
    if (wrkordrdts_obj.getProductDiscount(wodId) > (new Double("0.00")).doubleValue()) {
      // If Yes Return True
      USFEnv.getLog().writeDebug("Item has Discounts", this, null);
      return true;
    }
    // Return False
    return false;
  }
  /**
   * This Method is the Unit of Work related to a Item Deletion. This returns a boolean value based
   * on the Deletion Result.
   *
   * @param wodId - WorkOrder Detail Id(Product Key) Primary Key of WRK_ORDR_DETS table
   * @return boolean - TRUE ( If Deletion Success) FALSE (Deletion Failed)
   */
  public boolean deleteProduct(long wodId) throws RemoteException {

    WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn);

    // Check if the Product credit is greater than zero
    if (wrkordrdts_obj.getProductDiscount(wodId) > (new Double("0.00")).doubleValue()) {
      // If Yes return False as product cant be deleted
      USFEnv.getLog().writeWarn("Cannot Delete Item. Item has Discounts", this, null);
      return false;
    }
    // Else if credit not greater than zero Delete the Product.
    return wrkordrdts_obj.deleteWrkOrdrDets(wodId);
  }
  /**
   * This Method is the Unit of Work related to a Product Saving. This returns a boolean value based
   * on the Save Result.
   *
   * @param wod_obj - wodObj that has the info related to the Product that need to be saved to the
   *     of WRK_ORDR_DETS table
   * @return boolean - TRUE ( If Updation/Insertion Success) FALSE (Save Failed)
   */
  public boolean saveProduct(WrkOrdrDets wod_obj) throws RemoteException {
    WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn);

    // If the wodObj is related to Insertion of new Product
    if (wod_obj.getWODID() == 0) {
      // Assign the WOD_ID using the sequence.
      // wod_obj.setWODID(wrkordrdts_obj.getNewSeqId("WOD_ID"));
      // Insert the wod_obj
      return wrkordrdts_obj.insertWrkOrdrDets(wod_obj);
    }
    // If the wod_obj is related to Updation of an existing Product
    else {
      // Update the wod_obj
      return wrkordrdts_obj.updateWrkOrdrDets(wod_obj);
    }
  }
 /**
  * This Method returns the WrkOrdrDets Object for the passed in WorkOrderDetail Id (Product Key)
  *
  * @param wodId - WorkOrder Detail Id(Product Key) Primary Key of WRK_ORDR_DETS table
  * @return WrkOrdrDets - WorkOrder Detail Objects for the passed wodId
  */
 public WrkOrdrDets getProductInfo(long wodId) throws RemoteException {
   WrkOrdrDets wrkordrdts_obj = new WrkOrdrDets(conn);
   return wrkordrdts_obj.searchWrkOrdrDets(wodId);
 }