Imports IntraSell_DLL
Imports IntraSell_Net_Base

Public Class VorgangAktion
    Inherits AbstractForm
    Private Sub VorgangAktion_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Try
            ParentBindingNavigator.Visible = False
            BuchvorgaengestatusTableAdapter.Fill(DsVorgaenge.buchvorgaengestatus)
        Catch
        End Try
    End Sub

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

    Public Sub ShowStatus(vorgangTyp As String, status As String)
        BuchvorgaengestatusBindingSource.Filter = "VorgangTyp='" & vorgangTyp & "' and Status = '" & status & "'"
        If BuchvorgaengestatusBindingSource.Current Is Nothing Then
            Dim newRow = BuchvorgaengestatusBindingSource.AddNew()
            Dim r As dsVorgaenge.buchvorgaengestatusRow = newRow.Row
            TextBoxTyp.Text = vorgangTyp
            TextBoxStatus.Text = status
            chkKundenInformieren.Checked = False
            r.VorgangTyp = vorgangTyp
            r.Status = status
            r.KundenInformieren = False
        End If
    End Sub

    Private Sub BuchvorgaengestatusBindingSource_CurrentChanged(sender As Object, e As EventArgs) Handles BuchvorgaengestatusBindingSource.CurrentChanged
        Try
            TextBoxStyle.BackColor = ColorTranslator.FromHtml(TextBoxStyle.Text)
        Catch ex As Exception

        End Try
    End Sub

    Private Sub TextBox5_MouseDown(sender As Object, e As MouseEventArgs) Handles TextBoxStyle.MouseDown
        Try
            Dim s = TextBoxStyle.Text
            Dim cDialog As New ColorDialog()
            Try
                cDialog.Color = ColorTranslator.FromHtml(s)
            Catch ex As Exception

            End Try

            If (cDialog.ShowDialog() = DialogResult.OK) Then
                TextBoxStyle.BackColor = cDialog.Color ' update with user selected color.
                TextBoxStyle.Text = ColorTranslator.ToHtml(cDialog.Color)
            End If
        Catch ex As Exception

        End Try
    End Sub

    Private Sub ButtonSave_Click(sender As Object, e As EventArgs) Handles ButtonSave.Click
        Try
            BuchvorgaengestatusBindingSource.EndEdit()
            BuchvorgaengestatusTableAdapter.Update(DsVorgaenge)

            If TextBoxSendEmailAn.Text <> "" Or TextBoxSendSMSAn.Text <> "" Then
                Close()
            Else
                TextBoxSendEmailAn.BackColor = Color.Red
                TextBoxSendSMSAn.BackColor = Color.Red
            End If
        Catch ex As Exception
            HandleAppError(ex)
        End Try
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Close()
    End Sub
End Class