B4A Library SD: BindingNavigator (Sqlite GUI Navigator)

This is a first version of the BindingNavigator Library, which wants to somehow reproduce the corresponding BindingNavigator of VB.NET.
What is needed? I want to get something similar to the tools available on VB.NET to link the views to the DB. As in the pictures.

upload_2018-3-25_11-53-29.png
upload_2018-3-25_11-53-35.png


A DataSet Class is available that allows to associate some views (EditText, Label, ImageView, ToggleButton, CheckBox) with specific fields of a Sqlite DataBase.

By scrolling the position of the DataSet the fields will be updated and if the fields in some way undergo a variation by the user, raising the UpdateChange event will in turn be modified in the DataBase.
This very Agevolent construction of GUI related to the DB.

In addition you have a Second ViewCalss NavigatorBar that adds a new Seek view to the design that is linked to the DataSet. Scrolling through the Seek will change all the views linked to the DataSet. And if the UpdateChange eventio is updated, the DB will be updated based on changes in the views linked to the fields.

VERY IMPORTANT:
  1. The sql database must always have a Primarykey field, of type int with auto-increment, in the example i call it ID, but it could be called as you want.
    The name of the field that will be the Primarykey must be communicated to the DataSet when call query method.
  2. If you use NavigatorBar, in your code you must load FontAwesone, as in the example at post#2, or in the Wish you can have a view set with FontAwesone


SD_BindingNavigator

Author:
Star-Dust
Version: 0.50
  • DataSet
    • Functions:
      • AddGroupView (Panel As Panel) As String
      • AddLinkView (V As View, Field As String) As String
      • AddRecord As String
      • Class_Globals As String
      • ClearLinkView As String
      • DeleteRecord As String
      • getBitmap (Field As String) As Bitmap
      • getBlob (Field As String) As Byte()
      • getCurrentTable As String
      • getDouble (Field As String) As Double
      • getInt (Field As String) As Int
      • getLong (Field As String) As Long
      • getPosition As Int
        Return -3 : Not Initialized
        Return -2 : Is empty
        Return -1 : Not positoned
      • getSize As Int
        Return -1 id Query non execute
      • getSQL As SQL
      • getString (Field As String) As String
      • Initialize (Path As String, FileName As String, CreateIfNecessary As Boolean) As String
        Initializes the object. You can add parameters to this method if needed.
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • NextRecord As String
      • PreviousRecord As String
      • Query (StringQuery As String, PrimaryKeyName As String) As String
      • Query2 (StringQuery As String, StringArg As String(), PrimaryKeyName As String) As String
      • RefreshField As String
      • setPosition (Index As Int) As Boolean
        Return false if Query not execute, index out of range or other error
      • UpdateChange As String
    • Properties:
      • CurrentTable As String [read only]
      • Position As Int
        Return -3 : Not Initialized
        Return -2 : Is empty
        Return -1 : Not positoned
      • Size As Int [read only]
        Return -1 id Query non execute
      • SQL As SQL [read only]
  • NavigatorBar
    • Events:
      • ValueChanged (Value As Int)
    • Fields:
      • Coefficent As Float
      • FontAW As Typeface
    • Functions:
      • AddGroupView (Panel As Panel) As String
      • AddLinkView (V As View, Field As String) As String
      • Class_Globals As String
      • ConnectDB (Path As String, FileName As String, CreateIfNecessary As Boolean) As String
      • DesignerCreateView (Base As Panel, Lbl As Label, Props As Map) As String
      • GetBase As Panel
      • getDataSet As DataSet
      • getPosition As Int
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Query (StringQuery As String, PrimaryKeyName As String) As String
      • Query2 (StringQuery As String, StringArg As String(), PrimaryKeyName As String) As String
      • RefreshField As String
      • setDataSet (Dset As DataSet) As String
      • setPosition (pos As Int) As String
      • UpdateChange As String
    • Properties:
      • DataSet As DataSet
      • Position As Int
  • WizardMask
    • Events:
      • ValueChanged (Value As Int)
    • Fields:
      • Coefficent As Float
      • FontAW As Typeface
    • Functions:
      • AddAllField As String
      • AddField (FieldName As String, Hint As String) As String
      • Class_Globals As String
      • ClearField As String
      • ConnectDB (Path As String, FileName As String, CreateIfNecessary As Boolean) As String
      • CreateMask As String
      • DesignerCreateView (Base As Panel, Lbl As Label, Props As Map) As String
      • GetBase As Panel
      • getDataSet As DataSet
      • getPosition As Int
      • Initialize (Callback As Object, EventName As String) As String
      • IsInitialized As Boolean
        Verifica se l'oggetto sia stato inizializzato.
      • Query (StringQuery As String, PrimaryKeyName As String) As String
      • Query2 (StringQuery As String, StringArg As String(), PrimaryKeyName As String) As String
      • RefreshField As String
      • setDataSet (Dset As DataSet) As String
      • setPosition (pos As Int) As String
      • UpdateChange As String
    • Properties:
      • DataSet As DataSet
      • Position As Int


It is still undergoing improvements, if there are any suggestions or bugs, report them


video1.gif
3.gif


Video1.gif
4a.gif
 

Attachments

  • SD_BindingNavigator 0.50.zip
    21.1 KB · Views: 258
Last edited:

Star-Dust

Expert
Licensed User
Method AddGroupView

B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

    Private DBr As NavigatorBar
    Private Panel1 As Panel ' Main panel where the views linked to the table will be attached
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("Layout1")

    File.Copy(File.DirAssets,"user.s3db",File.DirInternal,"user.s3db")
  
    DBr.ConnectDB(File.DirInternal,"user.s3db",False)
    DBr.FontAW=Typeface.FONTAWESOME
    DBr.AddGroupView(Panel1)
    DBr.Query("SELECT * FROM user","ID")
End Sub

Video.gif
upload_2018-4-14_20-22-40.png
 

Attachments

  • Example4.zip
    11.6 KB · Views: 148
buonanotte, spero che tu stia bene grazie mille la creazione della tua libreria bindingnavigator è stata molto utile, vorrei chiedere se c'è un modo per sapere che la query non è stata eseguita è dire quando non viene eseguita non mi invia alcun messaggio di errore o avviso Sto usando un set di dati Vorrei mettere a avviso quando la query non ha trovato alcun risultato, apprezzerei molto il tuo aiuto e scusami se non sono molto bravo con l'italiano.
 
Top