Option Explicit On
Imports System.Data
Imports System.Data.SqlClient
Imports System.Diagnostics
Imports System.IO
Imports System.Web
Imports System.Web.UI
Imports System.Text
Imports Services.DBAccess
Imports Services.ProductGroups
Public Class TPABasicInfo
Inherits System.Web.UI.Page
Private htPgRegions As Hashtable
Private htPgSalesC As Hashtable
Private oConfigurationInformation As ConfigurationInformation
Private oDBAccess As DBAccess
Private oProductGroups As ProductGroups
Protected WithEvents LabelTitle As System.Web.UI.WebControls.Label
Protected WithEvents tbRegion As System.Web.UI.WebControls.TextBox
Protected WithEvents TextBox_first_name As System.Web.UI.WebControls.TextBox
Private Class SalesConsultant
Public Name As String
Public RegionCode As Integer = -1
Public RegionText As String
Public Producer_Id As Integer = -1
End Class
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
Dim drTPAA As DataRow
Dim sErr As String
Dim sUserName As String
Dim sUserLogonId As String
Dim sAppPhyPath As String
Dim sUserRights As String
Dim TPAA_ID As String
Try
sUserLogonId = Request.ServerVariables("LOGON_USER")
If sUserLogonId.Length < 1 Then
Response.Clear()
Response.Status = "Unauthorized"
Response.AddHeader("WWW-Authenticate", "NTLM")
Response.End()
End If
If InStr(sUserLogonId, "\") <> 0 Then
sUserLogonId = Mid(sUserLogonId, InStr(sUserLogonId, "\") + 1)
End If
sAppPhyPath = Request.PhysicalApplicationPath()
oConfigurationInformation = New ConfigurationInformation(sAppPhyPath)
sUserName = oConfigurationInformation.GetApplicationUsers(sUserLogonId.ToLower())
If IsNothing(sUserName) Then Response.Redirect("NotAValidUser.aspx")
If sUserName.Length < 1 Then Response.Redirect("NotAValidUser.aspx")
sUserRights = oConfigurationInformation.GetApplicationUsersRights(sUserLogonId.ToLower())
If sUserRights.IndexOf("w") < 1 Then Response.Redirect("List.aspx")
oDBAccess = New DBAccess(oConfigurationInformation)
oProductGroups = New ProductGroups(oDBAccess, oConfigurationInformation)
drTPAA = Nothing
TPAA_ID = String.Empty
If IsNothing(Session("List_TPAAid")) Then
' error
Throw New ApplicationException("Some type of error")
Else
TPAA_ID = CType(Session("List_TPAAid"), String)
If TPAA_ID = "0" Then
LabelTitle.Text = "NEW"
drTPAA = oDBAccess.GetTopRow()
drTPAA("first_name") = String.Empty
Else
drTPAA = oDBAccess.GetName(TPAA_ID)
End If
End If
If IsPostBack() Then
Else
If Not IsNothing(drTPAA) Then TextBox_first_name.Text = drTPAA("first_name")
End If
Catch ex As Exception
sErr = ex.Message
End Try
End Sub
End Class