Thursday, 21 May 2015
Sunday, 3 May 2015
Posted By:
Nulled
Aplikasi PSB Dengan Visual Basic 2012
PSB APPLICATION - VISUAL BASIC 2012 & SQL SERVER 2012
Pertama yang kita butuhkan adalah :
- Visual Basic 2012.
- SQL Server 2012.
- Tidak Mengantuk + Semangat.
Kedua buatlah database dengan nama "db_smkti"
Selanjutnya buatlah table dengan nama "tb_pendaftaran"
Lalu isi field nya beserta tipe data seperti gambar dibawah ini
Setelah pembuatan database selesai, sekarang kita akan membuat aplikasi nya.
1. pertama buatlah file config.vb , dengan langkah seperti gambar dibawah ini :
Selanjutnya ketikkan code berikut di file config.vb yang kita buat tadi..
Berikut codenya "config.vb" :
- Imports System.Data.SqlClient
- Module Config
- Public cn As New SqlConnection
- Public cmd As New SqlCommand
- Sub opendb()
- cn.ConnectionString = "Data Source=REZAPADILLAH-PC\SQLEXPRESS;Initial Catalog=db.smkti;Integrated Security=True"
- cn.Open()
- If cn.State = ConnectionState.Open Then
- MessageBox.Show("DB Open")
- Else
- MessageBox.Show("DB Open Failed")
- End If
- End Sub
- End Module
Setelah itu buat lah form baru dengan nama "FrmPendaftaran" dengan isi :
- 5 buah textbox
- 1 buah datetimepicker
- 1 buah datagridview
- 4 buah buttonSetelah selesai design form FrmPendaftaran sebagai berikut..
KETERANGAN :Selanjutnya ketikkan kode berikut di dalam form FrmPendaftaran :
- Textbox " id pendaftaran" diberi nama " txtid " - Textbox " nama " diberi nama " txtnama " - Textbox " tempat lahir " diberi nama " txttempatlahir " - Datetimepicker " tanggal lahir " diberi nama " tgl_lahir " - Textbox " asal sekolah " diberi nama " txtasalsekolah " - Textbox " alamat pendaftar " diberi nama " txtalamat " - Datagridview diberi nama " DataGridView1 " - Button " insert " diberi nama " btninsert " - Button " update " diberi nama " btnupdate " - Button " delete " diberi nama " btndelete " - Button " refresh " diberi nama " btnrefresh "
- Imports System.Data.SqlClient
- Public Class FrmPendaftaran
- Sub opentable()
- cmd.Connection = cn
- cmd.CommandText = "SELECT * FROM tb_pendaftaran"
- Dim rd As SqlDataReader = cmd.ExecuteReader
- Dim dt As New DataTable
- dt.Load(rd)
- DataGridView1.DataSource = dt
- End Sub
- Sub bersih()
- txtid.Text = ""
- txtnama.Text = ""
- txttempatlahir.Text = ""
- tgl_lahir.Text = ""
- txtasalsekolah.Text = ""
- txtalamat.Text = ""
- End Sub
- Sub kodeotomatis()
- Dim kodeauto As Single
- cmd.Connection = cn
- cmd.CommandText = "SELECT COUNT(*) as id_pendaftaran FROM tb_pendaftaran"
- Dim rd As SqlDataReader = cmd.ExecuteReader
- While rd.Read
- kodeauto = Val(rd.Item("id_pendaftaran").ToString) + 1
- End While
- Select Case Len(Trim(kodeauto))
- Case 1 : txtid.Text = "IP00" + Trim(Str(kodeauto))
- Case 1 : txtid.Text = "IP0" + Trim(Str(kodeauto))
- Case 1 : txtid.Text = "IP" + Trim(Str(kodeauto))
- End Select
- rd.Close()
- cn.Close()
- End Sub
- Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
- End
- End Sub
- Private Sub FrmPendaftaran_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- opendb()
- opentable()
- kodeotomatis()
- End Sub
- Private Sub btninsert_Click(sender As Object, e As EventArgs) Handles btninsert.Click
- cn.Open()
- cmd.Connection = cn
- cmd.CommandText = "INSERT INTO tb_pendaftaran VALUES ('" & txtid.Text & "','" & txtnama.Text & "','" & txttempatlahir.Text & "','" & tgl_lahir.Value & "','" & txtasalsekolah.Text & "','" & txtalamat.Text & "')"
- cmd.ExecuteNonQuery()
- MessageBox.Show("Data Berhasil Tersimpan")
- bersih()
- End Sub
- Private Sub DataGridView1_DoubleClick(sender As Object, e As EventArgs) Handles DataGridView1.DoubleClick
- txtid.Text = DataGridView1.SelectedCells(0).Value
- txtnama.Text = DataGridView1.SelectedCells(1).Value
- txttempatlahir.Text = DataGridView1.SelectedCells(2).Value
- tgl_lahir.Text = DataGridView1.SelectedCells(3).Value
- txtasalsekolah.Text = DataGridView1.SelectedCells(4).Value
- txtalamat.Text = DataGridView1.SelectedCells(5).Value
- End Sub
- Private Sub btnupdate_Click(sender As Object, e As EventArgs) Handles btnupdate.Click
- cmd.Connection = cn
- cmd.CommandText = "UPDATE tb_pendaftaran SET nama = '" & txtnama.Text & "', tempat_lahir = '" & txttempatlahir.Text & "', tanggal_lahir = '" & tgl_lahir.Value & "', asal_sekolah = '" & txtasalsekolah.Text & "', alamat_pendaftar = '" & txtalamat.Text & "' where id_pendaftaran = '" & txtid.Text & "'"
- cmd.ExecuteNonQuery()
- MessageBox.Show("Data Berhasil Terubah")
- bersih()
- End Sub
- Private Sub btnrefresh_Click(sender As Object, e As EventArgs) Handles btnrefresh.Click
- opentable()
- End Sub
- Private Sub btndelete_Click(sender As Object, e As EventArgs) Handles btndelete.Click
- Dim baris As Integer
- Dim id As String
- baris = DataGridView1.CurrentCell.RowIndex
- id = DataGridView1(0, baris).Value.ToString
- cmd.Connection = cn
- cmd.CommandText = "DELETE FROM tb_pendaftaran WHERE id_pendaftaran = '" + id + "'"
- cmd.ExecuteNonQuery()
- MessageBox.Show("Data Berhasil Terhapus")
- opentable()
- End Sub
- Private Sub FrmPendaftaran_FormClosed(sender As Object, e As FormClosedEventArgs) Handles MyBase.FormClosed
- cn.Open()
- End Sub
- Private Sub txtasalsekolah_TextChanged(sender As Object, e As EventArgs) Handles txtasalsekolah.TextChanged
- End Sub
- End Class
DOWNLOAD APLIKASI PSB - HERE
Subscribe to:
Posts (Atom)