'''
''' Override the ${Copy Button}_Click and get selected records
''' and create new database records.
'''
Public Overrides Sub ${Copy Button}_Click(ByVal sender As Object, ByVal args As EventArgs)
Try
DbUtils.StartTransaction()
Dim selectedRecords As ${Table Name}TableControlRow() = Me.GetSelectedRecordControls()
If (selectedRecords.Length > 0) Then
Dim ${Table Name}Rec As ${Table Name}TableControlRow
For Each ${Table Name}Rec In selectedRecords
Dim newRec As New ${${Table Name}RecordClassName}
newRec = CType(${Table Name}Rec.GetRecord.CopyRecord(), ${${Table Name}RecordClassName})
newRec.Save()
Next
DbUtils.CommitTransaction()
End If
Catch ex As Exception
DbUtils.RollBackTransaction()
'Report the error message to the user
Utils.MiscUtils.RegisterJScriptAlert(Me, "UNIQUE_SCRIPTKEY", ex.Message)
Finally
DbUtils.EndTransaction()
End Try
End Sub
|