HASH-Cafe (Server) VB.NET
HASH-Cafe (Server) VB.NET
FORM 1
Imports System.Data.OleDb
Public Class Server
Public PC As String
Public filepath As String = "C:\Users\Joshu\Desktop\COMLAB CLIENT\DATABASE\Config"
Private Sub GunaTileButton1_Click(sender As Object, e As EventArgs) Handles GunaTileButton1.Click
'Open
Try
connection()
With command
.Connection = con
.CommandText = "UPDATE [Clients] SET [u2] = @u2 WHERE [u1] LIKE '" & ListView1.FocusedItem.Text & "'"
.Parameters.AddWithValue("@u2", "True")
.ExecuteNonQuery()
IO.File.Copy(filepath & "\PC.txt", filepath & "\" & ListView1.FocusedItem.Text & ".txt", True)
MsgBox("Done!")
con.Close()
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub GunaTileButton2_Click(sender As Object, e As EventArgs) Handles GunaTileButton2.Click
'Lock
Try
connection()
With command
.Connection = con
.CommandText = "UPDATE [Clients] SET [u2] = @u2 WHERE [u1] LIKE '" & ListView1.FocusedItem.Text & "'"
.Parameters.AddWithValue("@u2", "False")
.ExecuteNonQuery()
My.Computer.FileSystem.DeleteFile(filepath & "\" & ListView1.FocusedItem.Text & ".txt")
MsgBox("Done!")
con.Close()
End With
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub GunaTileButton3_Click(sender As Object, e As EventArgs) Handles GunaTileButton3.Click
'Refresh
Try
connection()
Me.ListView1.Items.Clear()
command = New OleDbCommand("SELECT * FROM [Clients]", con)
dr = command.ExecuteReader
While dr.Read
list = Me.ListView1.Items.Add(dr.Item(1).ToString, 0)
End While
dr.Close()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Private Sub GunaTileButton4_Click(sender As Object, e As EventArgs) Handles GunaTileButton4.Click
'Config
Config.ShowDialog()
End Sub
Private Sub GunaAdvenceButton1_Click(sender As Object, e As EventArgs) Handles GunaAdvenceButton1.Click
'Close Message
Try
My.Computer.FileSystem.DeleteFile(filepath & "\Message.txt")
Catch ex As Exception
MsgBox("Message Already Close")
End Try
End Sub
Private Sub RichTextBox1_TextChanged(sender As Object, e As EventArgs) Handles RichTextBox1.TextChanged
End Sub
Private Sub GunaAdvenceButton2_Click(sender As Object, e As EventArgs) Handles GunaAdvenceButton2.Click
'Send Message
Try
IO.File.Copy(filepath & "\CM.txt", filepath & "\Message.txt", True)
Dim afile As New IO.StreamWriter(filepath & "\Message.txt", True)
afile.WriteLine(RichTextBox1.Text)
afile.Close()
Catch ex As Exception
End Try
End Sub
End Class
FORM 2
FORM 2
Option Explicit On
Imports System.Data.OleDb
Imports System.IO
Public Class Config
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
Try
Dim filepath As String = Application.StartupPath + "\DATABASE\Config\DBConnection.txt"
Dim linenumber As Integer
Dim reader As New System.IO.StreamReader(filepath)
Dim allLines As List(Of String) = New List(Of String)
Do While Not reader.EndOfStream
allLines.Add(reader.ReadLine())
Loop
If ReadLine(1, allLines) = "HASH" Then
GunaTextBox1.Text = ReadLine(2, allLines)
reader.Close()
Else
MsgBox("NOT OKAY")
End If
Catch ex As Exception
End Try
End Sub
Public Function ReadLine(lineNumber As Integer, lines As List(Of String)) As String
Return lines(lineNumber - 1)
End Function
Private Sub GunaButton1_Click(sender As Object, e As EventArgs) Handles GunaButton1.Click
Config1 = GunaTextBox1.Text
Try
If con.State = ConnectionState.Open Then
con.Close()
End If
con = New OleDbConnection("Provider = Microsoft.jet.OleDB.4.0;Data Source = " & Application.StartupPath & "\DATABASE\" & Config1 & ";")
con.Open()
Server.Show()
Me.Hide()
Catch ex As Exception
MessageBox.Show("Can't Connect to the Database!", "System", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Class
MODULE 1
Imports System.Data.OleDb
Module DB
Public list As ListViewItem
Public con As New OleDbConnection
Public command As New OleDbCommand
Public dr As OleDbDataReader
Public Config1 As String
Sub connection()
Try
If con.State = ConnectionState.Open Then
con.Close()
End If
con = New OleDbConnection("Provider = Microsoft.jet.OleDB.4.0;Data Source = " & Application.StartupPath & "\DATABASE\" & Config1 & ";")
con.Open()
Catch ex As Exception
MessageBox.Show("Can't Connect to the Database!", "System", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Sub
End Module

Comments
Post a Comment