home *** CD-ROM | disk | FTP | other *** search
/ C Programming Starter Kit 2.0 / SamsPublishing-CProgrammingStarterKit-v2.0-Win31.iso / bde / inventry.pak / INV_DATA.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-24  |  6.5 KB  |  137 lines

  1. // BDE - (C) Copyright 1994 by Borland International
  2.  
  3. #include "inventry.h"
  4.  
  5. // Global data
  6. HINSTANCE       hInst;
  7. HWND            hMainWnd;
  8. HWND            hErrorWnd;
  9. BOOL            NewRecMode = FALSE;
  10. BOOL            RangeSet = FALSE;
  11. WNDPROC         _wpOrigWndProc;
  12. char            szNoneOnOrder[] = "None on Order";
  13. char  far       szTblDirectory[DBIMAXPATHLEN+1];
  14. char  far       szPrivDirectory[DBIMAXPATHLEN+1];
  15.  
  16. const char far  szTblName[] = "Inventry" ;
  17. const char far  szTblType[] = szPARADOX;
  18.  
  19. // Fields for the table
  20. FLDDesc     fldDesc[]  = {
  21.                             {
  22.                                 1,            // Field Number
  23.                                 "Item_ID",    // Field Name
  24.                                 fldINT16,     // Field Type
  25.                                 fldUNKNOWN,   // Field Subype
  26.                                 1,            // Field Size
  27.                                 0,            // Decimal places
  28.                                 0,            // Offset in record
  29.                                 0,            // Length in Bytes
  30.                                 0,            // For Null Bits
  31.                                 fldvHASCHECKS,// Validiy checks
  32.                                 fldrREADWRITE // Rights
  33.                              }, {
  34.                                 2, "Building", fldZSTRING, fldUNKNOWN,
  35.                                 FLDLENGTH, 0, 0, 0, 0,
  36.                                 fldvNOCHECKS, fldrREADWRITE
  37.                              }, {
  38.                                 3, "Item", fldZSTRING, fldUNKNOWN,
  39.                                 FLDLENGTH, 0, 0, 0, 0,
  40.                                 fldvNOCHECKS, fldrREADWRITE
  41.                              }, {
  42.                                 4, "In Stock", fldFLOAT, fldUNKNOWN,
  43.                                 0, 0, 0, 0, 0,
  44.                                 fldvNOCHECKS, fldrREADWRITE
  45.                              }, {
  46.                                 5, "Cost", fldFLOAT, fldstMONEY,
  47.                                 0, 0, 0, 0, 0,
  48.                                 fldvNOCHECKS, fldrREADWRITE
  49.                              }, {
  50.                                  6, "Date Ordered", fldDATE, fldUNKNOWN,
  51.                                  0, 0, 0, 0, 0,
  52.                                  fldvNOCHECKS, fldrREADWRITE
  53.                              }, {
  54.                                  7, "Comment", fldBLOB, fldstMEMO,
  55.                                  20, 0, 0, 0, 0,
  56.                                  fldvNOCHECKS, fldrREADWRITE
  57.                              }
  58.                          };  // Array of field descriptors
  59.  
  60. // Validity Check Descriptor - Describes the validity checks.  This index
  61. // is going to be added to the table when the table is created.
  62. // Note: Beacuse the max value is saved in a string while our example fields
  63. // are numbers - we need to save the values as the ascii value of our
  64. // string.  In other words the value 3000 needs to fit into the first two
  65. // bytes of the string (as it is an INT16).
  66. // To do this we need to use a function called movemem() (you could do it
  67. // other ways but this is a nice looking workaround).  Therefore, we will
  68. // set the values in the structure as a string and convert it before using
  69. // it in a function.
  70. VCHKDesc VchkDesc[] = {
  71.             { // First field validity check - Required field.
  72.                 1,          // Field number, this belongs to
  73.                 TRUE,       // Is a required field
  74.                 TRUE,       // If True, has min value
  75.                 TRUE,       // If True, has max value
  76.                 FALSE,      // If True, has default value
  77.                 { "0" },    // Min Value
  78.                 { "32767" },// Max Value
  79.                 { NULL },   // Default value
  80.                 { NULL },   // Picture string
  81.                 lkupNONE,   // Lookup/Fill type
  82.                 { NULL },   // Lookup Table name
  83.             }
  84.         };
  85.  
  86. // Indexes used by the table
  87. IDXDesc idxDesc[] = {
  88.                         {
  89.                             "Item ID",    // Name
  90.                             1,            // Number
  91.                             { NULL },     // Tag Name ( for dBase only)
  92.                             { NULL },     // Optional Format
  93.                             TRUE,         // Primary?
  94.                             TRUE,         // Unique?
  95.                             FALSE,        // Descending?
  96.                             TRUE,         // Maintained?
  97.                             FALSE,        // SubSet?
  98.                             FALSE,        // Expression index?
  99.                             NULL,         // for QBE only
  100.                             2,            // Fields in key
  101.                             1,            // Length in bytes
  102.                             FALSE,        // Index out of date?
  103.                             0,            // Key Type of Expression
  104.                             { 1, 2 },     // Array of field numbers
  105.                             { 0 },        // Key expression
  106.                             { 0 },        // Key Condition
  107.                             FALSE,        // Case insensitive
  108.                             0,            // Block size in bytes
  109.                             0             // Restructure number
  110.                         },
  111.                         {
  112.                             "In Stock", 2, { NULL }, { NULL }, FALSE, FALSE,
  113.                             FALSE, TRUE, FALSE, FALSE, NULL, 2, 1, FALSE, 0,
  114.                             { 4, 1 }, { 0 }, { 0 }, TRUE, 0, 0
  115.                         },
  116.                         {
  117.                             "Item", 3, { NULL }, { NULL }, FALSE, FALSE,
  118.                             FALSE, TRUE, FALSE, FALSE, NULL, 1,  1, FALSE,
  119.                             0, { 3 }, { 0 }, { 0 }, FALSE, 0, 0 }
  120.                         };
  121.  
  122.                         // This is the array of index descrpitions used for the Index listbox
  123. const pCHAR IndexList[] = {"Item ID - Primary Index", "In Stock - In stock"
  124.                            " and ItemId", "Item - Item Name"};
  125.  
  126. const unsigned uNumFields = sizeof( fldDesc ) / sizeof ( fldDesc[0] ) ;
  127.  
  128. // Number of indexes to be created when the table is created - note
  129. //   that idxDesc is defined globally.
  130. const unsigned uNumIndexes = sizeof(idxDesc) / sizeof(idxDesc[0]);
  131.  
  132. // The number of validity checks.
  133. const UINT16 uNumVchks = sizeof(VchkDesc) / sizeof(VchkDesc[0]);
  134.  
  135. const UINT16 uNumRecs = 5;       // Number of records to insert
  136.  
  137.