VERSION 5.00
Begin VB.Form BaseItemFormer_mtnc 
   BorderStyle     =   3  'Fixed Dialog
   ClientHeight    =   4755
   ClientLeft      =   2640
   ClientTop       =   1305
   ClientWidth     =   4125
   ClipControls    =   0   'False
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4755
   ScaleWidth      =   4125
   ShowInTaskbar   =   0   'False
   Begin VB.PictureBox pic_Full 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H00C0C0C0&
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   480
      Left            =   3324
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   12
      Top             =   2685
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.TextBox txt_SAP 
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   1200
      Locked          =   -1  'True
      MaxLength       =   40
      TabIndex        =   11
      Top             =   990
      Width           =   1680
   End
   Begin VB.ListBox lst_Former 
      DragIcon        =   "BI_FORM.frx":0000
      ForeColor       =   &H00000000&
      Height          =   1815
      ItemData        =   "BI_FORM.frx":0442
      Left            =   1200
      List            =   "BI_FORM.frx":0444
      Sorted          =   -1  'True
      TabIndex        =   10
      Top             =   2640
      Width           =   1680
   End
   Begin VB.TextBox txt_Former 
      ForeColor       =   &H00000000&
      Height          =   288
      Left            =   1200
      MaxLength       =   20
      TabIndex        =   9
      Top             =   1680
      Width           =   1680
   End
   Begin VB.PictureBox pic_pic 
      Appearance      =   0  'Flat
      BackColor       =   &H80000005&
      ClipControls    =   0   'False
      ForeColor       =   &H80000008&
      Height          =   665
      Left            =   0
      ScaleHeight     =   630
      ScaleWidth      =   4095
      TabIndex        =   5
      Top             =   0
      Width           =   4125
      Begin VB.PictureBox pic_Save 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "BI_FORM.frx":0446
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   60
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   8
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "BI_FORM.frx":0750
         BeginProperty Font 
            Name            =   "MS Sans Serif"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   1200
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   7
         Top             =   60
         Width           =   480
      End
      Begin VB.PictureBox pic_UnDo 
         Appearance      =   0  'Flat
         AutoRedraw      =   -1  'True
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         ForeColor       =   &H80000008&
         Height          =   480
         Left            =   660
         ScaleHeight     =   480
         ScaleWidth      =   480
         TabIndex        =   6
         Top             =   60
         Width           =   480
      End
   End
   Begin VB.PictureBox pic_In 
      AutoSize        =   -1  'True
      Height          =   540
      Left            =   1800
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   4
      Top             =   2040
      Width           =   540
   End
   Begin VB.PictureBox pic_Trash 
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H00C0C0C0&
      BorderStyle     =   0  'None
      Height          =   384
      Left            =   3312
      ScaleHeight     =   390
      ScaleWidth      =   390
      TabIndex        =   3
      Top             =   2685
      Width           =   384
   End
   Begin VB.PictureBox ico_Right 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      ForeColor       =   &H80000008&
      Height          =   480
      Left            =   480
      ScaleHeight     =   450
      ScaleWidth      =   450
      TabIndex        =   2
      Top             =   2565
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.PictureBox ico_Empty 
      AutoSize        =   -1  'True
      Height          =   540
      Left            =   468
      Picture         =   "BI_FORM.frx":0A5A
      ScaleHeight     =   480
      ScaleWidth      =   480
      TabIndex        =   1
      Top             =   3060
      Visible         =   0   'False
      Width           =   540
   End
   Begin VB.PictureBox ico_Drop 
      Appearance      =   0  'Flat
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      FontTransparent =   0   'False
      ForeColor       =   &H80000008&
      Height          =   480
      Left            =   480
      ScaleHeight     =   450
      ScaleWidth      =   450
      TabIndex        =   0
      Top             =   3660
      Visible         =   0   'False
      Width           =   480
   End
   Begin VB.Label lbl_screen 
      Caption         =   "SKUC"
      Height          =   255
      Left            =   315
      TabIndex        =   15
      Top             =   4320
      Visible         =   0   'False
      Width           =   855
   End
   Begin VB.Label lbl_Sap 
      Alignment       =   2  'Center
      Height          =   210
      Left            =   1470
      TabIndex        =   14
      Top             =   735
      Width           =   1125
   End
   Begin VB.Label lbl_Separator 
      Alignment       =   2  'Center
      Height          =   210
      Left            =   180
      TabIndex        =   13
      Top             =   1395
      Width           =   3750
   End
End
Attribute VB_Name = "BaseItemFormer_mtnc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim ms_Former As String
Dim mi_Index As Integer

Private Sub pic_Trash_DragDrop(Source As Control, X As Single, Y As Single)

    On Error GoTo pic_Trash_DragDrop_Err
    
    If mi_Index < 0 Then Exit Sub
    lst_Former.RemoveItem mi_Index
    txt_Former = ""
    mi_Index = -1
    pic_Full.Visible = OK
    pic_Trash.Visible = KO
    Exit Sub
    
pic_Trash_DragDrop_Err:
    StdError
End Sub

Private Sub pic_full_DragDrop(Source As Control, X As Single, Y As Single)

    On Error GoTo pic_full_DragDrop_Err
    
    If mi_Index < 0 Then Exit Sub
    lst_Former.RemoveItem mi_Index
    txt_Former = ""
    mi_Index = -1
    Exit Sub
    
pic_full_DragDrop_Err:
    StdError
End Sub

Private Sub Permission()
Dim ls_Req As String
Dim ls_Perm As String
Dim ll_Statement As Long
Dim li_Status As Integer

    On Error GoTo Permission_Err
    
    pic_Save.Visible = KO
    pic_Undo.Visible = KO
    pic_In.Visible = KO
    pic_Trash.Visible = KO
    ls_Req = "EXEC Check_Security 'Converting', '" _
            & prg.LoginName & "'"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Perm = ODBCData(ll_Statement, 1)
            If ls_Perm = "Update" Then
                pic_Save.Visible = OK
                pic_Undo.Visible = OK
                pic_In.Visible = OK
                pic_Trash.Visible = OK
            End If
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
    
Permission_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Sub

Private Sub Form_Load()
    
    On Error GoTo Form_Load_Err
    
    MouseOff
    
    If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me

    ico_Drop.Picture = LoadResPicture(RES_DROP, 1)
    ico_Right.Picture = LoadResPicture(RES_DRAG, 1)
    pic_In.Picture = LoadResPicture(RES_DOWN2, 1)
    pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
    pic_Save.Picture = LoadResPicture(RES_OK, 1)
    pic_Trash.Picture = LoadResPicture(RES_DELETE, 1)
    pic_Undo.Picture = LoadResPicture(RES_CANCEL, 1)
    pic_Full.Picture = LoadResPicture(RES_DELETEFULL, 1)
    Permission
    BaseItem_detail.lst_On_What.Visible = KO
    BaseItem_detail.lst_Former.Visible = KO
    FillCsts
    FillList
    MouseOn
    Exit Sub
    
Form_Load_Err:
    StdError
End Sub

Private Sub FillCsts()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim ls_Field As String, ls_Text As String
   
    On Error GoTo FillCsts_Err
    
    ls_Req = "EXEC Screen_Csts 'SKUC', " _
            & gut_LangLogin.Code
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            ls_Field = ODBCData(ll_Statement, 1)
            ls_Text = ODBCData(ll_Statement, 2)
            Select Case ls_Field
            Case "lbl_sap": lbl_SAP = ls_Text
            Case "title": Caption = ls_Text
            Case "lbl_separator": lbl_Separator = ls_Text
            End Select
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
    
FillCsts_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Sub

Private Sub lst_Former_Click()
    MouseOff
    txt_Former = lst_Former.List(lst_Former.ListIndex)
    MouseOn
End Sub

Private Sub lst_Former_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    mi_Index = lst_Former.ListIndex
    lst_Former.Drag
    lst_Former.DragIcon = ico_Right.Picture
End Sub

Private Sub pic_Trash_DragOver(Source As Control, X As Single, Y As Single, state As Integer)

    On Error GoTo pic_Trash_DragOver_Err
    
    If state = 0 Then Source.DragIcon = ico_Drop.Picture
    If state = 1 Then Source.DragIcon = ico_Empty.Picture
    Exit Sub
    
pic_Trash_DragOver_Err:
    StdError
End Sub

Private Sub pic_full_DragOver(Source As Control, X As Single, Y As Single, state As Integer)

    On Error GoTo pic_full_DragOver_Err
    
    If state = 0 Then Source.DragIcon = ico_Drop.Picture
    If state = 1 Then Source.DragIcon = ico_Empty.Picture
    Exit Sub
    
pic_full_DragOver_Err:
    StdError
End Sub

Private Sub pic_Save_Click()
Dim i As Integer
Dim ls_Former As String

    On Error GoTo Pic_Save_Click_Err
    
    MouseOff
    ls_Former = ""
    If BeginTran(gl_Environment, gl_Database) Then
        If FormerDel Then
            For i = 0 To lst_Former.ListCount - 1
                ms_Former = QuoteParam(lst_Former.List(i))
                If ms_Former <> ls_Former Then
                    If Not FormerIns Then
                        RollbackTran gl_Environment, gl_Database
                        MouseOn
                        Exit Sub
                    End If
                End If
                ls_Former = ms_Former
            Next i
            CommitTran gl_Environment, gl_Database
            Unload Me
        Else
            RollbackTran gl_Environment, gl_Database
        End If
    End If
    MouseOn
    Exit Sub
    
Pic_Save_Click_Err:
    StdError
End Sub

Private Sub pic_quit_Click()
    MouseOff
    Unload Me
    MouseOn
End Sub

Private Sub FillList()
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim i As Integer

    On Error GoTo FillList_Err
    
    txt_SAP = gs_SAPCode
    txt_Former = ""
    lst_Former.Clear
    ls_Req = "EXEC Converting_sel '" & gs_SAPCode & "','Prod DB','XXX'"
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQL_SUCCESS
    Else
        li_Status = SQL_ERROR
    End If
    Do While li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO
        li_Status = SQLFetch(ll_Statement)
        If li_Status = SQL_SUCCESS Or li_Status = SQL_SUCCESS_WITH_INFO Then
            lst_Former.AddItem ODBCData(ll_Statement, 1)
        End If
    Loop
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    Exit Sub
    
FillList_Err:
    StdError
End Sub

Private Sub pic_In_Click()
    MouseOff
    txt_Former.SetFocus
    If txt_Former <> "" Then
        lst_Former.AddItem txt_Former
        txt_Former = ""
    End If
    MouseOn
End Sub

Private Sub pic_UnDo_Click()

    On Error GoTo pic_UnDo_Click_Err
    
    MouseOff
    pic_Full.Visible = KO
    pic_Trash.Visible = OK
    FillCsts
    FillList
    MouseOn
    Exit Sub
    
pic_UnDo_Click_Err:
    StdError
End Sub

Private Function FormerDel() As Boolean
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer

    FormerDel = KO
    
    On Error GoTo FormerDel_Err
    
    ls_Req = "EXEC Converting_del '" _
            & gs_SAPCode & "','Prod DB','XXX'," _
            & gi_BIConcurrency
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        FormerDel = OK
        gi_BIConcurrency = gi_BIConcurrency + 1
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 7, "Delete failed : concurrency problem ?", gut_LangLogin.Code
    End If
    Exit Function
    
FormerDel_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Function

Private Function FormerIns() As Boolean
Dim ls_Req As String
Dim ll_Statement As Long
Dim li_Status As Integer

    FormerIns = KO
    
    On Error GoTo FormerIns_Err
    
    ls_Req = "EXEC Converting_ins '" _
            & gs_SAPCode & "','" _
            & ms_Former & "','Prod DB','XXX'," _
            & gi_BIConcurrency
    If SQLSubmit(gl_Environment, gl_Database, ll_Statement, ls_Req) Then
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        FormerIns = OK
    Else
        li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
        SendMessage 4, "Insert failed", gut_LangLogin.Code
    End If
    Exit Function
    
FormerIns_Err:
    li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
    StdError
End Function
