@Override
    public void run() {

      RestAdapter restAdapter =
          new RestAdapter.Builder().setEndpoint("https://shedule.herokuapp.com").build();
      ScheduleInterface scheduleInterface = restAdapter.create(ScheduleInterface.class);
      Schedule schedule = scheduleInterface.getSchedule(parameters);

      ContentValues cv = new ContentValues();
      DBHelper dbHelper = new DBHelper(getApplicationContext());
      SQLiteDatabase db = dbHelper.getWritableDatabase();

      db.delete("schedule", null, null);

      for (Schedule.Objects elem : schedule.objects) {
        cv.put("room", elem.room);
        cv.put("day", elem.day);
        cv.put("groupNumber", elem.groupNumber);
        cv.put("hours", elem.hours);
        cv.put("lecture", elem.lecture);
        cv.put("teacher", elem.teacher);

        db.insert("schedule", null, cv);
      }

      dbHelper.close();

      Intent intent = new Intent("EndOperation");
      sendBroadcast(intent);
    }
 public int yangbenWaveModify(int id, YangbenWaveInfo yangbenWaveInfo) {
   int result = 0; // 影响记录的行数
   if (isYangbenWaveExistById(id)) {
     sql =
         "UPDATE yangbenwave SET userid="
             + yangbenWaveInfo.getUserid()
             + ",date='"
             + yangbenWaveInfo.getDate()
             + "',singlewave='"
             + yangbenWaveInfo.getWave()
             + "' WHERE id="
             + id;
     try {
       db1 = new DBHelper(sql); // 创建DBHelper对象
       result = db1.pst.executeUpdate(sql);
     } catch (SQLException e) {
       // TODO Auto-generated catch block
       System.out.println("样本波形信息修改失败");
       e.printStackTrace();
     }
     db1.close();
   } else {
     System.out.println("该样本波形id不存在,无法修改");
   }
   return result;
 }
  /** Returns an ArrayList of Annotations with a TicketID. */
  public static ArrayList<Annotation> getAnnotations(int ticketNum) {
    DBHelper db = DBHelperFactory.createDBHelper();
    ArrayList<Annotation> result = db.createAnnotationArrayListByTicket(ticketNum);

    db.close();
    return result;
  }
  /** Returns an ArrayList of all the registered accounts */
  public static ArrayList<String> getWorkerNames() {
    DBHelper db = DBHelperFactory.createDBHelper();
    ArrayList<String> result = db.createUsernameArrayList();

    db.close();
    return result;
  }
Beispiel #5
0
 public void deleteFav(MainPageItem qy) {
   Cursor cursor = null;
   String where =
       FavTable.USER_ID
           + " = '"
           + MyApplication.getInstance().getCurrentUser().getObjectId()
           + "' AND "
           + FavTable.OBJECT_ID
           + " = '"
           + qy.getObjectId()
           + "'";
   cursor = dbHelper.query(DBHelper.TABLE_NAME, null, where, null, null, null, null);
   if (cursor != null && cursor.getCount() > 0) {
     cursor.moveToFirst();
     int isLove = cursor.getInt(cursor.getColumnIndex(FavTable.IS_LOVE));
     if (isLove == 0) {
       dbHelper.delete(DBHelper.TABLE_NAME, where, null);
     } else {
       ContentValues cv = new ContentValues();
       cv.put(FavTable.IS_FAV, 0);
       dbHelper.update(DBHelper.TABLE_NAME, cv, where, null);
     }
   }
   if (cursor != null) {
     cursor.close();
     dbHelper.close();
   }
 }
  /** Gets a specified ticket. */
  public static Ticket getTicket(int ticketNum) {
    DBHelper db = DBHelperFactory.createDBHelper();
    Ticket result = db.retrieveTicket(ticketNum);

    db.close();
    return result;
  }
Beispiel #7
0
 /**
  * 设置内容的收藏状态
  *
  * @param context
  * @param lists
  */
 public List<MainPageItem> setFavInFav(List<MainPageItem> lists) {
   Cursor cursor = null;
   if (lists != null && lists.size() > 0) {
     for (Iterator iterator = lists.iterator(); iterator.hasNext(); ) {
       MainPageItem content = (MainPageItem) iterator.next();
       content.setMyFav(true);
       String where =
           FavTable.USER_ID
               + " = '"
               + MyApplication.getInstance().getCurrentUser().getObjectId()
               + "' AND "
               + FavTable.OBJECT_ID
               + " = '"
               + content.getObjectId()
               + "'";
       cursor = dbHelper.query(DBHelper.TABLE_NAME, null, where, null, null, null, null);
       if (cursor != null && cursor.getCount() > 0) {
         cursor.moveToFirst();
         if (cursor.getInt(cursor.getColumnIndex(FavTable.IS_LOVE)) == 1) {
           content.setMyLove(true);
         } else {
           content.setMyLove(false);
         }
       }
       LogUtils.i(TAG, content.getMyFav() + ".." + content.getMyLove());
     }
   }
   if (cursor != null) {
     cursor.close();
     dbHelper.close();
   }
   return lists;
 }
Beispiel #8
0
 /** 销毁 */
 public void onDestory() {
   instance = null;
   if (dbHelper != null) {
     dbHelper.close();
     dbHelper = null;
   }
 }
Beispiel #9
0
 public long insertFav(MainPageItem qy) {
   long uri = 0;
   Cursor cursor = null;
   String where =
       FavTable.USER_ID
           + " = '"
           + MyApplication.getInstance().getCurrentUser().getObjectId()
           + "' AND "
           + FavTable.OBJECT_ID
           + " = '"
           + qy.getObjectId()
           + "'";
   cursor = dbHelper.query(DBHelper.TABLE_NAME, null, where, null, null, null, null);
   if (cursor != null && cursor.getCount() > 0) {
     cursor.moveToFirst();
     ContentValues conv = new ContentValues();
     conv.put(FavTable.IS_FAV, 1);
     conv.put(FavTable.IS_LOVE, 1);
     dbHelper.update(DBHelper.TABLE_NAME, conv, where, null);
   } else {
     ContentValues cv = new ContentValues();
     cv.put(FavTable.USER_ID, MyApplication.getInstance().getCurrentUser().getObjectId());
     cv.put(FavTable.OBJECT_ID, qy.getObjectId());
     cv.put(FavTable.IS_LOVE, qy.getMyLove() == true ? 1 : 0);
     cv.put(FavTable.IS_FAV, qy.getMyFav() == true ? 1 : 0);
     uri = dbHelper.insert(DBHelper.TABLE_NAME, null, cv);
   }
   if (cursor != null) {
     cursor.close();
     dbHelper.close();
   }
   return uri;
 }
  @Override
  protected void onResume() {
    super.onResume();

    etLectNum = (EditText) findViewById(R.id.etLectNum);
    etLectTitle = (EditText) findViewById(R.id.etLectTitle);
    etLectDescription = (EditText) findViewById(R.id.etLectDescription);
    tvLastLect = (TextView) findViewById(R.id.tvLastLect);
    bSubmit = (Button) findViewById(R.id.bLectSubmit);

    spf = PreferenceManager.getDefaultSharedPreferences(this);
    ed = spf.edit();

    semSelected = spf.getInt("SemesterSelected", 0);
    courseSelected = spf.getString("CourseSelected", null);

    dbh = new DBHelper(this);

    if (getIntent().getExtras().getBoolean("Update")) {

      Cursor rs = dbh.getLectureData(semSelected, courseSelected, spf.getInt("LectureSelected", 0));
      rs.moveToFirst();
      etLectNum.setText(String.valueOf(rs.getInt(rs.getColumnIndex(DBHelper.LECTURES_NUMBER))));
      etLectNum.setFocusable(false);
      etLectNum.setClickable(false);
      etLectTitle.setText(rs.getString(rs.getColumnIndex(DBHelper.LECTURES_TITLE)));
      etLectDescription.setText(rs.getString(rs.getColumnIndex(DBHelper.LECTURES_DESCRIPTION)));
      rs.close();
      dbh.close();
    } else {
      tvLastLect.setText(
          "Last Lecture Number added: " + dbh.getLastAddedLecture(semSelected, courseSelected));
    }
    bSubmit.setOnClickListener(this);
  }
 /** Assigns a worker by name to a ticket by ID. */
 public static void assignWorker(int ticketNum, String workername) {
   DBHelper db = DBHelperFactory.createDBHelper();
   Account temp = db.retrieveAccount(workername);
   db.updateTicketWorker(ticketNum, temp.get_id());
   db.updateTicketQueue(ticketNum, 1);
   db.close();
 }
Beispiel #12
0
  public static ArrayList<Customer> getAllCustomers() {
    ArrayList<Customer> list = new ArrayList<Customer>();

    DBHelper db = new DBHelper();

    try {
      String queryString = "SELECT * FROM customer";
      ResultSet rs = db.executeQuery(queryString);

      while (rs.next()) {
        Customer customer = new Customer();

        customer.setId(rs.getInt("id"));
        customer.setFirstName(rs.getString("first_name"));
        customer.setLastName(rs.getString("last_name"));
        customer.setPhone(rs.getString("phone"));
        customer.setAddress(rs.getString("address"));
        customer.setZipCode(rs.getInt("zipcode"));
        customer.setCity(rs.getString("city"));
        customer.setEmail(rs.getString("email"));
        customer.setPassword(rs.getString("password"));

        list.add(customer);
      }
    } catch (Exception e) {
      e.printStackTrace();
    }
    db.close();

    return list;
  }
  @Override
  public void onClick(View arg0) {
    // TODO Auto-generated method stub
    if (etLectNum.getText().toString().length() == 0) {
      Dialog d = new Dialog(this);
      d.setTitle("Lecture Number cannot be empty!");
      d.show();
    } else {
      lecture_number = Integer.parseInt(etLectNum.getText().toString());
      lecture_title = etLectTitle.getText().toString();
      lecture_description = etLectDescription.getText().toString();

      dbh = new DBHelper(this);

      if (getIntent().getExtras().getBoolean("Update")) {
        dbh.updateLecture(
            semSelected, courseSelected, lecture_number, lecture_title, lecture_description, "");
        Toast.makeText(
                getApplicationContext(),
                "Lecture " + lecture_number + " updated successfully!",
                Toast.LENGTH_SHORT)
            .show();

        Intent intent =
            new Intent(getApplicationContext(), com.aakash.studentmanager.LectureList.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
        startActivity(intent);

      } else {

        Cursor rs = dbh.getLectureData(semSelected, courseSelected, lecture_number);

        rs.moveToFirst();
        if (rs.isAfterLast() == true) {

          dbh.insertLecture(
              semSelected, courseSelected, lecture_number, lecture_title, lecture_description, "");
          Toast.makeText(
                  getApplicationContext(),
                  "Lecture " + lecture_number + " added successfully!",
                  Toast.LENGTH_SHORT)
              .show();

          Intent intent =
              new Intent(getApplicationContext(), com.aakash.studentmanager.LectureList.class);
          intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          startActivity(intent);
        } else {
          Dialog d = new Dialog(this);
          d.setTitle("Duplicate Entry:");
          TextView tv = new TextView(this);
          tv.setText("Lecture Number " + lecture_number + " already added!");
          d.setContentView(tv);
          d.show();
        }
      }
      dbh.close();
    }
  }
  /** Returns the last Annotation by date attached to a specified TicketID. */
  public static Annotation getLastAnnotation(int ticketID) {
    DBHelper db = DBHelperFactory.createDBHelper();
    ArrayList<Annotation> temp = db.createAnnotationArrayListByTicket(ticketID);

    Annotation result = temp.get(temp.size() - 1);

    db.close();
    return result;
  }
  /** Creates a new Annotation with specified text, ticket ID, and worker name. */
  public static void createNewAnnotation(String text, int ticketid, String workername) {
    DBHelper db = DBHelperFactory.createDBHelper();

    java.util.Date date = new java.util.Date();
    java.sql.Timestamp ts = new java.sql.Timestamp(date.getTime());
    Account temp = db.retrieveAccount(workername);

    Annotation anno = ModelFactory.createAnnotation(text, ts, ticketid, temp.get_id());
    db.storeAnnotation(anno);
    db.close();
  }
  /** Returns a String for a workername by workerid. */
  public static String getWorkerName(int workerid) {
    if (workerid == 0) {
      return "TicketSystem";
    }

    DBHelper db = DBHelperFactory.createDBHelper();
    Account temp = db.retrieveAccount(workerid);
    String result = temp.getUsername();

    db.close();
    return result;
  }
  /** Called when the activity is first created. */
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Подключаемся к БД
    DBHelper dbh = new DBHelper(this);
    SQLiteDatabase db = dbh.getWritableDatabase();

    // Описание курсора
    Cursor c;

    // выводим в лог данные по должностям
    Log.d(LOG_TAG, "--- Table position ---");
    c = db.query("position", null, null, null, null, null, null);
    logCursor(c);
    c.close();
    Log.d(LOG_TAG, "--- ---");

    // выводим в лог данные по людям
    Log.d(LOG_TAG, "--- Table people ---");
    c = db.query("people", null, null, null, null, null, null);
    logCursor(c);
    c.close();
    Log.d(LOG_TAG, "--- ---");

    // выводим результат объединения
    // используем rawQuery
    Log.d(LOG_TAG, "--- INNER JOIN with rawQuery---");
    String query =
        "select PL.name as Name, PS.name as Position, salary as Salary from people as PL inner join position as PS on PL.posid=PS.id where salary > ?";
    c = db.rawQuery(query, new String[] {"12000"});
    logCursor(c);
    c.close();
    Log.d(LOG_TAG, "--- ---");

    // выводим результат объединения
    // используем query
    Log.d(LOG_TAG, "--- INNER JOIN with query---");
    String table = "people as PL inner join position as PS on PL.posid = PS.id";
    String columns[] = {"PL.name as Name", "PS.name as Position", "salary as Salary"};
    String selection = "salary < ?";
    String[] selectionArgs = {"12000"};
    c = db.query(table, columns, selection, selectionArgs, null, null, null);
    logCursor(c);
    c.close();
    Log.d(LOG_TAG, "--- ---");

    // закрываем БД
    dbh.close();
  }
  /** Creates a new Ticket based on user input for the subject. Returns the Ticket ID. */
  public static int createNewTicket(String desc) {
    DBHelper db = DBHelperFactory.createDBHelper();
    Ticket tick = ModelFactory.createTicket(0, desc, true, false, false);
    int dbid = db.storeTicket(tick);

    java.util.Date date = new java.util.Date();
    java.sql.Timestamp ts = new java.sql.Timestamp(date.getTime());
    Annotation open_ticket_annotation =
        ModelFactory.createAnnotation("Ticket has been opened.", ts, dbid, 0);
    db.storeAnnotation(open_ticket_annotation);

    db.close();
    return dbid;
  }
  @SuppressLint("SimpleDateFormat")
  public void GetAllMessages() {
    dbHelper = new DBHelper(this);
    SQLiteDatabase db = dbHelper.getWritableDatabase();

    String selection = "chat_id = ?";
    String[] selectionArgs = new String[] {ThisChatId.toString()};
    Cursor c = db.query("messages", null, selection, selectionArgs, null, null, null);

    ArrayList<Map<String, Object>> data = new ArrayList<Map<String, Object>>();
    Map<String, Object> m;

    if (c.moveToFirst()) {
      int nameColFrom = c.getColumnIndex("from_name");
      int nameColText = c.getColumnIndex("message_text");
      int nameColUserId = c.getColumnIndex("from_inet_id");
      int nameColMsgTime = c.getColumnIndex("message_time");
      do {
        m = new HashMap<String, Object>();
        m.put(ATTRIBUTE_NAME_ID, c.getString(nameColUserId));
        m.put(ATTRIBUTE_NAME_FROM, c.getString(nameColFrom));
        m.put(ATTRIBUTE_NAME_TEXT, c.getString(nameColText));
        m.put(ATTRIBUTE_NAME_MSG_TIME, c.getString(nameColMsgTime));
        data.add(m);
      } while (c.moveToNext());
    }
    c.close();

    String[] from = {
      ATTRIBUTE_NAME_ID, ATTRIBUTE_NAME_FROM, ATTRIBUTE_NAME_TEXT, ATTRIBUTE_NAME_MSG_TIME
    };
    int[] to = {R.id.tvMsgRowId, R.id.tvMsgFrom, R.id.tvMsgText, R.id.lastMsgTimeinChatList};
    SimpleAdapter sAdapter = new SimpleAdapter(this, data, R.layout.messages_item, from, to);
    lvMessages.setAdapter(sAdapter);

    /*lvAllContacts.setOnItemClickListener(new OnItemClickListener() {
         public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
    Intent intent = new Intent(AllContactsActivity.this, OneContactInfoActivity.class);
          TextView textView = (TextView) view.findViewById(R.id.tvAllContactId);
          Log.i("INFO OF CONTAACT",  textView.getText().toString());
    intent.putExtra("contact_id", Integer.parseInt(textView.getText().toString()));
    startActivity(intent);

         }
     }); */
    scrollMyListViewToBottom();

    dbHelper.close();
  }
Beispiel #20
0
  @Override
  protected void onPause() {
    super.onPause();

    if (debug) Log.d(TAG, "onPause()");

    if (blankPasswordToast != null) blankPasswordToast.cancel();
    if (invalidPasswordToast != null) invalidPasswordToast.cancel();
    if (confirmPasswordFailToast != null) confirmPasswordFailToast.cancel();

    if (dbHelper != null) {
      dbHelper.close();
      dbHelper = null;
    }
  }
  /** Returns an ArrayList of Tickets by worker username. */
  public static ArrayList<Ticket> getActiveTicketsByWorker(String username) {
    DBHelper db = DBHelperFactory.createDBHelper();
    Account temp = db.retrieveAccount(username);
    ArrayList<Ticket> temp2 = db.createTicketArrayListByWorker(temp.get_id());
    ArrayList<Ticket> result = new ArrayList<Ticket>();

    for (int i = 0; i < temp2.size(); i++) {
      if (temp2.get(i).getActive()) {
        result.add(temp2.get(i));
      }
    }

    db.close();
    return result;
  }
  // creates a local copy of db file from the working path in assets
  private final boolean setupLocalDB(String dbFileName) {
    // private class for help creating database file in setupLocalDB()
    class DBHelper extends SQLiteOpenHelper {
      public DBHelper(Context context, String name) {
        super(context, name, null, 1);
      }

      @Override
      public void onCreate(SQLiteDatabase db) {}

      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {}
    };

    try {
      // Open then close a SQLite database to prepare for copying
      DBHelper dbHelper = new DBHelper(assetsContext, dbFileName);
      SQLiteDatabase db = dbHelper.getReadableDatabase();
      localDbPath = db.getPath();
      db.close();
      dbHelper.close();

      // Open the empty db as the output stream
      OutputStream localDb = new FileOutputStream(localDbPath);

      // Open your local db as the input stream
      InputStream dbAsset = assetsContext.getAssets().open(workingPath + dbFileName);

      // transfer bytes from dbAsset to localDb
      byte[] buffer = new byte[1024];
      int length;
      while ((length = dbAsset.read(buffer)) > 0) localDb.write(buffer, 0, length);

      // Close the streams
      dbAsset.close();
      localDb.flush();
      localDb.close();
    } catch (Exception e) {
      e.printStackTrace();
      localDbPath = null; // reset to null if failed
      return false;
    }

    return true;
  }
Beispiel #23
0
  public static boolean destroyCustomer(String customerId) {
    boolean result = false;
    DBHelper db = new DBHelper();
    try {
      String queryString = "DELETE FROM webshop.customer WHERE id = " + customerId + ";";
      int rs = db.executeNonQuery(queryString);

      if (rs > 0) {
        result = true;
      }

      db.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return result;
  }
 public int yangbenWaveDelete(int id) { // 返回影响的行数
   int result = 0; // 影响记录的行数
   if (isYangbenWaveExistById(id)) {
     sql = "DELETE FROM yangbenwave WHERE id=" + id;
     try {
       db1 = new DBHelper(sql); // 创建DBHelper对象
       result = db1.pst.executeUpdate(sql);
     } catch (SQLException e) {
       // TODO Auto-generated catch block
       System.out.println("样本波形信息删除失败");
       e.printStackTrace();
     }
     db1.close();
   } else {
     System.out.println("该样本波形id不存在,无法删除");
   }
   return result;
 }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    String title = getIntent().getExtras().getString("title");
    int selectedId = getIntent().getExtras().getInt("id");

    super.onCreate(savedInstanceState);

    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.drug_info);
    getWindow().setFeatureInt(Window.FEATURE_CUSTOM_TITLE, R.layout.window_title_without_search);

    DBHelper myDbHelper = new DBHelper(this);
    myDbHelper = new DBHelper(this);
    try {
      myDbHelper.createDataBase();
    } catch (IOException ioe) {
      throw new Error("Unable to create database");
    }
    try {
      myDbHelper.openDataBase();

      drugInfo = myDbHelper.getDrugInfoById(selectedId);

      myDbHelper.close();
    } catch (SQLException e) {
      e.printStackTrace();
    }
    TextView headerText = (TextView) findViewById(R.id.headerTitle);
    headerText.setText(title);

    WebView drugInfoContainer = (WebView) findViewById(R.id.drugInfoWebView);
    drugInfoContainer.getSettings().setJavaScriptEnabled(true);
    String header =
        "<!DOCTYPE html>\n"
            + "<html>\n"
            + "<head>\n"
            + "    <meta content=\"text/html; charset=utf-8\" http-equiv=\"Content-Type\" />\n"
            + "</head>\n"
            + "<body style='background-color:#fefdfb'><p style='font-size:5px;'>&nbsp</p>\n"
            + drugInfo
            + "</body>\n"
            + "</html>";
    drugInfoContainer.loadDataWithBaseURL("", header, "text/html", "utf-8", null);
  }
Beispiel #26
0
  public static boolean addCustomer(
      String firstName,
      String lastName,
      String phone,
      String address,
      int zipCode,
      String city,
      String email,
      String password) {
    boolean result = false;
    DBHelper db = new DBHelper();
    try {
      String queryString =
          "INSERT INTO webshop.customer (first_name, last_name, phone, address, zipcode, city, email, password) VALUES ('"
              + firstName
              + "', '"
              + lastName
              + "', '"
              + phone
              + "', '"
              + address
              + "', "
              + zipCode
              + ", '"
              + city
              + "', '"
              + email
              + "', '"
              + password
              + "');";
      int rs = db.executeNonQuery(queryString);

      if (rs > 0) {
        result = true;
      }

      db.close();
    } catch (Exception e) {
      e.printStackTrace();
    }

    return result;
  }
  /**
   * Returns a formatted string that indicates the last time a Ticket was worked on (in other words,
   * the date of the last annotation)
   */
  public static String getLastActivity(int ticketNumber) {
    DBHelper db = DBHelperFactory.createDBHelper();
    ArrayList<Annotation> annos = db.createAnnotationArrayListByTicket(ticketNumber);

    java.sql.Timestamp lastActivity = new java.sql.Timestamp(0L);

    for (int i = 0; i < annos.size(); i++) {
      java.sql.Timestamp ts = annos.get(i).getCreatedOn();

      if (ts.after(lastActivity)) {
        lastActivity.setTime(ts.getTime());
      }
    }

    String result = getTime(lastActivity);

    db.close();
    return result;
  }
 public int yangbenWaveAdd(YangbenWaveInfo yangbenWaveInfo) { // 波形添加
   int result = 0; // 影响记录的行数
   sql =
       "insert into yangbenwave(userid,date,singlewave)values("
           + yangbenWaveInfo.getUserid()
           + ",'"
           + yangbenWaveInfo.getDate()
           + "','"
           + yangbenWaveInfo.getWave()
           + "')";
   try {
     db1 = new DBHelper(sql); // 创建DBHelper对象
     result = db1.pst.executeUpdate(sql);
   } catch (SQLException e) {
     // TODO Auto-generated catch block
     e.printStackTrace();
   }
   db1.close();
   return result;
 }
Beispiel #29
0
  public static void populatePatients(Spinner spinnerPatients) {
    Context context = spinnerPatients.getContext();
    DBHelper dbhelper = new DBHelper(context);
    SQLiteDatabase db = dbhelper.getReadableDatabase();
    Cursor patients = db.query(Database.PATIENT_TABLE_NAME, null, null, null, null, null, null);
    ArrayList<Patient> list = new ArrayList<Patient>();

    // adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    while (patients.moveToNext()) {
      Patient p1 = Database.cursorToAccount(patients);
      list.add(p1);
    }
    patients.close();
    db.close();
    dbhelper.close();

    ArrayAdapter<Patient> adapter =
        new ArrayAdapter<Patient>(context, android.R.layout.simple_spinner_item, list);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinnerPatients.setAdapter(adapter);
  }
 public YangbenWaveInfo getWaveInfoById(int id) { // 通过样本波形ID获取样本波形数据
   sql = "select * from yangbenwave where id=" + id;
   db1 = new DBHelper(sql); // 创建DBHelper对象
   YangbenWaveInfo yangbenWaveInfo = new YangbenWaveInfo();
   try {
     ret = db1.pst.executeQuery();
     while (ret.next()) {
       yangbenWaveInfo.setId(ret.getInt(1));
       yangbenWaveInfo.setUserid(ret.getInt(2));
       yangbenWaveInfo.setDate(ret.getString(3));
       yangbenWaveInfo.setWave(ret.getString(4));
     } // 显示数据
     ret.close();
   } catch (SQLException e) {
     System.out.println("按ID获取样本波形信息失败,可能是该样本波形id不存在");
     // TODO Auto-generated catch block
     e.printStackTrace();
   } // 执行语句,得到结果集
   db1.close(); // 关闭连接
   return yangbenWaveInfo;
 }