/** * Move the ID field to the code field. * @return */ public int moveIDToCodeField() { if (this.getCodeField().isNull()) return getCodeField().moveFieldToThis((BaseField)this.getOwner().getCounterField()); else return DBConstants.NORMAL_RETURN; } }
/** * Constructor. * @param record My owner (usually passed as null, and set on addListener in setOwner()). */ public MoveIDToCodeHandler(Record record) { this(); this.init(record); } /**
/** * Called when a change is the record status is about to happen/has happened. * @param field If this file change is due to a field, this is the field. * @param iChangeType The type of change that occurred. * @param bDisplayOption If true, display any changes. * @return an error code. */ public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption) { int iErrorCode = super.doRecordChange(field, iChangeType, bDisplayOption); if (iChangeType == DBConstants.AFTER_REFRESH_TYPE) iErrorCode = this.moveIDToCodeField(); else if ((iChangeType == DBConstants.AFTER_ADD_TYPE) && (this.getCodeField().isNull())) { try { Record record = this.getOwner(); Object bookmark = record.getLastModified(DBConstants.BOOKMARK_HANDLE); record.setHandle(bookmark, DBConstants.BOOKMARK_HANDLE); record.edit(); iErrorCode = this.moveIDToCodeField(); record.set(); } catch (DBException ex) { ex.printStackTrace(); } } return iErrorCode; } /**
/** * Get the code field. * @return The code field (or the index field if not found) */ public BaseField getCodeField() { Record record = this.getOwner(); if (m_iCodeField != -1) return record.getField(m_iCodeField); else return record.getKeyArea(record.getCodeKeyArea()).getField(DBConstants.MAIN_KEY_FIELD); } /**
/** * AddMasterListeners Method. */ public void addMasterListeners() { super.addMasterListeners(); this.getField(ApTrx.TRX_STATUS_ID).addListener(new UpdateActiveTrxStatus(this.getField(ApTrx.ACTIVE_TRX))); this.getField(ApTrx.DEPARTURE_DATE).addListener(new GetDepartureDateHandler((TourField)this.getField(ApTrx.TOUR_ID))); this.addListener(new NoDeleteModifyHandler(true, false)); Record recApControl = null; RecordOwner recordOwner = this.findRecordOwner(); if (recordOwner != null) recApControl = (Record)recordOwner.getRecord(ApControl.AP_CONTROL_FILE); if (recApControl == null) { recApControl = new ApControl(recordOwner); this.addListener(new FreeOnFreeHandler(recApControl)); } if (recApControl.getField(ApControl.AUTO_AP_CODE).getState() == true) this.addListener(new MoveIDToCodeHandler((String)null)); this.addListener(new ApTrxStatusHandler(null)); } /**
/** * Called when a change is the record status is about to happen/has happened. * @param field If this file change is due to a field, this is the field. * @param iChangeType The type of change that occurred. * @param bDisplayOption If true, display any changes. * @return an error code. */ public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption) { int iErrorCode = super.doRecordChange(field, iChangeType, bDisplayOption); if (iChangeType == DBConstants.AFTER_REFRESH_TYPE) iErrorCode = this.moveIDToCodeField(); else if ((iChangeType == DBConstants.AFTER_ADD_TYPE) && (this.getCodeField().isNull())) { try { Record record = this.getOwner(); Object bookmark = record.getLastModified(DBConstants.BOOKMARK_HANDLE); record.setHandle(bookmark, DBConstants.BOOKMARK_HANDLE); record.edit(); iErrorCode = this.moveIDToCodeField(); record.set(); } catch (DBException ex) { ex.printStackTrace(); } } return iErrorCode; } /**
/** * Get the code field. * @return The code field (or the index field if not found) */ public BaseField getCodeField() { Record record = this.getOwner(); if (m_iCodeField != -1) return record.getField(m_iCodeField); else return record.getKeyArea(record.getCodeKeyArea()).getField(DBConstants.MAIN_KEY_FIELD); } /**
this.addListener(new MoveIDToCodeHandler(Booking.CODE)); // If auto-booking numbers are turned on, set them return recBookingControl;
/** * Called when a change is the record status is about to happen/has happened. * @param field If this file change is due to a field, this is the field. * @param iChangeType The type of change that occurred. * @param bDisplayOption If true, display any changes. * @return an error code. */ public int doRecordChange(FieldInfo field, int iChangeType, boolean bDisplayOption) { int iErrorCode = super.doRecordChange(field, iChangeType, bDisplayOption); if (iChangeType == DBConstants.AFTER_REFRESH_TYPE) iErrorCode = this.moveIDToCodeField(); else if ((iChangeType == DBConstants.AFTER_ADD_TYPE) && (this.getCodeField().isNull())) { try { Record record = this.getOwner(); Object bookmark = record.getLastModified(DBConstants.BOOKMARK_HANDLE); record.setHandle(bookmark, DBConstants.BOOKMARK_HANDLE); record.edit(); iErrorCode = this.moveIDToCodeField(); record.set(); } catch (DBException ex) { ex.printStackTrace(); } } return iErrorCode; } /**
/** * Move the ID field to the code field. * @return */ public int moveIDToCodeField() { if (this.getCodeField().isNull()) return getCodeField().moveFieldToThis((BaseField)this.getOwner().getCounterField()); else return DBConstants.NORMAL_RETURN; } }
/** * Constructor. * @param record My owner (usually passed as null, and set on addListener in setOwner()). */ public MoveIDToCodeHandler(int iCodeField) { this(); this.init(null, iCodeField); } /**
/** * Get the code field. * @return The code field (or the index field if not found) */ public BaseField getCodeField() { Record record = this.getOwner(); if (m_iCodeField != null) return record.getField(m_iCodeField); else return record.getKeyArea(record.getCodeKeyArea()).getField(DBConstants.MAIN_KEY_FIELD); } /**
this.addListener(new MoveIDToCodeHandler(Booking.CODE)); // If auto-booking numbers are turned on, set them return recBookingControl;
/** * Move the ID field to the code field. * @return */ public int moveIDToCodeField() { if (this.getCodeField().isNull()) return getCodeField().moveFieldToThis((BaseField)this.getOwner().getCounterField()); else return DBConstants.NORMAL_RETURN; } }
/** * Constructor. * @param record My owner (usually passed as null, and set on addListener in setOwner()). */ public MoveIDToCodeHandler(int iCodeField) { this(); this.init(null, iCodeField); } /**
/** * Constructor. * @param record My owner (usually passed as null, and set on addListener in setOwner()). */ public MoveIDToCodeHandler(Record record) { this(); this.init(record); } /**
/** * Constructor. * @param record My owner (usually passed as null, and set on addListener in setOwner()). */ public MoveIDToCodeHandler(String iCodeField) { this(); this.init(null, iCodeField); } /**
/** * Constructor. * @param record My owner (usually passed as null, and set on addListener in setOwner()). */ public MoveIDToCodeHandler(Record record) { this(); this.init(record); } /**