modul x login dan periode - cahyosuminar.files.wordpress.com · 6 didik nugroho stmik sinar...

10
Modul x login dan Periode A.Tujuan 1.Membuat form untuk kegiatan proses posting B.Teori B.1 Membuat Pesan 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.") End If 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.

Upload: hoangcong

Post on 11-Mar-2019

222 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

Modul x

login dan Periode

A.Tujuan

1.Membuat form untuk kegiatan proses posting

B.Teori

B.1 Membuat Pesan

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.") End If

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.

Page 2: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

2 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

'

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.

End If

'

' 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 Sub

End Class

B.2

Page 3: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

3 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

C. Desain Sistem Proses posting

Gambar 7.1 DFD proses posting

D. Persiapan

1.1 Proses login

adminnya

Petugas Username password

Dt user

1.2 Proses

Pilih / buat periode

Tabel_periode

Dt periode

Dt periode baru

Data periode

Page 4: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

4 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

Isikan tabel

Page 5: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

5 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

Buat tabel_ periode

Page 6: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

6 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

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() End If Catch ex As Exception MsgBox(Err.Description, MsgBoxStyle.Critical, "Error") End Try End Sub End Module

d.1 Desain Form Login

Gambar desain Form login

a. Pada awal tambahkan Imports System.Data.SqlClient

b. Form load

Page 7: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

7 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

Private Sub Flogin_Load(sender As Object, e As EventArgs) Handles MyBase.Load Call buka() xlogin.Text = "" xpass.Text = "" End Sub 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 ") End If End Sub

c. Tombol logout

Private Sub logout_Click(sender As Object, e As EventArgs) Handles logout.Click

Application.Exit() End Sub

2. Buat form fperiode :

Page 8: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

8 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

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

Page 9: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

9 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

End If End Sub Sub isi_bulan() xbulan.Items.Clear() For i = 1 To 31 xbulan.Items.Add(Str(i)) Next End Sub 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) End Sub 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) End Sub ‘** TOMBOL PROSES Private Sub PROSES_Click(sender As Object, e As EventArgs) Handles PROSES.Click

Page 10: Modul x login dan Periode - cahyosuminar.files.wordpress.com · 6 Didik Nugroho STMIK SINAR NUSANTARA 2016/2017 semester Gasal Modul Pemrograman Database vb.net 1. Buat project Baru

10 Didik Nugroho

STMIK SINAR NUSANTARA 2016/2017 semester Gasal

Modul Pemrograman Database vb.net

If jperiode = 0 Then tambah_periode() Else periode_bulan = ListView1.SelectedItems(0).Text periode_tahun = ListView1.SelectedItems(0).SubItems(1).Text End If Me.Hide() ‘* ditulis jika fmenu sudah ada ‘ Fmenu_utama.ShowDialog() End Sub End Class

CATATAN :tanda ‘ pada fmenu dibuang jika fmenu sudah ada.