Imports System.IO Imports System.Data.SqlClient Public Class Main #Region "Settings" '#### Item Search #### Dim sTable As DataTable Dim sAdapter As SqlDataAdapter Dim sDs As New DataSet '#### Skill Search #### Dim sSkillTable As DataTable Dim sSkillAdapter As SqlDataAdapter Dim sSDs As New DataSet '#### Title Search #### Dim sTTable As DataTable Dim sTAdapter As SqlDataAdapter Dim sTDs As New DataSet '#### Character List #### Dim sCharsTable As DataTable Dim sCharsAdapter As SqlDataAdapter Dim sCharsDs As New DataSet '#### Account List #### Dim sAccTable As DataTable Dim sAccAdapter As SqlDataAdapter Dim sAccDs As New DataSet '#### Item List #### Dim sItemTable As DataTable Dim sItemAdapter As SqlDataAdapter Dim sItemDs As New DataSet '#### Characters Online #### Dim sOnTable As DataTable Dim sOnAdapter As SqlDataAdapter Dim sOnDs As New DataSet '#### Info Box ##### Dim NowWithout As String = DateTime.Now Dim Now As String = NowWithout.Replace(":", ":") Dim Daywithout As String = DateTime.Today Dim Day As String = Daywithout.Replace("/", ".") Dim ErrorHandling As Integer '#### SQL LOGIN #### Dim Config() As String = Split(My.Computer.FileSystem.ReadAllText("config.txt"), vbNewLine) Dim SQLHost As String = Config(0).Substring(Config(0).IndexOf("=") + 1) Dim SQLUserName As String = Config(1).Substring(Config(1).IndexOf("=") + 1) Dim SQLPassword As String = Config(2).Substring(Config(2).IndexOf("=") + 1) Dim SQLAccount As String = Config(3).Substring(Config(3).IndexOf("=") + 1) Dim SQLCharacter As String = Config(4).Substring(Config(4).IndexOf("=") + 1) #End Region #Region "Error Handling" Private Sub AccountNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) If InStr("0123456789" & Chr(8), e.KeyChar) = False Then e.Handled = True End Sub Private Sub CharacterNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles CharacterNo.KeyPress If InStr("0123456789" & Chr(8), e.KeyChar) = False Then e.Handled = True End Sub Private Sub STR_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles STR.KeyPress If InStr("0123456789" & Chr(8), e.KeyChar) = False Then e.Handled = True End Sub Private Sub DEX_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles DEX.KeyPress If InStr("0123456789" & Chr(8), e.KeyChar) = False Then e.Handled = True End Sub Private Sub END_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles END_.KeyPress If InStr("0123456789" & Chr(8), e.KeyChar) = False Then e.Handled = True End Sub Private Sub INT_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles INT.KeyPress If InStr("0123456789" & Chr(8), e.KeyChar) = False Then e.Handled = True End Sub Private Sub SPR_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles SPR.KeyPress If InStr("0123456789" & Chr(8), e.KeyChar) = False Then e.Handled = True End Sub Private Sub AdminLevel_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Admin.KeyPress If InStr("0123456789" & Chr(8), e.KeyChar) = False Then e.Handled = True End Sub #End Region Private Sub Main_Load(sender As Object, e As EventArgs) Handles MyBase.Load InfoTextBox.Text &= Now & " || " & " Welcome to the Pephix Online Database Editor [v.1.0.0.0]" TabPage4.Enabled = False FullCharSearch() 'OnlineChars() FullAccSearch() ServerStatistics() FullItemSearch() End Sub Private Sub InfoTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoTextBox.TextChanged InfoTextBox.SelectionStart = InfoTextBox.Text.Length InfoTextBox.ScrollToCaret() End Sub Private Sub ErrorCheck() If Val(Admin.Text) < Val("101") = False Then InfoTextBox.Text &= Environment.NewLine & Now & " Admin Level Number is unknow and impossible for Fiesta!!" ErrorHandling = 1 ElseIf Val(STR.Text) < Val("151") = False Then InfoTextBox.Text &= Environment.NewLine & Now & " Stats are overpowered for Fiesta and make your Stats to zero(0)!!" ErrorHandling = 1 ElseIf Val(DEX.Text) < Val("151") = False Then InfoTextBox.Text &= Environment.NewLine & Now & " Stats are overpowered for Fiesta and make your Stats to zero(0)!!" ErrorHandling = 1 ElseIf Val(END_.Text) < Val("151") = False Then InfoTextBox.Text &= Environment.NewLine & Now & " Stats are overpowered for Fiesta and make your Stats to zero(0)!!" ErrorHandling = 1 ElseIf Val(INT.Text) < Val("151") = False Then InfoTextBox.Text &= Environment.NewLine & Now & " Stats are overpowered for Fiesta and make your Stats to zero(0)!!" ErrorHandling = 1 ElseIf Val(SPR.Text) < Val("151") = False Then InfoTextBox.Text &= Environment.NewLine & Now & " Stats are overpowered for Fiesta and make your Stats to zero(0)!!" ErrorHandling = 1 ElseIf CharacterList.Text = "" Or CharacterNo.Text = "" Then InfoTextBox.Text &= Environment.NewLine & Now & " Character Name OR Character No are empty! I can not Update anything!" ErrorHandling = 1 Else ErrorHandling = 0 End If End Sub Private Sub CharacterSearch() Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim AccCon As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLAccount & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT COUNT(sID) FROM dbo.tCharacter WHERE sID='" & CharacterList.Text & "';" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Dim strSQL2 As String = "SELECT sID, nLevel, nUserNo, nCharNo, sLoginZone, nAdminLevel, nStrength, nConstitute, nDexterity, nIntelligence, nMentalPower, sKQMap, nMoney, nFame, nExp, nLoginCount FROM dbo.tCharacter WHERE sID='" & CharacterList.Text & "' OR nCharNo='" & CharacterNo.Text & "';" Dim catCMD As SqlCommand = New SqlCommand(strSQL2, Con) Dim strSQL3 As String = "SELECT COUNT(nCharNo) FROM dbo.tCharacter WHERE nCharNo='" & CharacterNo.Text & "';" Dim cdo2 As SqlCommand = New SqlCommand(strSQL3, Con) Con.Open() Dim countchar As Integer = cdo.ExecuteScalar() Con.Close() Con.Open() Dim countchar2 As Integer = cdo2.ExecuteScalar() Con.Close() If countchar = 1 Or countchar2 = 1 Then Con.Open() Dim myReader As SqlDataReader = catCMD.ExecuteReader() InfoTextBox.Text &= Environment.NewLine & Now & " || Character: " & CharacterList.Text & " has been selected." While myReader.Read() Logins.Text = myReader(15) Exp.Text = myReader(14) Fame.Text = myReader(13) Money.Text = myReader(12) KQZone.Text = myReader(11) SPR.Text = myReader(10) INT.Text = myReader(9) DEX.Text = myReader(8) END_.Text = myReader(7) STR.Text = myReader(6) Admin.Text = myReader(5) Zone.Text = myReader(4) CharacterNo.Text = myReader(3) AccountNo.Text = myReader(2) Level.Text = myReader(1) CharacterList.Text = myReader(0) End While myReader.Close() Con.Close() AccCon.Open() Dim strAccSQL As String = "SELECT sUserID FROM dbo.tUser WHERE nUserNo='" & AccountNo.Text & "';" Dim catCMDAcc As SqlCommand = New SqlCommand(strAccSQL, AccCon) Dim myAccountReader As SqlDataReader = catCMDAcc.ExecuteReader() While myAccountReader.Read AccountID.Text = myAccountReader(0) End While myAccountReader.Close() AccCon.Close() ClassSearch() ItemSearch() SkillSearch() TitleSearch() Else InfoTextBox.Text &= Environment.NewLine & Now & " || User Does not Exist!" Con.Close() End If AccountID.BackColor = Color.Empty Level.BackColor = Color.Empty CharacterList.BackColor = Color.Empty End Sub Private Sub ClassSearch() Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tCharacterShape WHERE nCharNo = '" & CharacterNo.Text & "'" Dim CatCMD As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() Dim myReader As SqlDataReader = CatCMD.ExecuteReader() While myReader.Read() Job.Text = myReader(1) Gender.Text = myReader(3) End While Con.Close() myReader.Close() If Job.Text = "1" Then Job.Text = "Fighter" ElseIf Job.Text = "2" Then Job.Text = "CleverFighter" ElseIf Job.Text = "3" Then Job.Text = "Warrior" ElseIf Job.Text = "4" Then Job.Text = "Gladiator" ElseIf Job.Text = "5" Then Job.Text = "Knight" ElseIf Job.Text = "6" Then Job.Text = "Cleric" ElseIf Job.Text = "7" Then Job.Text = "HighCleric" ElseIf Job.Text = "8" Then Job.Text = "Paladin" ElseIf Job.Text = "9" Then Job.Text = "HolyKnight" ElseIf Job.Text = "10" Then Job.Text = "Guardian" ElseIf Job.Text = "11" Then Job.Text = "Archer" ElseIf Job.Text = "12" Then Job.Text = "HawkArcher" ElseIf Job.Text = "13" Then Job.Text = "Scout" ElseIf Job.Text = "14" Then Job.Text = "SharpShooter" ElseIf Job.Text = "15" Then Job.Text = "Ranger" ElseIf Job.Text = "16" Then Job.Text = "Mage" ElseIf Job.Text = "17" Then Job.Text = "WizMage" ElseIf Job.Text = "18" Then Job.Text = "Enchanter" ElseIf Job.Text = "19" Then Job.Text = "Warlock" ElseIf Job.Text = "20" Then Job.Text = "Wizard" ElseIf Job.Text = "21" Then Job.Text = "Trickster" ElseIf Job.Text = "22" Then Job.Text = "Gambit" ElseIf Job.Text = "23" Then Job.Text = "Renegade" ElseIf Job.Text = "24" Then Job.Text = "Spectre" ElseIf Job.Text = "25" Then Job.Text = "Reaper" Else Job.Text = "unknow " End If If Gender.Text = "1" Then Gender.Text = "Male" ElseIf Gender.Text = "0" Then Gender.Text = "Female" Else Gender.Text = "unknow" End If End Sub Public Sub ClassUpdate() Dim NewJob As Integer = 1 Dim NewGender As Integer = 0 If Job.Text = "Fighter" Then NewJob = "1" ErrorHandling = 0 ElseIf Job.Text = "CleverFighter" Then NewJob = "2" ErrorHandling = 0 ElseIf Job.Text = "Warrior" Then NewJob = "3" ErrorHandling = 0 ElseIf Job.Text = "Gladiator" Then NewJob = "4" ErrorHandling = 0 ElseIf Job.Text = "Knight" Then NewJob = "5" ErrorHandling = 0 ElseIf Job.Text = "Cleric" Then NewJob = "6" ErrorHandling = 0 ElseIf Job.Text = "HighCleric" Then NewJob = "7" ErrorHandling = 0 ElseIf Job.Text = "Paladin" Then NewJob = "8" ErrorHandling = 0 ElseIf Job.Text = "HolyKnight" Then NewJob = "9" ErrorHandling = 0 ElseIf Job.Text = "Guardian" Then NewJob = "10" ErrorHandling = 0 ElseIf Job.Text = "Archer" Then NewJob = "11" ErrorHandling = 0 ElseIf Job.Text = "HawkArcher" Then NewJob = "12" ErrorHandling = 0 ElseIf Job.Text = "Scout" Then NewJob = "13" ErrorHandling = 0 ElseIf Job.Text = "SharpShooter" Then NewJob = "14" ErrorHandling = 0 ElseIf Job.Text = "Ranger" Then NewJob = "15" ErrorHandling = 0 ElseIf Job.Text = "Mage" Then NewJob = "16" ErrorHandling = 0 ElseIf Job.Text = "WizMage" Then NewJob = "17" ErrorHandling = 0 ElseIf Job.Text = "Enchanter" Then NewJob = "18" ErrorHandling = 0 ElseIf Job.Text = "Warlock" Then NewJob = "19" ErrorHandling = 0 ElseIf Job.Text = "Wizard" Then NewJob = "20" ErrorHandling = 0 ElseIf Job.Text = "Trickster" Then NewJob = "21" ErrorHandling = 0 ElseIf Job.Text = "Gambit" Then NewJob = "22" ErrorHandling = 0 ElseIf Job.Text = "Renegade" Then NewJob = "23" ErrorHandling = 0 ElseIf Job.Text = "Spectre" Then NewJob = "24" ErrorHandling = 0 ElseIf Job.Text = "Reaper" Then NewJob = "25" ErrorHandling = 0 Else ErrorHandling = 1 End If If Gender.Text = "Male" Then NewGender = "1" ErrorHandling = 0 ElseIf Gender.Text = "Female" Then NewGender = "0" ErrorHandling = 0 Else ErrorHandling = 1 End If If ErrorHandling = 0 Then Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "UPDATE tCharacterShape SET nClass = '" & NewJob & "', nGender = '" & NewGender & "' WHERE nCharNo = '" & CharacterNo.Text & "'" Dim CatCMD As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() CatCMD.ExecuteNonQuery() Con.Close() End If End Sub Public Sub ItemSearch() If DataGridView1.RowCount > 0 Then sDs.Clear() End If If ShowAll.Checked Then Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tItem WHERE nOwner = '" & CharacterNo.Text & "'" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sAdapter = New SqlDataAdapter(cdo) Dim sBuilder As New SqlCommandBuilder(sAdapter) sAdapter.Fill(sDs, "tItem") sTable = sDs.Tables("tItem") Con.Close() DataGridView1.DataSource = sDs.Tables("tItem") ElseIf ShowEquipped.Checked Then Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tItem WHERE nOwner = '" & CharacterNo.Text & "' AND nStorageType = '8'" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sAdapter = New SqlDataAdapter(cdo) Dim sBuilder As New SqlCommandBuilder(sAdapter) sAdapter.Fill(sDs, "tItem") sTable = sDs.Tables("tItem") Con.Close() DataGridView1.DataSource = sDs.Tables("tItem") ElseIf ShowInventory.Checked Then Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tItem WHERE nOwner = '" & CharacterNo.Text & "' AND nStorageType = '9'" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sAdapter = New SqlDataAdapter(cdo) Dim sBuilder As New SqlCommandBuilder(sAdapter) sAdapter.Fill(sDs, "tItem") sTable = sDs.Tables("tItem") Con.Close() DataGridView1.DataSource = sDs.Tables("tItem") End If End Sub Public Sub SkillSearch() If DataGridView2.RowCount > 0 Then sSDs.Clear() End If Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tSkill WHERE nCharNo = '" & CharacterNo.Text & "'" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sSkillAdapter = New SqlDataAdapter(cdo) Dim sSkillBuilder As New SqlCommandBuilder(sSkillAdapter) sSkillAdapter.Fill(sSDs, "tSkill") sSkillTable = sSDs.Tables("tSkill") Con.Close() DataGridView2.DataSource = sSDs.Tables("tSkill") End Sub Public Sub TitleSearch() If DataGridView3.RowCount > 0 Then sTDs.Clear() End If Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tCharacterTitle WHERE nCharNo = '" & CharacterNo.Text & "'" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sTAdapter = New SqlDataAdapter(cdo) Dim sTBuilder As New SqlCommandBuilder(sTAdapter) sTAdapter.Fill(sTDs, "tCharacterTitle") sTTable = sTDs.Tables("tCharacterTitle") Con.Close() DataGridView3.DataSource = sTDs.Tables("tCharacterTitle") End Sub Public Sub FullAccSearch() If AccList.RowCount > 0 Then sAccDs.Clear() End If Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLAccount & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tUser" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sAccAdapter = New SqlDataAdapter(cdo) Dim sAccBuilder As New SqlCommandBuilder(sAccAdapter) sAccAdapter.Fill(sAccDs, "tUser") sAccTable = sAccDs.Tables("tUser") Con.Close() AccList.DataSource = sAccDs.Tables("tUser") End Sub Public Sub FullCharSearch() If DataGridView5.RowCount > 0 Then sCharsDs.Clear() End If Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tCharacter" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sCharsAdapter = New SqlDataAdapter(cdo) Dim sCharsBuilder As New SqlCommandBuilder(sCharsAdapter) sCharsAdapter.Fill(sCharsDs, "tCharacter") sCharsTable = sCharsDs.Tables("tCharacter") Con.Close() DataGridView5.DataSource = sCharsDs.Tables("tCharacter") End Sub Public Sub FullItemSearch() If ItemView.RowCount > 0 Then sItemDs.Clear() End If Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM tItem" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sItemAdapter = New SqlDataAdapter(cdo) Dim sItemBuilder As New SqlCommandBuilder(sItemAdapter) sItemAdapter.Fill(sItemDs, "tItem") sItemTable = sItemDs.Tables("tItem") Con.Close() ItemView.DataSource = sItemDs.Tables("tItem") End Sub Public Function SplitToCurrency(x As Integer) As String Dim gem As Integer = CInt(Math.Truncate(CDec(x / 1000000))) Dim gold As Integer = CInt(Math.Truncate(CDec(x - gem * 1000000) / 1000)) Dim silver As Integer = x - gem * 1000000 - gold * 1000 Return gem.ToString & " Gem " & gold.ToString & " Gold " & silver.ToString & " Silver" TotalMoney.Text = SplitToCurrency End Function Public Sub OnlineChars() If OnlinePlayers.RowCount > 0 Then sOnDs.Clear() End If Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT * FROM LoggedInChars" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sOnAdapter = New SqlDataAdapter(cdo) Dim sOnBuilder As New SqlCommandBuilder(sOnAdapter) sOnAdapter.Fill(sOnDs, "LoggedInChars") sOnTable = sOnDs.Tables("LoggedInChars") Con.Close() OnlinePlayers.DataSource = sOnDs.Tables("LoggedInChars") OnlineNumber.Text = OnlinePlayers.RowCount End Sub Private Sub AccountSearch() Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim AccCon As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLAccount & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT COUNT(sUserID) FROM dbo.tUser WHERE sUserID='" & AccountID.Text & "';" Dim cdo As SqlCommand = New SqlCommand(strSQL, AccCon) Con.Open() AccCon.Open() Dim countchar As Integer = cdo.ExecuteScalar() If countchar = "1" Then Dim strAccSQL As String = "SELECT nUserNo, sIP, nAGPoints, sNotes FROM dbo.tUser WHERE sUserID='" & AccountID.Text & "';" Dim catCMDAcc As SqlCommand = New SqlCommand(strAccSQL, AccCon) Dim myAccountReader As SqlDataReader = catCMDAcc.ExecuteReader() While myAccountReader.Read AccountNo.Text = myAccountReader(0) IP.Text = myAccountReader(1) Coins.Text = myAccountReader(2) Notes.Text = myAccountReader(3) End While myAccountReader.Close() Con.Close() Con.Open() Dim strSQL2 As String If Delete.Checked = True Then strSQL2 = "SELECT sID FROM dbo.tCharacter WHERE nUserNo='" & AccountNo.Text & "';" Else strSQL2 = "SELECT sID FROM dbo.tCharacter WHERE nUserNo='" & AccountNo.Text & "' AND bDeleted = 0;" End If Dim catCMD As SqlCommand = New SqlCommand(strSQL2, Con) Dim myReader As SqlDataReader = catCMD.ExecuteReader() InfoTextBox.Text &= Environment.NewLine & Now & " || Account: " & AccountID.Text & " Found" CharacterList.Items.Clear() While myReader.Read() CharacterList.Items.Add(myReader(0)) End While myReader.Close() AccCon.Close() Con.Close() Else InfoTextBox.Text &= Environment.NewLine & Now & " || User Does not Exist!" AccCon.Close() Con.Close() End If AccountID.BackColor = Color.Empty Level.BackColor = Color.Empty CharacterList.BackColor = Color.Empty End Sub Private Sub AcocuntNoSearch() Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim AccCon As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLAccount & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "SELECT COUNT(sUserID) FROM dbo.tUser WHERE sUserID='" & AccountID.Text & "';" Dim cdo As SqlCommand = New SqlCommand(strSQL, AccCon) Con.Open() AccCon.Open() Dim countchar As Integer = cdo.ExecuteScalar() If countchar = "1" Then Dim strAccSQL As String = "SELECT nUserNo FROM dbo.tUser WHERE nUserNo='" & AccountID.Text & "';" Dim catCMDAcc As SqlCommand = New SqlCommand(strAccSQL, AccCon) Dim myAccountReader As SqlDataReader = catCMDAcc.ExecuteReader() While myAccountReader.Read AccountID.Text = myAccountReader(0) End While myAccountReader.Close() Con.Close() Con.Open() Dim strSQL2 As String = "SELECT sID FROM dbo.tCharacter WHERE nCharID='" & AccountNo.Text & "';" Dim catCMD As SqlCommand = New SqlCommand(strSQL2, Con) Dim myReader As SqlDataReader = catCMD.ExecuteReader() InfoTextBox.Text &= Environment.NewLine & Now & " Account: " & AccountNo.Text & " Found" CharacterList.Items.Clear() While myReader.Read() CharacterList.Items.Add(myReader(0)) End While myReader.Close() AccCon.Close() Con.Close() Else InfoTextBox.Text &= Environment.NewLine & Now & " User Does not Exist!" AccCon.Close() Con.Close() End If AccountID.BackColor = Color.Empty Level.BackColor = Color.Empty CharacterList.BackColor = Color.Empty End Sub Private Sub ServerStatistics() Dim AccCon As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLAccount & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim CharCon As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") '#### Accounts #### Dim strSQL As String = "SELECT COUNT(nUserNo) FROM dbo.tUser" Dim catCMD As SqlCommand = New SqlCommand(strSQL, AccCon) AccCon.Open() Dim Reader As SqlDataReader = catCMD.ExecuteReader() While Reader.Read TotalAcc.Text = Reader(0) End While Reader.Close() AccCon.Close() '#### Characters #### Dim strSQL2 As String = "SELECT COUNT(nCharNo) FROM dbo.tCharacter" Dim catCMD2 As SqlCommand = New SqlCommand(strSQL2, CharCon) CharCon.Open() Dim Reader2 As SqlDataReader = catCMD2.ExecuteReader() While Reader2.Read TotalChar.Text = Reader2(0) End While Reader2.Close() CharCon.Close() 'Dim strSQL3 As String = "SELECT COUNT(nCharNo) FROM dbo.LoggedInChars" 'Dim catCMD3 As SqlCommand = New SqlCommand(strSQL3, CharCon) 'CharCon.Open() 'Dim Reader3 As SqlDataReader = catCMD3.ExecuteReader() 'While Reader3.Read ' OnChar.Text = Reader3(0) 'End While 'Reader3.Close() 'CharCon.Close() Dim strSQL4 As String = "SELECT COUNT(nNo) FROM dbo.tGuild" Dim catCMD4 As SqlCommand = New SqlCommand(strSQL4, CharCon) CharCon.Open() Dim Reader4 As SqlDataReader = catCMD4.ExecuteReader() While Reader4.Read TotalGuild.Text = Reader4(0) End While Reader4.Close() CharCon.Close() End Sub Private Sub Search_Click(sender As System.Object, e As System.EventArgs) Handles Search.Click If AccountID.Text.Length > 0 Then AccountSearch() ElseIf CharacterList.Text.Length > 0 Then CharacterSearch() ElseIf CharacterNo.Text.Length > 0 Then CharacterSearch() ElseIf AccountNo.Text.Length > 0 Then AcocuntNoSearch() Else InfoTextBox.Text &= Environment.NewLine & Now & " Oops anything going wrong with me :S Try again!" End If End Sub Private Sub Save_Click(sender As System.Object, e As System.EventArgs) Handles Save.Click If ErrorHandling = 0 Then Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") Dim strSQL As String = "UPDATE dbo.tCharacter SET nExp='" & Exp.Text & "', nFame='" & Fame.Text & "', nMoney='" & Money.Text & "', nLevel='" & Level.Text & "', sID='" & CharacterList.Text & "', nAdminLevel='" & Admin.Text & "', nStrength='" & STR.Text & "', nConstitute='" & END_.Text & "', nDexterity='" & DEX.Text & "', nIntelligence='" & INT.Text & "', nMentalPower='" & SPR.Text & "', sLoginZone='" & Zone.Text & "', sKQMap='" & KQZone.Text & "' WHERE nCharNo='" & CharacterNo.Text & "';" Dim catCMD As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() catCMD.ExecuteNonQuery() Con.Close() ClassUpdate() sAdapter.Update(sTable) sSkillAdapter.Update(sSkillTable) sTAdapter.Update(sTTable) InfoTextBox.Text &= Environment.NewLine & Now & " || Character: " & CharacterList.Text & " has been successfully edited!" CharacterList.Items.Clear() AccountSearch() End If End Sub Private Sub CharacterName_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CharacterList.SelectedIndexChanged CharacterNo.Text = "" CharacterSearch() End Sub Private Sub Clear_Click(sender As Object, e As EventArgs) Handles Clear.Click InfoTextBox.Text &= Environment.NewLine & Now & " || Search Cleared" AccountNo.Text = "" AccountID.Text = "" CharacterList.Items.Clear() CharacterList.Text = "" CharacterNo.Text = "" Logins.Text = "" Exp.Text = "" Fame.Text = "" Money.Text = "" KQZone.Text = "" SPR.Text = "" INT.Text = "" DEX.Text = "" END_.Text = "" STR.Text = "" Admin.Text = "" Zone.Text = "" CharacterNo.Text = "" AccountNo.Text = "" Level.Text = "" CharacterList.Text = "" Job.Text = "" Gender.Text = "" IP.Text = "" Coins.Text = "" Notes.Text = "" DataGridView1.DataSource.Rows.Clear() DataGridView2.DataSource.Rows.Clear() DataGridView3.DataSource.Rows.Clear() End Sub Private Sub ShowChars_Click(sender As Object, e As EventArgs) Handles ShowChars.Click FullCharSearch() End Sub Private Sub ClearChars_Click(sender As Object, e As EventArgs) Handles ClearChars.Click DataGridView5.DataSource.Rows.Clear() End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick 'OnlineChars() ServerStatistics() End Sub Private Sub SaveT_Click(sender As Object, e As EventArgs) Handles SaveT.Click 'If ErrorHandling = 0 Then ' Dim AccCon As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLAccount & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") ' Dim strSQL2 As String = "UPDATE dbo.tUser SET sUserID='" & AccountID.Text & "', nAGPoints='" & Coins.Text & "', sNotes='" & Notes.Text & "' WHERE nCharNo='" & CharacterNo.Text & "';" ' Dim catCMD2 As SqlCommand = New SqlCommand(strSQL2, AccCon) ' AccCon.Open() ' catCMD2.ExecuteNonQuery() ' AccCon.Close() 'End If End Sub Private Sub StopTimer_Click(sender As Object, e As EventArgs) Handles StopTimer.Click Timer1.Stop() End Sub Private Sub StartTimer_Click(sender As Object, e As EventArgs) Handles StartTimer.Click Timer1.Start() End Sub Private Sub UpdateAcc_Click(sender As Object, e As EventArgs) Handles UpdateAcc.Click sAccAdapter.Update(sAccTable) If sAccAdapter.Update(sAccTable) = True Then UpAccLabel.Text = "Account Table updated successfully." UpAccLabel.ForeColor = Color.Olive End If End Sub Private Sub ReloadAcc_Click(sender As Object, e As EventArgs) Handles ReloadAcc.Click AccList.DataSource.Rows.Clear() Threading.Thread.Sleep(500) FullAccSearch() End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click ItemView.DataSource.Rows.Clear() Threading.Thread.Sleep(500) Dim Con As SqlConnection = New SqlConnection("Data Source=" & SQLHost & "; Initial Catalog=" & SQLCharacter & "; User ID=" & SQLUserName & "; Password=" & SQLPassword & ";") If ItemIDSearch.Text = "" Then Dim strSQL2 As String = "SELECT * FROM tItem" Dim cdo2 As SqlCommand = New SqlCommand(strSQL2, Con) Con.Open() sItemAdapter = New SqlDataAdapter(cdo2) Dim sItemBuilder2 As New SqlCommandBuilder(sItemAdapter) sItemAdapter.Fill(sItemDs, "tItem") sItemTable = sItemDs.Tables("tItem") Con.Close() ItemView.DataSource = sItemDs.Tables("tItem") Else Dim strSQL As String = "SELECT * FROM tItem WHERE nItemID=" & ItemIDSearch.Text & ";" Dim cdo As SqlCommand = New SqlCommand(strSQL, Con) Con.Open() sItemAdapter = New SqlDataAdapter(cdo) Dim sItemBuilder As New SqlCommandBuilder(sItemAdapter) sItemAdapter.Fill(sItemDs, "tItem") sItemTable = sItemDs.Tables("tItem") Con.Close() ItemView.DataSource = sItemDs.Tables("tItem") End If End Sub Private Sub Save_IDB_Click(sender As Object, e As EventArgs) Handles Save_IDB.Click sItemAdapter.Update(sItemTable) End Sub Private Sub ItemFilter_Click(sender As Object, e As EventArgs) Handles ItemFilter.Click ItemSearch() End Sub End Class