Imports C1.Data

Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents C1DataSet1 As C1.Data.C1DataSet
    Friend WithEvents button3 As System.Windows.Forms.Button
    Friend WithEvents button2 As System.Windows.Forms.Button
    Friend WithEvents button1 As System.Windows.Forms.Button
    Friend WithEvents dataGrid1 As System.Windows.Forms.DataGrid
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.C1DataSet1 = New C1.Data.C1DataSet()
        Me.button3 = New System.Windows.Forms.Button()
        Me.button2 = New System.Windows.Forms.Button()
        Me.button1 = New System.Windows.Forms.Button()
        Me.dataGrid1 = New System.Windows.Forms.DataGrid()
        CType(Me.C1DataSet1, System.ComponentModel.ISupportInitialize).BeginInit()
        CType(Me.dataGrid1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'C1DataSet1
        '
        Me.C1DataSet1.BindingContextCtrl = Me
        Me.C1DataSet1.DataLibrary = "DataLibrary"
        Me.C1DataSet1.DataLibraryUrl = "tcp://localhost:8000/ThreeTierServer.soap"
        Me.C1DataSet1.DataSetDef = "DataSet"
        Me.C1DataSet1.Locale = New System.Globalization.CultureInfo("en-US")
        Me.C1DataSet1.Name = "C1DataSet1"
        Me.C1DataSet1.SchemaClassName = "DataLibrary.DataClass"
        Me.C1DataSet1.SchemaDef = Nothing
        '
        'button3
        '
        Me.button3.Location = New System.Drawing.Point(544, 352)
        Me.button3.Name = "button3"
        Me.button3.Size = New System.Drawing.Size(120, 32)
        Me.button3.TabIndex = 7
        Me.button3.Text = "MyCustomUpdate()"
        '
        'button2
        '
        Me.button2.Location = New System.Drawing.Point(368, 352)
        Me.button2.Name = "button2"
        Me.button2.Size = New System.Drawing.Size(120, 32)
        Me.button2.TabIndex = 6
        Me.button2.Text = "MyCustomFill()"
        '
        'button1
        '
        Me.button1.Location = New System.Drawing.Point(184, 352)
        Me.button1.Name = "button1"
        Me.button1.Size = New System.Drawing.Size(120, 32)
        Me.button1.TabIndex = 5
        Me.button1.Text = "c1DataSet1.Update()"
        '
        'dataGrid1
        '
        Me.dataGrid1.DataMember = "Employees"
        Me.dataGrid1.DataSource = Me.C1DataSet1
        Me.dataGrid1.HeaderForeColor = System.Drawing.SystemColors.ControlText
        Me.dataGrid1.Location = New System.Drawing.Point(16, 16)
        Me.dataGrid1.Name = "dataGrid1"
        Me.dataGrid1.Size = New System.Drawing.Size(808, 320)
        Me.dataGrid1.TabIndex = 4
        '
        'Form1
        '
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(832, 397)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.button3, Me.button2, Me.button1, Me.dataGrid1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        CType(Me.C1DataSet1, System.ComponentModel.ISupportInitialize).EndInit()
        CType(Me.dataGrid1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button1.Click
        C1DataSet1.Update()
    End Sub

    Private Sub button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button2.Click
        Dim filters As FilterConditions = New FilterConditions()
        filters.Add(New FilterCondition(Nothing, "Employees", "[City] = 'London'"))
        Dim dataSet As C1DataSet = CType(C1DataSet1.RemoteDataService, DataLibrary.RemoteService).MyCustomFill("Employees", filters)
        dataGrid1.DataSource = dataSet
        dataGrid1.DataMember = "Employees"
    End Sub

    Private Sub button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles button3.Click
        Dim changesDataSet As C1DataSet = C1DataSet1.GetChanges()
        If Not changesDataSet Is Nothing Then
            Dim dataSet As C1DataSet = CType(C1DataSet1.RemoteDataService, DataLibrary.RemoteService).MyCustomUpdate(changesDataSet)
            C1DataSet1.Merge(dataSet)
            C1DataSet1.AcceptChanges()
        End If
    End Sub
End Class
