Modul VB Class Koneksi
Modul VB Class Koneksi
CLASS KONEKSI
Imports System.Data.OleDb
Public Class clskoneksi
Protected tblLogin = New DataTable
Protected SQL As String
Protected database As OleDb.OleDbConnection
Protected Cmd As OleDb.OleDbCommand
Protected Da As OleDb.OleDbDataAdapter
Protected Ds As DataSet
Protected Dt As DataTable
Public Function OpenConn() As Boolean
database = New OleDbConnection("Provider=Microsoft.ACE.OleDb.12.0; Data
Source=tubes vb.mdb")
database.Open()
If database.State <> ConnectionState.Open Then
Return False
Else
Return True
End If
End Function
Public Sub CloseConn()
If Not IsNothing(database) Then
database.Close()
database = Nothing
End If
End Sub
Public Function ExecuteQuery(ByVal Query As String) As DataTable
If Not OpenConn() Then
MsgBox("Koneksi gagal!!", MsgBoxStyle.Critical, "Access Failed")
Return Nothing
Exit Function
End If
Sub koneksi()
Try
database = New
OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=tubes vb.mdb")
database.Open()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub data_record()
Try
tabel = New Data.OleDb.OleDbDataAdapter("select * from
Pasien_Baru", database)
data = New DataSet
tabel.Fill(data)
record.DataSource = data
record.DataMember = data.Tables(0).ToString()
DataGridView1.DataSource = record
DataGridView1.Columns(0).Width = 200
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub bersih()
ComboBox1.Text = ""
TextBox1.Text = ""
Call koneksi()
Call data_record()
End Sub
ComboBox1.Text = DataGridView1.SelectedCells(0).Value
TextBox1.Text = DataGridView1.SelectedCells(1).Value
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
End Class
Imports System.Data
Imports System.Data.OleDb
Public Class FormObat
Dim database As OleDbConnection
Dim tabel As OleDbDataAdapter
Dim data As DataSet
Dim record As New BindingSource
Dim tekan As Integer
Sub koneksi()
Try
database = New
OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source=tubes vb.mdb")
database.Open()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub data_record()
Try
tabel = New Data.OleDb.OleDbDataAdapter("select * from Obat",
database)
data = New DataSet
tabel.Fill(data)
record.DataSource = data
record.DataMember = data.Tables(0).ToString()
dgview.DataSource = record
dgview.Columns(0).Width = 100
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
Call koneksi()
Call data_record()
End Sub
End Sub
Private Sub dgview_CellDoubleClick(ByVal sender As Object, ByVal e As
System.Windows.Forms.DataGridViewCellEventArgs) Handles
dgview.CellDoubleClick
Try
TextBox1.Text = dgview.SelectedCells(0).Value
TextBox2.Text = dgview.SelectedCells(1).Value
TextBox3.Text = dgview.SelectedCells(2).Value
TextBox4.Text = dgview.SelectedCells(3).Value
TextBox5.Text = dgview.SelectedCells(4).Value
TextBox6.Text = dgview.SelectedCells(5).Value
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
End Sub
Imports System.Data
Imports System.Data.OleDb
Sub Login()
If TextBox1.Text = "" Then TextBox1.Focus() : Exit Sub
If TextBox2.Text = "" Then TextBox2.Focus() : Exit Sub
tblLogin = Proses.ExecuteQuery("Select * From Admin Where Nama = '" &
TextBox1.Text & "' and Password='" & TextBox2.Text & "'")
If tblLogin.Rows.Count = 0 Then
MessageBox.Show("Login tidak berhasil..!!", "Informasi",
MessageBoxButtons.OK, MessageBoxIcon.Information)
TextBox1.Focus()
Else
FormIsiDataAdmin.Show()
Me.Hide()
End If
End Sub
Imports System.Data
Imports System.Data.OleDb
Public Class FormIsiUSerBaru
Dim database As OleDbConnection
Dim tabel As OleDbDataAdapter
Dim data As DataSet
Dim record As New BindingSource
Dim tekan As Integer
Sub koneksi()
Try
database = New
OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data Source = tubes
vb.mdb")
database.Open()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub data_record()
Try
tabel = New Data.OleDb.OleDbDataAdapter("select * from
Pasien_Baru", database)
data = New DataSet
tabel.Fill(data)
record.DataSource = data
record.DataMember = data.Tables(0).ToString()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub bersih()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
Call koneksi()
Call data_record()
End Sub
Imports System.Data
Imports System.Data.OleDb
Public Class FormDokter
Dim database As OleDbConnection
Dim tabel As OleDbDataAdapter
Dim data As DataSet
Dim record As New BindingSource
Dim tekan As Integer
Sub koneksi()
Try
database = New OleDbConnection("Provider=Microsoft.Jet.Oledb.4.0;Data
Source=tubes vb.mdb")
database.Open()
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub data_record()
Try
tabel = New Data.OleDb.OleDbDataAdapter("select * from dokter", database)
data = New DataSet
tabel.Fill(data)
record.DataSource = data
record.DataMember = data.Tables(0).ToString()
DataGridView1.DataSource = record
DataGridView1.Columns(0).Width = 100
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Sub bersih()
ComboBox1.Text = ""
TextBox1.Text = ""
TextBox2.Text = ""
Call koneksi()
Call data_record()
End Sub
ComboBox1.Text = DataGridView1.SelectedCells(0).Value
TextBox1.Text = DataGridView1.SelectedCells(1).Value
TextBox2.Text = DataGridView1.SelectedCells(2).Value
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
End Sub
DESCENDING
ListBox1.Sorted = True
ListBox1.Sorted = False
Dim i As Integer
Dim count = ListBox1.Items.Count
For i = ListBox1.Items.Count - 1 To 0 Step -1
ListBox1.Items.Add(ListBox1.Items(i))
Next
For i = 0 To count - 1
ListBox1.Items.RemoveAt(ListBox1.SelectedItem)
Next
End Sub