Panduan Membuat Aplikasi Koperasi Simpan Pinjam

 

Membuat database dan tabel-tabel

 

 

Membuat project dan module koneksi database

 

Imports System.Data.OleDb

Imports CrystalDecisions.CrystalReports.Engine

Imports CrystalDecisions.Shared

 

Module Module1

 

    Public CONN As OleDbConnection

    Public DA As OleDbDataAdapter

    Public DS As DataSet

    Public CMD As OleDbCommand

    Public DR As OleDbDataReader

 

    Public laporan As New ReportDocument

    Public TabelLogon As CrystalDecisions.Shared.TableLogOnInfo

 

    Public Sub SetingLaporan()

        Dim BacaTabel As CrystalDecisions.CrystalReports.Engine.Table

        For Each BacaTabel In laporan.Database.Tables

            TabelLogon = BacaTabel.LogOnInfo

            With TabelLogon.ConnectionInfo

                .ServerName = Application.StartupPath & "\DBKoperasi.mdb"

                .UserID = ""

                .Password = ""

                .DatabaseName = ""

            End With

            BacaTabel.ApplyLogOnInfo(TabelLogon)

        Next BacaTabel

    End Sub

 

    Public Sub Koneksi()

        CONN = New OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=DBKoperasi.mdb")

        CONN.Open()

    End Sub

End Module

 

Membuat form Login

 

 

 

Imports System.Data.OleDb

 

Public Class Login

 

    Sub Tampilidperusahaan()

        CMD = New OleDbCommand("select * from tblperusahaan", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            MenuUtama.PanelPerusahaan.Text = DR(0)

        End If

    End Sub

 

    Sub Tampilidpengaturan()

        CMD = New OleDbCommand("select * from tblpengaturan", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            MenuUtama.PanelPengaturan.Text = DR(0)

        End If

    End Sub

    Private Sub txtnama_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtnama.KeyPress

        If e.KeyChar = Chr(13) Then txtpassword.Focus()

    End Sub

 

    Private Sub txtpassword_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtpassword.KeyPress

        If e.KeyChar = Chr(13) Then BTNLogin.Focus()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNLogin.Click

 

        Call Koneksi()

        CMD = New OleDbCommand("select * from tbluser where nama_User= '" & TXTnama.Text & "' and pwd_user='" & TXTPassword.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

 

        If DR.HasRows Then

            If TXTnama.Text <> DR.Item("nama_user") And TXTPassword.Text <> DR.Item("Pwd_user") Then

                MsgBox("Login Gagal")

                TXTnama.Clear()

                TXTPassword.Clear()

                TXTnama.Focus()

                Exit Sub

            Else

                Me.Visible = False

                MenuUtama.Show()

                MenuUtama.PanelKode.Text = DR.Item("id_user")

                MenuUtama.PanelNama.Text = DR.Item("nama_User")

                MenuUtama.PanelStatus.Text = UCase(DR.Item("status_user"))

                If MenuUtama.PanelStatus.Text <> "ADMIN" Then

                    MenuUtama.UserToolStripMenuItem.Visible = False

                Else

                    MenuUtama.UserToolStripMenuItem.Visible = True

                End If

            End If

            Call Tampilidpengaturan()

            Call Tampilidperusahaan()

 

        Else

            MsgBox("Login Gagal")

            TXTnama.Clear()

            TXTPassword.Clear()

            TXTnama.Focus()

        End If

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNCancel.Click

        End

    End Sub

End Class

 

Membuat menu utama

 

 

Imports System.Data.OleDb

 

Public Class MenuUtama

 

    Private Sub UserToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UserToolStripMenuItem.Click

        User.Show()

    End Sub

 

    Private Sub AnggotaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnggotaToolStripMenuItem.Click

        Anggota.Show()

    End Sub

 

    Private Sub PengaturanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PengaturanToolStripMenuItem.Click

        Pengaturan.Show()

    End Sub

 

    Private Sub SimpananToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SimpananToolStripMenuItem.Click

        Simpanan.Show()

    End Sub

 

    Private Sub PengambilanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PengambilanToolStripMenuItem.Click

        Pengambilan.Show()

    End Sub

 

    Private Sub PinjamanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PinjamanToolStripMenuItem.Click

        Pinjaman.Show()

    End Sub

 

    Private Sub PembayaranToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PembayaranToolStripMenuItem.Click

        Pembayaran.Show()

    End Sub

 

    Private Sub TutupToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TutupToolStripMenuItem.Click

 

        If MessageBox.Show("Tutup aplikasi...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            End

        End If

 

    End Sub

 

    Private Sub PerusahaanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PerusahaanToolStripMenuItem.Click

        Perusahaan.Show()

    End Sub

 

    Private Sub MenuUtama_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown

        If e.KeyCode = Keys.Escape Then

            If MessageBox.Show("Tutup aplikasi...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                End

            End If

        End If

    End Sub

 

    Private Sub MenuUtama_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Call Koneksi()

        On Error Resume Next

        PictureBox1.Load("logo koperasi.png")

        PictureBox1.SizeMode = PictureBoxSizeMode.CenterImage

    End Sub

 

    Private Sub LaporanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LaporanToolStripMenuItem.Click

        FrmLaporan.Show()

    End Sub

End Class

 

Membuat form user

 

 

Imports System.Data.OleDb

 

Public Class User

 

    Sub Kosongkan()

        txtkodeuser.Clear()

        txtnamauser.Clear()

        cbostatus.Text = ""

        txtpassword.Clear()

        txtcaridata.Clear()

        txtkodeuser.Focus()

        Call TampilStatus_user()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        txtnamauser.Clear()

        cbostatus.Text = ""

        txtpassword.Clear()

        txtcaridata.Clear()

        txtnamauser.Focus()

    End Sub

 

    Sub Ketemu()

        txtnamauser.Text = DR.Item("nama_User")

        txtpassword.Text = DR.Item("pwd_User")

        cbostatus.Text = UCase(DR.Item("Status_user"))

        txtnamauser.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblUser", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub TampilStatus_user()

        CMD = New OleDbCommand("select distinct Status_user from tblUser", CONN)

        DR = CMD.ExecuteReader

        cbostatus.Items.Clear()

        Do While DR.Read

            cbostatus.Items.Add(DR.Item("Status_user"))

        Loop

    End Sub

 

    Sub cariID()

        CMD = New OleDbCommand("select * from tblUser where ID_USER='" & txtkodeuser.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Private Sub User_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CenterToScreen()

        Call Koneksi()

        Call Kosongkan()

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntutup.Click

        Me.Close()

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click

        Call cariID()

        Try

            If Not DR.HasRows Then

                Dim simpan As String = "insert into tblUser values ('" & txtkodeuser.Text & "','" & txtnamauser.Text & "','" & txtpassword.Text & "','" & UCase(cbostatus.Text) & "')"

                CMD = New OleDbCommand(simpan, CONN)

                CMD.ExecuteNonQuery()

            Else

                Dim edit As String = "update tblUser set nama_User='" & txtnamauser.Text & "',Status_user='" & UCase(cbostatus.Text) & "',pwd_User='" & txtpassword.Text & "' where ID_USER='" & txtkodeuser.Text & "'"

                CMD = New OleDbCommand(edit, CONN)

                CMD.ExecuteNonQuery()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

        Call Kosongkan()

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        txtkodeuser.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        txtnamauser.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        txtpassword.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        cbostatus.Text = DGV.Rows(e.RowIndex).Cells(3).Value

    End Sub

 

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click

        If txtkodeuser.Text = "" Then

            MsgBox("Kode User harus diisi")

            txtkodeuser.Focus()

            Exit Sub

        End If

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from tblUser where ID_USER='" & txtkodeuser.Text & "'"

            CMD = New OleDbCommand(hapus, CONN)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub txtkodeuser_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtkodeuser.KeyDown

        If e.KeyCode = Keys.Enter Then

            Call cariID()

            If Not DR.HasRows Then

                Call DataBaru()

            Else

                Call Ketemu()

            End If

        End If

    End Sub

 

    Private Sub TextBox6_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcaridata.TextChanged

        DA = New OleDbDataAdapter("select * from tblUser where nama_User like '%" & txtcaridata.Text & "%'", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

End Class

 

Membuat form anggota

 

 

Imports System.Data.OleDb

 

Public Class Anggota

 

    Sub IDOtomatis()

        CMD = New OleDbCommand("select id_anggota from tblanggota order by id_anggota desc", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            txtId.Text = "A" + "0001"

        Else

            txtId.Text = "A" + Format(Microsoft.VisualBasic.Right(DR(0), 4) + 1, "0000")

        End If

        txtId.Enabled = False

    End Sub

 

    Sub Kosongkan()

        txtId.Enabled = False

        Call IDOtomatis()

        txtNama.Clear()

        txtAlamat.Text = ""

        txtTelepon.Clear()

        txtcaridata.Clear()

        txtNama.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        txtNama.Clear()

        txtAlamat.Text = ""

        txtTelepon.Clear()

        txtcaridata.Clear()

        txtNama.Focus()

    End Sub

 

    Sub Ketemu()

        txtNama.Text = DR.Item("nama_anggota")

        txtTelepon.Text = DR.Item("alamat")

        txtAlamat.Text = DR.Item("telepon")

        txtNama.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblanggota", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub CariIDAnggota()

        CMD = New OleDbCommand("select * from tblanggota where id_anggota='" & txtId.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Private Sub Anggota_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CenterToScreen()

        Call Koneksi()

        Call Kosongkan()

    End Sub

 

    Private Sub btnbatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnbatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub btntutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btntutup.Click

        Me.Close()

    End Sub

 

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsimpan.Click

 

        Try

            Call CariIDAnggota()

            If Not DR.HasRows Then

                Dim simpan As String = "insert into tblanggota values ('" & txtId.Text & "','" & txtNama.Text & "','" & txtAlamat.Text & "','" & txtTelepon.Text & "',0)"

                CMD = New OleDbCommand(simpan, CONN)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

                Call TampilGrid()

            Else

                Dim edit As String = "update tblanggota set nama_anggota='" & txtNama.Text & "',ALAMAT='" & txtAlamat.Text & "',telepon='" & txtTelepon.Text & "' where id_anggota='" & txtId.Text & "'"

                CMD = New OleDbCommand(edit, CONN)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

                Call TampilGrid()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        txtId.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        txtNama.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        txtTelepon.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        txtAlamat.Text = DGV.Rows(e.RowIndex).Cells(3).Value

    End Sub

 

    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnhapus.Click

        If txtId.Text = "" Then

            MsgBox("Kode User harus diisi")

            txtId.Focus()

            Exit Sub

        End If

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from tblanggota where id_anggota='" & txtId.Text & "'"

            CMD = New OleDbCommand(hapus, CONN)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

            Call TampilGrid()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub txtId_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtId.KeyDown

        If e.KeyCode = Keys.Enter Then

            Call CariIDAnggota()

            If Not DR.HasRows Then

                Call DataBaru()

            Else

                Call Ketemu()

            End If

        End If

    End Sub

 

    Private Sub txtcaridata_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcaridata.TextChanged

        DA = New OleDbDataAdapter("select * from tblanggota where nama_anggota like '%" & txtcaridata.Text & "%'", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

End Class

 

Membuat form perusahaan

 

 

Imports System.Data.OleDb

 

Public Class Perusahaan

 

    Sub IDOtomatis()

        CMD = New OleDbCommand("select id_perusahaan from TBLPerusahaan order by id_perusahaan desc", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            ID.Text = "01"

        Else

            ID.Text = "01"

        End If

        ID.Enabled = False

    End Sub

 

    Sub Kosongkan()

        On Error Resume Next

        Nama.Clear()

        Alamat.Clear()

        Telepon.Clear()

        Fax.Clear()

        Email.Clear()

        Website.Clear()

        Nama.Focus()

    End Sub

 

    Sub Ketemu()

        On Error Resume Next

        Nama.Text = DR.Item(1)

        Alamat.Text = DR.Item(2)

        Telepon.Text = DR.Item(3)

        Fax.Text = DR.Item(4)

        Email.Text = DR.Item(5)

        Website.Text = DR.Item(6)

        Nama.Focus()

    End Sub

 

    Sub CariID()

        CMD = New OleDbCommand("select * from TBLPerusahaan where ID_perusahaan='" & ID.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Sub Awal()

        Call IDOtomatis()

        Call Kosongkan()

    End Sub

 

    Private Sub Perusahaan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CenterToScreen()

        Call Koneksi()

        Call IDOtomatis()

        Call CariID()

        If DR.HasRows Then

            Call Ketemu()

        End If

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        Try

            Call CariID()

            If Not DR.HasRows Then

                Dim simpan As String = "insert into TBLPerusahaan values('" & ID.Text & "','" & Nama.Text & "','" & Alamat.Text & "', '" & Telepon.Text & "', '" & Fax.Text & "', '" & Email.Text & "', '" & Website.Text & "')"

                CMD = New OleDbCommand(simpan, CONN)

                CMD.ExecuteNonQuery()

            Else

                CMD = New OleDbCommand("delete * from TBLPerusahaan", CONN)

                CMD.ExecuteNonQuery()

                Dim simpan As String = "insert into TBLPerusahaan values('" & ID.Text & "','" & Nama.Text & "','" & Alamat.Text & "', '" & Telepon.Text & "', '" & Fax.Text & "', '" & Email.Text & "', '" & Website.Text & "')"

                CMD = New OleDbCommand(simpan, CONN)

                CMD.ExecuteNonQuery()

            End If

            'Call Awal()

            MenuUtama.PanelPerusahaan.Text = ID.Text

            MsgBox("Data berhasil disimpan")

            Me.Close()

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        'Call Kosongkan()

        Call IDOtomatis()

        Call Ketemu()

        Nama.Focus()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

End Class

 

 

 

 

 

 

 

 

 

 

Membuat form pengaturan

 

 

Imports System.Data.OleDb

 

Public Class Pengaturan

 

    Sub IDOtomatis()

        CMD = New OleDbCommand("select id_PENGATURAN from TBLPengaturan order by id_pengaturan desc", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            ID.Text = "01"

        Else

            ID.Text = "01"

        End If

        ID.Enabled = False

    End Sub

 

    Sub Kosongkan()

        On Error Resume Next

        Pokok.Clear()

        Wajib.Clear()

        Sukarela.Clear()

        Denda.Clear()

        maksimalpinjaman.Clear()

        minimalsaldo.Clear()

        Pokok.Focus()

    End Sub

 

    Sub Ketemu()

        On Error Resume Next

        Pokok.Text = DR.Item(1)

        Wajib.Text = DR.Item(2)

        Sukarela.Text = DR.Item(3)

        Denda.Text = DR.Item(4)

        maksimalpinjaman.Text = DR.Item(5)

        minimalsaldo.Text = DR.Item(6)

        Pokok.Focus()

    End Sub

 

    Sub CariID()

        CMD = New OleDbCommand("select * from TBLPengaturan where ID_Pengaturan='" & ID.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Sub Awal()

        Call IDOtomatis()

        Call Kosongkan()

    End Sub

 

    Private Sub Pengaturan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CenterToScreen()

        Call Koneksi()

        Call IDOtomatis()

        Call CariID()

        If DR.HasRows Then

            Call Ketemu()

        End If

    End Sub

 

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Try

            Call CariID()

            If Not DR.HasRows Then

                Dim simpan As String = "insert into TBLPengaturan values('" & ID.Text & "','" & Pokok.Text & "','" & Wajib.Text & "', '" & Sukarela.Text & "', '" & Denda.Text & "', '" & maksimalpinjaman.Text & "', '" & minimalsaldo.Text & "')"

                CMD = New OleDbCommand(simpan, CONN)

                CMD.ExecuteNonQuery()

            Else

                CMD = New OleDbCommand("delete * from TBLPengaturan", CONN)

                CMD.ExecuteNonQuery()

                Dim simpan As String = "insert into TBLPengaturan values('" & ID.Text & "','" & Pokok.Text & "','" & Wajib.Text & "', '" & Sukarela.Text & "', '" & Denda.Text & "', '" & maksimalpinjaman.Text & "', '" & minimalsaldo.Text & "')"

                CMD = New OleDbCommand(simpan, CONN)

                CMD.ExecuteNonQuery()

            End If

            'Call Awal()

            'MenuUtama.PanelID.Text = ID.Text

            MenuUtama.PanelPengaturan.Text = ID.Text

            MsgBox("Data berhasil disimpan")

            Me.Close()

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

        'Call Kosongkan()

        Call IDOtomatis()

        Call Ketemu()

        Pokok.Focus()

    End Sub

 

    Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

        Me.Close()

    End Sub

End Class

 

Membuat form simpanan

 

 

Imports System.Data.OleDb

 

Public Class Simpanan

 

    Dim dataawal As Double

 

    Sub IDOtomatis()

        CMD = New OleDbCommand("select id_Simpanan from tblSimpanan order by id_Simpanan desc", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            txtidsimpanan.Text = "S" + "0001"

        Else

            txtidsimpanan.Text = "S" + Format(Microsoft.VisualBasic.Right(DR(0), 4) + 1, "0000")

        End If

        txtidsimpanan.Enabled = False

    End Sub

 

    Sub Kosongkan()

        txtidsimpanan.Enabled = False

        Call IDOtomatis()

        cmbidanggota.Text = ""

        txtNama.text = ""

        cmbjenis.Text = ""

        txtjumlah.Clear()

        'txtNama.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        txtNama.Text = ""

        cmbjenis.Text = ""

        txtjumlah.Clear()

        txtNama.Focus()

    End Sub

 

    Sub Ketemu()

        Tanggal.Text = DR("tanggal_simpanan")

        cmbidanggota.Text = DR("id_anggota")

        cmbjenis.Text = DR.Item("jenis_simpanan")

        txtjumlah.Text = DR.Item("Jumlah_simpanan")

        dataawal = DR.Item("Jumlah_simpanan")

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblSimpanan", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub CariIDSimpanan()

        CMD = New OleDbCommand("select * from tblSimpanan where id_Simpanan='" & txtidsimpanan.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Sub TampilIDAnggota()

        CMD = New OleDbCommand("select * from tblanggota", CONN)

        DR = CMD.ExecuteReader

        Do While DR.Read

            cmbidanggota.Items.Add(DR(0))

        Loop

    End Sub

 

    Private Sub Simpanan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CenterToScreen()

        Call Koneksi()

        Call Kosongkan()

        Call TampilIDAnggota()

    End Sub

 

    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNhapus.Click

        If txtidsimpanan.Text = "" Then

            MsgBox("id harus diisi")

            txtidsimpanan.Focus()

            Exit Sub

        End If

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from tblSimpanan where id_Simpanan='" & txtidsimpanan.Text & "'"

            CMD = New OleDbCommand(hapus, CONN)

            CMD.ExecuteNonQuery()

 

            Call hapussaldopermanen()

            Call Kosongkan()

            Call TampilGrid()

        Else

            Call Kosongkan()

        End If

 

    End Sub

 

    Private Sub btntutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBatal.Click

        Call Kosongkan()

    End Sub

 

    Sub tambahsaldo()

        CMD = New OleDbCommand("select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim simpansaldo As String = "update tblanggota set saldo ='" & DR("saldo") + txtjumlah.Text & "' where id_anggota='" & cmbidanggota.Text & "'"

            CMD = New OleDbCommand(simpansaldo, CONN)

            CMD.ExecuteNonQuery()

        End If

    End Sub

 

    Sub editsaldo()

        CMD = New OleDbCommand("select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim hapusdulu As String = "update tblanggota set saldo ='" & DR("saldo") - dataawal & "' where id_anggota='" & cmbidanggota.Text & "'"

            CMD = New OleDbCommand(hapusdulu, CONN)

            CMD.ExecuteNonQuery()

        End If

 

        CMD = New OleDbCommand("select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim ubahsaldo As String = "update tblanggota set saldo ='" & DR("saldo") + txtjumlah.Text & "' where id_anggota='" & cmbidanggota.Text & "'"

            CMD = New OleDbCommand(ubahsaldo, CONN)

            CMD.ExecuteNonQuery()

        End If

    End Sub

 

    Sub hapussaldopermanen()

        CMD = New OleDbCommand("select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim hapussaldo As String = "update tblanggota set saldo ='" & DR("saldo") - txtjumlah.Text & "' where id_anggota='" & cmbidanggota.Text & "'"

            CMD = New OleDbCommand(hapussaldo, CONN)

            CMD.ExecuteNonQuery()

        End If

    End Sub

 

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSimpan.Click

        Try

            Call CariIDSimpanan()

            If Not DR.HasRows Then

                Dim simpan As String = "insert into tblSimpanan values ('" & txtidsimpanan.Text & "','" & Tanggal.Text & "','" & cmbidanggota.Text & "','" & cmbjenis.Text & "','" & txtjumlah.Text & "','" & MenuUtama.PanelKode.Text & "','" & MenuUtama.PanelPerusahaan.Text & "')"

                CMD = New OleDbCommand(simpan, CONN)

                CMD.ExecuteNonQuery()

                Call tambahsaldo()

                If MessageBox.Show("cetak bukti setoran...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                    Cetak.Show()

                    Cetak.CRV.SelectionFormula = "{tblsimpanan.id_simpanan} = '" & txtidsimpanan.Text & "'"

                    laporan.Load("cetak simpanan.rpt")

                    Call SetingLaporan()

                    Cetak.CRV.ReportSource = laporan

                    Cetak.CRV.RefreshReport()

                End If

                Call Kosongkan()

                Call TampilGrid()

            Else

                Dim edit As String = "update tblSimpanan set tanggal_Simpanan='" & Tanggal.Text & "',id_anggota='" & cmbidanggota.Text & "',jenis_simpanan='" & cmbjenis.Text & "',jumlah_simpanan='" & txtjumlah.Text & "',ID_user='" & MenuUtama.PanelKode.Text & "' where id_Simpanan='" & txtidsimpanan.Text & "'"

                CMD = New OleDbCommand(edit, CONN)

                CMD.ExecuteNonQuery()

 

                Call editsaldo()

 

                If MessageBox.Show("cetak bukti setoran...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                    Cetak.Show()

                    Cetak.CRV.SelectionFormula = "{tblsimpanan.id_simpanan} = '" & txtidsimpanan.Text & "'"

                    laporan.Load("cetak simpanan.rpt")

                    Call SetingLaporan()

                    Cetak.CRV.ReportSource = laporan

                    Cetak.CRV.RefreshReport()

                End If

                Call Kosongkan()

                Call TampilGrid()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        txtidsimpanan.Text = DGV.Rows(e.RowIndex).Cells(0).Value

        Tanggal.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        cmbidanggota.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        txtjumlah.Text = DGV.Rows(e.RowIndex).Cells(4).Value

        Call CariIDSimpanan()

        If DR.HasRows Then

            Call Ketemu()

        End If

    End Sub

 

    Private Sub txtId_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtidsimpanan.KeyDown

        If e.KeyCode = Keys.Enter Then

            Call CariIDSimpanan()

            If Not DR.HasRows Then

                Call DataBaru()

            Else

                Call Ketemu()

            End If

        End If

    End Sub

 

    Private Sub cmbjenis_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbjenis.SelectedIndexChanged

 

        CMD = New OleDbCommand("Select * from tblpengaturan where id_pengaturan='" & MenuUtama.PanelPerusahaan.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            If cmbjenis.Text = "POKOK" Then

                txtjumlah.Text = DR("simpanan_pokok")

                txtjumlah.Enabled = False

                CMD = New OleDbCommand("select * from tblsimpanan where id_anggota='" & cmbidanggota.Text & "' and jenis_simpanan='" & cmbjenis.Text & "'", CONN)

                DR = CMD.ExecuteReader

                DR.Read()

                If DR.HasRows Then

                    MsgBox("Simpanan pokok atas nama " & txtNama.Text & " sudah ada")

                    cmbjenis.Text = ""

                    txtjumlah.Clear()

                    Exit Sub

                End If

            End If

 

            If cmbjenis.Text = "WAJIB" Then

                txtjumlah.Text = DR("simpanan_wajib")

                txtjumlah.Enabled = False

 

                CMD = New OleDbCommand("select * from tblsimpanan where id_anggota='" & cmbidanggota.Text & "' and jenis_simpanan='" & cmbjenis.Text & "' and month(tanggal_simpanan)=(" & Month(Tanggal.Text) & ") and year(tanggal_simpanan)=(" & Year(Tanggal.Text) & ")", CONN)

                DR = CMD.ExecuteReader

                DR.Read()

                If DR.HasRows Then

                    MsgBox("Simpanan wajib atas nama " & txtNama.Text & " bulan ini sudah ada")

                    cmbjenis.Text = ""

                    txtjumlah.Clear()

                    Exit Sub

                End If

            End If

 

            If cmbjenis.Text = "SUKARELA" Then

                txtjumlah.Text = DR("simpanan_SUKARELA")

                txtjumlah.Enabled = True

            End If

        End If

    End Sub

 

    Private Sub BTNTutup_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTutup.Click

        Me.Close()

    End Sub

 

    Private Sub cmbid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbidanggota.SelectedIndexChanged

        CMD = New OleDbCommand("Select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        txtNama.Text = DR("nama_anggota")

    End Sub

End Class

 

Membuat form pengambilan

 

 

Imports System.Data.OleDb

 

Public Class Pengambilan

 

    Dim saldoawal As Double

 

    Sub IDOtomatis()

        CMD = New OleDbCommand("select id_pengambilan from tblpengambilan order by id_pengambilan desc", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            txtidPengambilan.Text = "P" + "0001"

        Else

            txtidPengambilan.Text = "P" + Format(Microsoft.VisualBasic.Right(DR(0), 4) + 1, "0000")

        End If

        txtidPengambilan.Enabled = False

    End Sub

 

    Sub Kosongkan()

        txtidPengambilan.Enabled = False

        Call IDOtomatis()

        cmbidanggota.Text = ""

        txtNama.Text = ""

        txtjumlah.Clear()

        txtsaldo.Text = 0

        'txtNama.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        txtNama.Text = ""

        txtjumlah.Clear()

        txtsaldo.Text = 0

        txtNama.Focus()

    End Sub

 

    Sub Ketemu()

        Tanggal.Text = DR("tanggal_pengambilan")

        cmbidanggota.Text = DR("id_anggota")

        txtjumlah.Text = DR.Item("Jumlah_pengambilan")

        saldoawal = DR.Item("Jumlah_pengambilan")

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblpengambilan", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub CariIDpengambilan()

        CMD = New OleDbCommand("select * from tblpengambilan where id_pengambilan='" & txtidPengambilan.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Sub TampilIDAnggota()

        CMD = New OleDbCommand("select * from tblanggota", CONN)

        DR = CMD.ExecuteReader

        Do While DR.Read

            cmbidanggota.Items.Add(DR(0))

        Loop

    End Sub

 

    Private Sub Pengambilan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CenterToScreen()

        Call Koneksi()

        Call Kosongkan()

        Call TampilIDAnggota()

    End Sub

 

    Private Sub btnhapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNhapus.Click

        If txtidPengambilan.Text = "" Then

            MsgBox("id harus diisi")

            txtidPengambilan.Focus()

            Exit Sub

        End If

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from tblpengambilan where id_pengambilan='" & txtidPengambilan.Text & "'"

            CMD = New OleDbCommand(hapus, CONN)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

            Call TampilGrid()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub btntutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBatal.Click

        Call Kosongkan()

    End Sub

 

    Sub editsaldo()

 

        CMD = New OleDbCommand("select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim editdulu As String = "update tblanggota set saldo ='" & DR("saldo") + saldoawal & "' where id_anggota='" & cmbidanggota.Text & "'"

            CMD = New OleDbCommand(editdulu, CONN)

            CMD.ExecuteNonQuery()

        End If

 

        CMD = New OleDbCommand("select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim ubahsaldo As String = "update tblanggota set saldo ='" & DR("saldo") - txtjumlah.Text & "' where id_anggota='" & cmbidanggota.Text & "'"

            CMD = New OleDbCommand(ubahsaldo, CONN)

            CMD.ExecuteNonQuery()

        End If

    End Sub

 

    Private Sub btnsimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSimpan.Click

 

        CMD = New OleDbCommand("select * from tblpengaturan where id_pengaturan='" & MenuUtama.PanelPerusahaan.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            If Val(txtsaldo.Text) - Val(txtjumlah.Text) < DR("minimal_saldo") Then

                MsgBox("saldo tidak boleh kurang dari " & DR("minimal_saldo"))

                txtjumlah.Clear()

                Exit Sub

            End If

        End If

 

        Try

            Call CariIDpengambilan()

            If Not DR.HasRows Then

                Dim simpan As String = "insert into tblpengambilan values ('" & txtidPengambilan.Text & "','" & Tanggal.Text & "','" & cmbidanggota.Text & "','" & txtjumlah.Text & "','" & MenuUtama.PanelKode.Text & "','" & MenuUtama.PanelPerusahaan.Text & "')"

                CMD = New OleDbCommand(simpan, CONN)

                CMD.ExecuteNonQuery()

 

                CMD = New OleDbCommand("select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

                DR = CMD.ExecuteReader

                DR.Read()

                If DR.HasRows Then

                    Dim kurangisaldo As String = "update tblanggota set saldo ='" & DR("saldo") - txtjumlah.Text & "' where id_anggota='" & cmbidanggota.Text & "'"

                    CMD = New OleDbCommand(kurangisaldo, CONN)

                    CMD.ExecuteNonQuery()

                End If

 

                If MessageBox.Show("cetak bukti pengambilan...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                    Cetak.Show()

                    Cetak.CRV.SelectionFormula = "{tblpengambilan.id_pengambilan} = '" & txtidPengambilan.Text & "'"

                    laporan.Load("cetak pengambilan.rpt")

                    Call SetingLaporan()

                    Cetak.CRV.ReportSource = laporan

                    Cetak.CRV.RefreshReport()

                End If

 

                Call Kosongkan()

                Call TampilGrid()

            Else

                Dim edit As String = "update tblpengambilan set tanggal_pengambilan='" & Tanggal.Text & "',id_anggota='" & cmbidanggota.Text & "',jumlah_pengambilan='" & txtjumlah.Text & "',id_user='" & MenuUtama.PanelKode.Text & "' where id_pengambilan='" & txtidPengambilan.Text & "'"

                CMD = New OleDbCommand(edit, CONN)

                CMD.ExecuteNonQuery()

                Call editsaldo()

 

                If MessageBox.Show("cetak bukti pengambilan...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                    Cetak.Show()

                    Cetak.CRV.SelectionFormula = "{tblpengambilan.id_pengambilan} = '" & txtidPengambilan.Text & "'"

                    laporan.Load("cetak pengambilan.rpt")

                    Call SetingLaporan()

                    Cetak.CRV.ReportSource = laporan

                    Cetak.CRV.RefreshReport()

                End If

                Call Kosongkan()

                Call TampilGrid()

            End If

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

    Private Sub DGV_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGV.CellMouseClick

        On Error Resume Next

        txtidPengambilan.Text = DGV.Rows(e.RowIndex).Cells(0).Value

       

        Call CariIDpengambilan()

        Tanggal.Text = DGV.Rows(e.RowIndex).Cells(1).Value

        cmbidanggota.Text = DGV.Rows(e.RowIndex).Cells(2).Value

        txtjumlah.Text = DGV.Rows(e.RowIndex).Cells("Jumlah_pengambilan").Value

        If DR.HasRows Then

            Call Ketemu()

        End If

    End Sub

 

    Private Sub txtId_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtidPengambilan.KeyDown

        If e.KeyCode = Keys.Enter Then

            Call CariIDpengambilan()

            If Not DR.HasRows Then

                Call DataBaru()

            Else

                Call Ketemu()

            End If

        End If

    End Sub

 

    Private Sub BTNTutup_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTutup.Click

        Me.Close()

    End Sub

 

    Private Sub cmbid_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbidanggota.SelectedIndexChanged

        CMD = New OleDbCommand("Select * from tblanggota where id_anggota='" & cmbidanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        txtNama.Text = DR("nama_anggota")

        txtsaldo.Text = DR("saldo")   

    End Sub

 

    Private Sub txtjumlah_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtjumlah.KeyDown

        If e.KeyCode = Keys.Enter Then

            CMD = New OleDbCommand("select * from tblpengaturan where id_pengaturan='" & MenuUtama.PanelPerusahaan.Text & "'", CONN)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                If Val(txtsaldo.Text) - Val(txtjumlah.Text) < DR("minimal_saldo") Then

                    MsgBox("saldo tidak boleh kurang dari " & DR("minimal_saldo"))

                    txtjumlah.Clear()

                    Exit Sub

                End If

            End If

        End If

    End Sub

 

    Private Sub txtjumlah_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtjumlah.TextChanged

 

    End Sub

End Class

 

Membuat form pinjaman

 

 

Imports System.Data.OleDb

Imports System.Math

 

Public Class Pinjaman

 

    Sub Notis() 'nomor otomatis

        CMD = New OleDbCommand("select id_pinjaman from tblpinjaman order by id_pinjaman desc", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            txtidpinjaman.Text = "J" + "0001"

        Else

            txtidpinjaman.Text = "J" + Format(Microsoft.VisualBasic.Right(DR(0), 4) + 1, "0000")

        End If

    End Sub

 

    Sub Kosongkan()

        CmbIDanggota.Text = ""

        NamaAnggota.Text = ""

        Bungapertahun.Clear()

        Lamacicilan.Clear()

        JumlahPinjaman.Clear()

        txtsaldo.Text = ""

        Angsuran.Text = ""

        'CmbIDanggota.Focus()

    End Sub

 

    Sub ketemu()

        On Error Resume Next

        CmbIDanggota.Text = DR(2)

        Bungapertahun.Text = DR(3)

        Lamacicilan.Text = DR(4)

        JumlahPinjaman.Text = DR(5)

        Angsuran.Text = DR(6)

        CmbIDanggota.Focus()

    End Sub

 

    Sub tampilgrid()

        DA = New OleDbDataAdapter("select * from tblpinjaman", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub CariIDpinjaman()

        CMD = New OleDbCommand("select * from tblpinjaman where id_pinjaman='" & txtidpinjaman.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Sub tampilAnggota()

        CMD = New OleDbCommand("select id_Anggota from tblAnggota", CONN)

        DR = CMD.ExecuteReader

        Do While DR.Read

            CmbIDanggota.Items.Add(DR(0))

        Loop

    End Sub

 

    Private Sub Pinjaman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CenterToScreen()

        Call tampilgrid()

        Call tampilAnggota()

        Call Notis()

 

    End Sub

 

 

 

 

    'cari data Anggota

    Private Sub cmbIDAnggota_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmbIDanggota.SelectedIndexChanged

        Call Koneksi()

        CMD = New OleDbCommand("select * from tblAnggota where id_Anggota='" & CmbIDanggota.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Namaanggota.Text = DR(1)

            txtsaldo.Text = DR("saldo")

            CMD = New OleDbCommand("select * from tblpengaturan where id_pengaturan='" & MenuUtama.PanelPengaturan.Text & "'", CONN)

            DR = CMD.ExecuteReader

            DR.Read()

            JumlahPinjaman.Text = DR("maksimal_pinjaman") * Val(txtsaldo.Text)

        Else

            MsgBox("id Anggota tidak valid")

        End If

 

        'cari Anggota yang belum lunas

        Call Koneksi()

        CMD = New OleDbCommand("select * from tblpinjaman where id_Anggota='" & CmbIDanggota.Text & "' and status_pinjaman='BELUM LUNAS'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Call ketemu()

            MsgBox("Anggota pernah pinjam dan belum lunas")

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub Bungapertahun_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Bungapertahun.KeyDown

        If e.KeyCode = Keys.Enter Then

            Lamacicilan.Focus()

        End If

    End Sub

 

    Private Sub Lamacicilan_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Lamacicilan.KeyDown

        If e.KeyCode = Keys.Enter Then

            JumlahPinjaman.Focus()

        End If

    End Sub

 

    'mencari jumlah angsuran dengan komponen

    'bunga pertahun *12%,lama cicilan, jumlah pinjaman

    Private Sub JumlahPinjaman_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles JumlahPinjaman.KeyDown

        If e.KeyCode = Keys.Enter Then

 

            CMD = New OleDbCommand("select * from tblpengaturan where id_pengaturan='" & MenuUtama.PanelPengaturan.Text & "'", CONN)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                If Val(JumlahPinjaman.Text) > DR("maksimal_pinjaman") * Val(txtsaldo.Text) Then

                    MsgBox("maksimal pinjaman adalah " & DR("maksimal_pinjaman") * Val(txtsaldo.Text) & " = 3x saldo")

                    JumlahPinjaman.Text = DR("maksimal_pinjaman") * Val(txtsaldo.Text)

                    Exit Sub

                End If

            End If

            Angsuran.Text = Round(Pmt(Bungapertahun.Text / 12 / 100, Lamacicilan.Text, JumlahPinjaman.Text), 0) * -1

        End If

    End Sub

 

    Private Sub BTNSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSimpan.Click

        If CmbIDanggota.Text = "" Or Bungapertahun.Text = "" Or Lamacicilan.Text = "" Or JumlahPinjaman.Text = "" Then

            MsgBox("transaksi belum lengkap")

            Exit Sub

        End If

 

        Call CariIDpinjaman()

        If Not DR.HasRows Then

            Dim simpan As String = "insert into tblpinjaman values('" & txtidpinjaman.Text & "','" & Tanggal.Text & "','" & CmbIDanggota.Text & "','" & Bungapertahun.Text & "','" & Lamacicilan.Text & "','" & JumlahPinjaman.Text & "','" & Angsuran.Text & "','" & JumlahPinjaman.Text & "','BELUM LUNAS','" & MenuUtama.PanelKode.Text & "','" & MenuUtama.PanelPerusahaan.Text & "')"

            CMD = New OleDbCommand(simpan, CONN)

            CMD.ExecuteNonQuery()

 

            If MessageBox.Show("cetak bukti pinjaman...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                Cetak.Show()

                Cetak.CRV.SelectionFormula = "{tblpinjaman.id_pinjaman} = '" & txtidpinjaman.Text & "'"

                laporan.Load("cetak pinjaman.rpt")

                Call SetingLaporan()

                Cetak.CRV.ReportSource = laporan

                Cetak.CRV.RefreshReport()

            End If

            Call Kosongkan()

            Call Notis()

            Call tampilgrid()

        Else

            Dim edit As String = "update tblpinjaman set tanggal_pinjaman='" & Tanggal.Text & "',id_anggota='" & CmbIDanggota.Text & "',bunga_pertahun='" & Bungapertahun.Text & "',lama_cicilan='" & Lamacicilan.Text & "',jumlah_pinjaman='" & JumlahPinjaman.Text & "',angsuran='" & Angsuran.Text & "',id_user='" & MenuUtama.PanelKode.Text & "','" & MenuUtama.PanelPerusahaan.Text & "' where id_pinjaman='" & txtidpinjaman.Text & "'"

            CMD = New OleDbCommand(edit, CONN)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

            Call Notis()

            Call tampilgrid()

        End If

    End Sub

 

    Private Sub BTNBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNHapus.Click

        If txtidpinjaman.Text = "" Then

            MsgBox("id harus diisi")

            txtidpinjaman.Focus()

            Exit Sub

        End If

        If MessageBox.Show("yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Dim hapus As String = "delete * from tblpinjaman where id_pinjaman='" & txtidpinjaman.Text & "'"

            CMD = New OleDbCommand(hapus, CONN)

            CMD.ExecuteNonQuery()

 

            Call Kosongkan()

            Call tampilgrid()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub BTNTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBatal.Click

        Call Kosongkan()

    End Sub

 

    Private Sub BTNTutup_Click_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTutup.Click

        Me.Close()

    End Sub

End Class

 

Membuat form pembayaran

 

 

Imports System.Data.OleDb

 

Public Class Pembayaran

 

    Sub Notis() 'nomor otomatis

        CMD = New OleDbCommand("select id_pembayaran from tblpembayaran order by id_pembayaran desc", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            IDPembayaran.Text = "B" + "0001"

        Else

            IDPembayaran.Text = "B" + Format(Microsoft.VisualBasic.Right(DR(0), 4) + 1, "0000")

        End If

    End Sub

 

    Sub Kosongkan()

        IDPinjaman.Text = ""

        TanggalPinjam.Text = ""

        NamaAnggota.Text = ""

        Bunga.Text = ""

        Lamacicilan.Text = ""

        JumlahPinjaman.Text = ""

        Angsuran.Text = ""

        Sisalalu.Text = ""

        cicilanke.Text = ""

        terlambat.Text = ""

        jatuhtempo.Text = ""

        terlambat.Text = ""

        denda.Text = ""

        JumlahPembayaran.Text = ""

        SisaSekarang.Text = ""

        Keterangan.Text = ""

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblpembayaran", CONN)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub TampilidPinjaman()

        CMD = New OleDbCommand("select id_pinjaman from tblpinjaman where status_pinjaman='BELUM LUNAS'", CONN)

        DR = CMD.ExecuteReader

        IDPinjaman.Items.Clear()

        Do While DR.Read

            IDPinjaman.Items.Add(DR(0))

        Loop

    End Sub

 

    Private Sub Pembayaran_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

        Me.CenterToScreen()

        Call Koneksi()

        Call Notis()

        Call TampilGrid()

        Call TampilidPinjaman()

    End Sub

 

    Private Sub IDPinjaman_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IDPinjaman.SelectedIndexChanged

        CMD = New OleDbCommand("select * from tblpinjaman where id_pinjaman='" & IDPinjaman.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            On Error Resume Next

            TanggalPinjam.Text = DR(1)

            Bunga.Text = DR(3)

            Lamacicilan.Text = DR(4)

            JumlahPinjaman.Text = DR(5)

            Angsuran.Text = DR(6)

            Sisalalu.Text = DR(7)

        End If

 

        'cari nama Anggota

        CMD = New OleDbCommand("select tblAnggota.nama_Anggota from tblAnggota,tblpinjaman where tblAnggota.id_Anggota=tblpinjaman.id_Anggota and tblpinjaman.id_pinjaman='" & IDPinjaman.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            NamaAnggota.Text = DR(0)

        End If

 

        'cari cicilan ke berapa

        CMD = New OleDbCommand("select count(*) from tblpembayaran where id_pinjaman='" & IDPinjaman.Text & "'", CONN)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            cicilanke.Text = 1

        Else

            cicilanke.Text = DR(0) + 1

        End If

 

        'cari jatuh tempo berdasarkan cicilan ke ???

        jatuhtempo.Text = DateAdd(DateInterval.Month, Val(cicilanke.Text), DateValue(TanggalPinjam.Text))

 

        'cari terlambat

        terlambat.Text = DateDiff(DateInterval.Day, DateValue(jatuhtempo.Text), DateValue(TanggalBayar.Text))

 

        If terlambat.Text < 0 Then

            terlambat.Text = 0

        Else

            terlambat.Text = DateDiff(DateInterval.Day, DateValue(jatuhtempo.Text), DateValue(TanggalBayar.Text))

        End If

 

        'cari denda

        If DateValue(TanggalBayar.Text) > DateValue(jatuhtempo.Text) Then

            denda.Text = Val(Angsuran.Text) * 10 / 100

        Else

            denda.Text = 0

        End If

 

        'jumlah pembayaran = angsuran + denda

        JumlahPembayaran.Text = Val(Angsuran.Text) + Val(denda.Text)

 

        SisaSekarang.Text = Val(Sisalalu.Text) - Val(JumlahPembayaran.Text)

        Keterangan.Text = "Pembayaran untuk bulan " & Format(DateValue(jatuhtempo.Text), "MMMM") & " " & Year(TanggalBayar.Text) & ""

    End Sub

 

    Private Sub BTNBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBatal.Click

        Call Kosongkan()

 

    End Sub

 

    Private Sub BTNTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTutup.Click

        Me.Close()

    End Sub

 

    Private Sub JumlahPembayaran_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles JumlahPembayaran.KeyDown

        'cari sisa sekarang = sisa lalu - pembayaran

        If e.KeyCode = Keys.Enter Then

            SisaSekarang.Text = Val(Sisalalu.Text) - Val(JumlahPembayaran.Text)

            Keterangan.Text = "Pembayaran untuk bulan " & Format(DateValue(jatuhtempo.Text), "MMMM") & " " & Year(TanggalBayar.Text) & ""

        End If

    End Sub

 

    Private Sub BTNSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSimpan.Click

 

        If IDPinjaman.Text = "" Or JumlahPembayaran.Text = "" Then

            MsgBox("Transaksi belum lengkap")

            Exit Sub

        End If

 

        'Simpan pembayaran

        Dim simpan As String = "insert into tblpembayaran values('" & IDPembayaran.Text & "','" & TanggalBayar.Text & "','" & IDPinjaman.Text & "','" & cicilanke.Text & "','" & denda.Text & "','" & JumlahPembayaran.Text & "','" & Keterangan.Text & "','USR01','" & MenuUtama.PanelPerusahaan.Text & "')"

        CMD = New OleDbCommand(simpan, CONN)

        CMD.ExecuteNonQuery()

 

        'update sisa pinjaman

        Dim edit As String = "update tblpinjaman set sisa_pinjaman='" & SisaSekarang.Text & "' where id_pinjaman='" & IDPinjaman.Text & "'"

        CMD = New OleDbCommand(edit, CONN)

        CMD.ExecuteNonQuery()

 

        'jika sisa lalu <=0 maka update status menjadi LUNAS

        If SisaSekarang.Text <= 0 Then

            Dim editstatus As String = "update tblpinjaman set status_pinjaman='LUNAS' where id_pinjaman='" & IDPinjaman.Text & "'"

            CMD = New OleDbCommand(editstatus, CONN)

            CMD.ExecuteNonQuery()

        End If

 

        If MessageBox.Show("cetak bukti pembayan...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

            Cetak.Show()

            Cetak.CRV.SelectionFormula = "{tblpembayaran.id_pembayaran} = '" & IDPembayaran.Text & "'"

            laporan.Load("cetak pembayaran.rpt")

            Call SetingLaporan()

            Cetak.CRV.ReportSource = laporan

            Cetak.CRV.RefreshReport()

        End If

        Call Notis()

        Call Kosongkan()

        Call TampilGrid()

        Call TampilidPinjaman()

    End Sub

End Class

 

Membuat laporan

 

 

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        laporan.Load("anggota.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

 

 

 

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        laporan.Load("master simpanan.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

 

 

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click

        laporan.Load("master pengambilan.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

 

 

 

 

 

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click

        laporan.Load("master PINJAMAN.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

 

 

 

 

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

        laporan.Load("master Pembayaran.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub