コード例 #1
0
  private void updateInDB() {

    if (_mWhereClause != null) {
      ContentValues lValues = new ContentValues();
      String[] lArgs = new String[_mWhereClauseColumns.length];
      int lSize = _mListOfColumns.size();

      for (int i = 0; i < lSize; i++) {

        String lColumnName = _mListOfColumns.get(i).getName();
        TCell lCell = cellByName(lColumnName);
        String lColumnValue = lCell.asString();
        DBAccessMode lAccessMode = lCell.getDBAccessMode();

        if (lAccessMode == DBAccessMode.UPDATE) lValues.put(lColumnName, lColumnValue);
      }

      for (int i = 0; i < _mWhereClauseColumns.length; i++) {

        if (indexOfColumn(_mWhereClauseColumns[i]) == -1) {
          PuUtils.showMessage(
              _mContext,
              "Erreur Column",
              "Column "
                  + _mWhereClauseColumns[i]
                  + " de clause Where  "
                  + "n'est pas une column de client data table :"
                  + _mCDTName);
          return;
        } else if (lValues.containsKey(_mWhereClauseColumns[i])) {
          PuUtils.showMessage(
              _mContext,
              "Erreur Column",
              "impossible de definir la colonne "
                  + _mWhereClauseColumns[i]
                  + " de clause Where comme colonne à modifier dans le CDT:"
                  + _mCDTName);
          return;
        }
        TCell lCell = cellByName(_mWhereClauseColumns[i]);
        lArgs[i] = lCell.asString();
      }
      if (lValues.size() != 0)
        _mSqliteDataBase.update(_mTableName, lValues, _mWhereClause.toString(), lArgs);
    } else PuUtils.showMessage(_mContext, "Erreur Update", "Clause where non definit");
  }
コード例 #2
0
  private void insertInDB() {

    ContentValues lValues = new ContentValues();

    int lSize = _mListOfColumns.size();

    for (int i = 0; i < lSize; i++) {

      String lColumnName = _mListOfColumns.get(i).getName();
      TCell lCell = cellByName(lColumnName);
      String lColumnValue = lCell.asString();
      DBAccessMode lAccessMode = lCell.getDBAccessMode();

      if (lAccessMode == DBAccessMode.INSERT) lValues.put(lColumnName, lColumnValue);
    }
    if (lValues.size() == 0) {
      PuUtils.showMessage(_mContext, "Erreur insertion", "Acune valeur définie pour inserer");
      return;
    }
    _mSqliteDataBase.insertOrThrow(_mTableName, null, lValues);
  }