Imports System.Data.SqlClient
Public Class frmRegister
Dim myCaptcha As New Captcha
Private Sub frmRegister_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub frmRegister_Shown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shown
myCaptcha.CaptchaHeight = bmpCaptcha.Height
myCaptcha.CaptchaWidth = bmpCaptcha.Width
myCaptcha.CaptchaFont = New Font("Verdana", 20, FontStyle.Regular)
myCaptcha.GenerateNewCaptcha()
bmpCaptcha.Image = myCaptcha.CaptchaImage
'txtSecurityCode.Text = myCaptcha.CaptchaCode
cbGMLevel.Text = cbGMLevel.Items(0).ToString
End Sub
Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click
'Me.Close()
If txtAccount.Text = "" Or txtConfirmPassword.Text = "" Or txtEMail.Text = "" Or txtPassword.Text = "" Or txtSecurityCode.Text = "" Then
MsgBox("Required Field Missing", MsgBoxStyle.Critical, "Create Account - Validation Error")
Exit Sub
End If
If txtSecurityCode.Text <> myCaptcha.CaptchaCode Then
MsgBox("Captcha Code Invalid", MsgBoxStyle.Critical, "Create Account - Validation Error")
Exit Sub
End If
If txtPassword.Text <> txtConfirmPassword.Text Then
MsgBox("Passwords do not match.", MsgBoxStyle.Critical, "Create Account - Validation Error")
Exit Sub
End If
Dim connstring As String
connstring = "Data Source=127.0.0.1;Initial Catalog=youxiuser;User ID=sa;Password=PASSWORDHERE"
Dim SQLConn As New SqlConnection(connstring)
Call SQLConn.Open()
Dim strQuery As String
strQuery = "EXECUTE [youxiuser].[dbo].[spJoinUser] '" & txtAccount.Text & "', '" & txtPassword.Text & "','" & txtEMail.Text & "'"
Dim SQLCmd As New SqlCommand(strQuery, SQLConn)
Call SQLCmd.ExecuteNonQuery()
Dim SQLdr As SqlDataReader
Dim UID As String = ""
If cbGMLevel.Text <> "Level 0" Then
strQuery = "SELECT uid FROM [youxiuser].[dbo].[usertbl] WHERE account = '" & txtAccount.Text & "' and email = '" & txtEMail.Text & "'"
SQLCmd = New SqlCommand(strQuery, SQLConn)
SQLdr = SQLCmd.ExecuteReader
SQLdr.Read()
UID = SQLdr(0)
SQLdr.Close()
Dim GMLevel As String = "0"
Select Case cbGMLevel.Text
Case "Level 0"
GMLevel = "0"
Case "Level 1"
GMLevel = "1"
Case "Level 2"
GMLevel = "2"
Case "Level 3"
GMLevel = "3"
Case "Level 4"
GMLevel = "4"
Case "Level 5"
GMLevel = "5"
End Select
strQuery = "EXECUTE [gameDB].[dbo].[InsertAdmin] '" & UID & "', '" & GMLevel & "'"
SQLCmd = New SqlCommand(strQuery, SQLConn)
Call SQLCmd.ExecuteNonQuery()
End If
SQLConn.Close()
If cbGMLevel.Text <> "Level 0" Then
Call MsgBox(cbGMLevel.Text & " Admin Account Created: " & txtAccount.Text, MsgBoxStyle.Information, "Account Created")
Else
Call MsgBox("Account Created: " & txtAccount.Text, MsgBoxStyle.Information, "Account Created")
End If
Me.Close()
End Sub