//DDB-FileStart //DDB-HeaderStart // File Name : CODEMAST.DD // Class Name: Codemast_DataDictionary // Revision : 3 // Version : 2 Use Windows // Basic Definitions Use DataDict.pkg // DataDictionary Class Definition Use DDvalTbl // Validation Table Class Definitions #Include CodeMast.FD // Two more fields have been added... Open Codemast Open Codetype Open Master //DDB-HeaderEnd // The DD files for codetype and codemnt must be manually // maintained. The DD reader in dbBldr expects these two // files to be available as utility files and so they are // already open. In addition, we must open these with // "open as" and not open. //DDB-FileStart class Codemast_DataDictionary Is A DataDictionary Procedure Construct_Object Property String psOldCode "" Forward Send Construct_Object End_Procedure // Construct_Object // This is triggered _before_ the global table record buffer is updated by the DDO logic. Procedure Backout String sOldCode Move CodeMast.Code to sOldCode Set psOldCode to sOldCode End_Procedure // Backout procedure Define_Fields Forward Send Define_Fields //DDB-Generated-Code-Location //DDB-DefineFieldStart Set Main_File To Codemast.File_Number // Parent (Server) file structure............... Send Add_Server_File Codetype.File_Number // Field-based properties....................... // Codemast.Type // Codemast.Code Set Status_Help Field Codemast.Code To "Actual database code value for this type/category." // Codemast.Description Set Status_Help Field Codemast.Description To "Description of the database code value." //DDB-DefineFieldEnd end_procedure // Disallow blank codes and edit of codes if Master table records exist that // uses that code. Function Validate_Save Returns Integer Integer iRecnum String sOldCode sNewCode Boolean bExist bVerboseState If (CodeMast.Code = '') Begin Error 300 'Blank ID values is not allowed.' End Get psOldCode to sOldCode Move (Trim(CodeMast.Code)) to sNewCode Move False to bExist // Has the code value been edited for the Master.type? If (sNewCode <> sOldCode) Begin Move Master.Recnum to iRecnum Clear Master Move sOldCode to Master.Subject Find Ge Master.Subject If (Found) Move (Trim(Master.Subject) = sOldCode) to bExist // Reset the Master table's global record buffer. Clear Master Move iRecnum To Master.Recnum Find Eq Master by Recnum Get Verbose_State of Error_Object_Id to bVerboseState Set Verbose_State of Error_Object_Id to False If (bExist = True) Error 300 "It is not allowed to change a Subject ID while there are questions using it. Change or remove the questions first." Set Verbose_State of Error_Object_Id to bVerboseState End // If (sNewCode <> sOldCode) Begin // Has the code value been edited for the Master.level? If (sNewCode <> sOldCode) Begin Move Master.Recnum to iRecnum Clear Master Move sOldCode to Master.Level Find Ge Master.Level If (Found) Move (Trim(Master.Level) = sOldCode) to bExist // Reset the Master table's global record buffer. Clear Master Move iRecnum To Master.Recnum Find Eq Master by Recnum Get Verbose_State of Error_Object_Id to bVerboseState Set Verbose_State of Error_Object_Id to False If (bExist = True) Error 300 "It is not allowed to change a Level ID while there are quesions using it. Change or remove the questions first." Set Verbose_State of Error_Object_Id to bVerboseState End // If (sNewCode <> sOldCode) Begin End_Function // Validate_Save // To check that there are no Master table records that has been saved // with the selected CodeMast.Code value. Function Validate_Delete Returns Integer String sType sLevel Boolean bOk bVerboseState Move (Trim(CodeMast.Code)) to sType Move (Trim(CodeMast.Code)) to sLevel Get IsTypeInMaster sType to bOk // Helper function below. If (bOk = False) Begin Get Verbose_State of Error_Object_Id to bVerboseState Set Verbose_State of Error_Object_Id to False Error 300 "It is not allowed to remove a Subject when there are questions using it. Change the Subject for these questions or remove them." Set Verbose_State of Error_Object_Id to bVerboseState End Get IsLevelInMaster sLevel to bOk // Helper function below. If (bOk = False) Begin Get Verbose_State of Error_Object_Id to bVerboseState Set Verbose_State of Error_Object_Id to False Error 300 "It is not allowed to remove a Level when there are questions using it. Change the Level for these questions or remove them." Set Verbose_State of Error_Object_Id to bVerboseState End End_Function // Validate_Delete // Helper function to Request_Delete above. // Takes a CodeMast.Code value as an argument and checks if there are any // Master.Type records with that value. If there is; returns false. Function IsTypeInMaster String sType Returns Boolean String sMasterType Integer iRecnum Boolean bOk Move Master.Recnum to iRecnum Clear Master Move sType to Master.Subject Find Ge Master.Subject If (Found) Move (Trim(Master.Subject)) to sMasterType // Reset the Master record buffer after the find. Clear Master Move iRecnum to Master.Recnum Find Eq Master by Recnum Function_Return (not(sMasterType = sType)) End_Function // IsTypeInMaster // Helper function to Request_Delete above. // Takes a CodeMast.Code value as an argument and checks if there are any // Master.Level records with that value. If there is; returns false. Function IsLevelInMaster String sLevel Returns Boolean String sMasterLevel Integer iRecnum Boolean bOk Move Master.Recnum to iRecnum Clear Master Move sLevel to Master.Level Find Ge Master.Level Move (Trim(Master.Level)) to sMasterLevel // Reset the Master record buffer after the find. Clear Master Move iRecnum to Master.Recnum Find Eq Master by Recnum Function_Return (not(sMasterLevel = sLevel)) End_Function // IsLevelnMaster // Field_Defaults: // This procedure is used to establish default field values. procedure Field_Defaults Forward Send Field_Defaults //DDB-Generated-Code-Location //DDB-FieldDefaultStart //DDB-FieldDefaultEnd end_procedure // Field_Defaults end_class // Codemast_DataDictionary //DDB-FileEnd