LibreOffice logo
BASEDOCUMENTER
The software tool for documenting your LibreOffice Base applications
 
Database file/home/jean-pierre/Documents/BaseDocumenter/www/databases/LODoc/Example_serial_Number_Year.odb
File actual save date2018-06-27 14:04:54
Scanning done on2018-08-21 17:40:52
Documentation generated on2018-08-21 17:41:03
Table of contents
Example_serial_Number_Year
Procedures by module
Library Module name Procedure name Language Used by Number of code lines Procedure code
Standard Module1 Current_Date_and_ID Basic orders|button (Control) 52
SUB Current_Date_and_ID
DIM oDatasource AS OBJECT
DIM oConnection AS OBJECT
DIM oSQL_Command AS OBJECT
DIM stSql AS STRING
DIM oResult AS OBJECT
DIM oDoc AS OBJECT
DIM oDrawpage AS OBJECT
DIM oForm AS OBJECT
DIM oField1 AS OBJECT
DIM oField2 AS OBJECT
DIM oField3 AS OBJECT
DIM inIDnew AS INTEGER
DIM inYear AS INTEGER
DIM unoDate
oDoc = thisComponent
oDrawpage = oDoc.drawpage
oForm = oDrawpage.forms.getByName("MainForm")
oField1 = oForm.getByName("fmt_year")
oField2 = oForm.getByName("fmtID")
oField3 = oForm.getByName("dat_date")
IF IsEmpty(oField2.getCurrentValue()) THEN
IF IsEmpty(oField3.getCurrentValue()) THEN
unoDate = createUnoStruct("com.sun.star.util.Date")
unoDate.Day = Day(Date)
unoDate.Month = Month(Date)
unoDate.Year = Year(Date)
inYear = Year(Date)
ELSE
inYear = oField3.CurrentValue.Year
END IF
oDatasource = ThisComponent.Parent.CurrentController
If NOT (oDatasource.isConnected()) THEN
oDatasource.connect()
END IF
oConnection = oDatasource.ActiveConnection()
oSQL_Command = oConnection.createStatement()
stSql = "SELECT MAX( ""ID"" )+1 FROM ""orders"" WHERE ""year"" = '" + inYear + "'"
oResult = oSQL_Command.executeQuery(stSql) ' analyse result
WHILE oResult.next
inIDnew = oResult.getInt(1)
WEND ' next row
IF inIDnew = 0 THEN
inIDnew = 1
END IF
oField1.BoundField.updateInt(inYear)
oField2.BoundField.updateInt(inIDnew)
IF IsEmpty(oField3.getCurrentValue()) THEN
oField3.BoundField.updateDate(unoDate)
END IF
END IF
END SUB