Exemplo n.º 1
0
  public static Purchase jsonToObject(JSONObject jsonObject) {
    Purchase model = new Purchase();
    if (jsonObject.containsKey("purchaseid")) {
      model.setPurchaseid(jsonObject.getLong("purchaseid"));
    }
    if (jsonObject.containsKey("purchaseno")) {
      model.setPurchaseno(jsonObject.getString("purchaseno"));
    }
    if (jsonObject.containsKey("area")) {
      model.setArea(jsonObject.getString("area"));
    }
    if (jsonObject.containsKey("company")) {
      model.setCompany(jsonObject.getString("company"));
    }
    if (jsonObject.containsKey("dept")) {
      model.setDept(jsonObject.getString("dept"));
    }
    if (jsonObject.containsKey("post")) {
      model.setPost(jsonObject.getString("post"));
    }
    if (jsonObject.containsKey("appuser")) {
      model.setAppuser(jsonObject.getString("appuser"));
    }
    if (jsonObject.containsKey("appdate")) {
      model.setAppdate(jsonObject.getDate("appdate"));
    }
    if (jsonObject.containsKey("purchasesum")) {
      model.setPurchasesum(jsonObject.getDouble("purchasesum"));
    }
    if (jsonObject.containsKey("status")) {
      model.setStatus(jsonObject.getInteger("status"));
    }
    if (jsonObject.containsKey("processname")) {
      model.setProcessname(jsonObject.getString("processname"));
    }
    if (jsonObject.containsKey("processinstanceid")) {
      model.setProcessinstanceid(jsonObject.getLong("processinstanceid"));
    }
    if (jsonObject.containsKey("wfstatus")) {
      model.setWfstatus(jsonObject.getLong("wfstatus"));
    }
    if (jsonObject.containsKey("createBy")) {
      model.setCreateBy(jsonObject.getString("createBy"));
    }
    if (jsonObject.containsKey("createDate")) {
      model.setCreateDate(jsonObject.getDate("createDate"));
    }
    if (jsonObject.containsKey("updateDate")) {
      model.setUpdateDate(jsonObject.getDate("updateDate"));
    }
    if (jsonObject.containsKey("updateBy")) {
      model.setUpdateBy(jsonObject.getString("updateBy"));
    }

    return model;
  }
Exemplo n.º 2
0
  public void saveCourse(JSONObject jsonObject) {
    //        Cursor cursor = null;
    String sql = "delete from course;";

    JSONArray jsonArray = jsonObject.getJSONArray("result");
    //        Object[] obj = jsonArray.toArray();
    int length = jsonArray.size();
    JSONObject obj;
    ContentValues cv = new ContentValues();
    SQLiteDatabase database = DatabaseUtil.this.getWritableDatabase();
    database.execSQL(sql);
    for (int i = 0; i < length; i++) {
      obj = (JSONObject) jsonArray.get(i);
      cv.put("courseId", obj.getString("courseId"));
      cv.put("credit", obj.getDouble("credit"));
      cv.put("teacherId", obj.getString("teacherId"));
      cv.put("studentId", obj.getString("studentId"));
      cv.put("courseName", obj.getString("courseName"));
      cv.put("courseTime", obj.getString("courseTime"));
      cv.put("courseDate", obj.getString("courseDate"));
      cv.put("test1", obj.getDouble("test1"));
      cv.put("test2", obj.getDouble("test2"));
      cv.put("test3", obj.getDouble("test3"));
      cv.put("exercises1", obj.getDouble("exercises1"));
      cv.put("exercises2", obj.getDouble("exercises2"));
      cv.put("exercises3", obj.getDouble("exercises3"));
      cv.put("exercises4", obj.getDouble("exercises4"));
      cv.put("exercises5", obj.getDouble("exercises5"));
      cv.put("finalTest", obj.getDouble("finalTest"));
      cv.put("dailyMark", obj.getDouble("dailyMark"));
      cv.put("sum", obj.getDouble("sum"));
      Object t = database.insert("course", null, cv);
      Log.i(
          "devouty",
          "insert into course:" + i + "  Name:" + obj.getString("courseName") + "----" + t);
      //
      // Log.i("devouty","count:"+database.query("course",null,null,null,null,null,null).getCount());
    }
    //        cursor = database.query("course",null,null,null,null,null,null);
    database.close();
    //        database = DatabaseUtil.this.getReadableDatabase();
    //        cursor = database.query("course",null,null,null,null,null,null);
    //        return cursor;
  }