Source Code Sistem Informasi Parkiran ( VB .NET)

Imports System.Data.SqlClient


Public Class Form1
Dim kon As New SqlConnection
Dim kom As New SqlCommand
Dim da As New SqlDataAdapter
Dim ds As New DataSet
Dim sql As String
Dim tbl As DataTable
Sub konek()
Try
kon.Close()
kon.ConnectionString = "Data Source=.\SQLEXPRESS;AttachDbFilename=D:\KULIAH\SEMESTER 4\PRAKTIKUM BASIS DATA\FINAL PROJECT\FP PARKIRAN\FP PARKIRAN\parkir.mdf;Integrated Security=True;User Instance=True"
kon.Open()
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub
Sub data_record()
Call konek()
sql = "select*from parkir"
da = New SqlDataAdapter(sql, kon)
da.Fill(ds, "parkir")
Dim gridview As New DataView(ds.Tables("parkir"))
DGparkir.DataSource = gridview
DGparkir.Columns(0).Width = 40
DGparkir.Columns(1).Width = 100
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
konek()
data_record()
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
kom.Connection = kon
kom.CommandText = "insert into parkir values('" & TextBox1.Text & "','" & TextBox2.Text & "')"
kom.ExecuteNonQuery()
MsgBox("Data Telah Di Simpan")

Catch ex As Exception
MsgBox(ex.Message)

End Try
End Sub

Private Sub DGparkir_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGparkir.CellContentClick

End Sub

Private Sub DGparkir_DoubleClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles DGparkir.DoubleClick
TextBox1.Text = DGparkir.SelectedCells(0).Value
TextBox2.Text = DGparkir.SelectedCells(1).Value
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Try
kom.Connection = kon
kom.CommandText = "delete from parkir where nopol = ('" & TextBox1.Text & "')"
kom.ExecuteNonQuery()
MsgBox("Data Telah Di Hapus")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
kom.Connection = kon
kom.CommandText = "update parkir set jenis_kendaraan = '" & TextBox2.Text & "' where nopol = '" & TextBox1.Text & "'"
kom.ExecuteNonQuery()
TextBox1.Text = ""
TextBox1.Text = ""
MsgBox("Data Telah Di Ubah")
Catch ex As Exception
MsgBox(ex.Message)
End Try
End Sub

Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click

End Sub

Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

End Sub
End Class

Posting Komentar

About this blog

Diberdayakan oleh Blogger.

About Me

Foto saya
kalo anda mengenAL saya,, anda ga mgkin menyesal apabila ntar qta berteman...