VERSION 5.00
Begin VB.Form DC_Choice2 
   BorderStyle     =   1  'Fixed Single
   Caption         =   "Form1"
   ClientHeight    =   1545
   ClientLeft      =   2250
   ClientTop       =   2745
   ClientWidth     =   4800
   ControlBox      =   0   'False
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   1545
   ScaleWidth      =   4800
   ShowInTaskbar   =   0   'False
   Begin VB.ComboBox cbo_year 
      Height          =   288
      Left            =   3600
      TabIndex        =   2
      Text            =   "yyyy"
      Top             =   1080
      Width           =   972
   End
   Begin VB.ComboBox cbo_month 
      Height          =   288
      Left            =   2760
      TabIndex        =   8
      Text            =   "mm"
      Top             =   1080
      Width           =   732
   End
   Begin VB.PictureBox ButtonBox 
      Appearance      =   0  'Flat
      AutoRedraw      =   -1  'True
      AutoSize        =   -1  'True
      BackColor       =   &H80000005&
      BeginProperty Font 
         Name            =   "Arial"
         Size            =   8.25
         Charset         =   238
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H80000008&
      Height          =   612
      Left            =   0
      ScaleHeight     =   585
      ScaleWidth      =   4785
      TabIndex        =   1
      Top             =   0
      Width           =   4812
      Begin VB.PictureBox pic_FillGrid 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "DCCHOIC2.frx":0000
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   120
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   9
         Top             =   65
         Width           =   384
      End
      Begin VB.PictureBox pic_quit 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "DCCHOIC2.frx":030A
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   3720
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   4
         Top             =   65
         Width           =   384
      End
      Begin VB.PictureBox pic_help 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00FFFFFF&
         BorderStyle     =   0  'None
         DragIcon        =   "DCCHOIC2.frx":0614
         BeginProperty Font 
            Name            =   "Arial"
            Size            =   8.25
            Charset         =   238
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   384
         Left            =   4200
         ScaleHeight     =   390
         ScaleWidth      =   390
         TabIndex        =   3
         Top             =   65
         Width           =   384
      End
   End
   Begin VB.ComboBox cbo_Ship_DC_code 
      Height          =   288
      ItemData        =   "DCCHOIC2.frx":091E
      Left            =   1260
      List            =   "DCCHOIC2.frx":0920
      Style           =   2  'Dropdown List
      TabIndex        =   5
      Top             =   1080
      Visible         =   0   'False
      Width           =   312
   End
   Begin VB.ComboBox cbo_Ship_DC 
      Height          =   288
      ItemData        =   "DCCHOIC2.frx":0922
      Left            =   180
      List            =   "DCCHOIC2.frx":0924
      Style           =   2  'Dropdown List
      TabIndex        =   0
      Top             =   1080
      Width           =   1692
   End
   Begin VB.Label lbl_Ship_Date 
      Alignment       =   2  'Center
      Caption         =   "Date"
      Height          =   252
      Left            =   2880
      TabIndex        =   7
      Top             =   720
      Width           =   1572
   End
   Begin VB.Label lbl_DC 
      Alignment       =   2  'Center
      Caption         =   "DC"
      Height          =   252
      Left            =   180
      TabIndex        =   6
      Top             =   720
      Width           =   1692
   End
End
Attribute VB_Name = "DC_Choice2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

'what is new
'2.6.4 : Now DC combobox stay enabled and containt only available data when called from Calendar (JN)

Private Sub Form_Load()

Dim li_Count As Integer

MouseOff

If gl_CodePage <> 1252 And gl_CodePage <> 0 Then ChangeCharset Me

pic_quit.Picture = LoadResPicture(RES_QUIT, 1)
pic_help.Picture = LoadResPicture(RES_HELP, 1)
pic_FillGrid.Picture = LoadResPicture(RES_FILLGRID, 1)
DC_choice_constants

If gs_TableName = "DC_Calendar" Then
    FillCbo "DC_cbo_autorized", cbo_Ship_DC_code, cbo_Ship_DC
Else
    FillCbo "DC_cbo", cbo_Ship_DC_code, cbo_Ship_DC
End If


CboFindList
For li_Count = 1 To 12
    cbo_month.AddItem Format(li_Count, "00")
Next
cbo_month.ListIndex = ComboFindItem(cbo_month, Format(Month(Date), "00"))
For li_Count = 1998 To 2100
    cbo_year.AddItem li_Count
Next
cbo_year.ListIndex = ComboFindItem(cbo_year, Format(Year(Date), "0000"))
MouseOn

End Sub

Private Sub pic_FillGrid_Click()

Dim li_Count As Integer

MouseOff
If Control Then
    Select Case gs_TableName
    Case "DC_Calendar":
        gs_ParamReq1 = "EXEC DC_Max_Activity_t_lst '" & cbo_Ship_DC_code.List(cbo_Ship_DC.ListIndex) & "', '" & CInt(cbo_month) & "', '" & cbo_year & "', '"
        gs_ParamReq2 = "EXEC Screen_Csts 'main_DC_Calendar', '" & gut_LangLogin.Code & "'"
        gs_ParamReq3 = "EXEC Check_Security DC_Max_Activity, " & prg.LoginName
        gi_TranslateType = 1
        gi_GridWidth(0) = 1060
        gi_GridWidth(1) = 1
        gi_GridWidth(2) = 2200
        gi_GridWidth(3) = 2200
        gi_GridWidth(4) = 2200
        gi_GridWidth(5) = 2200
        For li_Count = 6 To 29
            gi_GridWidth(li_Count) = 1
        Next li_Count
    Case "DC_Work":
        gs_ParamReq1 = "EXEC DC_WorkLoad '" & cbo_Ship_DC_code.List(cbo_Ship_DC.ListIndex) & "', '" & CInt(cbo_month) & "', '" & cbo_year & "', '"
        gs_ParamReq2 = "EXEC Screen_Csts 'main_DC_Work', '" & gut_LangLogin.Code & "'"
        gs_ParamReq3 = "EXEC Check_Security DC_Transaction, " & prg.LoginName
        gs_ParamReq4 = "EXEC DC_Transaction_lst '" & cbo_Ship_DC_code.List(cbo_Ship_DC.ListIndex) & "', NULL, "
        gi_TranslateType = 1
        gi_GridWidth(0) = 1100
        gi_GridWidth(1) = 1000
        gi_GridWidth(2) = 1000
        gi_GridWidth(3) = 1000
        gi_GridWidth(4) = 1000
        gi_GridWidth(5) = 1000
        gi_GridWidth(6) = 1000
        gi_GridWidth(7) = 1000
        gi_GridWidth(8) = 1000
'        gi_GridWidth(9) = 1000 'mmmm
'        gi_GridWidth(10) = 1000 'mmmm
        For li_Count = 9 To 29
            gi_GridWidth(li_Count) = 0
        Next li_Count

    End Select
    C_main.show 1
End If
MouseOn

End Sub
Private Sub pic_quit_Click()

Unload Me

End Sub
Private Sub DC_choice_constants()

Dim ls_Field As String
Dim ls_Text As String
Dim ll_Statement As Long
Dim li_Status As Integer

On Error GoTo suite

If SQLSubmit(gl_Environment, gl_Database, ll_Statement, gs_ParamReq2) 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 = Left(ODBCData(ll_Statement, 2), 30)
        Select Case ls_Field
            Case "title": Caption = ls_Text
            Case "lbl_Ship_DC": lbl_DC = ls_Text
            Case "lbl_Ship_Date": lbl_Ship_Date = ls_Text
        End Select
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Sub
Private Function Control() As Boolean

Control = KO
If cbo_Ship_DC = "" Then
    If cbo_Ship_DC.Enabled = OK Then
        cbo_Ship_DC.SetFocus
    End If
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If cbo_month = "" Then
    cbo_month.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
If cbo_year = "" Then
    cbo_year.SetFocus
    SendMessage 8, "Value must be filled in", gut_LangLogin.Code
    Exit Function
End If
Control = OK

End Function

Private Sub CboFindList()
Dim ls_req As String
Dim ll_Statement As Long
Dim li_Status As Integer
Dim DC_name As String

On Error GoTo suite

ls_req = "SELECT TOP 1 dc.DC_desc FROM Dist_Centre dc, security_identity si " _
         & "WHERE si.login_name = '" & prg.LoginName & "' " _
         & "AND si.company = dc.COMP_code " _
         & "AND dc.Language_code = 'E' " _
         & "ORDER BY dc.IsDefault DESC"

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
        DC_name = ODBCData(ll_Statement, 1)
    End If
Loop
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
cbo_Ship_DC.ListIndex = ComboFindItem(cbo_Ship_DC, DC_name)
'If gs_TableName = "DC_Calendar" Then
'    cbo_Ship_DC.Enabled = False ' 03/07/2012 JN
'End If
Exit Sub

suite:
li_Status = SQLFreeStatement(ll_Statement, SQL_DROP)
StdError
End Sub
