Imports IntraSell_DLL

Public Class ArtikelMengeWaehlen

    Public Event ArtikelGewaehlt(ByRef ArtNr As Decimal, ByRef Stk As Decimal)

    Dim IstMengeEingabe As Boolean = False
    Dim artikelGefunden
    Dim stk As Decimal = 1

    Private Sub ArtikelMengeWaehlen_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    End Sub

    Private Sub Ziffernblock1_AmountChanging(amount As Decimal) Handles Ziffernblock1.AmountChanging
        If Not IsNumeric(amount) Then
            Exit Sub
        End If
        If IstMengeEingabe Then
            stk = amount
            Me.txtMenge.Text = stk
        Else
            artikelGefunden = FirstRow("select artnr from grArtikel where EAN like '" & amount & "' and produktAktiv<>0 order by ArtNr desc")
            Me.txtEAN.Text = amount
            Me.lblArtikelBezeichnung.Text = IntraSell_DLL.ModuleArtikel.ArtikelBezeichnung(artikelGefunden)
        End If
    End Sub

    Private Sub Ziffernblock1_AmountChanged(amount As Decimal) Handles Ziffernblock1.AmountChanged
        If amount > 0 Then
            btnÜbernehmen_Click(Nothing, Nothing)
        End If
    End Sub

    Private Sub Ziffernblock1_AmountCleared() Handles Ziffernblock1.AmountCleared
        Me.txtEAN.Text = ""
        Me.lblArtikelBezeichnung.Text = ""
    End Sub


    Private Sub btnÜbernehmen_Click(sender As Object, e As EventArgs) Handles btnÜbernehmen.Click
        If IsNumeric(artikelGefunden) And IsNumeric(stk) Then
            RaiseEvent ArtikelGewaehlt(artikelGefunden, stk)
        End If
    End Sub

    Private Sub btnClose_Click(sender As Object, e As EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub txtEAN_MouseClick(sender As Object, e As MouseEventArgs) Handles txtEAN.MouseClick
        IstMengeEingabe = False
    End Sub

    Private Sub txtMenge_MouseClick(sender As Object, e As MouseEventArgs) Handles txtMenge.MouseClick
        IstMengeEingabe = True
    End Sub
End Class