VERSION 5.00
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Begin VB.Form frmAdoFiles 
   Caption         =   "ADO files Creation and usage"
   ClientHeight    =   6465
   ClientLeft      =   60
   ClientTop       =   510
   ClientWidth     =   8250
   Icon            =   "frmAdoFiles.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   6465
   ScaleWidth      =   8250
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdExit 
      Caption         =   "&Exit"
      Height          =   855
      Left            =   7200
      Picture         =   "frmAdoFiles.frx":08CA
      Style           =   1  'Graphical
      TabIndex        =   44
      Top             =   960
      Width           =   975
   End
   Begin VB.Frame fraEditing 
      Caption         =   "Editing"
      Height          =   1215
      Left            =   4080
      TabIndex        =   39
      Top             =   2040
      Width           =   4095
      Begin VB.CommandButton cmdAdd 
         Caption         =   "&Add"
         Height          =   855
         Left            =   120
         Picture         =   "frmAdoFiles.frx":1194
         Style           =   1  'Graphical
         TabIndex        =   43
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdDeleteRecord 
         Caption         =   "&Delete"
         Height          =   855
         Left            =   1080
         Picture         =   "frmAdoFiles.frx":1A5E
         Style           =   1  'Graphical
         TabIndex        =   42
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdEdit 
         Caption         =   "&Edit"
         Height          =   855
         Left            =   2040
         Picture         =   "frmAdoFiles.frx":2328
         Style           =   1  'Graphical
         TabIndex        =   41
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdUpdate 
         Caption         =   "&Update"
         Height          =   855
         Left            =   3000
         Picture         =   "frmAdoFiles.frx":2BF2
         Style           =   1  'Graphical
         TabIndex        =   40
         Top             =   240
         Width           =   975
      End
   End
   Begin VB.Frame fraCreation 
      Caption         =   "file ADO-XML"
      Height          =   1215
      Left            =   4080
      TabIndex        =   35
      Top             =   720
      Width           =   3135
      Begin VB.CommandButton cmdSave 
         Caption         =   "&Save"
         Height          =   855
         Left            =   2040
         Picture         =   "frmAdoFiles.frx":34BC
         Style           =   1  'Graphical
         TabIndex        =   38
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdOpen 
         Caption         =   "&Open"
         Height          =   855
         Left            =   1080
         Picture         =   "frmAdoFiles.frx":3D86
         Style           =   1  'Graphical
         TabIndex        =   37
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdCreate 
         Caption         =   "&Create"
         Height          =   855
         Left            =   120
         Picture         =   "frmAdoFiles.frx":4650
         Style           =   1  'Graphical
         TabIndex        =   36
         Top             =   240
         Width           =   975
      End
   End
   Begin VB.Frame fraNavigation 
      Caption         =   "Navigation"
      Height          =   1215
      Left            =   4080
      TabIndex        =   30
      Top             =   3480
      Width           =   4095
      Begin VB.CommandButton cmdLast 
         Caption         =   "&Last"
         Height          =   855
         Left            =   3000
         Picture         =   "frmAdoFiles.frx":4F1A
         Style           =   1  'Graphical
         TabIndex        =   34
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdFirst 
         Caption         =   "&First"
         Height          =   855
         Left            =   120
         Picture         =   "frmAdoFiles.frx":57E4
         Style           =   1  'Graphical
         TabIndex        =   33
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdNext 
         Caption         =   "&Next"
         Height          =   855
         Left            =   2040
         Picture         =   "frmAdoFiles.frx":60AE
         Style           =   1  'Graphical
         TabIndex        =   32
         Top             =   240
         Width           =   975
      End
      Begin VB.CommandButton cmdPrevious 
         Caption         =   "&Previous"
         Height          =   855
         Left            =   1080
         Picture         =   "frmAdoFiles.frx":6978
         Style           =   1  'Graphical
         TabIndex        =   31
         Top             =   240
         Width           =   975
      End
   End
   Begin VB.TextBox txtUnsignedTinyInt 
      Height          =   285
      Left            =   2160
      TabIndex        =   29
      Top             =   600
      Width           =   495
   End
   Begin VB.TextBox txtVarChar 
      Height          =   285
      Left            =   2160
      TabIndex        =   28
      Top             =   4920
      Width           =   4815
   End
   Begin VB.TextBox txtUnsignedInt 
      Height          =   285
      Left            =   2160
      TabIndex        =   27
      Top             =   4560
      Width           =   1695
   End
   Begin VB.TextBox txtUnsignedSmallInt 
      Height          =   285
      Left            =   2160
      TabIndex        =   26
      Top             =   4200
      Width           =   1695
   End
   Begin VB.TextBox txtSingle 
      Height          =   285
      Left            =   2160
      TabIndex        =   25
      Top             =   3840
      Width           =   1695
   End
   Begin VB.TextBox txtTinyInt 
      Height          =   285
      Left            =   2160
      TabIndex        =   24
      Top             =   3480
      Width           =   1695
   End
   Begin VB.TextBox txtBigInt 
      Height          =   285
      Left            =   2160
      TabIndex        =   23
      Top             =   3120
      Width           =   1695
   End
   Begin VB.TextBox txtInteger 
      Height          =   285
      Left            =   2160
      TabIndex        =   22
      Top             =   2760
      Width           =   1695
   End
   Begin VB.TextBox txtSmallInt 
      Height          =   285
      Left            =   2160
      TabIndex        =   21
      Top             =   2400
      Width           =   1695
   End
   Begin VB.TextBox txtDouble 
      Height          =   285
      Left            =   2160
      TabIndex        =   20
      Top             =   2040
      Width           =   1695
   End
   Begin MSMask.MaskEdBox medCurrency 
      Height          =   255
      Left            =   2160
      TabIndex        =   18
      Top             =   1680
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   450
      _Version        =   393216
      PromptChar      =   "_"
   End
   Begin VB.TextBox txtChar 
      Height          =   285
      Left            =   2160
      TabIndex        =   16
      Top             =   960
      Width           =   1695
   End
   Begin VB.CheckBox chkBoolean 
      Height          =   255
      Left            =   2160
      TabIndex        =   15
      Top             =   240
      Width           =   255
   End
   Begin VB.Frame fraButton 
      Height          =   1215
      Left            =   120
      TabIndex        =   0
      Top             =   5160
      Width           =   8055
      Begin VB.Label lblInfo 
         Caption         =   $"frmAdoFiles.frx":7242
         Height          =   855
         Left            =   120
         TabIndex        =   19
         Top             =   240
         Width           =   7815
      End
   End
   Begin MSMask.MaskEdBox medDate 
      Height          =   255
      Left            =   2160
      TabIndex        =   17
      Top             =   1320
      Width           =   1815
      _ExtentX        =   3201
      _ExtentY        =   450
      _Version        =   393216
      Format          =   "dd-mmm-yy"
      PromptChar      =   "_"
   End
   Begin VB.Label Label1 
      Caption         =   "VarChar"
      Height          =   255
      Index           =   13
      Left            =   120
      TabIndex        =   14
      Top             =   4920
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "UnsignedInt"
      Height          =   255
      Index           =   12
      Left            =   120
      TabIndex        =   13
      Top             =   4560
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "UnsignedSmallInt"
      Height          =   255
      Index           =   11
      Left            =   120
      TabIndex        =   12
      Top             =   4200
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Single"
      Height          =   255
      Index           =   10
      Left            =   120
      TabIndex        =   11
      Top             =   3840
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "TinyInt"
      Height          =   255
      Index           =   9
      Left            =   120
      TabIndex        =   10
      Top             =   3480
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "BigInt"
      Height          =   255
      Index           =   8
      Left            =   120
      TabIndex        =   9
      Top             =   3120
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Integer"
      Height          =   255
      Index           =   7
      Left            =   120
      TabIndex        =   8
      Top             =   2760
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "SmallInt"
      Height          =   255
      Index           =   6
      Left            =   120
      TabIndex        =   7
      Top             =   2400
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Double"
      Height          =   255
      Index           =   5
      Left            =   120
      TabIndex        =   6
      Top             =   2040
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Currency"
      Height          =   255
      Index           =   4
      Left            =   120
      TabIndex        =   5
      Top             =   1680
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Date"
      Height          =   255
      Index           =   3
      Left            =   120
      TabIndex        =   4
      Top             =   1320
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Char"
      Height          =   255
      Index           =   2
      Left            =   120
      TabIndex        =   3
      Top             =   960
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "UnsignedTinyInt"
      Height          =   255
      Index           =   1
      Left            =   120
      TabIndex        =   2
      Top             =   600
      Width           =   1935
   End
   Begin VB.Label Label1 
      Caption         =   "Boolean"
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   1
      Top             =   240
      Width           =   1935
   End
End
Attribute VB_Name = "frmAdoFiles"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit


Private Const kFORM_LEFT = 0
Private Const kFORM_TOP = 0
Private Const kFORM_HEIGHT = 7250
Private Const kFORM_WIDTH = 11900

Dim rsTest As New ADODB.Recordset

''
' Add a new record on the Ado file
Private Sub cmdAdd_Click()
    rsTest.AddNew
    maskEnable True
    maskFill
  
End Sub

''
' Create an ADO file and fill it with values
Private Sub cmdCreate_Click()

    rsTest.Fields.Append "FieldBoolean", adBoolean, , adFldIsNullable
    rsTest.Fields.Append "fieldUnsignedTinyInt", adUnsignedTinyInt, , adFldIsNullable
    rsTest.Fields.Append "fieldChar", adChar, 12, adFldIsNullable
    rsTest.Fields.Append "fieldDate", adDate, , adFldIsNullable
    rsTest.Fields.Append "fieldCurrency", adCurrency, , adFldIsNullable
    rsTest.Fields.Append "fieldDouble", adDouble, , adFldIsNullable
    rsTest.Fields.Append "fieldSmallInt", adSmallInt, , adFldIsNullable
    rsTest.Fields.Append "fieldInteger", adInteger, , adFldIsNullable
    rsTest.Fields.Append "fieldBigInt", adBigInt, , adFldIsNullable
    rsTest.Fields.Append "fieldTinyInt", adTinyInt, , adFldIsNullable
    rsTest.Fields.Append "fieldSingle", adSingle, , adFldIsNullable
    rsTest.Fields.Append "fieldUnsignedSmallInt", adUnsignedSmallInt, , adFldIsNullable
    rsTest.Fields.Append "fieldUnsignedInt", adUnsignedInt, , adFldIsNullable
    rsTest.Fields.Append "fieldVarChar", adVarChar, 255, adFldIsNullable
    
    rsTest.Open App.Path & "\" & "gmd-ado.xml"
    
    If rsTest.RecordCount = 0 Then
        rsTest.AddNew
    End If
        
    rsTest!fieldBoolean = True
    rsTest!fieldUnsignedTinyInt = 1
    rsTest!fieldChar = "hallo world!"
    rsTest!fieldDate = Now
    rsTest!fieldCurrency = "100"
    rsTest!fieldDouble = 16000
    rsTest!FieldSmallInt = 512
    rsTest!fieldInteger = 255
    rsTest!fieldBigInt = 222222
    rsTest!fieldTinyInt = 33
    rsTest!fieldSingle = 64414
    rsTest!fieldUnsignedSmallInt = 255
    rsTest!fieldUnsignedInt = 255
    rsTest!fieldVarChar = "Linux rulez!!!"
    
    rsTest.Update
    rsTest.Save App.Path & "\" & "gmd-ado.xml", adPersistXML
    rsTest.Close
  
End Sub

''
' Delete the current record
Private Sub cmdDeleteRecord_Click()
    rsTest.Delete
    rsTest.Update
    rsTest.MoveFirst
    maskEnable False
    maskFill
End Sub

''
'
Private Sub cmdEdit_Click()
    maskEnable True
    maskFill
End Sub

Private Sub cmdExit_Click()
    
    rsTest.Save App.Path & "\" & "gmd-ado.xml", adPersistXML
    rsTest.Close
    Set rsTest = Nothing
    
    Unload Me
End Sub

''
'
Private Sub cmdFirst_Click()
    rsTest.MoveFirst
    maskFill
    maskEnable False
End Sub

''
'
Private Sub cmdprevious_Click()
    rsTest.MovePrevious
    If rsTest.BOF Then
        rsTest.MoveNext
        MsgBox "Fist record reached!"
    End If
    maskFill
    maskEnable False
End Sub

''
'
Private Sub cmdNext_Click()
    rsTest.MoveNext
    If rsTest.EOF Then
        rsTest.MovePrevious
        MsgBox "Last record reached! "
    End If
    maskFill
    maskEnable False
End Sub

''
'
Private Sub cmdLast_Click()
    rsTest.MoveLast
    maskFill
    maskEnable False
End Sub

''
' Open an ADO file ed put the values into the mask
Private Sub cmdOpen_Click()
    rsTest.Open App.Path & "\" & "gmd-ado.xml"
    fraNavigation.Enabled = True
    editingEnable True
    navigationEnable True
    maskFill
    
    cmdCreate.Enabled = False
    cmdOpen.Enabled = False
End Sub

''
'
Private Sub maskEnable(blnEnabled As Boolean)
    txtUnsignedTinyInt.Enabled = blnEnabled
    txtChar.Enabled = blnEnabled
    medDate.Enabled = blnEnabled
    medCurrency.Enabled = blnEnabled
    txtDouble.Enabled = blnEnabled
    txtSmallInt.Enabled = blnEnabled
    txtInteger.Enabled = blnEnabled
    txtBigInt.Enabled = blnEnabled
    txtTinyInt.Enabled = blnEnabled
    txtSingle.Enabled = blnEnabled
    txtUnsignedSmallInt.Enabled = blnEnabled
    txtUnsignedInt.Enabled = blnEnabled
    txtVarChar.Enabled = blnEnabled
End Sub

''
'
Private Sub maskFill()
    txtUnsignedTinyInt = NullToEmpty(rsTest!fieldUnsignedTinyInt)
    txtChar = NullToEmpty(rsTest!fieldChar)
    medDate = NullToEmpty(rsTest!fieldDate)
    medCurrency = NullToEmpty(rsTest!fieldCurrency)
    txtDouble = NullToEmpty(rsTest!fieldDouble)
    txtSmallInt = NullToEmpty(rsTest!FieldSmallInt)
    txtInteger = NullToEmpty(rsTest!fieldInteger)
    txtBigInt = NullToEmpty(rsTest!fieldBigInt)
    txtTinyInt = NullToEmpty(rsTest!fieldTinyInt)
    txtSingle = NullToEmpty(rsTest!fieldSingle)
    txtUnsignedSmallInt = NullToEmpty(rsTest!fieldUnsignedSmallInt)
    txtUnsignedInt = NullToEmpty(rsTest!fieldUnsignedInt)
    txtVarChar = NullToEmpty(rsTest!fieldVarChar)
End Sub

''
'
Private Sub cmdSave_Click()
    rsTest.Save App.Path & "\" & "gmd-ado.xml", adPersistXML
End Sub

''
'
Private Sub cmdUpdate_Click()

    'rsTest!fieldUnsignedTinyInt = txtUnsignedTinyInt
    rsTest!fieldChar = cnv.EmptyToNull(txtChar)
'    rsTest!fieldDate = cnv.EmptyToNull(medDate)
    rsTest!fieldCurrency = cnv.EmptyToZero(medCurrency)
    rsTest!fieldDouble = cnv.EmptyToZero(txtDouble)
    rsTest!FieldSmallInt = cnv.EmptyToZero(txtSmallInt)
    rsTest!fieldInteger = cnv.EmptyToZero(txtInteger)
    rsTest!fieldBigInt = cnv.EmptyToZero(txtBigInt)
    rsTest!fieldTinyInt = cnv.EmptyToZero(txtTinyInt)
    rsTest!fieldSingle = cnv.EmptyToZero(txtSingle)
    rsTest!fieldUnsignedSmallInt = cnv.EmptyToZero(txtUnsignedSmallInt)
    rsTest!fieldUnsignedInt = cnv.EmptyToZero(txtUnsignedInt)
    rsTest!fieldVarChar = cnv.EmptyToNull(txtVarChar)
    rsTest.Update
    maskEnable False
    maskFill
End Sub

''
'
Private Sub Form_Load()
    maskEnable False
    editingEnable False
    navigationEnable False
End Sub

''
'
Private Sub navigationEnable(blnEnable)
    cmdFirst.Enabled = blnEnable
    cmdPrevious.Enabled = blnEnable
    cmdNext.Enabled = blnEnable
    cmdLast.Enabled = blnEnable
End Sub

''
'
Private Sub editingEnable(blnEnable)
    cmdAdd.Enabled = blnEnable
    cmdDeleteRecord.Enabled = blnEnable
    cmdEdit.Enabled = blnEnable
    cmdUpdate.Enabled = blnEnable
End Sub

