Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Why the Method does not fire?
Message
Information générale
Forum:
ASP.NET
Catégorie:
Formulaires
Divers
Thread ID:
01235347
Message ID:
01235361
Vues:
13
I forgot to tell you that the parent form is not a form is a User COntrol. Here is the code from the User control.

Update --- I changed the .Show() to .Showdialog() and stop doing that behavior.
Public Class Department_UC
    Event closeactivetab(ByVal sender As System.Object, ByVal e As System.EventArgs)
    Public checkcount As Integer



    Public Sub CloseButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CloseButton.Click
        Me.Dispose()
        RaiseEvent closeactivetab(sender, e)

    End Sub

    Private Sub Department_UC_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Depts_LookupTableAdapter.Fill(Me.Depts_LookupDataSet.Depts_Lookup)
    End Sub



    Private Sub Department_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.Depts_LookupTableAdapter.Fill(Me.Depts_LookupDataSet.Depts_Lookup)
        Me.BackColor = My.Settings.Color5
        Me.Uan_SqlConnection.ConnectionString = My.Settings.UANConnection
        Me.Dept_Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor = My.Settings.Color6
        Me.Dept_Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor2 = My.Settings.Color6

        AddHandler My.Forms.DepartmentADD.Fill_Parent_Grid, AddressOf Fill_Parent_Grid
    End Sub


    Private Sub Dept_Grid_CellChange(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.CellEventArgs) Handles Dept_Grid.CellChange


        Dim binVisible As Boolean = False

        If e.Cell.Column.Key = "lsele" Then
            If CType(e.Cell.Text, Boolean) = True Then
                checkcount += 1
                e.Cell.Row.Appearance.BackColor = My.Settings.Color4
                e.Cell.Row.Appearance.BackColor2 = My.Settings.Color4
            Else
                checkcount -= 1
                e.Cell.Row.Appearance.ResetBackColor()
                e.Cell.Row.Appearance.ResetBackColor2()

            End If
            If checkcount = 0 Then
                binVisible = False
            Else
                binVisible = True

            End If
            Me.Del_btn.Enabled = binVisible
            Me.Edit_btn.Enabled = binVisible

            Me.Dept_Grid.Refresh()
        End If
    End Sub

    Private Sub Grid_doubleClickHeader(ByVal sender As Object, ByVal e As Infragistics.Win.UltraWinGrid.DoubleClickHeaderEventArgs) Handles Dept_Grid.DoubleClickHeader
        Dim Cvalue As String
        Dim drdepts As DataRow
        Dim I As Integer
        Dim rposition As CurrencyManager

        rposition = CType(Me.BindingContext(Me.Depts_LookupDataSet.Depts_Lookup), CurrencyManager)
        Me.Depts_LookupDataSet.GetChanges()
        rposition.Position = 0
        I = 0
        Cvalue = e.Header.Column.ToString

        Me.Dept_Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.FirstRowInGrid)
        If Cvalue = "lsele" Then
            For Each drdepts In Me.Depts_LookupDataSet.Tables(0).Rows
                If drdepts("lsele") = False Then
                    I = I + 1
                End If
            Next drdepts
            If I = 0 Then
                For Each drdepts In Me.Depts_LookupDataSet.Tables(0).Rows
                    Me.Dept_Grid.DisplayLayout.Override.RowAppearance.ResetBackColor()
                    Me.Dept_Grid.DisplayLayout.Override.RowAppearance.ResetBackColor2()
                    Me.Dept_Grid.DisplayLayout.EmptyRowSettings.RowAppearance.ResetBackColor()
                    Me.Dept_Grid.DisplayLayout.EmptyRowSettings.RowAppearance.ResetBackColor2()
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ResetBackColor()
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ResetBackColor2()
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ResetForeColor()
                    Me.Dept_Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor = My.Settings.Color6
                    Me.Dept_Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor2 = My.Settings.Color6
                    drdepts("lsele") = 0

                    Me.Dept_Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow)


                Next drdepts
            Else
                For Each drdepts In Me.Depts_LookupDataSet.Tables(0).Rows
                    Me.Dept_Grid.DisplayLayout.Override.RowAppearance.BackColor = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.RowAppearance.BackColor2 = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor2 = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ForeColor = Color.Black
                    Me.Dept_Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor2 = My.Settings.Color4
                    drdepts("lsele") = 1
                    Me.Dept_Grid.PerformAction(Infragistics.Win.UltraWinGrid.UltraGridAction.NextRow)

                Next drdepts

                Me.Dept_Grid.DisplayLayout.EmptyRowSettings.RowAppearance.BackColor = Color.White
                Me.Dept_Grid.DisplayLayout.EmptyRowSettings.RowAppearance.BackColor2 = Color.White

                Me.Add_btn.Focus()

            End If
            Dim xx As Integer
            System.Math.DivRem(Me.Dept_Grid.Rows.Count, 2, xx)
            If xx > 0 Then
                If I = 0 Then
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor = Color.White
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor2 = Color.White
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ForeColor = Color.Black
                    Me.Edit_btn.Enabled = False
                    Me.Del_btn.Enabled = False
                    checkcount = 0
                Else
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor2 = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ForeColor = Color.Black
                    Me.Edit_btn.Enabled = True
                    Me.Del_btn.Enabled = True
                    checkcount = Me.Dept_Grid.Rows.Count
                End If

            Else
                If I = 0 Then
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor = My.Settings.Color6
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor2 = My.Settings.Color6
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ForeColor = Color.Black
                    Me.Edit_btn.Enabled = False
                    Me.Del_btn.Enabled = False
                    checkcount = 0
                Else
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.BackColor2 = My.Settings.Color4
                    Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ForeColor = Color.Black
                    Me.Edit_btn.Enabled = True
                    Me.Del_btn.Enabled = True
                    checkcount = Me.Dept_Grid.Rows.Count
                End If

            End If


            Me.Dept_Grid.Refresh()
            'I = 0


            'For Each drdepts In Me.Depts_LookupDataSet.Tables(0).Rows
            '    If drdepts("lsele") = True Then
            '        I = I + 1
            '    End If
            'Next drdepts


            'If I = 0 Then
            '    Me.Edit_btn.Enabled = False
            '    Me.Del_btn.Enabled = False
            '    checkcount = 0
            'Else
            '    Me.Edit_btn.Enabled = True
            '    Me.Del_btn.Enabled = True
            '    checkcount = Me.Dept_Grid.Rows.Count

            'End If
        End If
    End Sub

    Private Sub Add_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add_btn.Click
        DepartmentADD.ShowDialog()
    End Sub

    Private Sub Edit_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Edit_btn.Click
        Dim frmDepartmentEdit1 As New DepartmentEdit(Me.Depts_LookupDataSet)
        frmDepartmentEdit1.ShowDialog()
        Me.checkcount = 0
        Me.Edit_btn.Enabled = False
        Me.Del_btn.Enabled = False
        Me.Fill_Parent_Grid()
        'You can also do frmEditDepartment1.ShowDialog
        'DepartmentEdit.Show(Me.Depts_LookupDataSet)
    End Sub

    Private Sub Del_btn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Del_btn.Click
        Dim error_msg As String
        Dim depts_changes As New DataView
        Dim drdepts As DataRowView

        Dim I As Integer
        Dim Y As Integer
        error_msg = "Some of the record selected is been using in other"
        error_msg = error_msg + vbCrLf + "databases:"
        depts_changes.Table = Me.Depts_LookupDataSet.Tables(0)
        depts_changes.RowFilter = "Lsele = True"

        For Each drdepts In depts_changes
            Try
                Me.Dept_Delete_SQLCMD.Parameters("@Dept_Pk").Value = drdepts("DepartmentsPK")
                'Me.Dept_Delete_SQLCMD.Parameters("@Return_Value").Value = 0
                Me.Uan_SqlConnection.Open()
                Me.Dept_Delete_SQLCMD.ExecuteNonQuery()
                Me.Uan_SqlConnection.Close()
                If Me.Dept_Delete_SQLCMD.Parameters("@Return_Value").Value = True Then
                    I = I + 1
                    error_msg = error_msg + vbCrLf + drdepts("DepartmentAbbreviation") + "    " + drdepts("DepartmentName")
                Else
                    Y = Y + 1
                End If
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
                Me.Uan_SqlConnection.Close()
            End Try
        Next
        If I > 0 Then
            MessageBox.Show(error_msg)
        End If
        If Y > 0 Then
            Me.MSG_TXT.Text = CType(Y, String) + " record(s) has been deleted"
        End If
        Me.Fill_Parent_Grid()

    End Sub
    Public Sub Fill_Parent_Grid()
        Me.Depts_LookupTableAdapter.Fill(Me.Depts_LookupDataSet.Depts_Lookup)
        Me.Dept_Grid.DisplayLayout.Override.RowAppearance.ResetBackColor()
        Me.Dept_Grid.DisplayLayout.Override.RowAppearance.ResetBackColor2()
        Me.Dept_Grid.DisplayLayout.EmptyRowSettings.RowAppearance.ResetBackColor()
        Me.Dept_Grid.DisplayLayout.EmptyRowSettings.RowAppearance.ResetBackColor2()
        Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ResetBackColor()
        Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ResetBackColor2()
        Me.Dept_Grid.DisplayLayout.Override.SelectedRowAppearance.ResetForeColor()
        Me.Dept_Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor = My.Settings.Color6
        Me.Dept_Grid.DisplayLayout.Override.RowAlternateAppearance.BackColor2 = My.Settings.Color6
        Me.checkcount = 0
        Me.Edit_btn.Enabled = False
        Me.Del_btn.Enabled = False
    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
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform