Standard |
Module1 |
Data1Save |
Basic |
Dialog1|CommandButton1 (Control) |
28 |
SUB Data1Save DIM oDatasource AS OBJECT DIM oConnection AS OBJECT DIM oSQL_Command AS OBJECT DIM loID AS LONG DIM stForename AS STRING DIM stSurname AS STRING loID = oDialog1.getControl("NumericField1").Value stForename = oDialog1.getControl("TextField1").Text stSurname = oDialog1.getControl("TextField2").Text IF loID > 0 AND stSurname <> "" THEN oDatasource = thisDatabaseDocument.CurrentController If NOT (oDatasource.isConnected()) THEN oDatasource.connect() END IF oConnection = oDatasource.ActiveConnection() oSQL_Command = oConnection.createStatement() stSql = "SELECT ""ID"" FROM ""name"" WHERE ""ID"" = '"+loID+"'" oResult = oSQL_Command.executeQuery(stSql) WHILE oResult.next MsgBox ("The value for field 'ID' already exist",16,"Duplicate Value") EXIT SUB WEND stSql = "INSERT INTO ""name"" (""ID"", ""forename"", ""surname"") VALUES ('"+loID+"','"+stForename+"','"+stSurname+"')" oSQL_Command.executeUpdate(stSql) DatafieldsClear END IF END SUB |
Standard |
Module1 |
Data2Save |
Basic |
Dialog2|CommandButton1 (Control) |
49 |
SUB Data2Save(oEvent AS OBJECT) DIM oDatasource AS OBJECT DIM oConnection AS OBJECT DIM oSQL_Command AS OBJECT DIM oDlg AS OBJECT DIM loID AS LONG DIM stForename AS STRING DIM stSurname AS STRING DIM inMsg AS INTEGER DIM loRow AS LONG DIM loRowMax AS LONG DIM stSql AS STRING oDlg = oEvent.Source.getContext() loID = oDlg.getControl("NumericField1").Value stForename = oDlg.getControl("TextField1").Text stSurname = oDlg.getControl("TextField2").Text IF loID > 0 AND stSurname <> "" THEN oDatasource = thisDatabaseDocument.CurrentController If NOT (oDatasource.isConnected()) THEN oDatasource.connect() END IF oConnection = oDatasource.ActiveConnection() oSQL_Command = oConnection.createStatement() loRow = oDlg.getControl("NumericField2").Value loRowMax = oDlg.getControl("NumericField3").Value IF loRowMax < loRow THEN IF loRowMax > 0 THEN stSql = "SELECT ""ID"" FROM ""name"" WHERE ""ID"" = '"+loID+"'" oResult = oSQL_Command.executeQuery(stSql) WHILE oResult.next inMsg = MsgBox ("The value for field 'ID' already exist." & CHR(13) & "Should the row be updated?",20,"Duplicate Value") IF inMsg = 6 THEN stSql = "UPDATE ""name"" SET ""forename""='"+stForename+"', ""surname""='"+stSurname+"' WHERE ""ID"" = '"+loID+"'" oSQL_Command.executeUpdate(stSql) DataLoad(loID) END IF EXIT SUB WEND END IF stSql = "INSERT INTO ""name"" (""ID"", ""forename"", ""surname"") VALUES ('"+loID+"','"+stForename+"','"+stSurname+"')" oSQL_Command.executeUpdate(stSql) oDlg.getControl("NumericField3").Value = loRowMax + 1 Datafields2Clear ELSE stSql = "UPDATE ""name"" SET ""forename""='"+stForename+"', ""surname""='"+stSurname+"' WHERE ""ID"" = '"+loID+"'" oSQL_Command.executeUpdate(stSql) END IF END IF END SUB |
Standard |
Module1 |
DataDelete |
Basic |
Dialog2|CommandButton6 (Control) |
27 |
SUB DataDelete(oEvent AS OBJECT) DIM oDatasource AS OBJECT DIM oConnection AS OBJECT DIM oSQL_Command AS OBJECT DIM oDlg AS OBJECT DIM loID AS LONG oDlg = oEvent.Source.getContext() loID = oDlg.getControl("NumericField1").Value IF loID > 0 THEN inMsg = MsgBox ("Should current data be deleted?",20,"Delete current row") IF inMsg = 6 THEN oDatasource = thisDatabaseDocument.CurrentController If NOT (oDatasource.isConnected()) THEN oDatasource.connect() END IF oConnection = oDatasource.ActiveConnection() oSQL_Command = oConnection.createStatement() stSql = "DELETE FROM ""name"" WHERE ""ID"" = '"+loID+"'" oSQL_Command.executeUpdate(stSql) loRowMax = oDlg.getControl("NumericField3").Value oDlg.getControl("NumericField3").Value = loRowMax - 1 NextRow END IF ELSE MsgBox ("No row deleted." & CHR(13) & "No data selected.",64,"Delete impossible") END IF END SUB |
Standard |
Module1 |
Datafields2Clear |
Basic |
Dialog2|CommandButton2 (Control) NextRow (Procedure) Data2Save (Procedure) |
11 |
SUB Datafields2Clear loRowMax = oDialog2.getControl("NumericField3").Value oDialog2.getControl("NumericField1").Text = "" oDialog2.getControl("TextField1").Text = "" oDialog2.getControl("TextField2").Text = "" oDialog2.getControl("NumericField2").Value = loRowMax + 1 oDialog2.getControl("CommandButton4").Model.enabled = True oDialog2.getControl("CommandButton5").Model.enabled = False oDialog2.getControl("CommandButton2").Model.enabled = False oDialog2.getControl("CommandButton6").Model.enabled = False END SUB |
Standard |
Module1 |
DatafieldsClear |
Basic |
Dialog1|CommandButton3 (Control) Data1Save (Procedure) |
5 |
SUB DatafieldsClear oDialog1.getControl("NumericField1").Text = "" oDialog1.getControl("TextField1").Text = "" oDialog1.getControl("TextField2").Text = "" END SUB |
Standard |
Module1 |
DataLoad |
Basic |
Dialog2Start (Procedure) PreviousRow (Procedure) NextRow (Procedure) Data2Save (Procedure) |
66 |
SUB DataLoad(loID AS LONG) DIM oDatasource AS OBJECT DIM oConnection AS OBJECT DIM oSQL_Command AS OBJECT DIM stForename AS STRING DIM stSurname AS STRING DIM loRow AS LONG DIM loRowMax AS LONG DIM inStart AS INTEGER loRow = 1 oDatasource = thisDatabaseDocument.CurrentController If NOT (oDatasource.isConnected()) THEN oDatasource.connect() END IF oConnection = oDatasource.ActiveConnection() oSQL_Command = oConnection.createStatement() IF loID < 1 THEN stSql = "SELECT MIN(""ID"") FROM ""name""" oResult = oSQL_Command.executeQuery(stSql) WHILE oResult.next loID = oResult.getInt(1) WEND inStart = 1 END IF IF loID > 0 THEN stSql = "SELECT * FROM ""name"" WHERE ""ID"" = '"+loID+"'" oResult = oSQL_Command.executeQuery(stSql) WHILE oResult.next loID = oResult.getInt(1) stForename = oResult.getString(2) stSurname = oResult.getString(3) WEND stSql = "SELECT COUNT(""ID"") FROM ""name""" oResult = oSQL_Command.executeQuery(stSql) WHILE oResult.next loRowMax = oResult.getInt(1) WEND stSql = "SELECT COUNT(""ID"") FROM ""name"" WHERE ""ID"" <= '"+loID+"'" oResult = oSQL_Command.executeQuery(stSql) WHILE oResult.next loRow = oResult.getInt(1) WEND oDialog2.getControl("NumericField1").Value = loID oDialog2.getControl("TextField1").Text = stForename oDialog2.getControl("TextField2").Text = stSurname END IF oDialog2.getControl("NumericField2").Value = loRow oDialog2.getControl("NumericField3").Value = loRowMax IF loRow = 1 THEN oDialog2.getControl("CommandButton4").Model.enabled = False ELSE oDialog2.getControl("CommandButton4").Model.enabled = True END IF IF loRow <= loRowMax THEN oDialog2.getControl("CommandButton5").Model.enabled = True oDialog2.getControl("CommandButton2").Model.enabled = True oDialog2.getControl("CommandButton6").Model.enabled = True ELSE oDialog2.getControl("CommandButton5").Model.enabled = False oDialog2.getControl("CommandButton2").Model.enabled = False oDialog2.getControl("CommandButton6").Model.enabled = False END IF IF inStart = 1 THEN oDialog2.Execute() END IF END SUB |
Standard |
Module1 |
Dialog0End |
Basic |
|
3 |
SUB Dialog0End oDialog0.EndExecute() END SUB |
Standard |
Module1 |
Dialog0Start |
Basic |
Example_Dialogs.odb (Database) |
5 |
SUB Dialog0Start DialogLibraries.LoadLibrary("Standard") oDialog0 = createUnoDialog(DialogLibraries.Standard.Dialog0) oDialog0.Execute() END SUB |
Standard |
Module1 |
Dialog1End |
Basic |
Dialog1|CommandButton2 (Control) |
3 |
SUB Dialog1End oDialog1.EndExecute() END SUB |
Standard |
Module1 |
Dialog1Start |
Basic |
Dialog0|CommandButton1 (Control) |
5 |
SUB Dialog1Start DialogLibraries.LoadLibrary("Standard") oDialog1 = createUnoDialog(DialogLibraries.Standard.Dialog1) oDialog1.Execute() END SUB |
Standard |
Module1 |
Dialog2End |
Basic |
Dialog2|CommandButton3 (Control) |
3 |
SUB Dialog2End oDialog2.EndExecute() END SUB |
Standard |
Module1 |
Dialog2Start |
Basic |
Dialog0|CommandButton2 (Control) |
5 |
SUB Dialog2Start DialogLibraries.LoadLibrary("Standard") oDialog2 = createUnoDialog(DialogLibraries.Standard.Dialog2) DataLoad(0) END SUB |
Standard |
Module1 |
NextRow |
Basic |
Dialog2|CommandButton5 (Control) DataDelete (Procedure) |
21 |
SUB NextRow DIM loID AS LONG DIM loIDnew AS LONG loID = oDialog2.getControl("NumericField1").Value oDatasource = thisDatabaseDocument.CurrentController If NOT (oDatasource.isConnected()) THEN oDatasource.connect() END IF oConnection = oDatasource.ActiveConnection() oSQL_Command = oConnection.createStatement() stSql = "SELECT MIN(""ID"") FROM ""name"" WHERE ""ID"" > '"+loID+"'" oResult = oSQL_Command.executeQuery(stSql) WHILE oResult.next loIDnew = oResult.getInt(1) WEND IF loIDnew > 0 THEN DataLoad(loIDnew) ELSE Datafields2Clear END IF END SUB |
Standard |
Module1 |
PreviousRow |
Basic |
Dialog2|CommandButton4 (Control) |
23 |
SUB PreviousRow DIM loID AS LONG DIM loIDnew AS LONG loID = oDialog2.getControl("NumericField1").Value oDatasource = thisDatabaseDocument.CurrentController If NOT (oDatasource.isConnected()) THEN oDatasource.connect() END IF oConnection = oDatasource.ActiveConnection() oSQL_Command = oConnection.createStatement() IF loID < 1 THEN stSql = "SELECT MAX(""ID"") FROM ""name""" ELSE stSql = "SELECT MAX(""ID"") FROM ""name"" WHERE ""ID"" < '"+loID+"'" END IF oResult = oSQL_Command.executeQuery(stSql) WHILE oResult.next loIDnew = oResult.getInt(1) WEND IF loIDnew > 0 THEN DataLoad(loIDnew) END IF END SUB |