Sie sind auf Seite 1von 4

Mata Kuliah : Pemrograman Akuntansi – KA 4B

Pertemuan :8
NIM : 4.41.16.1.23
Nama : Shalsabila

FORM ARUS KAS

Kode Program:
Public Class FrmArusKas
Dim tahun, tahun1 As Integer
Dim bulan As Byte
Dim cektahun As Boolean
Private Sub FrmArusKas_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
cmbbulan.Items.Clear()
cmbtahun.Items.Clear()
bulan = 0
tahun1 = 0
cektahun = False
For i As Integer = 1 To 12
cmbbulan.Items.Add(i)
Next
tahun = Year(Now) '2018
For j As Integer = (tahun - 2) To tahun
cmbtahun.Items.Add(j) '2016-2018
Next
cmbbulan.SelectedIndex = Month(Now) - 1
cmbtahun.Text = tahun
init_arusKas()
End Sub
Private Sub init_arusKas()
Dim jmlKas As Double = 0
Dim saldoAwal As Double = 0
Dim saldoAkhir As Double = 0
lstData.Items.Clear()
baca_ArusKas(1)
baca_ArusKas(2)
baca_ArusKas(3)
jmlKas = getJumlah(lstData, 2)
If jmlKas > 0 Then
Item = Me.lstData.Items.Add("Kenaikan arus kas")
Else
Item = Me.lstData.Items.Add("Penurunan arus kas")
End If
Item.SubItems.Add(jmlKas)
saldoAwal = ambilSaldoAwal("Kas")
Item = Me.lstData.Items.Add("Saldo Awal")
Item.SubItems.Add(saldoAwal)
Item = Me.lstData.Items.Add("")
Item.SubItems.Add("---------------")
saldoAkhir = saldoAwal + jmlKas
Item = Me.lstData.Items.Add("Posisi Kas " & Format(Now(), "dd-MM-yyyy"))
Item.SubItems.Add(saldoAkhir)
End Sub
Private Function ambilSaldoAwal(ByVal nama As String) As Double
Dim msql As String
Dim proses As New ClsKoneksi
Dim tabel As DataTable
Dim hasil As Double = 0
msql = "select SaldoAwal from akun where namaakun='" & _
nama & "'"
tabel = proses.ExecuteQuery(msql)
If tabel.Rows.Count = 1 Then
hasil = tabel.Rows(0).Item(0)
End If
Return hasil
End Function
Private Sub baca_ArusKas(ByVal grup As Byte)
Dim msql As String
Dim proses As New ClsKoneksi
Dim tabel As DataTable
Dim saldo As Double = 0
Dim saldoAwal As Double = 0
Dim saldoGrup As Double = 0
Dim ket As String
'MsgBox("bulan=" & bulan & ", tahun ="& tahun1)
If grup = 1 Then
ket = "Aktivitas Operasinal"
ElseIf grup = 2 Then
ket = "Aktivitas Investasi"
Else
ket = "Aktivitas Pendanaan"
End If
msql = "select a.namaakun,k.jumlah,k.jenis,k.grup,a.kodeakun,k.jenisSum from " _
& "akun_aruskas k,akun a where k.kodeakun=a.kodeakun and k.grup=" _
& grup & " order by k.grup,k.kodeakun "

tabel = proses.ExecuteQuery(msql)
saldo = saldoAwal
item = Me.lstdata.Items.Add(ket)
item.SubItems.Add("")
item.SubItems.Add("")
For i As Integer = 0 To tabel.Rows.Count - 1
item = Me.lstdata.Items.Add(Space(5) & tabel.Rows(i).Item(0))
item.SubItems.Add(getJumlahAK(tabel.Rows(i).Item(4), tabel.Rows(i).Item(5),
bulan, tahun1))
If tabel.Rows(i).Item(2) = "D" Then
saldoGrup = saldoGrup + getJumlahAK(tabel.Rows(i).Item(4),
tabel.Rows(i).Item(5), bulan, tahun1)
Else
saldoGrup = saldoGrup - getJumlahAK(tabel.Rows(i).Item(4),
tabel.Rows(i).Item(5), bulan, tahun1)
End If
item.SubItems.Add("")
Next i
item = Me.lstdata.Items.Add("Arus Kas untuk " & ket)
item.SubItems.Add("")
item.SubItems.Add(saldoGrup)
End Sub
Private Function getJumlahAK(ByVal kode As String, ByVal jenis As String, ByVal bln
As Byte, ByVal thn As Integer) As Double
Dim msql As String
Dim proses As New ClsKoneksi
Dim tabel As DataTable
Dim jml As Double = 0
If jenis = "D" Then
If bln = 0 And thn = 0 Then
msql = "select sum(debet) as jdebet from v_jurnal where kodeakun='" & _
kode & "'"
ElseIf bln = 0 And thn <> 0 Then
msql = "select sum(debet) as jdebet from v_jurnal where kodeakun='" & _
kode & "' And year(tanggal) = " & thn
Else
msql = "select sum(debet) as jdebet from v_jurnal where kodeakun='" & _
kode & "' And month(tanggal) = " & bln & " And year(tanggal) = " &
thn
End If
Else
If bln = 0 And thn = 0 Then
msql = "select sum(kredit) as jkredit from v_jurnal where kodeakun='" & _
kode & "'"
ElseIf bln = 0 And thn <> 0 Then
msql = "select sum(kredit) as jkredit from v_jurnal where kodeakun='" & _
kode & "' And year(tanggal) = " & thn
Else
msql = "select sum(kredit) as jkredit from v_jurnal where kodeakun='" & _
kode & "' And month(tanggal) = " & bln & " And year(tanggal) = " &
thn
End If
End If
tabel = proses.ExecuteQuery(msql)

If tabel.Rows.Count > 0 Then

If IsDBNull(tabel.Rows(0).Item(0)) = True Then


jml = 0
Else
jml = tabel.Rows(0).Item(0)
End If
Else
jml = 0
End If
Return jml
End Function
Private Sub cmdExport_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles cmdExport.Click
exportLvToExcel(lstData)
End Sub

Private Sub cmdCari_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles cmdCari.Click
If cekBulan.Checked = True Then
bulan = Val(cmbbulan.Text)
tahun1 = Val(cmbtahun.Text)
init_arusKas()
Else
bulan = 0
If cektahun = True Then
tahun1 = Val(cmbtahun.Text)
Else
tahun1 = 0
End If
init_arusKas()
End If
End Sub

Private Sub cmbtahun_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles cmbtahun.Click
cektahun = True
End Sub
End Class