Sub Class_Globals
Private fx As JFX
Private frm1 As Form
Private ScrollPane1 As ScrollPane
Private saveit As Button
Private cancelit As Button
Private Pane1 As Pane
Dim lb As Int
Dim et As Int
Dim dt As Int
Dim y As Int
Dim wtype As Int=0
Dim fid As String
Dim scrolly As Int=40
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize(Parent As Form)
frm1.Initialize("frm",600dip,600dip)
frm1.Resizable=True
frm1.RootPane.LoadLayout("newform")
frm1.SetFormStyle("UTILITY")
frm1.Title=Main.formtitle
frm1.SetOwner(Parent)
ScrollPane1.LoadLayout("newpane",-1, scrolly)
y=10
Select Case Main.formjob
Case "NEWPEL"
createtextfield("ID:","id",True,False)
createtextfield("Name:","pelaths",False,True)
createcheckfield("Check if want to enable:","chk", True)
End Select
ScrollPane1.innernode.SetSize(Pane1.Width,scrolly)
End Sub
Sub createcheckfield(lbl As String,fieldname As String, isenabled As Boolean)
Dim mylabel As Label
mylabel.Initialize("mylbl")
mylabel.Text=lbl
CSSUtils.SetStyleProperty(mylabel,"-fx-alignment","center-left")
Dim mytext As CheckBox
mytext.Initialize("mytxt")
mytext.Text=""
mytext.Tag=fieldname
If isenabled=False Then
mytext.Enabled=False
End If
Pane1.AddNode(mylabel,10,y,250,25)
Pane1.AddNode(mytext,270,y,280,25)
y=y+35
End Sub
Sub createtextfield(lbl As String,fieldname As String,no As Boolean, isenabled As Boolean)
Dim mylabel As Label
mylabel.Initialize("mylbl")
mylabel.Text=lbl
CSSUtils.SetStyleProperty(mylabel,"-fx-alignment","center-left")
Dim mytext As TextField
mytext.Initialize("mytxt")
mytext.PromptText=""
mytext.Tag=fieldname
If no=True Then
CSSUtils.SetStyleProperty(mytext,"-fx-alignment","center-right")
End If
If isenabled=False Then
mytext.Enabled=False
End If
Pane1.AddNode(mylabel,10,y,250,25)
Pane1.AddNode(mytext,270,y,280,25)
y=y+35
scrolly=scrolly+35
End Sub
Sub createdatefield(lbl As String,fieldname As String, isenabled As Boolean)
Dim mylabel As Label
mylabel.Initialize("mylbl")
mylabel.Text=lbl
CSSUtils.SetStyleProperty(mylabel,"-fx-alignment","center-left")
Dim mytext As DatePicker
mytext.Initialize("mytxt")
mytext.Tag=fieldname
If isenabled=False Then
mytext.Enabled=False
End If
Pane1.AddNode(mylabel,10,y,250,25)
Pane1.AddNode(mytext,270,y,280,25)
y=y+35
scrolly=scrolly+35
End Sub
Public Sub Show As String
frm1.showandwait
Return "OK"
End Sub
Sub frm_CloseRequest (EventData As Event)
'EventData.Consume
End Sub
Sub saveit_Action
Select Case Main.formjob
Case "NEWPEL"
Dim wvalues As String
wvalues=getfields
'Main.sql1.ExecNonQuery("INSERT INTO pelates " & wvalues & ";")
Log(wvalues)
cancelit_Action
End Select
End Sub
Sub readfields
Dim cur As ResultSet
If IsNumber(Main.recnow)=True Then
wtype=1
End If
cur=Main.sql1.ExecQuery("SELECT * from " & Main.tablenow & ";")
fid = cur.GetColumnName(0)
cur.Close
Log(fid)
Log(Main.recnow)
Log(wtype)
If wtype=1 Then
cur=Main.sql1.ExecQuery("SELECT * from " & Main.tablenow & " WHERE " & fid & "=" & Main.recnow & " LIMIT 1;")
Else
cur=Main.sql1.ExecQuery("SELECT * from " & Main.tablenow & " WHERE " & fid & "='" & Main.recnow & "' LIMIT 1;")
End If
Do While cur.nextrow
For Each n As Node In Pane1.GetAllViewsRecursive
Dim jo As JavaObject
jo=n
If n.Tag<>"" Then
If n Is TextField Then
If CSSUtils.GetStyleProperty(n,"-fx-alignment")="center-right" Then
For k=0 To cur.ColumnCount-1
If cur.GetColumnName(k)=n.Tag Then
jo.RunMethod("setText", Array As Object(cur.GetString2(k)))
n=jo
Exit
End If
Next
Else
For k=0 To cur.ColumnCount-1
If cur.GetColumnName(k)=n.Tag Then
jo.RunMethod("setText", Array As Object(cur.Getstring2(k)))
n=jo
Exit
End If
Next
End If
End If
End If
If n Is CheckBox Then
'here is my problem...
End If
Next
Loop
cur.close
End Sub
Sub getfields As String
Dim su As StringBuilder
su.Initialize
su.Append("SET ")
Dim o As Int
For Each n As Node In Pane1.GetAllViewsRecursive
Dim jo As JavaObject
jo=n
If n Is TextField Then
If n.Tag<>"" Then
If jo.RunMethod("getText", Null)<>"" Then
o=o+1
If o>1 Then
su.Append(",")
End If
su.Append(n.tag & "=" )
If CSSUtils.GetStyleProperty(n,"-fx-alignment")="center-right" Then
su.Append(jo.RunMethod("getText", Null))
Else
su.Append("'" & jo.RunMethod("getText", Null)&"'")
End If
End If
End If
End If
If n Is DatePicker Then
If n.Tag<>"" Then
If jo.RunMethod("getValue", Null)<>"" Then
o=o+1
If o>1 Then
su.Append(",")
End If
su.Append(n.tag & "='" & jo.RunMethod("getValue", Null) & "'" )
End If
End If
End If
If n Is CheckBox Then
If n.Tag<>"" Then
If jo.RunMethod("Isselected", Null)=True Then
o=o+1
If o>1 Then
su.Append(",")
End If
su.Append(n.tag & "=1" )
Else
o=o+1
If o>1 Then
su.Append(",")
End If
su.Append(n.tag & "=0" )
End If
End If
End If
Next
Dim s As String
s=su.ToString
Log(s)
Return s
End Sub
Sub cancelit_Action
frm1.close
End Sub