// Insert Purchase krub.
  public boolean insertTransPurchase(List list, String invoiceId) throws Exception {
    CallableStatement clbstmt = null;
    Connection conn = null;
    int i = 1;
    // ***********
    boolean isInsert = true; // true is fail
    boolean isInsItem = true; // true is fail
    boolean isUpdProduct = true; // true is fail
    boolean isResult = true;
    try {
      // ::TODO
      conn = open();
      Common.beginTransaction(conn);
      // ********************************************************

      int totalUnit = 0;
      float totalPrice = 0.0f;
      ProductBean prod = null;
      Iterator it = list.iterator();
      while (it.hasNext()) {
        prod = (ProductBean) it.next();
        totalPrice = prod.getProductItem() * prod.getPriceSale();
        totalUnit += prod.getProductItem();
      }
      // *******************************************************
      Log.debug("-->Before Insert.");
      // Insert to DB
      clbstmt = conn.prepareCall("{call " + INSTANT_DB_NAME + ".INSERT_PURCHASE(?,?,?,?,?)}");
      clbstmt.setString(i++, invoiceId);
      clbstmt.setFloat(i++, totalPrice);
      clbstmt.setInt(i++, totalUnit);
      clbstmt.setString(i++, "99999999999"); // CustomerID
      clbstmt.setString(i++, "11111111111"); // UserID

      Log.debug("-->Mapping parameter Okay.");
      isInsert = clbstmt.execute();
      Log.debug("-->Execute INSERT_PURCHASE successfully. :" + isInsert);

      // **************************************************************
      Log.debug("-->Start Insert INSERT_PURCHASE_ITEMS.");
      it = list.iterator();
      while (it.hasNext()) {
        i = 1;
        prod = (ProductBean) it.next();
        // Insert to DB
        clbstmt = conn.prepareCall("{call " + INSTANT_DB_NAME + ".INSERT_PURCHASE_ITEMS(?,?,?,?)}");
        clbstmt.setString(i++, invoiceId);
        clbstmt.setString(i++, prod.getProductId()); // p_productId
        clbstmt.setInt(i++, prod.getProductItem());
        clbstmt.setFloat(i++, prod.getPriceSale());

        Log.debug("-->Mapping parameter Okay.");
        isInsItem = clbstmt.execute();
        Log.debug("-->INSERT_PURCHASE_ITEMS successfully. :" + isInsItem);
      }
      // **********************************************************************
      /*	        	CREATE PROCEDURE db_merchant.`INSERT_PURCHASE`(
      IN p_Id varchar(12),
      IN p_total_unit  int,
      IN p_total_price  float,
      IN p_supp_id    varchar(12),
      IN p_usr_id  varchar(12)*/

      /*	        	CREATE PROCEDURE db_merchant.`INSERT_PURCHASE_ITEMS`(
      IN p_voiceId varchar(12),
      IN p_Id varchar(12),
      IN p_unit  int,
      IN p_price  float
      )*/

      Log.debug("-->Update Product.");
      it = list.iterator();
      while (it.hasNext()) {
        i = 1;
        prod = (ProductBean) it.next();

        Log.debug("-->Before Insert.");
        // Insert to DB
        clbstmt =
            conn.prepareCall("{call " + INSTANT_DB_NAME + ".UPDATE_PRODUCT_BY_PURCHASE(?,?,?,?)}");
        clbstmt.setString(i++, prod.getProductId());
        clbstmt.setFloat(i++, prod.getPriceCost());
        clbstmt.setFloat(i++, prod.getPriceSale());
        clbstmt.setInt(i++, prod.getProductItem());

        Log.debug("-->Mapping parameter Okay.");
        isUpdProduct = clbstmt.execute();
        Log.debug("-->Update product successfully .:" + isUpdProduct);
      }
      /*	        	CREATE PROCEDURE db_merchant.`UPDATE_PRODUCT_BY_PURCHASE`(
      		IN p_id  varchar(12),
      		IN p_cost   float,
      		IN p_sale   float,
      		IN p_item     int(7)
      		)
      */

      if (!isInsert && !isInsItem && !isUpdProduct) {
        isResult = false;
        Log.debug("-->Update product successfully .");
      } else {
        isResult = true;
        Log.debug("-->Update product not successfully .");
      }

      // **************************************************************
      Common.commitTransaction(conn);
      Log.debug("-->commit successfully.");
    } catch (Exception e) {
      isResult = true;
      e.fillInStackTrace();
      Log.debug("Insert Exception e:" + e.toString());
      // try{
      Common.rollbackTransaction(conn);
      // }catch(Exception ex){}
    } finally {
      try {
        if (clbstmt != null) clbstmt.close();
        if (conn != null) conn.close();
      } catch (SQLException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
    // *******Return*********
    return isResult; // #End
  }