Imports System
Imports System.Data
Imports System.Data.SqlClient
Partial Class BusinessAssociates_SSA_Mentor
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
            If Not IsPostBack Then
                If Not Session("SSAID") = Nothing Then
                    FillSSADetails()
                    If Not lblMentorID.Text.Trim = "" Then
                        FillMentor(lblMentorID.Text.Trim)
                    End If
                End If
            End If
        Catch ex As Exception
            Response.Write(ex.Message)
        End Try
    End Sub

    Public Sub FillSSADetails()

        Dim cmd As New Data.SqlClient.SqlCommand()
        Dim con As New Data.SqlClient.SqlConnection
        con.ConnectionString = System.Configuration.ConfigurationManager.AppSettings("ConnectionString")

        Dim Str As String
        Str = "select * From SSA_Master Where SSA_KID='" & Session("SSAID").ToString & "'"
        If con.State = Data.ConnectionState.Open Then
            con.Close()
        End If
        con.Open()
        cmd = New SqlCommand(Str, con)
        Dim adp As New SqlDataAdapter
        Dim ds As New DataSet
        Dim Dr As DataRow
        adp.SelectCommand = cmd
        adp.Fill(ds)

        If ds.Tables(0).Rows.Count > 0 Then
            Dr = ds.Tables(0).Rows(0)

            txtSSAID.Text = Session("SSAID").ToString
            lblMentorID.Text = Dr("SSA_MentorID").ToString
        End If
        ds.Clear()
        ds.Dispose()

        con.Close()
        con.Dispose()

    End Sub

    Public Sub FillMentor(ByVal MentorID As String)
        Dim cn As New System.Data.SqlClient.SqlConnection(ConfigurationManager.AppSettings("Connection4Voffice"))

        '  Dim cn As New System.Data.SqlClient.SqlConnection("server=DEVLOPER;Initial Catalog=V_Office;Persist Security Info=True;pwd=atcodev;User ID=sa;connect timeout=360;Max Pool Size=200")
        Dim objAdapter As SqlDataAdapter
        Dim ObjDS As DataSet
        Dim ObjDR As DataRow

        cn.Open()

        Try
            objAdapter = New SqlDataAdapter("Select_EmployeeByEmployeeID_Proc", cn)
            objAdapter.SelectCommand.CommandType = CommandType.StoredProcedure

            objAdapter.SelectCommand.Parameters.Add(New SqlParameter("@EmployeeID", SqlDbType.VarChar)).Value = MentorID.ToString.Trim

            ObjDS = New DataSet
            objAdapter.Fill(ObjDS, "EmployeeDetails")

            If ObjDS.Tables(0).Rows.Count > 0 Then
                ObjDR = ObjDS.Tables(0).Rows(0)
                lblName.Text = ObjDR("V_Emp_Name")
                lblPhone.Text = ObjDR("V_Emp_PhoneNo1")
                lblEmailAddress.Text = ObjDR("V_Emp_EmailId")
            End If

            ds.Clear()
            ds.Dispose()

        Catch ex As Exception

        Finally
            cn.Close()
            cn.Dispose()
        End Try
    End Sub
End Class
