Partial Class Project2_Login
Inherits System.Web.UI.Page
Private prDbConnection As New ORAConnection *** 'Connection Oracle 10g
Private prDbTransaction As OracleTransaction*** 'Obj SQL Transaction
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
'Connect Database
prDbConnection.CommandConnect = Session.Item("ConnectionString").ToString
prDbConnection.Connection()
Catch ex As Exception
MessageBox.ShowAlert_VBError(Err.Number, Err.Description)
End Try
End Sub
Protected Sub bt_submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles bt_submit.Click
Dim str_sqlCommand As String 'คำสั่ง SQL Command
Dim da_UserLogin As Ora10gClient.OracleDataAdapter**** 'Data Adapter
Dim dt_UserLogin As New Data.DataTable
Dim da_DateString As Ora10gClient.OracleDataAdapter **** 'Data Adapter
Dim dt_DateString As New Data.DataTable
Dim LDAPCon As New LDAP
'กำหนดค่าการ Connect LDAP
LDAPCon.Authentication = DirectoryServices.AuthenticationTypes.None
LDAPCon.IPAddressServer = "202.28.68.94"
LDAPCon.Port = "389"
LDAPCon.Domain = "o=walailak,c=TH"
LDAPCon.UserName = tx_user.Text.ToString
LDAPCon.Password = tx_password.Text.ToString
LDAPCon.Connection()
If LDAPCon.ValidUser Then
'เก็บข้อมูล Session.Item("User"),Session.Item("LoginSuccess"),Session.Item("UserID")
'Session.Item("UserCode"),Redirect to frm_PersonResume.aspx
If dt_UserLogin.Rows.Count = 1 Then
'กำหนดค่า ชื่อสกุล ผู้ใช้งานให้ Session User
Session.Item("User") = dt_UserLogin.Rows(0).Item("PrefixTHName").ToString & " " & dt_UserLogin.Rows(0).Item("FNameThai").ToString & " " & dt_UserLogin.Rows(0).Item("LNameThai").ToString
Session.Item("LoginSuccess") = True
Session.Item("UserID") = dt_UserLogin.Rows(0).Item("PersonID").ToString
Session.Item("UserCode") = dt_UserLogin.Rows(0).Item("PersonCode").ToString
Session.Item("DivID") = dt_UserLogin.Rows(0).Item("divid").ToString
Session.Item("EMail") = LDAPCon.MailAddress
'คำสั่ง SQL Command ข้อมูลวันที่จากเครื่อง
str_sqlCommand = "select to_char(sysdate,'yyyymmdd') as strDate from dual"
da_DateString = New ORA10gclient.OracleDataAdapter*******(str_sqlCommand, db_Connection.dbConnecting)
da_DateString.Fill(dt_DateString)
Session.Item("datestring") = dt_DateString.Rows(0).Item("strDate").ToString
Session.Item("datestringBE") = fpbChangeYear(Session.Item("datestring"), "BE")
'MessageBox.ShowAlert(Session.Item("UserID") & " " & Session.Item("UserCode") & " " & Session.Item("User"))
Response.Redirect("Welcome.aspx", False)
Else
MessageBox.ShowAlert("คุณไม่มีสิทธิ์เข้าใช้งานระบบ กรุณาตรวจสอบฝ่ายการเจ้าหน้าที่")
End If 'If ds_UserLogin.Tables("UserLogin").Rows.Count = 1
Else
MessageBox.ShowAlert("ชื่อผู้ใช้ หรือ รหัสผ่าน ไม่ถูกต้องกรุณาป้อนข้อมูลใหม่")
End If 'If LDAPCon.ValidUser
End Sub
Protected Sub Page_Unload(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Unload
Try
If Not (prDbConnection Is Nothing) Then
prDbConnection.Disconnection()
End If
Catch ex As Exception
MessageBox.ShowAlert_VBError(Err.Number, Err.Description)
End Try
End Sub
End Class