Program aplikasi berkaitan dengan database dan penggunaan report dengan Visual Basic.net
Aplikasi Database Undian Berhadiah dan Reportnya
Program "Hadiah" ini adalah program yang menghubungkan database pelanggan beberapa opertaor yang menjadi member undian berhadiah. setiap penukaran poinnya berarti menukar poin sebanyak nilainya.
Organisasi akan membuat program database dan laporan untuk proyek ini.
1) Buat database Poin berhadiah dan membernya dalam Microsoft Office Access
2) Buat sebuah project VB dalam Visual Studio
3) Kemudian buatlah sebuah form untuk login. Add New Item, Login Form
4) Buat coding pada button OK:
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim login As New MDIParent1
'masukkan username dan password yg diinginkan'
If UsernameTextBox.Text = "Annisa" And PasswordTextBox.Text = "987654" Then
login.Show()
Else
MsgBox("Kesalahan saat memasukan Username atau Password")
End If
Me.Close()
End Sub
5) Buat Form MDI Parent. Add New Item, MDI Parent Form
dalam form MDI terdapat: Menu Customer dan Menu Hadiah
dalam report terdapat: Report Customer dan Report Hadiah
6) Form Menu Hadiah
Buat item windows form , masukkan data access , caranya
Add New data source, ikuti petunjuk hingga finish
--> muncul data source drag semua tabel poin
--> drag gridview, masukkan isian data gridview dengan menekan tombol kecil di bagian atas kanan datagridview. ikuti petunjuk dan pilih tampilan yang diinginkan
7) Seperti langkah pada nomor 6, lakukan untuk form Menu Customer
8) Buat windows form baru untuk menampilkan report
--> dalam form tersebut, drag MicrosoftReportViewer dari toolbox
--> buat desain report baru dengan klik tombol kecil di atas kanan report
--> new design
--> ikkuti petunjuk pembuatan desain
--> setelah selesai klik forward (segitiga kecil) lalu pilih report yg dibuat
berlaku sama pada form menu yang lain
9) tampilkan report masing-masing menu
SOURCE CODE
Login Form:
Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click
Dim login As New MDIParent1
If UsernameTextBox.Text = "Annisa" And PasswordTextBox.Text = "987654" Then
login.Show()
Else
MsgBox("Kesalahan saat memasukan Username atau Password")
End If
Me.Close()
End Sub
Form 1:
Public Class Form1
Private Sub THadiahBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles THadiahBindingNavigatorSaveItem.Click
Me.Validate()
Me.THadiahBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.HadiahDataSet)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'HadiahDataSet.THadiah' table. You can move, or remove it, as needed.
Me.THadiahTableAdapter.Fill(Me.HadiahDataSet.THadiah)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.THadiahBindingSource.Filter = "KodePoin like '%" & TextBox1.Text & "%'"
End Sub
End Class
Form 2:
Public Class Form2
Private Sub TCustomerBindingNavigatorSaveItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TCustomerBindingNavigatorSaveItem.Click
Me.Validate()
Me.TCustomerBindingSource.EndEdit()
Me.TableAdapterManager.UpdateAll(Me.HadiahDataSet)
End Sub
Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'HadiahDataSet.TCustomer' table. You can move, or remove it, as needed.
Me.TCustomerTableAdapter.Fill(Me.HadiahDataSet.TCustomer)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.TCustomerBindingSource.Filter = "KodePoin like '%" & TextBox1.Text & "%' "
End Sub
End Class
MDI Parent:
Imports System.Windows.Forms
Public Class MDIParent1
Private Sub ShowNewForm(ByVal sender As Object, ByVal e As EventArgs) Handles NewToolStripMenuItem.Click, NewWindowToolStripMenuItem.Click
Dim s As New Form1
s.MdiParent = Me
s.Show()
End Sub
Private Sub OpenFile(ByVal sender As Object, ByVal e As EventArgs) Handles OpenToolStripMenuItem.Click
Dim s As New Form2
s.MdiParent = Me
s.Show()
End Sub
Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim SaveFileDialog As New SaveFileDialog
SaveFileDialog.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.MyDocuments
SaveFileDialog.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*"
If (SaveFileDialog.ShowDialog(Me) = System.Windows.Forms.DialogResult.OK) Then
Dim FileName As String = SaveFileDialog.FileName
' TODO: Add code here to save the current contents of the form to a file.
End If
End Sub
Private Sub ExitToolsStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ExitToolStripMenuItem.Click
Me.Close()
End Sub
Private Sub CutToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
' Use My.Computer.Clipboard to insert the selected text or images into the clipboard
End Sub
Private Sub CopyToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
' Use My.Computer.Clipboard to insert the selected text or images into the clipboard
End Sub
Private Sub PasteToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
'Use My.Computer.Clipboard.GetText() or My.Computer.Clipboard.GetData to retrieve information from the clipboard.
End Sub
Private Sub ToolBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub StatusBarToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub CascadeToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CascadeToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.Cascade)
End Sub
Private Sub TileVerticalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileVerticalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileVertical)
End Sub
Private Sub TileHorizontalToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles TileHorizontalToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.TileHorizontal)
End Sub
Private Sub ArrangeIconsToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles ArrangeIconsToolStripMenuItem.Click
Me.LayoutMdi(MdiLayout.ArrangeIcons)
End Sub
Private Sub CloseAllToolStripMenuItem_Click(ByVal sender As Object, ByVal e As EventArgs) Handles CloseAllToolStripMenuItem.Click
' Close all child forms of the parent.
For Each ChildForm As Form In Me.MdiChildren
ChildForm.Close()
Next
End Sub
Private m_ChildFormNumber As Integer
Private Sub OptionsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OptionsToolStripMenuItem.Click
Dim s As New Form3
s.MdiParent = Me
s.Show()
End Sub
Private Sub CustomerToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim s As New Form4
s.MdiParent = Me
s.Show()
End Sub
Private Sub CustomerToolStripMenuItem_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CustomerToolStripMenuItem.Click
Dim s As New Form4
s.MdiParent = Me
s.Show()
End Sub