2025-06-25 11:19:00 +09:00

93 lines
3.3 KiB
VB.net

Public Class LoginForm
' TODO: 제공된 사용자 이름과 암호를 사용하여 사용자 지정 인증을 수행하는 코드를 삽입합니다
' (https://go.microsoft.com/fwlink/?LinkId=35339 참조).
' 그러면 사용자 지정 보안 주체가 현재 스레드의 보안 주체에 다음과 같이 첨부될 수 있습니다.
' My.User.CurrentPrincipal = CustomPrincipal
' 여기서 CustomPrincipal은 인증을 수행하는 데 사용되는 IPrincipal이 구현된 것입니다.
' 나중에 My.User는 CustomPrincipal 개체에 캡슐화된 사용자 이름, 표시 이름 등의
' ID 정보를 반환합니다.
Public Structure UserData
Public UserID As String
Public UserPW As String
Public IDType As String
Public ExtPermition As String
Public NowState As Int16
End Structure
Public UserInfo As UserData
Private Const InfoTypeNumber As String = "10"
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Try
With UserInfo
.UserID = String.Empty
.UserPW = String.Empty
.IDType = String.Empty
.ExtPermition = String.Empty
End With
Dim DBCmd As String = "SELECT UserID,UserPW,IDType,ExtPermition,NowState FROM " & LoginDB & " WHERE UserID = '" & txbUserID.Text & "'"
If DBQueryReader(DBCmd) Then
UserInfo.UserID = sqlDataQuery(0)
UserInfo.UserPW = sqlDataQuery(1)
UserInfo.IDType = sqlDataQuery(2)
UserInfo.ExtPermition = sqlDataQuery(3)
UserInfo.NowState = sqlDataQuery(4)
If UserInfo.UserPW = txbUserPW.Text Then
If UserInfo.IDType = InfoTypeNumber Then
If UserInfo.NowState <> 1 Then
If NowStateUpdate() Then
MsgBox("로그인 도중 오류가 발생하였습니다.", vbCritical)
GoTo FailFunc
End If
MainForm.Show()
Me.Hide()
Exit Sub
Else
MsgBox("현재 접속중인 계정입니다.", vbExclamation)
GoTo FailFunc
End If
Else
GoTo loginFail
End If
Else
GoTo loginFail
End If
Else
GoTo loginFail
End If
Catch ex As Exception
GoTo loginFail
End Try
loginFail:
MsgBox("아이디 및 비밀번호가 잘못되었습니다.", vbExclamation)
FailFunc:
txbUserID.Text = String.Empty
txbUserPW.Text = String.Empty
txbUserID.Focus()
End Sub
Private Function NowStateUpdate() As Boolean
Dim DBCmd As String = "UPDATE " & LoginDB & " SET NowState = '1' WHERE UserID = '" & txbUserID.Text & "'"
If DBCommand(DBCmd) Then
Return False
Else
Return True
End If
End Function
Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click
Me.Close()
End Sub
Private Sub LoginForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load
End Sub
End Class