Imports System.Configuration
Imports System.Data.SqlClient
Imports System.Globalization
Imports System.Net
Imports System.IO
Imports System.Net.Cookie
Imports System.Text
Imports System.Web.HttpContext
Public Class connection
Private MyConn As SqlConnection
Private sqlTrans As SqlTransaction
Private ci As New CultureInfo("en-US")
Private objDs As DataSet
Private myCommand As SqlCommand
Function Connection() As SqlConnection
Connection = New SqlConnection("Server=70.87.28.215;Uid=missmut;PASSWORD=1q2w3e4r;database=MUT2012;")
Return Connection
End Function
Function QueryData(ByVal strSql As String, ByVal vStrDs As String, _
Optional ByVal vStrDatabase As String = "", _
Optional ByVal currentIndex As String = "", _
Optional ByVal PageSize As String = "") As DataSet
Try
Dim Objrecordset As SqlDataAdapter
Dim Objds As DataSet
MyConn = Connection()
If MyConn.State = ConnectionState.Closed Then
MyConn.Open()
End If
If vStrDatabase <> "" Then
MyConn.ChangeDatabase(vStrDatabase)
End If
Objrecordset = New SqlDataAdapter(strSql, MyConn)
Objds = New DataSet
If currentIndex <> "" And PageSize <> "" Then
Objrecordset.Fill(Objds, currentIndex, PageSize, vStrDs)
Else
Objrecordset.Fill(Objds, vStrDs)
End If
MyConn.Close()
Return Objds
Catch ex As Exception
MyConn.Close()
'Return Nothing
'EventLog1.WriteEntry("QueryData SQL=" & strSql & vbNewLine & "Error Detail =" & ex.Message)
Finally
If MyConn.State = ConnectionState.Open Then
MyConn.Close()
End If
End Try
End Function
Function executeData(ByVal strSql As String, Optional ByVal vStrDatabase As String = "")
Try
MyConn = Connection()
If MyConn.State = ConnectionState.Closed Then
MyConn.Open()
End If
If vStrDatabase <> "" Then
MyConn.ChangeDatabase(vStrDatabase)
End If
myCommand = New SqlCommand(strSql, MyConn)
If MyConn.State = ConnectionState.Closed Then
MyConn.Open()
End If
myCommand.ExecuteNonQuery()
MyConn.Close()
Return "0"
Catch ex As Exception
MyConn.Close()
Return ex.Message
Finally
If MyConn.State = ConnectionState.Open Then
MyConn.Close()
End If
End Try
End Function
End Class
Imports System.Data
Imports System.Data.SqlClient
Imports System.IO
Public Class detailVote
Inherits System.Web.UI.Page
Public Nmut As Integer
Dim objConn As SqlConnection
Dim strConn As String
Dim objCom As SqlCommand
Dim strCom As String
Dim temp As SqlDataReader
Dim Number As String
Dim value As String
Dim funMUT As New connection
Dim objDs As DataSet
Dim strExecute As String
Public cookieUserName As String
Public UserVote1 As String = ""
Public Cookie As HttpCookie
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
Nmut = Request.Params("id")
Cookie = Request.Cookies("UserVote")
UserVote1 = Cookie.Item("UserVote1")
Catch ex As Exception
'Response.Write("1")
End Try
Try
If UserVote1 = "" Then
If Not Request.Cookies("UserVote") Is Nothing Then
UserVote1 = Server.HtmlEncode(Request.Cookies("UserVote")("UserVote1"))
End If
End If
Catch ex As Exception
End Try
Try
'If UserVote1 <> "" Then
' btnLogout.Visible = True
'Else
' btnLogout.Visible = False
'End If
'Response.Write(UserVote1)
'If Request.Cookies("UserVote") Is Nothing Then
'cookie2 = Request.Cookies("UserNameVote")
'cookieUserName = cookie2.Item("UserNameVote1")
'Else
'End If
'Response.Write(Request.Cookies("UserVote"))
If Not IsPostBack Then
getDetail()
End If
Catch ex As Exception
'Response.Write(ex.Message & "2")
End Try
End Sub
Sub getDetail()
Try
strCom = "SELECT A.APPLICANT_NO,A.FIRSTNAME_USED,A.LASTNAME_USED,A.NICKNAME,A.AGE,A.CHEST,A.HIP,A.HEIGHT,A.WEIGHT," & _
"A.EDU_LAST_NAME,A.EDU_LAST_LEVEL,A.EDU_LAST_STATUS,A.EDU_LAST_DESCRIPTION,P.PVN_NAME,PHOTO1,WAIST" & _
" FROM APPLICATION_FORM A,PROVINCE P" & _
" WHERE(A.APPLICANT_NO Is Not NULL)" & _
" AND A.BP_ADDR_PVN_ID = P.PVN_ID AND A.APPLICANT_NO = " & Nmut
objDs = funMUT.QueryData(strCom, "DATA")
If objDs.Tables("DATA").Rows.Count > 0 Then
lblnumber.Text = "MUT " & objDs.Tables("DATA").Rows(0).Item("APPLICANT_NO")
lblname.Text = objDs.Tables("DATA").Rows(0).Item("FIRSTNAME_USED") & " " & objDs.Tables("DATA").Rows(0).Item("LASTNAME_USED") & " ชื่อเล่น : " & objDs.Tables("DATA").Rows(0).Item("NICKNAME")
lblage.Text = "อายุ : " & objDs.Tables("DATA").Rows(0).Item("AGE")
lblsc.Text = "สัดส่วน : " & objDs.Tables("DATA").Rows(0).Item("CHEST") & "-" & objDs.Tables("DATA").Rows(0).Item("WAIST") & "-" & objDs.Tables("DATA").Rows(0).Item("HIP")
lblheight.Text = "ส่วนสูง : " & objDs.Tables("DATA").Rows(0).Item("HEIGHT")
lblweight.Text = "น้ำหนัก : " & objDs.Tables("DATA").Rows(0).Item("WEIGHT")
lblEducation.Text = "การศึกษา : " & objDs.Tables("DATA").Rows(0).Item("EDU_LAST_STATUS") & " " & objDs.Tables("DATA").Rows(0).Item("EDU_LAST_LEVEL") & " " & objDs.Tables("DATA").Rows(0).Item("EDU_LAST_DESCRIPTION") & " " & objDs.Tables("DATA").Rows(0).Item("EDU_LAST_NAME")
lblprovide.Text = "จังหวัด : " & objDs.Tables("DATA").Rows(0).Item("PVN_NAME")
imageMain.ImageUrl = "ImageMut/3/" & objDs.Tables("DATA").Rows(0).Item("APPLICANT_NO") & ".jpg"
Else
End If
Catch ex As Exception
Response.Write(ex.Message)
End Try
End Sub
Public Function voteToBase() As Boolean
Try
Dim userID As String = Request.Cookies("UserVote").Value
strCom = "EXECUTE USP_WEB_VOTE " & userID & ", " & Nmut & ""
strExecute = funMUT.executeData(strCom, "MUTVOTE")
Response.Write(strExecute)
Response.Write("123")
Catch ex As Exception
Response.Write(ex.Message)
End Try
Return False
End Function
'Protected Sub btnLogout_Click(sender As Object, e As EventArgs) Handles btnLogout.Click
' Response.Redirect("clare2.aspx")
'End Sub
End Class