proc setDefaultTable {tableBrowser databaseType} {
if {$databaseType == "surveys"} {
$tableBrowser setDefault "survey_stations"
}
}
proc changePage {databaseTable field } {
$databaseTable goToPage [$field getCurrentValue]
$field setCurrentValue [$databaseTable getPage]
}
GuidoApp get_handle "GET DATABASE HANDLE"
set result [$get_handle invoke]
if { $result >= 0 } {
set databaseHandle [$get_handle getParam DatabaseHandle]
set databaseType [$get_handle getParam DatabaseType]
GuidoForm selectTableForm {
-default_buttons
-label "Select Table"
-layout CentreLineLayout
GuidoDatabaseTableBrowser tableBrowser {
-display_length 16
-database_handle $databaseHandle
-label "Select table name"
-action initial {[setDefaultTable $tableBrowser "$databaseType"]}
-null false
}
GuidoFiller filler {
-height 3
}
}
GuidoForm constrainTableForm {
-default_buttons
-label "Define Query Constraints"
-layout BoxLayout Y_AXIS
-tip DB_QUERY_CONSTRAINTS
GuidoPanel frm00012_26 {
-layout BoxLayout X_AXIS
GuidoLabel frm00012_2 {
-label "Table Name"
}
GuidoFiller frm00012_27 {
-width 1
}
GuidoLabel tname {
-no_mlt
}
}
GuidoPanel frm00012_30 {
-layout BoxLayout X_AXIS
GuidoScrollPane frm00012_14 {
-height 10
-next_focus frm00012_17
GuidoTable cons {
-instances 1 1 17
-interactive true
GuidoTableFieldBrowser field {
-display_length 13
-format none
-label "Field Name"
-max_length 18
-database_handle $databaseHandle
-table_handle [$tname getCurrentValue]
}
GuidoComboBox operator {
-default =
-display_length 5
-format none
-label Operand
-max_length 2
-value_in < <= > >= <> =
}
GuidoField value {
-display_length 14
-format none
-label "Constraint Value"
-max_length 32
-translate none
}
}
}
GuidoFiller frm00012_31 {
-width 1
}
GuidoPanel frm00012_29 {
-layout BoxLayout Y_AXIS
GuidoButton frm00012_17 {
-caption Load
-legacy_button
-next_focus frm00012_20
-selected_value load_constraint
-visible true
}
GuidoButton frm00012_20 {
-caption Save
-legacy_button
-selected_value save_constraint
-visible true
}
}
GuidoFiller frm00012_31 {
-width 1
}
}
}
$tableBrowser updateBrowserList [lindex $argv 0]
set redisplay 1
while {$redisplay == 1} {
set redisplay 0
if { [$selectTableForm interact] == "apply" } {
$tname setCurrentValue [$tableBrowser getCurrentValue]
$field setTableHandle [$tableBrowser getCurrentValue]
$field updateBrowserList
$cons setInitialRows 1 1 17
$field setCurrentValue 0 ""
$operator setCurrentValue 0 "="
$value setCurrentValue 0 ""
set redisplay_constraint 1
while {$redisplay_constraint == 1} {
set redisplay_constraint 0
set action [$constrainTableForm interact]
if {$action  == "apply" } {
set tableName [$tableBrowser getCurrentValue]
set editable [lindex $argv 0]
set translated_text [GuidoMessage translate DATABASE_TABLE]
lappend translated_text $tableName
GuidoForm databaseTableForm {
-default_buttons
-layout BoxLayout Y_AXIS
-label $translated_text
-tip EDIT_DATABASE_TABLE_TIP
GuidoPanel borderLayout {
-layout borderlayout
GuidoScrollPane scroll {
-height 33
GuidoDatabaseTable databaseTable {
-input $editable
-interactive false
-position Centre
-database_handle $databaseHandle
-table_name $tableName
-row_header_width 60
}
}
}
GuidoPanel databaseTableForm_29 {
GuidoButton databaseTableForm_start {
-icon "icons/ms_anim_back_end.gif"
-legacy_button
-selected_value "first_page"
-visible true
}
GuidoButton databaseTableForm_20 {
-icon "icons/ms_anim_back.gif"
-legacy_button
-selected_value "prev_page"
-visible true
}
GuidoField databaseTableForm_numLabel {
-display_length 3
-label ""
-translate none
-default -1
-format integer
-action valueChanged { [changePage $databaseTable $databaseTableForm_numLabel]}
}
GuidoLabel databaseTableForm_oflabel {
-label " of  "
}
GuidoLabel databaseTableForm_label {
}
GuidoButton databaseTableForm_17 {
-icon "icons/ms_anim_forward.gif"
-legacy_button
-selected_value "next_page"
-visible true
}
GuidoButton databaseTableForm_end {
-icon "icons/ms_anim_forward_end.gif"
-legacy_button
-selected_value "last_page"
-visible true
}
}
}
for {set row_idx 0} {$row_idx < [$cons getRowCount]} {incr row_idx} {
if {[$field getCurrentValue $row_idx] > ""} {
$databaseTable addQueryRow [$field getCurrentValue $row_idx] [$operator getCurrentValue $row_idx] [$value getCurrentValue $row_idx]
}
}
$databaseTable connectToDatabase
$databaseTableForm_numLabel setCurrentValue [$databaseTable getPage]
$databaseTableForm_label setLabel [$databaseTable getNumPages]
set redisplaymain 1
while {$redisplaymain == 1} {
set redisplaymain 0
set mainaction [$databaseTableForm interact]
if {$mainaction == "next_page"} {
$databaseTable nextPage
$databaseTableForm_numLabel setCurrentValue [$databaseTable getPage]
set redisplaymain 1
} elseif {$mainaction == "last_page"} {
$databaseTable lastPage
$databaseTableForm_numLabel setCurrentValue [$databaseTable getPage]
set redisplaymain 1
} elseif {$mainaction == "prev_page"} {
$databaseTable prevPage
$databaseTableForm_numLabel setCurrentValue [$databaseTable getPage]
set redisplaymain 1
} elseif {$mainaction == "first_page"} {
$databaseTable firstPage
$databaseTableForm_numLabel setCurrentValue [$databaseTable getPage]
set redisplaymain 1
} else {
set redisplaymain 0
}
}
$databaseTable disconnectFromDatabase
$databaseTableForm destroy
} elseif {$action == "load_constraint"} {
GuidoForm loadconstraints {
-default_buttons
-label "Select Database Constraint File To Load"
GuidoFileBrowserField filename {
-display_length 32
-extension false
-file_mask *.dbc
-format none
-label Filename
-max_length FIO_MAX_LOCATION_LENGTH
-translate none
}
}
if { [$loadconstraints interact] == "apply" } {
if {[$filename getCurrentValue] != ""} {
set loadFileParams [GuidoExecServer "LoadDatabaseConstraintsFile" [subst {databasetype = "$databaseType" table = [$tableBrowser getCurrentValue] filename = [$filename getCurrentValue]}]]
set status [GuidoGetParamBufferValue $loadFileParams status]
if {$status >= 0} {
set num_rows [GuidoGetParamBufferValue $loadFileParams num_rows]
$cons setInitialRows $num_rows 1 17
for {set i 0} {$i < $num_rows} {incr i} {
$field    setCurrentValue $i "[GuidoGetParamBufferValue $loadFileParams field($i)]"
$operator setCurrentValue $i "[GuidoGetParamBufferValue $loadFileParams operator($i)]"
$value    setCurrentValue $i "[GuidoGetParamBufferValue $loadFileParams value($i)]"
}
}
}
}
$loadconstraints destroy
set redisplay_constraint 1
} elseif {$action == "save_constraint"} {
GuidoForm saveconstraints {
-default_buttons
-label "Select Database Constraint File To Save"
GuidoFileBrowserField filename {
-display_length 32
-extension false
-file_mask *.dbc
-format none
-label Filename
-max_length FIO_MAX_LOCATION_LENGTH
-translate none
-file_access write
}
}
set namefile 1
while {$namefile == 1} {
set namefile 0
if { [$saveconstraints interact] == "apply" } {
if {[$filename getCurrentValue] != ""} {
GuidoApp saveconstraints "SAVE DATABASE CONSTRAINTS FILE"
$saveconstraints setParam "filename" [$filename getCurrentValue]
set row 0
for {set row_idx 0} {$row_idx < [$cons getRowCount]} {incr row_idx} {
if {[$field getCurrentValue $row_idx] > ""} {
$saveconstraints setParam "field($row)"    [$field getCurrentValue $row_idx]
$saveconstraints setParam "operator($row)" [$operator getCurrentValue $row_idx]
$saveconstraints setParam "value($row)"    [$value getCurrentValue $row_idx]
incr row
}
}
$saveconstraints setParam num_rows $row
$saveconstraints invoke
} else {
set namefile 1
}
}
}
$saveconstraints destroy
set redisplay_constraint 1
} else {
set redisplay 1
}
}
}
}
}
$get_handle destroy
$selectTableForm destroy
$constrainTableForm destroy
