/** * Get the main (base) record for this table. * Same as getFieldList, but casts the class to Record. * @return The record. */ public Record getRecord() { return (Record)super.getRecord(); } /**
this.open(); this.getRecord().setEditMode(Constants.EDIT_NONE); Object objData = this.doGet(iRowIndex); if (objData instanceof Integer) if (iRecordStatus == DELETED_RECORD.intValue()) // DBConstants.RECORD_NEW this.addNew(); this.getRecord().setEditMode(Constants.EDIT_NONE); // Invalid record return m_record; this.setDataSource(objData); //m_tableRemote.dataToFields(); this.dataToFields(this.getRecord()); this.getRecord().setEditMode(Constants.EDIT_CURRENT); return m_record;
/** * Create the new main record. * @return */ public int createNewMainRecord() { try { FieldTable tableMain = m_recMain.getTable(); tableMain.add(m_recMain); Object bookmark = tableMain.getLastModified(0); tableMain.setHandle(bookmark, 0); return Constants.NORMAL_RETURN; } catch (DBException ex) { return Constants.ERROR_RETURN; } } }
/** * Reposition to this record Using this bookmark. * @param Object bookmark Bookmark. * @param int iHandleType Type of handle (see getHandle). * @exception FILE_NOT_OPEN. * @return record if found/null - record not found. */ public FieldList setHandle(Object bookmark, int iHandleType) throws DBException { if (this.doSetHandle(bookmark, iHandleType)) return this.getRecord(); else return null; } /**
/** * Reset the current position and open the file. * Note: This is called automatically on your first file access. */ public void open() throws DBException { m_bIsOpen = true; this.getRecord().setEditMode(Constants.EDIT_NONE); this.setDataSource(null); } /**
/** * Get the next record (return a null at EOF). * @param iRelPosition The relative records to move. * @return next FieldList or null if EOF. */ public FieldList move(int iRelPosition) throws DBException { if (!m_bIsOpen) this.open(); // This will requery the table the first time this.getRecord().setEditMode(Constants.EDIT_NONE); int iRecordStatus = this.doMove(iRelPosition); if (iRecordStatus == Constants.NORMAL_RETURN) { this.dataToFields(this.getRecord()); // Usually, you would setDataSource(null), but if in hasNext(), you will need the dataSource. this.getRecord().setEditMode(Constants.EDIT_CURRENT); return m_record; } else return null; // Usually EOF } /**
/** * Change the start time of this service. */ public void updateField(String strFieldName, Object objData) { try { FieldInfo fieldInfo = m_table.getRecord().getField(strFieldName); if (fieldInfo != null) { m_table.edit(); fieldInfo.setData(objData); m_table.set(m_table.getRecord()); m_table.seek(null); // Read this record } } catch (Exception ex) { ex.printStackTrace(); } } }
(record.getEditMode() == Constants.EDIT_CURRENT)) fieldTable.set(record); fieldTable.add(record); strID = fieldTable.getLastModified(0).toString(); // Bookmark handle fieldTable.addNew(); this.resetFocus(); if ((strID != null) String strKeyName = record.getKeyName(); record.setKeyName(Constants.PRIMARY_KEY); boolean bSuccess = record.getTable().seek(null); if (bSuccess) this.fieldsToControls();
table.close(); model.resetTheModel(); return true; tlbBookingDetail.addNew(); tlbBookingDetail.getRecord().getField(Params.ID).setData(intDetailID); if (tlbBookingDetail.seek(null)) screen = mainScreen.createNewScreen(Constants.FORM, tlbBookingDetail.getRecord()); screen = new JBookingDetailGridScreen(this, tlbBookingDetail.getRecord()); if (screen != null)
/** * Read the record that matches this record's current key. * <p>NOTE: You do not need to Open to do a seek or addNew. * @param strSeekSign - Seek sign: * @return true if successful, false if not found. * @exception FILE_NOT_OPEN. * @exception KEY_NOT_FOUND - The key was not found on read. */ public boolean seek(String strSeekSign) throws DBException { this.getRecord().setEditMode(Constants.EDIT_NONE); if (strSeekSign == null) strSeekSign = Constants.EQUALS; boolean bSuccess = this.doSeek(strSeekSign); if (bSuccess) { this.dataToFields(this.getRecord()); this.setDataSource(null); this.getRecord().setEditMode(Constants.EDIT_CURRENT); return true; } else return false; // Not found } /**
/** * Add this record to this table. * Add this record to the table and set the current edit mode to NONE. * @param record The record to add. * @throws Exception */ public void add(Rec record) throws DBException { if (this.getRecord().getEditMode() != Constants.EDIT_ADD) throw new DBException(Constants.INVALID_RECORD); m_record = (FieldList)record; this.fieldsToData(record); this.doAdd(record); this.setDataSource(null); this.getRecord().setEditMode(Constants.EDIT_NONE); } /**
/** * Set the current record to this (new) record. * NOTE: In the thin model, it is not necessary to call edit() before set. * @exception Throws an exception if there is no current record. */ public void set(Rec record) throws DBException { if ((this.getRecord().getEditMode() != Constants.EDIT_CURRENT) && ((this.getRecord().getEditMode() != Constants.EDIT_IN_PROGRESS))) throw new DBException(Constants.INVALID_RECORD); m_record = (FieldList)record; this.fieldsToData(record); this.doSet(record); this.setDataSource(null); this.getRecord().setEditMode(Constants.EDIT_NONE); } /**
try { if (record != null) record.getTable().remove(); } catch (DBException ex) { ex.printStackTrace(); m_model.getFieldTable().addNew(); // Make sure it is clear m_model.getFieldTable().getRecord().getField(BookingDetail.PRODUCT_TYPE).setString(strAction); JBookingDetailMainScreen mainScreen = (JBookingDetailMainScreen)this.getTargetScreen(JBookingDetailMainScreen.class); mainScreen.setSource(this);
this.initKeyAreas(table); BaseBuffer bufferNew = (BaseBuffer)table.getDataSource(); // same as .getHandle(Constants.DATA_SOURCE_HANDLE); if (table.getRecord().getEditMode() == Constants.EDIT_ADD) for (int iKeyArea = Constants.MAIN_KEY_AREA; iKeyArea < table.getRecord().getKeyAreaCount() + Constants.MAIN_KEY_AREA; iKeyArea++) FieldInfo field = table.getRecord().getCounterField(); if (field != null) if (!field.isNull()) if (!table.getRecord().isAutoSequence()) table.fieldsToData(table.getRecord()); // Update buffer bufferNew = (BaseBuffer)table.getDataSource(); // same as .getHandle(Constants.DATA_SOURCE_HANDLE); bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE); this.getPKeyArea(iKeyArea).doWrite(table, table.getRecord().getKeyArea(iKeyArea), bufferNew); } catch (DBException ex) { if (ex.getErrorCode() == Constants.DUPLICATE_KEY) bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE); this.getPKeyArea(iKeyArea).doRemove(table, table.getRecord().getKeyArea(iKeyArea), bufferNew); iKeyArea--; bufferNew.bufferToFields(table.getRecord(), Constants.DONT_DISPLAY, Constants.READ_MOVE);
recBooking.getTable().addNew(); recBooking.getField(strKeyField).setString(strKeyValue); String strOldKeyArea = recBooking.getKeyName(); recBooking.setKeyArea(strKeyField); bSuccess = recBooking.getTable().seek(Constants.EQUALS); recBooking.setKeyArea(strOldKeyArea); if (bSuccess) bSuccess = this.getTourRecord().getTable().seek(Constants.SEEK_CURRENT_RECORD); if (bSuccess) bSuccess = this.getCurrencyRecord().getTable().seek(Constants.SEEK_CURRENT_RECORD); recBooking.getTable().addNew(); // Clean the booking record this.getRemoteSession().doRemoteAction(Constants.RESET, null); // Tell the remote session that I'm done with this booking this.getTourRecord().getTable().addNew(); // Clear tour record bSuccess = true;
/** * Reposition to this record using this bookmark. * @param bookmark The handle to use to position the record. * @param iHandleType The type of handle (DATA_SOURCE/OBJECT_ID,OBJECT_SOURCE,BOOKMARK). * @return - true - record found/false - record not found * @exception FILE_NOT_OPEN. * @exception DBException File exception. */ public boolean doSetHandle(Object bookmark, int iHandleType) throws DBException { String strCurrentOrder = this.getRecord().getKeyName(); this.getRecord().setKeyArea(Constants.PRIMARY_KEY); this.getRecord().getCounterField().setData(bookmark); boolean bSuccess = this.seek(Constants.EQUALS); this.getRecord().setKeyArea(strCurrentOrder); return bSuccess; } /**
(recBooking.getEditMode() == Constants.EDIT_CURRENT)) bookmark = tblBooking.getHandle(0); tblBooking.set(recBooking); if (bRefreshRecord) tblBooking.setHandle(bookmark, 0); tblBooking.add(recBooking); if (bRefreshRecord) bookmark = tblBooking.getLastModified(0); tblBooking.setHandle(bookmark, 0); (recTour.getEditMode() == Constants.EDIT_CURRENT)) bookmark = tblTour.getHandle(0); tblTour.set(recTour); if (bRefreshRecord) tblTour.setHandle(bookmark, 0); tblTour.add(recTour); if (bRefreshRecord) bookmark = tblTour.getLastModified(0); tblTour.setHandle(bookmark, 0);
this.setKeyName(Constants.PRIMARY_KEY); this.getCounterField().setData(bookmark); boolean bSuccess = this.getTable().seek(null); this.setKeyName(strOldKey); this.getTable().addNew(); else this.getTable().edit(); // If I haven't changed any data, just refresh it. buffer.resetPosition(); for (int iFieldSeq = 0; iFieldSeq < this.getFieldCount(); iFieldSeq++) this.getTable().addNew(); // Clear current bookmark if (iChangeType != Constants.AFTER_DELETE_TYPE) this.setKeyName(Constants.PRIMARY_KEY); this.getCounterField().setData(bookmark); this.getTable().seek(null); this.setKeyName(strOldKey);