Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Update the Dataset
Message
 
À
21/06/2007 21:40:11
Information générale
Forum:
ASP.NET
Catégorie:
ADO.NET
Versions des environnements
Environment:
VB 8.0
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01233541
Message ID:
01235010
Vues:
25
Bonnie:

Here is the complete code for the edit form. I add the code you suggested but still I dont see the changes when i move out of the record and come back using the navigator control.
Public Class DepartmentEdit
    Dim Depts_changes_final As New DataSet
    Dim depts_changes As New DataView
    Dim rposition As CurrencyManager
    Dim depts_DB As New BindingSource

    Private Sub Dept_Retrieve_value(ByVal Dept_PK As Integer)
        Try
            Me.Dept_SQLRetrieve.Parameters("@Dept_Pk").Value = Dept_PK
            Me.Dept_SQLRetrieve.Parameters("@Dept_abr").Value = ""
            Me.Dept_SQLRetrieve.Parameters("@Dept_Name").Value = ""
            Me.Department_SQLCN.Open()
            Me.Dept_SQLRetrieve.ExecuteNonQuery()
            Me.Department_SQLCN.Close()
            Me.Dept_AbbTxt.Text = Me.Dept_SQLRetrieve.Parameters("@Dept_abr").Value
            Me.Dept_nameTXT.Text = Me.Dept_SQLRetrieve.Parameters("@Dept_Name").Value
           
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
            Me.Department_SQLCN.Close()

        End Try

    End Sub
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If Len(Trim(Me.Dept_nameTXT.Text)) = 0 Then
            MessageBox.Show("The value of the Department Name can be empty")
            Return
        End If
        If Len(Trim(Me.Dept_AbbTxt.Text)) = 0 Then
            MessageBox.Show("The value of the Department Abbreviation can be empty")
            Return
        End If
        Try
            Me.Dept_SqlCommand.Parameters("@Dept_Pk").Value = Me.Dept_PkTxt.Text
            Me.Dept_SqlCommand.Parameters("@Dept_abr").Value = Me.Dept_AbbTxt.Text
            Me.Dept_SqlCommand.Parameters("@Dept_Name").Value = Me.Dept_nameTXT.Text
            Me.Department_SQLCN.Open()
            Me.Dept_SqlCommand.ExecuteNonQuery()
            Me.Department_SQLCN.Close()
            Me.DisplayMessageLabel.Text = Trim(Me.Dept_nameTXT.Text) + " Edited"
            If rposition.Position < rposition.Count - 1 Then
                Me.Dept_selection_BNav.MoveNextItem.PerformClick()
                If CType(Me.Dept_PkTxt.Text, Integer) >= 0 Then
                    Me.Dept_Retrieve_value(CType(Me.Dept_PkTxt.Text, Integer))
                End If
            Else
                rposition.Position = 0
                Me.Dept_selection_BNav.MoveFirstItem.PerformClick()
                If CType(Me.Dept_PkTxt.Text, Integer) >= 0 Then
                    Me.Dept_Retrieve_value(CType(Me.Dept_PkTxt.Text, Integer))
                End If
            End If
        Catch ex As Exception
            MessageBox.Show(ex.ToString)
            Me.Department_SQLCN.Close()
        End Try

    End Sub

    Private Sub DepartmentEdit_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'Depts_LookupDataSet.Depts_Lookup' table. You can move, or remove it, as needed.
        Me.Dept_nameTXT.BackColor = My.Settings.RequiredFields
        Me.Dept_AbbTxt.BackColor = My.Settings.RequiredFields
        Me.BackColor = My.Settings.Background

        rposition.Position = 0
        If CType(Me.Dept_PkTxt.Text, Integer) >= 0 Then
            ' Me.Dept_Retrieve_value(CType(Me.Dept_PkTxt.Text, Integer))
        End If
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()
        My.Forms.Department.Depts_LookupTableAdapter.Fill(My.Forms.Department.Depts_LookupDataSet.Depts_Lookup)
        My.Forms.Department.checkcount = 0
        My.Forms.Department.Del_btn.Enabled = False
        My.Forms.Department.Edit_btn.Enabled = False

    End Sub

    Public Sub New(ByVal parentdataset As DataSet)
        Depts_changes_final = parentdataset

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        Dim depts_lookupdataset2 As New DataSet
        depts_changes.Table = parentdataset.Tables(0)
        depts_changes.RowFilter = "Lsele = True"
        depts_changes.AllowEdit = True
        rposition = CType(Me.BindingContext(depts_changes), CurrencyManager)

        depts_DB.DataSource = depts_changes
        Me.Dept_selection_BNav.BindingSource = depts_DB

        Me.Dept_PkTxt.DataBindings.Add("Text", depts_changes, depts_changes.Table.Columns(1).ToString)
        Me.Dept_nameTXT.DataBindings.Add("Text", depts_changes, depts_changes.Table.Columns(3).ToString)
        Me.Dept_AbbTxt.DataBindings.Add("Text", depts_changes, depts_changes.Table.Columns(2).ToString)
        depts_changes.AllowEdit = True
       
        ' Add any initialization after the InitializeComponent() call.
    End Sub

    
    Private Sub BindingNavigatorMovePreviousItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMovePreviousItem.Click
        If rposition.Position > 0 Then
            Me.depts_DB.EndEdit()
            Me.Dept_selection_BNav.BindingSource.EndEdit()
            rposition.Position = rposition.Position - 1
            'If CType(Me.Dept_PkTxt.Text, Integer) >= 0 Then
            '    Me.Dept_Retrieve_value(CType(Me.Dept_PkTxt.Text, Integer))
            'End If

        End If
    End Sub

    Private Sub BindingNavigatorMoveNextItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveNextItem.Click
        If rposition.Position < rposition.Count - 1 Then
            Me.depts_DB.EndEdit()
            Me.Dept_selection_BNav.BindingSource.EndEdit()
            rposition.Position = rposition.Position + 1
            'If CType(Me.Dept_PkTxt.Text, Integer) >= 0 Then
            '    Me.Dept_Retrieve_value(CType(Me.Dept_PkTxt.Text, Integer))
            'End If
        End If
    End Sub

    Private Sub BindingNavigatorMoveFirstItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveFirstItem.Click
        rposition.Position = 0
        Me.depts_DB.EndEdit()
        If CType(Me.Dept_PkTxt.Text, Integer) >= 0 Then
            'Me.Dept_Retrieve_value(CType(Me.Dept_PkTxt.Text, Integer))
        End If

    End Sub

    Private Sub BindingNavigatorMoveLastItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BindingNavigatorMoveLastItem.Click
        Me.depts_DB.EndEdit()
        Me.Dept_selection_BNav.BindingSource.EndEdit()
        rposition.Position = rposition.Count - 1
        If CType(Me.Dept_PkTxt.Text, Integer) >= 0 Then
            'Me.Dept_Retrieve_value(CType(Me.Dept_PkTxt.Text, Integer))
        End If

    End Sub

    Private Sub Dept_nameTXT_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dept_nameTXT.LostFocus
        Me.depts_DB.EndEdit()
        Me.Dept_selection_BNav.BindingSource.EndEdit()
        Me.depts_changes.Table.Rows(3).EndEdit()

    End Sub

   
End Class
Gregorio J. Placeres
IT Analyst
Uniform Accounting Network
Auditor of State of Ohio
88 East Broad Street
P.O. Box 1140
Columbus, Ohio 43216-1140

Tel. 614-728-4694

Gregorio_J@MSN.COM

http://www.gjpproductions.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform