========================================== POT_PARTS: Std-Barc Part Numbers Database (Paradox) ========================================== char pntMfrPN A30 //*Manufacturer's Part Number(Key) char pntMfrCAGE A8 // Manufacturer's CAGE Code char pntItemNSN A22 // National Stock Number char pntItemName A30 // Description of Item char pntItemUOI A2 // Unit of Issue char pntPresMeth A3 // Preservation Method (MS2073) double pntUnitPrice N // Unit Price char pntPkgDate A10 // Date of Packaging char pntShelfCode A3 // Shelf Life Code char pntAddlInfo A34 // Additional Info Line char pntContract A25 // Standard Contract or P.O. Number char pntOrderNum A4 // DOD type supplemental, or BOA char pntWeight A6 // Weight // DVD Data char pntReqnNum A24 // Requistion Number char pntRIC A3 // Routing Identification Code char pntCondCode A1 // Condition Code char pntDistCode A2 // Distribution Code // Inventory Levels int pntQtyRFI S // On Hand, Ready for Issue int pntQtyIR S // Quantity In Repair int pntDelayed S // Quantity Promised for Delivery int pntInMfr S // Quantity Expected from Mfr'ing int pntDueIn S // Quantity Due in for Refurbishment boolean pntRecDeleted S // Record was deleted /*$pa*/ /*=================================================================*/ /*=================================================================*/ /*==== ====*/ /*==== ----- INTERNAL GLOBAL VARIABLES ----- ====*/ /*==== ====*/ /*=================================================================*/ /*=================================================================*/ PRIVATE boolean pdxInitialized=FALSE; // Paradox Engine initialized? PRIVATE int *curSMThandle = NULL; // ^to current database handle PRIVATE mpdxflds *curEFT_TDef = NULL; // ^to " " definition PRIVATE char *curEFT_DB = NULL; // ^to " " name PRIVATE char *curEFT_Temp = NULL; // ^to " " temp name PRIVATE char *curEFT_Path = NULL; // ^to " " DB path PRIVATE char poTablesPath [MAXPATH] =""; // location of ShipMan databases PRIVATE HGLOBAL hImageBuf = NULL; // Handle to archive record PRIVATE char *pImageBuf = NULL; // ^to archive record memory PRIVATE UINT nImageBuf; // size of the buffer PRIVATE boolean docInFile = FALSE; // Doc file was too large for DB storage PRIVATE char tempmsg[512]; // Buffer for error/log messages PRIVATE char *SysErrMsg = "System Error"; PRIVATE char *ImplErrMsg = "Implementation Error"; PRIVATE char *pnt_Names[] = // Note: These have to be in the same order { // as defined (in PO-PDX.H) "POT_UNDEFINED", "POT_PARTS" }; //======================================================================== //======= POT_PARTS: Part Numbers Database ============================= //======================================================================== PRIVATE char *pntPdx_fname = "PO-PARTS"; // name of the db table PRIVATE char *pntPdx_ftemp = "$$-PARTS"; // name of temporary table PRIVATE int pntTableHndl = 0; // Current DB handle PRIVATE mpdxflds pnt_tbldef [] = { {"*pntMfrPN", "A30", pntMfrPN, sizeof(pntMfrPN) }, { "pntMfrCAGE", "A8", pntMfrCAGE, sizeof(pntMfrCAGE) }, { "pntItemNSN", "A22", pntItemNSN, sizeof(pntItemNSN) }, { "pntItemName", "A30", pntItemName, sizeof(pntItemName) }, { "pntItemUOI", "A2", pntItemUOI, sizeof(pntItemUOI) }, { "pntPresMeth", "A3", pntPresMeth, sizeof(pntPresMeth) }, { "pntUnitPrice", "N", &pntUnitPrice }, { "pntPkgDate", "A10", pntPkgDate, sizeof(pntPkgDate) }, { "pntShelfCode", "A3", pntShelfCode, sizeof(pntShelfCode) }, { "pntAddlInfo", "A34", pntAddlInfo, sizeof(pntAddlInfo) }, { "pntContract", "A25", pntContract, sizeof(pntContract) }, { "pntOrderNum", "A4", pntOrderNum, sizeof(pntOrderNum) }, { "pntWeight", "A6", pntWeight, sizeof(pntWeight) }, { "pntReqnNum", "A24", pntReqnNum, sizeof(pntReqnNum) }, { "pntRIC", "A3", pntRIC, sizeof(pntRIC) }, { "pntCondCode", "A1", pntCondCode, sizeof(pntCondCode) }, { "pntDistCode", "A2", pntDistCode, sizeof(pntDistCode) }, { "pntQtyRFI", "S", &pntQtyRFI }, { "pntQtyIR", "S", &pntQtyIR }, { "pntDelayed", "S", &pntDelayed }, { "pntInMfr", "S", &pntInMfr }, { "pntDueIn", "S", &pntDueIn }, { "pntRecDeleted", "S", &pntRecDeleted }, { NULL, NULL, NULL, 0 } // ------------- End of table ------------- }; /*-----------------------------------------------------------------*/ /* */ /* ----- INTERNAL FUNCTION PROTOTYPES ----- */ /* */ /*-----------------------------------------------------------------*/ boolean lock_unlockTable ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Which table to add to(database ID) pdxLockOps lockType, // I: Locking type requested boolean isLock ); boolean openPdxTable ( HWND hWnd, // I: Parent Window POTtype poTable ); // I: Identifies type of text block boolean setSM_TblPtrs ( HWND hWnd, // I: Parent Window POTtype poTable ); // I: Identifies type of text block //---------- debugging -------------------- char *lockTypeName( pdxLockOps lockType ); /*$. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /*$he ^v3 ^t55 Function: ^v2 */ /*$sh [ Rev: ^s0 ] ^t55 Page: # */ /*$. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/ /*$V2 pnt_setTblPath $pa*/ /************************************************************************/ PUBLIC boolean pnt_setTblPath ( HWND hWnd, // I: The parent window handle char *tblPath, // I: Drive/Path location of database tables boolean chkNetCtrlPath) // I: Check Network File Ctrl Path? /*------------------------------------------------------------------------ pnt_setTblPath() sets the location for the database tables. This action takes effect the next time the tables are opened. Passing tblPath as a blank string or NULL indicates that the table is located in the application's working directory. Not calling the function at all has the same effect. The path should not exceed the MAXPATH constant in length. SIDE EFFECTS setSM_TblPtrs() is called, internal pointers are set. GLOBALS AFFECTED *curEFT_Path is written to. RETURNED TRUE if successful, FALSE if an error occurred. *************************************************************************/ { /* start of pnt_setTblPath() */ char netCtrlPath[MAXPATH]; char *errMsg1 = "\ NOTE: The Paradox Network Control File path for shared network databases \ should be set the same for all users of the database. One solution is to \ set it the same as the Database Path.\ \n\ \n PartsONL DB Path: %s\ \n Control File Path: %s\ \n\ \n Correct it?"; // The following method assumes one table location for all SM tables, another for FS tables /*------------------------- if ((poTable != EFT_ITEMS) /*--- && (poTable != EFT_FSX_IDX) - No longer doing FS-IDX---*/ ) { MessageBox( hWnd, "Unknown group ID", ImplErrMsg, MB_ICONSTOP ); return FALSE; } -------------------------*/ /***/ TL( "[pnt_setTblPath] tbl: %u", POT_PARTS ); if ( !setSM_TblPtrs( hWnd, POT_PARTS ) ) return FALSE; if ( is_blank(tblPath) ) { *curEFT_Path = '\0'; return TRUE; } if ( strlen(tblPath) > (MAXPATH - 13) ) { sprintf( tempmsg, "Table path too long [max: %u].", (MAXPATH - 13) ); MessageBox( hWnd, tempmsg, SysErrMsg, MB_ICONSTOP ); return FALSE; } stccpy( curEFT_Path, tblPath, MAXPATH ); // Ensure that the Network Control File is same location as the databases (because we know users have R/W access) if (chkNetCtrlPath) // Check Network File Ctrl Path? { //****/ TraceLine( "[pnt_setTblPath] Assuming (%s) '%s' for NET-CTRL-PATH", pnt_TableID_Name(poTable), curEFT_Path ); GetProfileString( "Paradox Engine", "NetNamePath", "", netCtrlPath, sizeof(netCtrlPath) ); //****/ TraceLine( "\t\t NetNamePath: '%s'", netCtrlPath ); if ( !strgs_equal( netCtrlPath, curEFT_Path ) ) { sprintf( tempmsg, errMsg1, curEFT_Path, netCtrlPath ); if ( MessageBox( hWnd, tempmsg, "Confirm", MB_OKCANCEL ) == IDCANCEL ) return FALSE; WriteProfileString( "Paradox Engine", "NetNamePath", curEFT_Path ); } } return TRUE; } /* end of pnt_setTblPath() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_closePdxTbl $pa*/ /************************************************************************/ PUBLIC boolean pnt_closePdxTbl ( HWND hWnd, // I: The parent window handle POTtype poTable ) // I: Which table to close /*------------------------------------------------------------------------ pnt_closePdxTbl() closes the indicated poTable, and disconnects its record (application data). SIDE EFFECTS curSMThandle is set, associated table is closed, *curSMThandle set NIL. GLOBALS AFFECTED None. RETURNED TRUE if successful, FALSE if an error occurred. *************************************************************************/ { /* start of pnt_closePdxTbl() */ if ( !pdxInitialized ) return TRUE; // nobody's open yet //*-*-*/ TraceLine( "\t\t[pnt_closePdxTbl] About to close %s", pnt_TableID_Name(poTable) ); if ( !setSM_TblPtrs(hWnd, poTable) ) return FALSE; if ( *curSMThandle == 0 ) // table is not currently open return TRUE; if ( !close_pdx_table( hWnd, *curSMThandle ) ) return FALSE; *curSMThandle= 0; // invalidate the handle curSMThandle = NULL; curEFT_TDef = NULL; curEFT_DB = NULL; curEFT_Path = NULL; curEFT_Temp = NULL; return TRUE; } /* end of pnt_closePdxTbl() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_closePdx $pa*/ /************************************************************************/ PUBLIC void pnt_closePdx ( HWND hWnd, // I: Parent Window boolean shutDownAlso ) // I: Shut down the engine also? /*------------------------------------------------------------------------ pnt_closePdx() closes all open paradox tables. If shutDownAlsom, then it shuts down the database engine also. IDE EFFECTS None, directly. GLOBALS AFFECTED pdxInitialized - is set to FALSE. RETURNED Nothing. *************************************************************************/ { /* start of pnt_closePdx() */ POTtype efTblIdx; if (!pdxInitialized) // Engine has already been shut down return; //----- Close all open tables ---------------- for (efTblIdx = POT_UNDEFINED + 1; efTblIdx < POT_LAST_TABLE_MARKER; efTblIdx++ ) pnt_closePdxTbl( hWnd, efTblIdx ); //----- Shut down the Paradox Engine --------- if ( !shutDownAlso ) return; //*-*-*/ MB( "[pnt_closePdx]\n\n Shutting down the Paradox Engine.", "ADVISORY" ); pdxInitialized = FALSE; (void) close_pdx_tool(hWnd); } /* end of pnt_closePdx() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_lockTable $pa*/ /************************************************************************/ PUBLIC boolean pnt_lockTable ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Which table to add to(database ID) pdxLockOps lockType ) // I: Locking type requested /*------------------------------------------------------------------------ pnt_lockTable() places the lock of type lockType on the indicated table, return an error message if unsuccessful. The () marks the (PDX-TOOL) internal flag to indicate the locking type. SIDE EFFECTS The specified table may be locked. GLOBALS AFFECTED table record's lock indicator may be set (if locking successful). RETURNED NULL on success. *************************************************************************/ { /* start of pnt_lockTable() */ /****/ TraceLine( "\t[pnt_lockTable] requesting a lock of type %s ...", lockTypeName(lockType) ); return lock_unlockTable( hWnd, poTable, lockType, TRUE ); } /* end of pnt_lockTable() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_unlockTable $pa*/ /************************************************************************/ PUBLIC boolean pnt_unlockTable ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Which table to add to(database ID) pdxLockOps lockType ) // I: Locking type requested /*------------------------------------------------------------------------ pnt_unlockTable() places the lock of type lockType on the indicated table, return an error message if unsuccessful. The () clears the (PDX-TOOL) internal flag indicating the locking type. No unlocking operation or error occurs if the internal flag was already clear. SIDE EFFECTS The specified table may be locked. GLOBALS AFFECTED table record's lock indicator will be cleated (if locking successful). RETURNED TRUE if successful. *************************************************************************/ { /* start of pnt_unlockTable() */ /****/ TraceLine( "\t[pnt_unlockTable] requesting unlock of type %s ...", lockTypeName(lockType) ); return lock_unlockTable( hWnd, poTable, lockType, FALSE ); } /* end of pnt_unlockTable() */ /*.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_addRecord $pa*/ /************************************************************************/ PUBLIC boolean pnt_addRecord ( HWND hWnd, // I: The parent window handle POTtype poTable, // I: Which table to add to(database ID) long *newRecNum ) // O: Record number of new item (optional) /*------------------------------------------------------------------------ pnt_addRecord() adds the indicated poTable record to the appropriate table. If the entry already exists, it is overwritten. *newRecNum receives the record number of the new record, if it is passed as a non-NULL pointer. SIDE EFFECTS poTable is accessed, entry added or overwritten. GLOBALS AFFECTED None. RETURNED TRUE if successful, FALSE if an error occurred. *************************************************************************/ { /* start of pnt_addRecord() */ int entrylen; boolean foundrec; mpdxflds *secondaryFld; long recordNum; if ( !openPdxTable(hWnd, poTable) ) return FALSE; // sprintf( tempmsg, "[pnt_addRecord] About to add, with prime key: '%s'", curEFT_TDef->app_buffer ); // MBT; // sprintf( tempmsg, "[pnt_addRecord] About to add to table: '%s' (%d)", curEFT_DB, poTable ); // MBT; loop { if ( pnt_lockTable( hWnd, poTable, pdxLOCK_WRITE ) ) break; if ( MessageBox( hWnd, "Time out occurred trying to update the database.\n\n Try again?", "Network Conflict", MB_OKCANCEL | MB_ICONEXCLAMATION ) == IDCANCEL ) return FALSE; } if ( !add_pdxitem ( NULL, *curSMThandle, &recordNum ) ) return FALSE; if ( newRecNum != NULL ) *newRecNum = recordNum; if ( !pnt_unlockTable( hWnd, poTable, pdxLOCK_WRITE ) ) MessageBox( hWnd, "Error trying to release table lock.", "Network Conflict", MB_ICONINFORMATION ); return TRUE; } /* end of pnt_addRecord() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_findRecord $pa*/ /************************************************************************/ PUBLIC boolean pnt_findRecord ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Kind of text block (database ID) boolean isPrimeSearch, // I: Search for Primary (or Secondary)? boolean *pdx_OK ) // O: Was the operation error free? (opt) /*------------------------------------------------------------------------ pnt_findRecord() locates the record in the poTable associated with either the primary and secondary keys (if applicable) stored in the application buffer associated with the table. If the function returns FALSE, the caller may check *pdx_OK to ensure that a database error did not occur (pdx_OK is option, can be passed as NULL). SIDE EFFECTS None. GLOBALS AFFECTED None. RETURNED TRUE if found. *************************************************************************/ { /* start of pnt_findRecord() */ /***/ void dumpDBFields( char *why ); // PO-LOOK.c int entrylen; boolean foundBlock, status; /*-------------------------------------------------------------------- /***/ TL( "[pnt_findRecord]..." ); /***/ if ( poTable == POT_PARTS ) /***/ { TL( "\t citContract: '%s'", citContract ); /***/ TL( "\t citOrder: '%s'", citOrder ); /***/ TL( "\t citCLIN: '%s'", citCLIN ); /***/ } --------------------------------------------------------------------*/ if ( !openPdxTable(hWnd, poTable) ) return FALSE; isPrimeSearch = TRUE; if (isPrimeSearch) { status = find_pdxitem ( hWnd, *curSMThandle, TRUE, &foundBlock ); } else { MessageBox( hWnd, "Secondary key searches not yet supported", "Implementation Error", MB_ICONSTOP ); return NULL; } //*-*-*/ genTextBuf[200] = '\0'; //*-*-*/ sprintf( tempmsg, "Block retreived:\n>>>%s<<<", (foundBlock) ? genTextBuf : "(NONE)" ); //*-*-*/ MessageBox( NULL, tempmsg, "[pnt_findRecord]", MB_OK ); if (pdx_OK != NULL) *pdx_OK = status; return (status && foundBlock); } /* end of pnt_findRecord() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_FindApproximate $pa*/ /************************************************************************/ PUBLIC boolean pnt_FindApproximate ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Database Table ID boolean *pdx_OK, // O: Was the operation error free? (opt) boolean *foundOne, // O: Was a record found? (opt) long *itemRecNum ) // O: Record number of found item (opt) /*------------------------------------------------------------------------ pnt_FindApproximate() locates the record in the poTable associated with either the primary keys. It differs from pnt_findRecord() in that it will find the first record with a key greater than or equal to those pre-loaded. This function is useful for locating the first record of a collection of composite keyed records. If the function returns FALSE, the caller may check *pdx_OK to ensure that a database error did not occur (pdx_OK is option, can be passed as NULL). SIDE EFFECTS None. GLOBALS AFFECTED None. RETURNED TRUE if found. *************************************************************************/ { /* start of pnt_FindApproximate() */ int entrylen; boolean foundBlock, status; if ( !openPdxTable(hWnd, poTable) ) return FALSE; status = find_pdx_approx ( hWnd, *curSMThandle, TRUE, &foundBlock, itemRecNum ); //****/ TL( "[pnt_FindApproximate] foundBlock: %s", BS(foundBlock) ); if (pdx_OK != NULL) *pdx_OK = status; if (foundOne != NULL) *foundOne = foundBlock; return (status && foundBlock); } /* end of pnt_FindApproximate() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_recordExists $pa*/ /************************************************************************/ PUBLIC boolean pnt_recordExists ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Kind of text block (database ID) boolean *pdx_OK ) // O: Was the operation error free? (opt) /*------------------------------------------------------------------------ pnt_recordExists() searches for the record in the poTable associated with either the primary key(s) stored in the application buffer associated with the table. No data is loaded. If the function returns FALSE, the caller may check *pdx_OK to ensure that a database error did not occur (pdx_OK is option, can be passed as NULL). SIDE EFFECTS None. GLOBALS AFFECTED None. RETURNED TRUE if found. *************************************************************************/ { /* start of pnt_recordExists() */ boolean foundBlock, status; if ( !openPdxTable(hWnd, poTable) ) return FALSE; status = find_pdxitem ( hWnd, *curSMThandle, FALSE, &foundBlock ); if (pdx_OK != NULL) *pdx_OK = status; return (status && foundBlock); } /* end of pnt_recordExists() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_nextRecord $pa*/ /************************************************************************/ PUBLIC boolean pnt_nextRecord ( HWND hWnd, // I: Parent Window boolean get_first, // I: Get the first (or next) POTtype poTable, // I: Kind of text block (database ID) boolean *pdx_OK, // O: Returns TRUE if no paradox error long *pdxIdxPtr ) // O: ^to return addr's database index (opt) /*------------------------------------------------------------------------ pnt_nextRecord() gets the next poTable database entry. If get_first is TRUE, the first entry in the database is returned. The database entry is returned in the application's associated buffers. Note that the contents of this record are affected by subsequent database operations. It should be copied or used used immediately. SIDE EFFECTS None. GLOBALS AFFECTED None. RETURNED TRUE if successful. *************************************************************************/ { /* start of pnt_nextRecord() */ boolean success, got_next; long dummyIndex; if ( !openPdxTable(hWnd, poTable) ) return FALSE; if ( !pdxIdxPtr ) // make it "optional" pdxIdxPtr = &dummyIndex; // sprintf( tempmsg, "[pnt_nextRecord] Post _open_ \n getfirst: %s", BOOL_STRG(get_first) ); // MB(tempmsg, "" ); success = getnext_pdxitem( hWnd, *curSMThandle, get_first, &got_next, pdxIdxPtr ); // sprintf( tempmsg, "[pnt_nextRecord] getnext_pdxitem(): Pdx-OK: %s, got_next: %s \n addrID: %s", // BOOL_STRG(success), BOOL_STRG(got_next), addrItem.addrID ); // MB(tempmsg, "" ); if (pdx_OK != NULL) *pdx_OK = success; return success; } /* end of pnt_nextRecord() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_getRecord$pa*/ /************************************************************************/ PUBLIC boolean pnt_getRecord ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Kind of text block (database ID) long pdxRecNumber, // I: record's database index number boolean *pdx_OK ) // O: Returns TRUE if no paradox error (opt) /*------------------------------------------------------------------------ pnt_getRecord() gets the poTable database entry corresponding to the pdxRecNumber passed. The database entry is returned in the application's associated buffers. Note that the contents of this record are affected by subsequent database operations. It should be copied or used used immediately. NOTE: This was revised for use with get_pdxitem(), allowing caller to sequence through records until the end is reached. SIDE EFFECTS None. GLOBALS AFFECTED None. RETURNED TRUE if successful in retrieving record, FALSE if error occurred, or if was out of range (beyond the end). *pdx_OK returns FALSE only if an error occurred. *************************************************************************/ { /* start of pnt_getRecord() */ boolean dbOk, gotRecord; if ( !openPdxTable(hWnd, poTable) ) return FALSE; gotRecord = get_pdxitem2( hWnd, *curSMThandle, pdxRecNumber, &dbOk ); if (pdx_OK != NULL) *pdx_OK = dbOk; return gotRecord; } /* end of pnt_getRecord() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_deleteRecord$pa*/ /************************************************************************/ PUBLIC boolean pnt_deleteRecord ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Kind of text block (database ID) boolean findRecord, // I: Do a pnt_findRecord() first? long pdxRecNumber, // I: record's database index num (opt) boolean *pdx_OK ) // O: Returns TRUE if no DB error (opt) /*------------------------------------------------------------------------ pnt_deleteRecord() deletes the poTable database entry indicated by the findRecord and pdxRecNumber parameters. If findRecord is TRUE, pnt_findRecord() is called to locate the record based on the key values pre-loaded by the caller into the application data record. If findRecord is FALSE, the function will delete record specified by the pdxRecNumber argument. If that is -1L, the () will delete the current record. WARNING: Unpredictable results may occur if the delete current mode is used on an unopen table!!! This operation should only be performed immediately after a ...find...() or ...next...(). NOTE: The delete by pdxRecNumber has not been tested yet. SIDE EFFECTS None. GLOBALS AFFECTED None. RETURNED TRUE if successful. *************************************************************************/ { /* start of pnt_deleteRecord() */ boolean pdx_wasOK, gotRecord; if ( !openPdxTable(hWnd, poTable) ) return FALSE; pdx_wasOK = TRUE; if (findRecord) { gotRecord = pnt_findRecord( hWnd, poTable, TRUE, &pdx_wasOK ); } else if ( pdxRecNumber != -1L ) gotRecord = get_pdxitem( hWnd, *curSMThandle, pdxRecNumber, &pdx_wasOK ); else gotRecord = TRUE; // use the current record if ( !pdx_wasOK ) gotRecord = FALSE; if ( gotRecord ) pdx_wasOK = delete_pdxitem( hWnd, *curSMThandle, FALSE ); else pdx_wasOK = FALSE; if (pdx_OK != NULL) *pdx_OK = pdx_wasOK; return pdx_wasOK; } /* end of pnt_deleteRecord() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_TestOpen $pa*/ /************************************************************************/ PUBLIC boolean pnt_TestOpen ( HWND hWnd, // I: The parent window handle POTtype poTable, // I: ID of table to test PXTerrs *efError ) // O: Error result (NOT opt) /*------------------------------------------------------------------------ pnt_TestOpen() attempts to open the table indicated. If the table is obsolete due to missing fields, the error will be reported to the caller (no message will appear to user). A message box will appear if the poTable ID is bad. *receives the type of error found, if any. SIDE EFFECTS poTable may opened. GLOBALS AFFECTED None. RETURNED TRUE if successful, FALSE if an error occurred. *************************************************************************/ { /* start of pnt_TestOpen() */ PXTerrs pdxError; int testSMThandle; if ( !pdxInitialized ) { if ( !init_pdx_tool( hWnd ) ) { MessageBox( hWnd, "ERROR Initializing Paradox", "System Error", MB_ICONSTOP ); return PXTERR_PDX_DEAD; } pdxInitialized = TRUE; } if ( !setSM_TblPtrs(hWnd, poTable) ) { *efError = PXTERR_BAD_APPL_ID; return FALSE; } //****/ TraceLine( "[pnt_TestOpen] curEFT_Path: %s ", curEFT_Path ); testSMThandle = test_pdxTable( hWnd, curEFT_TDef, curEFT_Path, curEFT_DB, &pdxError ); //****/ TraceLine( "[pnt_TestOpen] test_pdxTable(), table: %s, testSMThandle = %d, pdxError: %u", pnt_TableID_Name(poTable), testSMThandle, pdxError ); *efError = pdxError; if ( (pdxError == PXTERR_NO_SUCH_TBL) || (pdxError == PXTERR_TBL_LOCKED) || (pdxError == PXTERR_UNKNOWN) || (*efError == PXTERR_UNKNOWN) ) return FALSE; if ( pdxError == PXTERR_NO_ERROR ) { // (void) close_pdx_table( hWnd, testSMThandle ); *curSMThandle = testSMThandle; return TRUE; } if ( (pdxError == PXTERR_OLD_TBLVER) || (pdxError == PXTERR_BAD_FIELD) ) { *efError = PXTERR_OLD_TBLVER; *curSMThandle = testSMThandle; return TRUE; } return FALSE; } /* end of pnt_TestOpen() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_UpgradeTbl $pa*/ /************************************************************************/ PUBLIC boolean pnt_UpgradeTbl ( HWND hWnd, // I: The parent window handle POTtype poTable, // I: ID of table to test PXTerrs *efError, // O: Error result (opt) char **tempFName ) // O: Old table's file name (opt) /*------------------------------------------------------------------------ pnt_UpgradeTbl() attempts to open the table indicated. If the table is obsolete due to missing fields, an attempt will be made to upgrade it. A backup copy of the original table files is made, starting with "$$". SIDE EFFECTS None. GLOBALS AFFECTED None. RETURNED TRUE if successful, FALSE if an error occurred. *************************************************************************/ { /* start of pnt_UpgradeTbl() */ PXTerrs pdxError; boolean status; //***/ TraceLine( "[pnt_UpgradeTbl] ... " ); if ( !pdxInitialized ) { if ( !init_pdx_tool( hWnd ) ) { MessageBox( hWnd, "ERROR Initializing Paradox", "System Error", MB_ICONSTOP ); return PXTERR_PDX_DEAD; } pdxInitialized = TRUE; } if ( !setSM_TblPtrs(hWnd, poTable) ) { if (efError != NULL) *efError = PXTERR_BAD_APPL_ID; return FALSE; } status = upgrade_pdxTable( hWnd, curEFT_TDef, curEFT_Path, curEFT_DB, curEFT_Temp, &pdxError ); if (efError != NULL) *efError = pdxError; if (tempFName != NULL ) *tempFName = curEFT_Temp; return status; } /* end of pnt_UpgradeTbl() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_showOpenTables $pa*/ /************************************************************************/ PUBLIC boolean pnt_showOpenTables ( void ) /*------------------------------------------------------------------------ pnt_showOpenTables() dumps a list of the currently open tables to TraceLine(). IDE EFFECTS None. GLOBALS AFFECTED The SM Table handles are used. RETURNED TRUE if any tables were open. *************************************************************************/ { /* start of pnt_showOpenTables() */ POTtype efTblIdx; boolean anyOpen; // TraceLine( "\n\t\t[pnt_showOpenTablesTbl] Currently Open Tables:" ); if (!pdxInitialized) // Engine has already been shut down return FALSE; //----- Show all open tables ---------------- anyOpen = FALSE; for (efTblIdx = POT_UNDEFINED + 1; efTblIdx < POT_LAST_TABLE_MARKER; efTblIdx++ ) { if ( !setSM_TblPtrs(NULL, efTblIdx) ) continue; if ( *curSMThandle == 0 ) // table is not currently open continue; // TraceLine( "\t\t\t %s", pnt_TableID_Name(efTblIdx) ); anyOpen = TRUE; } return anyOpen; } /* end of pnt_showOpenTables() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 openPdxTable $pa*/ /************************************************************************/ PRIVATE boolean openPdxTable ( HWND hWnd, // I: Parent Window POTtype poTable ) // I: Identifies type of text block /*------------------------------------------------------------------------ openPdxTable() creates the application table descriptor and opens/ creates the file index database file(s). The actual database accessed is dependent on the poTable. This function is called at the top of every TextBlock() in this module to ensure that the table is indeed open, and that the curSMThandle is addressing the correct TextBlock database. PDX-TOOL:init_pdx_tool() is called to initialize the Paradox engine the first time through. Call fed_close_pdx() to close the open tables and shut down the Paradox engine. SIDE EFFECTS None, directly. GLOBALS AFFECTED pdxInitialized - is referenced, set to TRUE after init'ing the Engine. curSMThandle - ^to the Pdx-Tool handle for current text block table is set RETURNED TRUE if successful. *************************************************************************/ { /* start of openPdxTable() */ if ( !pdxInitialized ) { set_pdx_tool_limits( hWnd, 9 ); if ( !init_pdx_tool( hWnd ) ) { MessageBox( hWnd, "ERROR Initializing Paradox", "System Error", MB_ICONSTOP ); return 999; } pdxInitialized = TRUE; } curSMThandle = NULL; curEFT_TDef = NULL; curEFT_DB = NULL; curEFT_Path = NULL; curEFT_Temp = NULL; if ( !setSM_TblPtrs( hWnd, poTable ) ) return FALSE; if (*curSMThandle != 0) // already open return TRUE; #ifdef MIGHT_USE_LATER //================================================ if (poTable == EFT_DOCUMENTS) if ( !allocDocImage( hWnd ) ) // Allocates and locks the doc pImageBuf { return FALSE; } #endif //======== MIGHT_USE_LATER ======================================== *curSMThandle = open_pdx_table( hWnd, curEFT_TDef, curEFT_DB, curEFT_Path ); //***/ TL( "[openPdxTable] returned from open_pdx_table, handle = %d", *curSMThandle ); if ( *curSMThandle == 0 ) return FALSE; //***/ TL( "[openPdxTable] Idx table opened, handle = %d", *curSMThandle ); return TRUE; } /* end of openPdxTable() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 setSM_TblPtrs $pa*/ /************************************************************************/ PRIVATE boolean setSM_TblPtrs ( HWND hWnd, // I: Parent Window POTtype poTable ) // I: Identifies type of text block /*------------------------------------------------------------------------ setSM_TblPtrs() sets the pointers for the application table descriptors curSMThandle, curEFT_TDef and curEFT_DB, based on the poTable identifier. SIDE EFFECTS None. GLOBALS AFFECTED See above. RETURNED TRUE if successful. *************************************************************************/ { /* start of setSM_TblPtrs() */ curSMThandle = NULL; curEFT_TDef = NULL; curEFT_DB = NULL; curEFT_Path = NULL; curEFT_Temp = NULL; switch (poTable) { case POT_PARTS: curSMThandle = &pntTableHndl; curEFT_TDef = &pnt_tbldef[0]; curEFT_DB = pntPdx_fname; curEFT_Path = poTablesPath; curEFT_Temp = pntPdx_ftemp; break; default: sprintf( tempmsg, "Invalid poTable ID: %d", poTable ); MessageBox( hWnd, tempmsg, "[setSM_TblPtrs]", MB_ICONSTOP ); return FALSE; } /* switch */ //****/ TraceLine( "[setSM_TblPtrs] fsxPdx_fname: '%s', curEFT_Path: '%s'", fsxPdx_fname, curEFT_Path ); return TRUE; } /* end of setSM_TblPtrs() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_TableID_Name $pa*/ /************************************************************************/ PUBLIC char *pnt_TableID_Name ( POTtype poTable ) // I: Identifies type of text block /*------------------------------------------------------------------------ pnt_TableID_Name() returns the database table identifier (in human- readable format) for the poTable. SIDE EFFECTS None. GLOBALS AFFECTED None. RETURNED See above. *************************************************************************/ { /* start of pnt_TableID_Name() */ if ( (poTable >= POT_UNDEFINED) && (poTable < POT_LAST_TABLE_MARKER ) ) return pnt_Names[poTable]; return NULL; } /* end of pnt_TableID_Name() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$v2 Miscellany $pa*/ PRIVATE boolean lock_unlockTable ( HWND hWnd, // I: Parent Window POTtype poTable, // I: Which table to add to(database ID) pdxLockOps lockType, // I: Locking type requested boolean isLock ) { char *lockResult; if ( !openPdxTable(hWnd, poTable) ) return FALSE; if (isLock) lockResult = lock_pdxTable( hWnd, *curSMThandle, lockType ); else lockResult = unlock_pdxTable( hWnd, *curSMThandle, lockType ); /****/ TraceLine( "\t[lock_unlockTable] back from (un)lock_pdxTable ..." ); /****/ TraceLine( "\t[lock_unlockTable] %s() result: %s", ((isLock) ? "lock_pdxTable" : "unlock_pdxTable"), lockResult ); if (lockResult != NULL) MessageBox( hWnd, lockResult, pnt_TableID_Name(poTable), MB_ICONINFORMATION ); if (isLock && (lockResult != NULL) ) { /***/ TraceLine( "-----------------------------------------------------------------" ); /***/ TraceLine( ">>>> Table was locked, we should ask if the user wants to retry. " ); /***/ TraceLine( "-----------------------------------------------------------------" ); } return (lockResult == NULL); } /*.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$V2 pnt_ClearDBRec $pa*/ /************************************************************************/ PUBLIC boolean pnt_ClearDBRec ( POTtype poTable, // I: DB Record to clear boolean clearKeys, // I: Clear the key values? boolean clearData ) // I: Clear the data values? /*------------------------------------------------------------------------ pnt_ClearDBRec() clears the public record buffers of the poTable specified. SIDE EFFECTS None. GLOBALS AFFECTED The public database record variables RETURNED Nothing. *************************************************************************/ { /* start of pnt_ClearDBRec() */ mpdxflds *fldRecPtr; UINT fieldSize; boolean status; char alphaType[7], typeChar; //***/ TL( "[pnt_ClearDBRec] {%u}: %s", poTable, pnt_TableID_Name( poTable ) ); // if ( !openPdxTable( NULL, poTable) ) if ( !setSM_TblPtrs( NULL, poTable) ) return FALSE; //***/ TL( "[pnt_ClearDBRec]: %s (@ %s", curEFT_DB, curEFT_Path ); status = TRUE; fldRecPtr = curEFT_TDef; for ( fldRecPtr = curEFT_TDef; fldRecPtr->pdx_name; fldRecPtr++ ) { //***/ TL( "\t %-12s %-6s %4u ", fldRecPtr->pdx_name, fldRecPtr->pdx_type, fldRecPtr-> app_bufsize ); if ( fldRecPtr->pdx_name[0] == '*' ) { if ( !clearKeys ) continue; } else if ( !clearData ) continue; fieldSize = fldRecPtr-> app_bufsize; if ( !fieldSize ) { TL( " **** Could not clear %s:%s field (size: %u)", curEFT_DB, fldRecPtr->pdx_name, fieldSize ); status = FALSE; continue; } typeChar = fldRecPtr->pdx_type[0]; // if ( (typeChar == 'A') || (typeChar == 'M') ) if ( (typeChar == 'A') ) { sprintf( alphaType, "%c%u", typeChar, (fldRecPtr-> app_bufsize - 1) ); if ( !strgs_equal( alphaType, fldRecPtr->pdx_type ) ) { TL( " **** %s:%s field size (%u) error. Type: '%s' Expecting: '%s'", curEFT_DB, fldRecPtr->pdx_name, fieldSize, fldRecPtr->pdx_type, alphaType ); status = FALSE; continue; } } memset( fldRecPtr->app_buffer, 0, fieldSize ); } // -------- Transitionary Legacy method .... #ifdef MIGHT_USE_LATER //================================================ if ( poTable >= EFT_ITEMS ) switch (poTable) { case EFT_DOCUMENTS: docFileName [0] = '\0'; docConNum [0] = '\0'; docOrdNum [0] = '\0'; docSeqNum [0] = '\0'; docShipForm [0] = '\0'; docStatus = 0; break; // ----------- End of Transitionary ----------------------------------------------------- default: sprintf( tempmsg, "pnt_ClearDBRec(%s) not supported", pnt_TableID_Name( poTable ) ); MessageBox( NULL, tempmsg, ImplErrMsg, MB_ICONSTOP ); return FALSE; } #endif //======== MIGHT_USE_LATER ======================================== return status; } /* end of pnt_ClearDBRec() */ /*$.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ PRIVATE char *lockTypeName( pdxLockOps lockType ) { char *lockName; if (lockType == pdxLOCK_FULL) lockName = "Full-Lock"; else if (lockType == pdxLOCK_WRITE) lockName = "Write-Lock"; else if (lockType == pdxLOCK_PREVENT_FULL) lockName = "Prevent-Full"; else if (lockType == pdxLOCK_PREVENT_WRITE) lockName = "Prevent-Write"; else lockName = "Unknown"; return lockName; } /*.- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -.*/ /*$v2 Miscellany $pa*/