Click or drag to resize
RunSaveRecord Method
Saves the given record, with undo.

Namespace:  Biolomics.BioCallback
Assembly:  Biolomics.BioCallback (in Biolomics.BioCallback.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static bool SaveRecord(
	XRecord p_Record
)

Parameters

p_Record
Type: Biolomics.BioCallbackXRecord
The record to save.

Return Value

Type: Boolean
true if an error occures, false otherwise.
Examples
This is an exemple of loading remarks field information for first record and saving the record after edit
Example VB.Net
Imports System
Imports BioloMICS.BioCallback
Imports BioloMICS.SharedClasses

Public Class Program

    <STAThread()>
    Shared Sub Main()
        Dim program As New Program()
        program.EditRemarks()
    End Sub

    '    Write sub functions here
    Public Sub EditRemarks()
        '    get the current connection
        Dim SqlCo As XConnection = Run.GetCurrentConnection()
        If SqlCo Is Nothing Then
            Return
        End If

        '    get the current layout
        Dim Layout As XDataLayout = Run.GetCurrentLayout()
        If Layout Is Nothing Then  '    no current layout in a search page
            Return
        End If

        '    get the current table
        Dim TableDef As XTableDef = SqlCo.GetTableDef(Layout.TableKey)
        If TableDef Is Nothing Then   '    should never happen
            Return
        End If
        'gets the remarks field definition,it is a XEField
        Dim efield As XFieldDef = SqlCo.GetFieldByUserName("Your_Field_Name", Layout.TableKey)
        'add new XFieldDefMap to be used for loading record informations
        Dim fieldefmap As New XFieldDefMap
        'add remarks field
        If efield IsNot Nothing Then
            fieldefmap.Add(efield)
        Else
            Console.WriteLine("The remarks field is not found please check the field name to be loaded")
            'exits the function
            Exit Sub
        End If

        'load first record and changes the remarks field value
        Dim loadedrecod As XRecord = run.LoadRecord(Layout.TableKey, 1, fieldefmap)
        'check if the loaded record is not nothing to be sure that the records exists
        If loadedrecod IsNot Nothing Then
            'the record exists
            'gets the XEField to get and edit the value
            Dim xefield As XEField = CType(loadedrecod.Fields(efield.Key), xefield)
            If xefield IsNot Nothing Then
                Console.WriteLine("old efield value : " & xefield.Value)
                xefield.Value = "new value " & loadedrecod.Id
                'using saverecord to save the record
                run.SaveRecord(loadedrecod)
            End If
        Else
            Console.WriteLine("The record is not loaded check your database please.")
        End If

    End Sub

End Class
See Also