public User[] getAllUser() { Vector<User> v = new Vector<User>(); Cursor cursor = null; try { cursor = db.find("select * from " + TABLENAME, null); while (cursor.moveToNext()) { User temp = new User(); temp.setId_DB(cursor.getInt(cursor.getColumnIndex("id_DB"))); temp.setAddress(cursor.getString(cursor.getColumnIndex(User.ADDRESS))); temp.setQq(cursor.getString(cursor.getColumnIndex(User.QQ))); temp.setDanwei(cursor.getString(cursor.getColumnIndex(User.DANWEI))); temp.setName(cursor.getString(cursor.getColumnIndex(User.NAME))); temp.setMobile(cursor.getString(cursor.getColumnIndex(User.MOBILE))); v.add(temp); } } catch (Exception e) { e.printStackTrace(); } finally { if (cursor != null) cursor.close(); db.closeConnection(); } if (v.size() > 0) { return v.toArray(new User[] {}); } else { User[] users = new User[1]; User user = new User(); user.setName("无结果111"); users[0] = user; return users; } }
public boolean updateUser(User user) { ContentValues values = new ContentValues(); values.put(User.NAME, user.getName()); values.put(User.ADDRESS, user.getAddress()); values.put(User.QQ, user.getQq()); values.put(User.DANWEI, user.getDanwei()); values.put(User.MOBILE, user.getMobile()); return db.update(TABLENAME, values, "id_db=?", new String[] {user.getId_DB() + ""}); }
public boolean addDate(User user) { ContentValues values = new ContentValues(); values.put(User.NAME, user.getName()); values.put(User.MOBILE, user.getMobile()); values.put(User.DANWEI, user.getDanwei()); values.put(User.QQ, user.getQq()); values.put(User.ADDRESS, user.getAddress()); return db.save(TABLENAME, values); }
public ContactsTable(Context context) { db = new MyDB(context); if (!db.isTableExists(TABLENAME)) { String createTableSql = "CREATE TABLE IF NOT EXISTS " + TABLENAME + "(id_DB integer primary key AUTOINCREMENT, " + User.NAME + " VARCHAR," + User.MOBILE + " VARCHAR," + User.DANWEI + " VARCHAR," + User.QQ + " VARCHAR," + User.ADDRESS + " VARCHAR)"; db.createTable(createTableSql); } }
/** @see ServletContextListener#contextInitialized(ServletContextEvent) */ public void contextInitialized(ServletContextEvent arg0) { ServletContext sc = arg0.getServletContext(); Connection con = (Connection) MyDB.getConnection(); sc.setAttribute("connect", con); AccountManager am = new AccountManager(con); sc.setAttribute("accounts", am); MailManager mm = new MailManager(con); sc.setAttribute("mail", mm); // TODO Auto-generated method stub }
public User getUserByID(int id) { Cursor cursor = null; try { cursor = db.find("select * from " + TABLENAME + " where id_DB=?", new String[] {id + ""}); User temp = new User(); cursor.moveToNext(); temp.setId_DB(cursor.getInt(cursor.getColumnIndex("id_DB"))); temp.setAddress(cursor.getString(cursor.getColumnIndex(User.ADDRESS))); temp.setQq(cursor.getString(cursor.getColumnIndex(User.QQ))); temp.setDanwei(cursor.getString(cursor.getColumnIndex(User.DANWEI))); temp.setMobile(cursor.getString(cursor.getColumnIndex(User.MOBILE))); temp.setName(cursor.getString(cursor.getColumnIndex(User.NAME))); return temp; } catch (Exception e) { e.printStackTrace(); } finally { if (cursor != null) { cursor.close(); } db.closeConnection(); } return null; }
public boolean deleteByUser(User user) { return db.delete(TABLENAME, " id_DB=?", new String[] {user.getId_DB() + ""}); }
public int postInsertOk( SessionContext ctx, DatabaseConnection conn, FormInstance instance, ErrorMessages msgs, EventManager manager) { if (this.isG) { return conn.executeUpdate( "delete from cmguarantor where id='" + ctx.getParameter("ID") + "'"); } if (this.initClientNo == null) { return 0; } MyDB.getInstance().addDBConn(conn); int ret = 0; try { UserManager um = (UserManager) ctx.getAttribute(SystemAttributeNames.USER_INFO_NAME); String OPERATOR = null; OPERATOR = um.getUserName(); String clientno = null; if (this.initClientNo != null) { if (currClientNo == null) { msgs.add("客户号码未发现,请重做交易!"); return -1; } else { ret = ClientMigration.clientMrig(initClientNo, currClientNo, OPERATOR); if (ret >= 0) { /** I comment following line temporarily to speed up perfomance JGO on 20040905 */ // ret = CMClientMan.updateClientCatAndType(currClientNo, OPERATOR); ret = 0; } if (ret < 0) { String msg = PropertyManager.getProperty("" + ret); if (msg == null) { msg = "" + ret; } ctx.setRequestAtrribute("title", "客户信息移行"); ctx.setRequestAtrribute("msg", "处理失败:" + msg); ctx.setRequestAtrribute("flag", "0"); ctx.setTarget("/showinfo.jsp"); } else { ctx.setRequestAtrribute("title", "客户信息移行"); ctx.setRequestAtrribute("msg", "处理成功完成!"); ctx.setRequestAtrribute("flag", "1"); ctx.setTarget("/showinfo.jsp"); } } } } catch (Exception e) { if (Debug.isDebugMode) { e.printStackTrace(); } ret = -1; } finally { MyDB.getInstance().releaseDBConn(); return ret; } }
/** 扩展基类的beforeInsert方法,点击“添加”按钮后响应的事件 */ public int beforeInsert( SessionContext ctx, DatabaseConnection conn, FormInstance instance, ErrorMessages msgs, EventManager manager) { String GID = (String) ctx.getRequestAttribute("GID"); String GIDTYPE = (String) ctx.getRequestAttribute("GIDTYPE"); String GNAME = (String) ctx.getRequestAttribute("GNAME"); String GCREDITCLASS = (String) ctx.getRequestAttribute("GCREDITCLASS"); if (GID != null) { instance.setReadonly(false); instance.setValue("NAME", GNAME); instance.setValue("IDTYPE", GIDTYPE); instance.setValue("ID", GID); instance.setValue("CREDITCLASS", GCREDITCLASS); instance.setFieldReadonly("NAME", true); instance.setFieldReadonly("IDTYPE", true); instance.setFieldReadonly("ID", true); instance.setFieldReadonly("CREDITCLASS", true); this.isG = true; } UserManager um = (UserManager) ctx.getAttribute(SystemAttributeNames.USER_INFO_NAME); String BrhId = SCUser.getBrhId(um.getUserName()); String APPDATE = SystemDate.getSystemDate5(""); String OPERATOR = null; try { OPERATOR = um.getUserName(); } catch (Exception ex) { return -1; } if (BrhId != null) { instance.setValue("MNTBRHID", BrhId); if (!SCBranch.getBrhtype(BrhId).trim().equals("9")) { instance.setValue("APPBRHID", BrhId); } instance.setValue("OPERATOR", OPERATOR); instance.setValue("APPDATE", APPDATE); instance.setValue("INVESTDATE", APPDATE); instance.setValue("LASTMODIFIED", APPDATE); } if (this.initClientNo != null) { MyDB.getInstance().addDBConn(conn); InitClientData initdata = InitClientMan.getInitClient(initClientNo); MyDB.getInstance().releaseDBConn(); if (initdata == null) { msgs.add("移行客户信息不存在,请检查数据!"); return -1; } else { if (initdata.appBrhID != null) { instance.setValue("APPBRHID", initdata.appBrhID); } if (initdata.appDate != null) { instance.setValue("APPDATE", util.calToString(initdata.appDate, null)); } if (initdata.clientType != null) { instance.setValue("CLIENTTYPE", initdata.clientType.intValue()); } if (initdata.ecomDeptType != null) { instance.setValue("ECOMDEPTTYPE", initdata.ecomDeptType.intValue()); } if (initdata.ecomType != null) { instance.setValue("ECOMTYPE", initdata.ecomType.intValue()); } if (initdata.etpScopType != null) { instance.setValue("ETPSCOPTYPE", initdata.etpScopType.intValue()); } if (initdata.gender != null) { instance.setValue("GENDER", initdata.gender.intValue()); } if (initdata.ID != null) { instance.setValue("ID", initdata.ID); } if (initdata.IDType != null) { // instance.setValue("IDTYPE", initdata.IDType.intValue()); } if (initdata.name != null) { instance.setValue("NAME", initdata.name); } if (initdata.sectorCat1 != null) { instance.setValue("SECTORCAT1", initdata.sectorCat1.intValue()); } } } return 0; }