A.Tujuan 1.Membuat form untuk kegiatan proses posting B.Teori B.1 Membuat Pesan Modul x login dan Periode Dim msgrslt As MsgBoxResult = MsgBox("Are you 21 years old or older?.", MsgBoxStyle.YesNo) If msgrslt = MsgBoxResult.Yes Then MsgBox("You are welcome to join.") ElseIf msgrslt = MsgBoxResult.No Then MsgBox("You must be at least 21 years old to join.") Public Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles MyBase.Load First show a single-argument dialog box with MessageBox.Show. MessageBox.Show("Dot Net Perls is awesome.") Show a two-argument dialog box with this method. MessageBox.Show("Dot Net Perls is awesome.", _ "Important Message") Use a three-argument dialog box with MessageBox.Show.... Also store the result value in a variable slot. Dim result1 As DialogResult = MessageBox.Show("Is Dot Net Perls awesome?", _ "Important Question", _ MessageBoxButtons.YesNo) Use four parameters with the method.... Use the YesNoCancel enumerated constant and the Question icon. Dim result2 As DialogResult = MessageBox.Show("Is Dot Net Perls awesome?", _ "Important Query", _ MessageBoxButtons.YesNoCancel, _ MessageBoxIcon.Question) Use five arguments on the method.... This asks a question and you can test the result using the variable.
2 Dim result3 As DialogResult = MessageBox.Show("Is Visual Basic awesome?", _ "The Question", _ MessageBoxButtons.YesNoCancel, _ MessageBoxIcon.Question, _ MessageBoxDefaultButton.Button2) Use if-statement with dialog result. If result1 = DialogResult.Yes And _ result2 = DialogResult.Yes And _ result3 = DialogResult.No Then MessageBox.Show("You answered yes, yes and no.") Another dialog. Use MessageBox.Show overload that has seven arguments. MessageBox.Show("Dot Net Perls is the best.", _ "Critical Warning", _ MessageBoxButtons.OKCancel, _ MessageBoxIcon.Warning, _ MessageBoxDefaultButton.Button1, _ MessageBoxOptions.RightAlign, _ True) Show a dialog box with a single button. MessageBox.Show("Dot Net Perls is super.", _ "Important Note", _ MessageBoxButtons.OK, _ MessageBoxIcon.Exclamation, _ MessageBoxDefaultButton.Button1) End Class B.2
3 C. Desain Sistem Proses posting adminnya Dt user 1.1 Proses login Username password Petugas Tabel_periode Dt periode 1.2 Proses Pilih / buat periode Data periode Dt periode baru Gambar 7.1 DFD proses posting D. Persiapan
4 Isikan tabel
5 Buat tabel_ periode
6 1. Buat project Baru :contoh dengan nama : akunting 2. Buat Modul, dengan nama : Moduletoko Imports System.Data.Sql Imports System.Data.SqlClient Module Moduletoko Public koneksi As SqlConnection Public data As DataSet Public baca As SqlDataReader Public adaptor As SqlDataAdapter Public cmd As SqlCommand Public ass As DataTable Public sql As String Public periode_bulan, periode_tahun As String Public Sub buka() sql = "Data Source=WIN7-PC\SQLEXPRESS;Initial Catalog=toko_db;Integrated Security=True" koneksi = New SqlConnection(sql) Try If koneksi.state = ConnectionState.Closed Then koneksi.open() Catch ex As Exception MsgBox(Err.Description, MsgBoxStyle.Critical, "Error") End Try End Module d.1 Desain Form Login Gambar desain Form login a. Pada awal tambahkan Imports System.Data.SqlClient b. Form load
7 Private Sub Flogin_Load(sender As Object, e As EventArgs) Handles MyBase.Load Call buka() xlogin.text = "" xpass.text = "" b.tombol proses Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim ada As Boolean koneksi.close() Call buka() ada = False Try piye cmd = New SqlClient.SqlCommand("SELECT * FROM adminnya where username=" & xlogin.text & " and password=" & xpass.text & "", koneksi) cmd = New MySqlCommand("SELECT kode,nama FROM coba", koneksi) baca = cmd.executereader() While baca.read() ada = True End While Catch ex As Exception MessageBox.Show("tabel adminnya tidak terbaca!!!, karena " & ex.message) End Try If ada = True Then fperiode.showdialog() Me.Hide() Else MsgBox("login atau pass word salah ") c. Tombol logout Private Sub logout_click(sender As Object, e As EventArgs) Handles logout.click Application.Exit() 2. Buat form fperiode :
8 b.buat desain form Imports System.Data.SqlClient Public Class fperiode Dim jperiode As Integer Private Sub fperiode_load(sender As Object, e As EventArgs) Handles MyBase.Load Call buka() jperiode = 0 isi_bulan() periode() If jperiode > 0 Then ListView1.Enabled = True ListView1.Visible = True xbulan.visible = False XTAHUN.Visible = False Else ListView1.Enabled = False ListView1.Visible = False
9 Sub isi_bulan() xbulan.items.clear() For i = 1 To 31 xbulan.items.add(str(i)) Next Sub periode() Dim list(5) As String Dim itemlist As ListViewItem ListView1.View = View.Details ListView1.GridLines = True ListView1.FullRowSelect = True Add column header ListView1.Columns.Add("BULAN", 100) ListView1.Columns.Add("TAHUN", 70) ListView1.Columns.Add("STATUS", 70) ListView1.Items.Clear() koneksi.close() buka() Try cmd = New SqlCommand("SELECT * from tabel_periode", koneksi) baca = cmd.executereader() While baca.read() list(0) = baca("bulan") list(1) = baca("tahun") list(2) = baca("status") jperiode = jperiode + 1 End While Catch ex As Exception MessageBox.Show("tabel periode!!!, karena " & ex.message) End Try itemlist = New ListViewItem(list) ListView1.Items.Add(itemlist) Sub tambah_periode() Dim st As String st = "AKTIVE" koneksi.close() koneksi.open() sql = "INSERT INTO tabel_periode(bulan,tahun,status) VALUES(" & xbulan.text & "," & XTAHUN.Text & "," & st & ")" cmd.dispose() cmd = New SqlClient.SqlCommand(sql) cmd.connection = koneksi cmd.executenonquery() periode_bulan = Trim(xbulan.Text) periode_tahun = Trim(XTAHUN.Text) ** TOMBOL PROSES Private Sub PROSES_Click(sender As Object, e As EventArgs) Handles PROSES.Click
10 If jperiode = 0 Then tambah_periode() Else periode_bulan = ListView1.SelectedItems(0).Text periode_tahun = ListView1.SelectedItems(0).SubItems(1).Text Me.Hide() * ditulis jika fmenu sudah ada Fmenu_utama.ShowDialog() End Class CATATAN :tanda pada fmenu dibuang jika fmenu sudah ada.