Imports IntraSell_DLL
Imports IntraSell_Net_Base
Public Class ArtikelKategorien
    Inherits AbstractForm

    Private Sub Form_Verlassen() Handles MyBase.Verlassen
        Me.Close()
    End Sub

    Private Sub Grartikel_kategorienBindingNavigatorSaveItem_Click(sender As Object, e As System.EventArgs) Handles MyBase.Save
        Try
            ErrorProvider1.Clear()
            If NameTextBox.Text = "" Then
                ErrorProvider1.SetError(NameTextBox, "Name fehlt!")
                Exit Sub
            End If

            If ArtKatNrTextBox.Text = "" Then
                ErrorProvider1.SetError(ArtKatNrTextBox, "ArtKatNr fehlt!")
                Exit Sub
            End If

            Validate()
            Grartikel_kategorienBindingSource.EndEdit()
            TableAdapterManager.UpdateAll(DsArtikel)
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub ArtikelKategorien_Load(sender As Object, e As System.EventArgs) Handles MyBase.Load
        Try
            ds = DsArtikel
            ParentBindingNavigator.BindingSource = Grartikel_kategorienBindingSource
            Grartikel_kategorienTableAdapter.Fill(DsArtikel._grartikel_kategorien)
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub ButtonHGFarbe_Click(sender As Object, e As EventArgs) Handles ButtonHGFarbe.Click
        Dim cDialog As New ColorDialog With {
            .Color = StylesheetTextBox.BackColor ' initial selection is current color.
            }

        If (cDialog.ShowDialog() = DialogResult.OK) Then
            StylesheetTextBox.BackColor = cDialog.Color ' update with user selected color.
            StylesheetTextBox.Text = cDialog.Color.ToArgb
        End If
    End Sub

    Private Sub Grartikel_kategorienBindingSource_CurrentItemChanged(sender As Object, e As EventArgs) Handles Grartikel_kategorienBindingSource.CurrentItemChanged
        Try
            If IsNumeric(StylesheetTextBox.Text) Then
                StylesheetTextBox.BackColor = Color.FromArgb(StylesheetTextBox.Text)
            Else
                StylesheetTextBox.BackColor = Color.White
            End If
        Catch ex As Exception
        End Try
    End Sub

    Private Sub DataGridViewVorgangPositionen_CellFormatting(sender As Object, e As DataGridViewCellFormattingEventArgs) Handles DataGridView1.CellFormatting
        Dim STYLE_COL_INDEX = 8
        Try
            If e.ColumnIndex = STYLE_COL_INDEX Then
                Dim bgCol = DataGridView1.Rows(e.RowIndex).Cells(STYLE_COL_INDEX).Value
                DataGridView1.Rows(e.RowIndex).DefaultCellStyle.BackColor = Color.FromArgb(bgCol)
            End If
        Catch ex As Exception
        End Try
    End Sub

    Private Sub DataGridView1_DataError(sender As Object, e As DataGridViewDataErrorEventArgs) Handles DataGridView1.DataError

    End Sub


End Class