﻿'v1.2.4 - added AdvAudit 20090508 to Brand, Product, Customer, Reps
'v1.2.5 - added sales to date bashboard on home.aspx
'v1.2.6 - added strCountry to customer Details/dwdCustomer
'v1.3.1 - Changed Non RGBC Customers list & Detals: Added refChannelSegmentID, removed refChannelID
'v1.3.3 - 20100127 - Disabled duplicate record check on non RGBC Customer details
'v1.3.3 - 20100127 - Added region & sales rep filters on Non RGBC Customer List
'v1.3.4 - 20100722 - Added the Product Archive util - albert
'v1.4.0 - 20120720 - .net4 upgrade - pj
'v1.4.1 - 20120914 - Using vs2012!! - Restructured some of the db class functions to help prevent Open DataReader Error
'       - 20121107 - bugs in the navigated filtering system: changed "NavList" to "CustomerList" on CustomerList.vb (similar change on ProductList.vb)
'v1.4.2 - 20130227 - changed non rgbc customer list export() to pull data from dwdCustomer for updated channel-segment definitions
'v1.4.3 - 20131105 - Changed Product Archive to send job to the CronJob - Christiaan
'v1.4.3 - 20131106 - Added strPriceGroupCode to mstKeyAccount:: update dwdCustomer and mstKeyAccount, modified existing KeyAccountDetails code to update/insert/save the new field strPriceGroup - Christiaan 
'v1.4.4 - 20160906 - rebinded brand ddl before doing check to see if user exists - maanie
'v1.4.5 - 20160913 - Fixed logged In user & savings (i.e use session instead) - maanie
'v1.4.6 - 20160920 - Added strCategory to product details + removed category from product list filter - maanie

Imports System.Web.Configuration
Imports Superbowl.sqlDB

Partial Public Class Admin
  Inherits System.Web.UI.MasterPage
	Private blnDebug = WebConfigurationManager.AppSettings("blnDebug")

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
		Dim ds As DataSet
		Dim dr As DataRow
      Dim db As New sqlDB

		Page.Title = "RGBC Superbowl"
    Try
         lblUser.Text = "Logout: " & Session.Item("User") 'v1.4.5 - 20160913 - Fixed logged In user & savings (i.e use session instead) - maanie
         lblLevel.Text = WebConfigurationManager.AppSettings("UGROUP")
      Catch ex As Exception
      End Try

      If blnDebug = True Then
#If DEBUG Then
         If WebConfigurationManager.AppSettings("UDOMAIN").Length = 0 Or WebConfigurationManager.AppSettings("UDOMAIN") = Nothing Then
            Session.Item("User") = "a"
            WebConfigurationManager.AppSettings("UDOMAIN") = "x"
            WebConfigurationManager.AppSettings("UID") = 1
            WebConfigurationManager.AppSettings("UGROUP") = "Debug"
            WebConfigurationManager.AppSettings("ULEVEL") = 5
         End If
#End If
      Else

         Try

            If WebConfigurationManager.AppSettings("UDOMAIN").Length = 0 Or WebConfigurationManager.AppSettings("UDOMAIN") = Nothing Or WebConfigurationManager.AppSettings("UGROUP").Length = 0 Or WebConfigurationManager.AppSettings("ULEVEL") = 0 Then
               FormsAuthentication.SignOut()
               Response.Redirect("Index.aspx", True)
               'Else			 
               '	If WebConfigurationManager.AppSettings("UGROUP").ToLower.Contains("admin") Then
               '		mnuAdmin.Items(1).Enabled = True
               '		mnuAdmin.Items(2).Enabled = True
               '	End If		  
            End If

         Catch ex As Exception
            FormsAuthentication.SignOut()
            Response.Redirect("Index.aspx")
         End Try

      End If

	End Sub

End Class