Attribute VB_Name = "retourek"

Public dev(3), faxjn(3)
Public idkopf
Public dirtykopf As Boolean
Public kopfbewart
Public sema1, sema2 As Boolean
Public posbewart As String
Public sammeljn As Boolean
Public nachkjn As Boolean

Public einh_cnt As Integer
Public einh_code(100) As String
Public einh_bez(100) As String

Public eanerg As Boolean
Public posdirty As Boolean
Public glob1, glob2
Public demojn As Boolean
Public lsnrjn As Boolean

Public hgbaujn As Boolean
Public expert As Integer

Public berctest As String

Public posanz As Long

Public Status(5)

Public Const fixStandort = 0

Public Const lizenzdate = #3/15/2020#

Sub dberror()

End Sub





Sub toolenabled()

  With FMStart
  
    st = .LIStatus.ListIndex
    .LIStatus.Enabled = (ACCESS >= expert)
    'st<5
    .Tool2.ItemEnabled(1) = (dirtykopf And .txtLnr <> "" And .TXTLnr1 <> "" And .LIRetart.ListIndex > 0 And .LIRetTyp.ListIndex > 0)
    .Tool2.ItemEnabled(2) = True
    .Tool2.ItemEnabled(3) = (st > 0)
    .Tool2.ItemEnabled(4) = (st > 0)
    .Tool2.ItemEnabled(5) = (st > 0)
    .Tool2.ItemEnabled(6) = (st > 0) And ACCESS >= expert
    .Tool2.ItemEnabled(7) = ACCESS >= expert And posanz = 0
  End With

End Sub


Sub set_verhalten(verh As String)

With FMPos
    .CHLager.Value = Val(Mid(verh, 1, 1))
    .CHReparatur.Value = Val(Mid(verh, 2, 1))
    .CHGarantie.Value = Val(Mid(verh, 3, 1))
    .CHAustausch.Value = Val(Mid(verh, 4, 1))
    .CHKundbeleg.Value = Val(Mid(verh, 5, 1))
    .CHLiefBeleg.Value = Val(Mid(verh, 6, 1))
End With

End Sub

Sub pos_neu()
 
 sema1 = True
 
 With FMPos

    .Frame1.Visible = True
    .TXTAnr.SetFocus
    
    .LIStatus.ListIndex = 0
    
    .TXTPos.Text = "NEU"
    
    .TXTKnr.Text = FMStart.TXTKnr.Text
    .TXTAnr.Text = ""
    .TXTKbez.Text = ""
    .TXTBez1.Text = ""
    .TXTBez2.Text = ""
    .TXTNotiz.Text = ""
    .TXTEPM.Value = 1
    .TXTVPM.Value = 1
    .TXTVPM1.Value = 1
   
    .MEVPE.Value = 1
    .MEVRE.Value = 1
    .MEERE.Value = 1
    .MEVKE.Value = 1
     
    .TXTEPM.Value = 1
    .TXTVPI.Value = 1
    .TXTVRM.Value = 1
    .TXTEVM.Value = 1
    
    .LIVKE.Text = "ST"
    .LIVPE.Text = "ST"
    .LIVRE.Text = "ST"
    .LIERE.Text = "ST"
    .TXTVRE.Text = "ST"
    
    .Poswert = 0
    .TXTKRechnr = ""
    .TXTKAunr = ""
    .TXTKLiefRechnr = ""
    .TXTKBnr = ""
    '.TXTKLsnr = ""
    
    posbewart = kopfbewart
    Select Case posbewart
       Case "D"
           .OPBewDurch.Value = True
       Case "A"
           .OPBewAkt.Value = True
       Case "L"
           .OPBewLetzt.Value = True
    End Select
    .txtest.Value = 0
     verhalten = Piece(FMStart.LIRetTyp.ListCargo(FMStart.LIRetTyp.ListIndex), "|", 2)
     set_verhalten (verhalten)
     
     sammeljn = False
     nachkjn = False
     
     FMPos.setvis
    
 End With
 sema1 = False
 
End Sub


Sub beleg_neu()

With FMStart

    .Frame1.Visible = True
    .TXTBelnr.Text = "NEU"
    .TXTDatum.DateValue = Date
    
    .TXTErfPers.Text = Piece(Personal, "|", 1)
    .TXTErfDatum.Text = Date
    
    .LIStatus.ListIndex = 0
    .txtLnr.Text = ""
    .TXTLName.Text = ""
    .TXTLnr1.Text = ""
    .TXTLName1.Text = ""
    .TXTKnr.Text = "99999"
    .TXTKName.Text = ""
    .TXTKnr_LostFocus
    
    .LIRetart.ListIndex = 0
    .LIRetTyp.ListIndex = 0
    
    
    LockEIN
    Set obj = WWS_Server.OpenId("RETOUREK.Para", Firma)
    kopfbewart = obj.bewart
    obj.sys_close
    Set obj = Nothing
    LockAUS
    
    .OPBewDurch.Value = False
    .OPBewLetzt.Value = False
    .OPBewAkt.Value = False
    If kopfbewart = "D" Then .OPBewDurch.Value = True
    If kopfbewart = "L" Then .OPBewLetzt.Value = True
    If kopfbewart = "A" Then .OPBewAkt.Value = True
    
    
    .LIRetart.ListIndex = 0
    .LIRetTyp.ListIndex = 0
    
    .txtLnr.SetFocus
    
    .Tool2.ItemEnabled(1) = False
    .Tool2.ItemEnabled(2) = False
    .Tool2.ItemEnabled(5) = False
    .Tool2.ItemEnabled(6) = False
    
    .lipaketnr.ClearItems
    .lipaketnr.AddItem ""
     
    toolenabled
    dirtykopf = False
    
End With
idkopf = ""
End Sub

Sub suche()
Dim rs As CacheObject.ResultSet

'1=status,2=datum-von,3=datum-bis,4=abteilung,5=lief,6=paketnr
erg = GetSetting("Retourek", "Filter", "Filter")
If erg = "" Then Exit Sub

LockEIN
Set rs = WWS_Server.ResultSet("RETOUREK.Kopf", "SucheTEST")

rs.execute Firma, Piece(erg, "|", 1), CDate(Piece(erg, "|", 2)), CDate(Piece(erg, "|", 3)), Piece(erg, "|", 4), Piece(erg, "|", 5), Piece(erg, "|", 6), Piece(erg, "|", 7), Piece(erg, "|", 8)
With FMStart
 .LIBeleg.ClearList
 i = 0
 While rs.Next()
   .LIBeleg.AddItem rs.GetData(2) & Chr(10) & rs.GetData(3) & Chr(10) & rs.GetData(4) & Chr(10) & rs.GetData(5) & Chr(10) & rs.GetData(6) & Chr(10) & rs.GetData(7) & Chr(10) & rs.GetData(8) & Chr(10) & rs.GetData(9) & Chr(10) & rs.GetData(10) & Chr(10) & rs.GetData(11) & Chr(10) & Format(rs.GetData(12), "###,##0.00") & Chr(10) & rs.GetData(13)
   .LIBeleg.ListCargo(i) = rs.GetData(1)
   i = i + 1
 Wend
 rs.Close
 Set rs = Nothing
End With
LockAUS

End Sub


 ' Public Function getWindowPos(ByVal obj As Form, ByVal Name As String) As Boolean
 '       s = GetSetting("Retourek", "Windowpos", Name, "")
 '       If s <> "" Then
 '           obj.left = Val(Piece(s, "|", 1))
 '           obj.top = Val(Piece(s, "|", 2))
 '           obj.Width = Val(Piece(s, "|", 3))
 '           obj.Height = Val(Piece(s, "|", 4))
 '       End If
 '       getWindowPos = (s <> "")
 '  End Function

 '  Public Sub setWindowPos(ByVal obj As Form, ByVal Name As String)

 '       If obj.WindowState = 1 Then Exit Sub
        
 '       s = Format(obj.left) & "|" & Format(obj.top) & "|" & Format(obj.Width) & "|" & Format(obj.Height)
 '       SaveSetting "Retourek", "Windowpos", Name, s

'   End Sub
