    21  

    -   

         ,   - 
      /.    
,    -  .   
          
 ,     ()  .    
,        ,  
         
,        ,  
 -,        
,   . 
           
   -  /  
  .       ,     
       ,   , 
   -,     
 . 
      ,    ,   -  
   .       
       
-,    .  
            
.       
     -,   
  .     ,  
/        -,   
 . 
           , 
       -.   
  -    "  "   
        
      . ,   Sybase 
         
,             
,      .   
 -        , 
        
     .    -  , 
     (Jerry Garcia): "    
,     ". 
            
   .   - 
 ,  - .   ,  , 
  Delphi,     ""    
 ""          
.        
     .     
  .    - 
     ,   ,   
     . 
           ,    .   
 , ,    -,  
   /,   .     
 ,    :    
    -,     
       ,  , 
 ,   .  ,      

    424     IV.    


 Paradox     /.  ,  
   ,     
   . 
         -  .  
   ,     
  -   .  ,  
      -   
Delphi:   ,  ,  TField   
TDataSet.       ,    
     . 

     - 

    -   :   .   
   . , , ,  
     ,     
  ..          . 
             . 
   .       
     . 
        -      
.    ,   .  "" - 
         .   
    ,      . 
          
.      - 
.   ,     ,   
    . 
    Delphi      -,  
 ,       
       
.           . 
       - 
       -      
.    ,      
   .      
,   ,     , 
     . 

       

       -    :  
   . 
      VCL Delphi      
,     . , , 
    ,      
  ,          
  Boolean.        ; 
Delphi   .       
  . 
    -     .  
   ,   .   
 ,    .     
  ,      .  
   ,        
    . 
      ,      
    -,   
,   .   
   ,   Object Pascal, 
         .  
Sybase SQL Server  Microsof SQL Server, ,   
  (identity columns)   ,  
     .    
 ,       
    -  " Y  X 
 "      . 

     21. -  	425 

 ,       
       
.           . 

       - 

       -      
.    ,      
   .      
,   ,     , 
     . 

       

       -    :  
   . 
      VCL Delphi      
,     . , , 
    ,      
  ,          
  Boolean.        ; 
Delphi   .       
  . 
    -     .  
   ,   .   
 ,    .     
  ,      .  
   ,        
    . 
      ,      
    -,   
,   .   
   ,   Object Pascal, 
         .  
Sybase SQL Server  Microsof SQL Server, ,   
  (identity columns)   ,  
     .    
 ,       
    -  " Y  X 
 "      . 

     21. -  	425 

       

       -   : 
      Delphi,      . 
            
   .  ,  DBEdit, TEdit 
 TMaskEdit,   ,    ,  
  .       
 . 
    ,    DBEdit    Boolean.    
     True  False.    
,    .   DBEdit    
,       .  
 DBText.        
    Readonly . DBEdit  
     ,   ^    
  .      
 DBRadioGroup.  . 21.1.    
    . 

     21.1.         VCL 

           				 

         	    				DBCheckBox,   DBRadioGroup,   DBComboBox,   DBListBox
         	    				DBEdit,   Calendar,   SpinEdit,   DataTimePicker
     (  )  DBEdit,   SpinEdit
     (  )DBRadioGroup
     (  ) 	DBEdit
     (  ) 	DBComboBox,   DBListBox

        ,     , 
   TControldass  Database Explorer.   
    -    
TField   . 
        ,   ,   
     ,     
  . 

     

       -     
 (custom component layer).  Delphi,   
,        
 .    -   
.      -  
DataSet,      -. 
     ,            
       .   
    -,   Delphi 1.0. 
          - 
 Delphi,       
 .  ,     
   Delphi,  ,      
(  Borland C++ Builder),    , 
    TDataSet. 
            ,      
-   :       
 , -    -  
  ,       
   . 

    426 IV.    

     TFieid  - 

       -      
 TFieid.    -   
 ,      ,    
 TFieid        -. , 
, ,    TFieid,   , 
  ,   .     
-.          
,   ,     
       . 
  -      . 
         -   
   TFieid. -,    
 Delphi     TFieid   . 
-,       
-"rax~DataSet .         
  ;roitTField   (Attribute Set),    
  TFieid        
  (Data Dictionary).   TFieid   Data 
Dictionary    ,      
DataSet. To,         , 
     DataSet.     
        . 

       

           Delphi    
. ,    ,     
 ,   ,     
 .         
    -   .  
         . 
    1.       Dictionary  Database Explorer   
 Databases. 
    2.            . 
        ,   
 Dictionary* New,    ,   DBDEMOS,  
    Delphi. 
    3.      Dictionary   Import from Database. 
    4.        Import Database  
     BDE     . 
              
    .     
     .   
    (   
)   Delphi.  ,     
 ,     CHECK,    
     Delphi,     . 
 ,   ,    
  ,       
  . 

        

          ,   
       .    
      . 
    1.      Dictionary       
Attribute Sets        New. 
    2.	    . 
    3.	    TFieid. 
    4.	   ,    Apply  
 Database Explorer. 

     21. -  	427 

    5.      Dictionary   Database    
 ,       . 
    6.      Definition   Attribute Set    
   . 
    7.    ,    Apply   
Database Explorer. 
      ,     TField. 
  Delphi       
-   TField.      
      DataSet    
 -   Delphi,   
 .        
-      ,  
        . 

     -   TField 

      TField        
Delphi,       TField.    
    DataSet   Add fields,  
Delphi   TField  .    TField 
   ,    ,   
 Object Inspector. 
      -   TField,   . 
    1.        DataSet (TTable, TQuery  
TStoredProc),      . 
    2.       TField    <Ctrl+A>. 
    3.           Object Inspector 
    . Required 
        TField,      Object 
Inspector,   Required.  ,    
 .       
 , ,  ,       
  NOT NULL  .      
, Delphi ,      .  
,    Required   True.    
 ,     .  ,  
   .   Required  False 
       ,    
 - .       . 

      

             
         
  .  Delphi     
  ,   ,   
  ..        
,      - . 
       ,     . 
    1.          . 
    2.          OnCalcFields 
   DataSet. 
         . 
    1.     ,     DataSet. 
    2.              
    New field. 
    3.       New Field     , 
        Calculated   Field type. 
    1 

    428 IV.    

    4.     ,    . 
    5.      ,     Object Inspector 
   .  ,   Calculated  
 True. 
    6.   ,   ,      
  OnCalcFields. : 

    taORDERSOrderDateTime.Value   := Now; 

         taORDERSOrderDateTime  
  Now,     . 
         -  ,  
     . ,   
     ,   
,         
.    OnCalcFields     , 
   .     
.   ,        
^      . 

    OnValidate 

    -  TField        
 OnValidate.    TField    
OnValidate,        
.           
  ,      .  
       
.      ,     
       .     
       
,   Delphi. 

    OnExit 

    ,      -  
 OnExit  ,  DBEdit.    OnExit 
  ,        
     .     
   (,  ,      
  ),      , 
        . 

       - 

       -   DataSet.  
     DataSet (  
  Table, Query  StoredProc),   
.  OnNewRecord, BeforeDelete  BeforePost.   
    ,      
INSERT, DELETE  UPDATE. 

    OnNewRecord 

     OnNewRecord         
.         
 .      
     PetDeposit  LawnService 
 LEASE. 

    procedure TForml.taLEASENewRecord(DataSet: TDataSet); begin 
    taLEASEPetDeposit.Value:=0; 
    taLEASELawnService.Value:=True; end; 

     21. -  	429 

    BeforeDelete 

         .    
       . ,  
  ,       .  
       .  
      . 
    ,    
 LEASE  PROPERTY. 

    taLEASE.IndexName:='Property_Number'; 
    If  taLEASE.FindKeyf[taPROPERTYProperty_Number.Aslnteger])   then 
    raise  EDatabaseError.Create('Property_Number   is   in  use   -   delete  
 failed1); 

           PROPERTY,   
   LEASE. 

    BeforePost 

     BeforePost      .  
            
.         
      .   
 , ,   LeaseEndDate  
   LeaseBeginDate. 

    procedure  TForml.taLEASEBeforePost (DataSet:   TDataSet); begin 
    If   (taLEASELeaseBeginDate.AsDateTime   >   
taLEASELeaseEndDate.AsDateTime)   then 
    raise  EDatabaseError.Create('Lease  ending data must  come  after  its  
beginning  date'); end; 

         DataSet,     
 -  .      
. 21.2. 

     21.2.    DataSet,   
 -   

          	  

    AfterCancel	    
    Afterdose	    
    AfterDelete	   
    AfterEdit	   
    Afterlnsert	     
    AfterOpen	    
    AfterPost	   
    BeforeCancel	    
    BeforeClose	    
    BeforeEdit	   
    Beforelnsert	     
    BeforeOpen	    
    OnCalcFields	     
    OnDeleteError	      
    OnEditError	      
    OnFilterRecor	   (    ( 

    430 IV.    

     

              - 
  Delphi:   ,  ,  
TField   TDataSet.       
.          
       . 
,     TField,     
DataSet   .   -  
 :     ,    
. ,    ,    
 ,     .   
    -  ,   
        . 

     ... 

           Delphi  
    .     
  MIDAS (Multi-tier Distributed Applications Services Suite 
      ),   
     /    
 . 

     21. -  	431