Imports System.IO
Public Class Master
Private Sub IndukToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles IndukToolStripMenuItem.Click
End Sub
Private Sub AdminToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AdminToolStripMenuItem.Click
Admin.Show()
End Sub
Private Sub AnggotaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AnggotaToolStripMenuItem.Click
NASABAH.Show()
End Sub
Private Sub BukuPinjamanToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BukuPinjamanToolStripMenuItem.Click
Pinjaman.Show()
End Sub
Private Sub BukuSetoranToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BukuSetoranToolStripMenuItem.Click
BayarCicilan.Show()
End Sub
Private Sub Master_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub GantiPasswordAdmToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GantiPasswordAdmToolStripMenuItem.Click
GantiPassword.Show()
End Sub
Private Sub LapDataAnggotaToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LapDataAnggotaToolStripMenuItem.Click
FLaporan.Show()
End Sub
Private Sub TutupProgramToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TutupProgramToolStripMenuItem1.Click
Me.Close()
Login.Show()
End Sub
Private Sub TutupProgramToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TutupProgramToolStripMenuItem.Click
Dim dlg As New SaveFileDialog
dlg.DefaultExt = "*.mdb"
dlg.Filter = "ACCESS 2007|*.mdb|All File|*"
If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
Conn.Close()
File.Copy(Application.StartupPath & "\BKc.mdb", dlg.FileName, True)
Conn.Open()
End If
End Sub
Private Sub ImportToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ImportToolStripMenuItem.Click
Dim dlg As New OpenFileDialog
dlg.DefaultExt = "*.mdb"
dlg.Filter = "ACCESS 2007|*.mdb|All File|*"
If dlg.ShowDialog = Windows.Forms.DialogResult.OK Then
Conn.Close()
File.Copy(dlg.FileName, Application.StartupPath & "\KDS.mdb", True)
Master_Load(Nothing, Nothing)
End If
End Sub
End Class
Imports System.Data.OleDb
Public Class Admin
Sub Tampilkan()
da = New OleDbDataAdapter("Select * from ADMIN ORDER BY 1", Conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "ADMIN")
DGV.DataSource = (ds.Tables("ADMIN"))
DGV.ReadOnly = True
End Sub
Sub Kosongkan()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = ""
TextBox1.Focus()
End Sub
Sub DataBaru()
TextBox2.Text = ""
TextBox3.Text = ""
ComboBox1.Text = ""
TextBox2.Focus()
End Sub
Sub TampilstatusADMIN()
ComboBox1.Items.Clear()
cmd = New OleDbCommand("select distinct Status_Admin from ADMIN", Conn)
rd = cmd.ExecuteReader
While rd.Read
ComboBox1.Items.Add(rd.GetString(0))
End While
End Sub
Sub aturform()
Me.Top = 100
Me.Left = 450
End Sub
Private Sub Admin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Koneksi()
Call Tampilkan()
Call aturform()
ComboBox1.Items.Add("Administrasi")
ComboBox1.Items.Add("Operator")
ComboBox1.Items.Add("User")
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
TextBox1.Text = UCase(TextBox1.Text)
cmd = New OleDbCommand("select * from ADMIN where Kode_Admin='" & TextBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows = True Then
TextBox2.Text = rd.GetString(1)
TextBox3.Text = rd.GetString(2)
ComboBox1.Text = rd.GetString(3)
TextBox2.Focus()
Else
Call DataBaru()
TextBox2.Focus()
End If
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then
TextBox3.Focus()
TextBox2.Text = UCase(TextBox2.Text)
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then ComboBox1.Focus()
End Sub
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
If e.KeyChar = Chr(13) Then CmdSimpan.Focus()
End Sub
Private Sub CmdSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSimpan.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or ComboBox1.Text = "" Then
MsgBox("Data Belum Lengkap")
Exit Sub
Else
cmd = New OleDbCommand("Select * from ADMIN where Kode_Admin='" & TextBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
Dim sqltambah As String = "Insert into ADMIN (Kode_Admin,Nama_Admin,Password_Admin,Status_Admin) values " & _
"('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.Text & "')"
cmd = New OleDbCommand(sqltambah, Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
Else
Dim sqledit As String = "Update ADMIN set " & _
"Nama_Admin='" & TextBox2.Text & "', " & _
"Password_Admin='" & TextBox3.Text & "', " & _
"Status_Admin='" & ComboBox1.Text & "' where Kode_Admin='" & TextBox1.Text & "'"
cmd = New OleDbCommand(sqledit, Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
End If
End If
End Sub
Private Sub CmdBatal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdBatal.Click
Call Kosongkan()
End Sub
Private Sub CmdTutup_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdTutup.Click
Me.Close()
End Sub
Private Sub CmdHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdHapus.Click
If TextBox1.Text = "" Then
MsgBox("Isi kode Petugas terlebih dahulu")
TextBox1.Focus()
Exit Sub
Else
If MessageBox.Show("Yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
cmd = New OleDbCommand("Delete * from ADMIN where Kode_Admin='" & TextBox1.Text & "'", Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
Else
Call Kosongkan()
End If
End If
End Sub
End Class
Imports System.Data.OleDb
Public Class BayarCicilan
Sub Bersihkan()
ComboBox1.Text = ""
LblNama.Text = ""
LblAlamat.Text = ""
LblTelepon.Text = ""
LblJumlah.Text = ""
LblTanggalTempo.Text = ""
LblTerlambat.Text = ""
LblTelahBayar.Text = ""
LblSisaLalu.Text = ""
LblDenda.Text = ""
TxtAngsuran.Text = ""
LblCicilanKe.Text = ""
LblSisaSekarang.Text = ""
LblTanggalKredit.Text = ""
Label3.Text = ""
TxtKeterangan.Text = "-"
End Sub
Sub Otomatis()
cmd = New OleDbCommand("Select * from BayarCicilan where NomorByr in (select max(NomorByr) from BayarCicilan) order by NomorByr desc", Conn)
Dim urutan As String
Dim hitung As Long
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
urutan = "BY" + Format(Now, "yyMMdd") + "01"
Else
If Microsoft.VisualBasic.Mid(rd.GetString(0), 3, 6) <> Format(Now, "yyMMdd") Then
urutan = "BY" + Format(Now, "yyMMdd") + "01"
Else
hitung = Microsoft.VisualBasic.Right(rd.GetString(0), 8) + 1
urutan = "BY" + Format(Now, "yyMMdd") + Microsoft.VisualBasic.Right("00" & hitung, 2)
End If
End If
LblNomorByr.Text = urutan
End Sub
Sub TampilPinjaman()
da = New OleDbDataAdapter("select * from Pinjaman ", Conn)
ds = New DataSet
da.Fill(ds, "Pinjaman")
DGV1.DataSource = ds.Tables("Pinjaman")
End Sub
Sub TampilCicilan()
da = New OleDbDataAdapter("select * from Bayarcicilan", Conn)
ds = New DataSet
da.Fill(ds, "Bayarcicilan")
DGV2.DataSource = ds.Tables("Bayarcicilan")
End Sub
Sub TampilIDKREDIT()
cmd = New OleDbCommand("Select * from pinjaman where ketERANGAN<>'LUNAS'", Conn)
rd = cmd.ExecuteReader
Do While rd.Read
ComboBox1.Items.Add(rd.Item(0))
Loop
End Sub
Private Sub BayarCicilan_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call Otomatis()
LblTanggalByr.Text = Today
End Sub
Private Sub BayarCicilan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Koneksi()
Call TampilIDKredit()
Call TampilPinjaman()
Call TampilCicilan()
Call Bersihkan()
End Sub
Private Sub ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
If e.KeyChar = Chr(13) Then TxtAngsuran.Focus()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cmd = New OleDbCommand("select * from Pinjaman where IDKREDIT='" & ComboBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
LblJumlah.Text = rd.Item("jumlah")
TxtAngsuran.Text = rd.Item("angsuran")
LblSisaLalu.Text = rd.Item("sisa")
LblTanggalKredit.Text = rd.Item("tanggal")
LblCicilanKe.Text = Val(rd.Item("angsuranke")) + 1
'jika belum pernah membayar angsuran maka jatuh tempo pembayaran adalah dimulai dari tanggal beli + 30 hari
If rd.Item("angsuranke") = 2 Then
LblTanggalTempo.Text = DateAdd(DateInterval.Day, 30, rd.Item(1))
Else
'jika pernah ada angsuran, maka angsuran berikutnya
'adalah 30 hari X jumlah angsuran yang penah dibayar
LblTanggalTempo.Text = DateAdd(DateInterval.Day, 30 * LblCicilanKe.Text, rd.Item(1))
End If
'jumlah denda adalah 5000 x hari keterlambatan dati tgl jatuh tempo
If CDate(LblTanggalByr.Text) > CDate(LblTanggalTempo.Text) Then
LblTerlambat.Text = Val(LblTanggalByr.Text) - Val(LblTanggalTempo.Text)
LblDenda.Text = 5000 * Val(LblTerlambat.Text)
Else
LblTerlambat.Text = 0
LblDenda.Text = 0
End If
If rd.Item("telahbayar") = 0 Then
LblTelahBayar.Text = 0
Else
LblTelahBayar.Text = rd.Item("telahbayar")
End If
'mencari identitas Anggota yang dihasilkan dari query Pinjaman
cmd = New OleDbCommand("select * from NASABAH where ID_nasabah='" & rd.Item(2) & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
LblNama.Text = rd.Item("Nama")
LblAlamat.Text = rd.Item("Alamat_Instansi")
LblTelepon.Text = rd.Item("Telepon")
Label3.Text = rd.Item("ID_nasabah")
End If
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNBatal.Click
Call Bersihkan()
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNTutup.Click
Me.Close()
End Sub
Private Sub TxtAngsuran_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtAngsuran.KeyPress
If e.KeyChar = Chr(13) Then
cmd = New OleDbCommand("SELECT * FROM Pinjaman WHERE IDKREDIT='" & ComboBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
'jika angsuran melebihi sisa pembayaran, maka tampilkan dalam keterangan uang kembaliannya
If Val(TxtAngsuran.Text) > rd.Item("sisa") Then
TxtAngsuran.Text = TxtAngsuran.Text
TxtKeterangan.Text = "kembali" & Space(1) & (TxtAngsuran.Text - rd.Item("sisa")) & Space(1) & "LUNAS"
'LblCicilanKe.Text = 1
LblSisaSekarang.Text = 0
Else
'sisa sekarang tampil setelah dikurang angsuran indikasi cicilan terus berubah yaitu cicilan bulan lalu + 1
LblSisaSekarang.Text = LblSisaLalu.Text - TxtAngsuran.Text
TxtKeterangan.Text = "Pembayaran Bulan" & Space(1) & (MonthName(Month(LblTanggalTempo.Text)))
TxtKeterangan.Text = TxtKeterangan.Text & Space(1) & Year(LblTanggalTempo.Text)
TxtKeterangan.Focus()
End If
TxtKeterangan.Focus()
End If
End If
End Sub
Private Sub BTNSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSimpan.Click
If ComboBox1.Text = "" Or TxtAngsuran.Text = "" Or LblSisaSekarang.Text = "" Then
MsgBox("Data belum lengkap, coba enter di angsuran + denda")
TxtAngsuran.Focus()
Exit Sub
End If
Dim Simpan As String = "INSERT INTO bayarcicilan(nomorbyr,tanggalbyr,IDKREDIT,ID_nasabah,JUMLAH,sisa,CICILAN,keterangan,Kode_Admin) VALUES " & _
"('" & LblNomorByr.Text & "','" & LblTanggalByr.Text & "','" & ComboBox1.Text & "','" & Label3.Text & "','" & TxtAngsuran.Text & "','" & LblSisaSekarang.Text & "','" & LblCicilanKe.Text & "','" & TxtKeterangan.Text & "','" & Master.ToolStripStatusLabel1.Text & "')"
cmd = New OleDbCommand(Simpan, Conn)
cmd.ExecuteNonQuery()
'sisa pembayaran terus berkurang akibat pembayaran
'jumlah telah bayar terus bertambah
'jika sisa sekarang = 0 maka keterangan =lunas
'indikasi angsuran terus berubah 1,2,3 dan seterusnya
cmd = New OleDbCommand("SELECT * FROM Pinjaman WHERE IDKREDIT='" & ComboBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
If LblSisaSekarang.Text = 0 Then
Dim updatedata As String = "UPDATE Pinjaman SET SISA='" & LblSisaSekarang.Text & "',telahbayar= '" & rd.Item("telahbayar") + TxtAngsuran.Text & "',ANGSURANKE='" & LblCicilanKe.Text & "',keterangan='LUNAS' WHERE IDKREDIT='" & ComboBox1.Text & "'"
cmd = New OleDbCommand(updatedata, Conn)
cmd.ExecuteNonQuery()
Else
Dim updatedata As String = "UPDATE Pinjaman SET SISA='" & rd.Item("sisa") - TxtAngsuran.Text & "',telahbayar= '" & rd.Item("telahbayar") + TxtAngsuran.Text & "',ANGSURANKE='" & LblCicilanKe.Text & "',keterangan='-' WHERE IDKREDIT='" & ComboBox1.Text & "'"
cmd = New OleDbCommand(updatedata, Conn)
cmd.ExecuteNonQuery()
End If
cmd = New OleDbCommand("SELECT * FROM Pinjaman WHERE IDKREDIT='" & ComboBox1.Text & "' AND SISA=0", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
Dim UBAHKET As String = "UPDATE Pinjaman SET KETerangan='LUNAS' WHERE IDKREDIT='" & ComboBox1.Text & "'"
cmd = New OleDbCommand(UBAHKET, Conn)
cmd.ExecuteNonQuery()
End If
Call Otomatis()
Call Bersihkan()
Call TampilPinjaman()
Call TampilCicilan()
ComboBox1.Focus()
End If
End Sub
Private Sub TxtKeterangan_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtKeterangan.KeyPress
If e.KeyChar = Chr(13) Then
If TxtKeterangan.Text = "" Then
TxtKeterangan.Text = "-"
Else
btnsimpan.Focus()
End If
End If
End Sub
Private Sub TxtAngsuran_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtAngsuran.TextChanged
End Sub
End Class
Imports System.Data.OleDb
Public Class FLaporan
Sub setingform()
Me.Top = 60
Me.Left = 250
End Sub
Sub bayarcicilan()
Dim A As CrystalDecisions.CrystalReports.Engine.Table
Dim B As CrystalDecisions.Shared.TableLogOnInfo
Dim Report1 As CrystalDecisions.CrystalReports.Engine.ReportDocument
Report1 = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Report1.Load(Application.StartupPath & "\lap_BayarCicil.rpt")
For Each A In Report1.Database.Tables
B = A.LogOnInfo
With B.ConnectionInfo
.ServerName = Application.StartupPath & "\BKc.mdb"
.UserID = ""
.Password = ""
.DatabaseName = ""
End With
A.ApplyLogOnInfo(B)
Next A
Me.CrystalReportViewer1.ReportSource = Report1
End Sub
Sub nasabah()
Dim A As CrystalDecisions.CrystalReports.Engine.Table
Dim B As CrystalDecisions.Shared.TableLogOnInfo
Dim Report1 As CrystalDecisions.CrystalReports.Engine.ReportDocument
Report1 = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Report1.Load(Application.StartupPath & "\NASABAH.rpt")
For Each A In Report1.Database.Tables
B = A.LogOnInfo
With B.ConnectionInfo
.ServerName = Application.StartupPath & "\BKc.mdb"
.UserID = ""
.Password = ""
.DatabaseName = ""
End With
A.ApplyLogOnInfo(B)
Next A
Me.CrystalReportViewer1.ReportSource = Report1
End Sub
Sub pinjaman()
Dim A As CrystalDecisions.CrystalReports.Engine.Table
Dim B As CrystalDecisions.Shared.TableLogOnInfo
Dim Report1 As CrystalDecisions.CrystalReports.Engine.ReportDocument
Report1 = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Report1.Load(Application.StartupPath & "\PINJAMAN.rpt")
For Each A In Report1.Database.Tables
B = A.LogOnInfo
With B.ConnectionInfo
.ServerName = Application.StartupPath & "\BKc.mdb"
.UserID = ""
.Password = ""
.DatabaseName = ""
End With
A.ApplyLogOnInfo(B)
Next A
Me.CrystalReportViewer1.ReportSource = Report1
End Sub
Sub kopetgaring()
Dim A As CrystalDecisions.CrystalReports.Engine.Table
Dim B As CrystalDecisions.Shared.TableLogOnInfo
Dim Report1 As CrystalDecisions.CrystalReports.Engine.ReportDocument
Report1 = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Report1.Load(Application.StartupPath & "\lappertgl.rpt")
For Each A In Report1.Database.Tables
B = A.LogOnInfo
With B.ConnectionInfo
.ServerName = Application.StartupPath & "\BKc.mdb"
.UserID = ""
.Password = ""
.DatabaseName = ""
End With
A.ApplyLogOnInfo(B)
Next A
Me.CrystalReportViewer1.ReportSource = Report1
End Sub
Sub laporanperorangan()
Dim A As CrystalDecisions.CrystalReports.Engine.Table
Dim B As CrystalDecisions.Shared.TableLogOnInfo
Dim Report1 As CrystalDecisions.CrystalReports.Engine.ReportDocument
Report1 = New CrystalDecisions.CrystalReports.Engine.ReportDocument()
Report1.Load(Application.StartupPath & "\LAP_PERORANGAN.rpt")
For Each A In Report1.Database.Tables
B = A.LogOnInfo
With B.ConnectionInfo
.ServerName = Application.StartupPath & "\BKc.mdb"
.UserID = ""
.Password = ""
.DatabaseName = ""
End With
A.ApplyLogOnInfo(B)
Next A
Me.CrystalReportViewer1.ReportSource = Report1
End Sub
Private Sub FLaporan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call setingform()
End Sub
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
Call nasabah()
End Sub
Private Sub Label2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label2.Click
Call pinjaman()
End Sub
Private Sub Label3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label3.Click
Call kopetgaring()
End Sub
Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click
CrystalReportViewer1.Hide()
End Sub
Private Sub Label5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label5.Click
CrystalReportViewer1.Show()
End Sub
Private Sub Label6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label6.Click
Call bayarcicilan()
End Sub
Private Sub Label7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label7.Click
Call laporanperorangan()
End Sub
End Class
Imports System.Data.OleDb
Public Class GantiPassword
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then
cmd = New OleDbCommand("select * from ADMIN where Nama_Admin='" & TextBox1.Text & "' and Kode_Admin='" & Master.ToolStripStatusLabel1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
TextBox2.Enabled = True
TextBox2.Focus()
Else
MsgBox("Anda tidak berhak mengganti password disini")
TextBox1.Focus()
End If
End If
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then
cmd = New OleDbCommand("select * from ADMIN where Nama_Admin='" & Master.ToolStripStatusLabel2.Text & "' and Password_Admin='" & TextBox2.Text & "' ", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
TextBox3.Enabled = True
TextBox3.Focus()
Else
MsgBox("Password lama salah")
TextBox2.Focus()
End If
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then
If TextBox3.Text = "" Then
MsgBox("Passwrod baru wajib diisi")
TextBox3.Focus()
Else
TextBox4.Enabled = True
TextBox4.Focus()
End If
End If
End Sub
Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
If e.KeyChar = Chr(13) Then
If TextBox4.Text <> TextBox3.Text Then
MsgBox("Password konfirmasi salah")
TextBox4.Focus()
Else
If MessageBox.Show("Yakin akan ganti password..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
Dim ganti As String = "Update ADMIN set Password_Admin='" & TextBox3.Text & "' where Nama_Admin='" & TextBox1.Text & "' and Kode_Admin='" & Master.ToolStripStatusLabel1.Text & "'"
cmd = New OleDbCommand(ganti, Conn)
cmd.ExecuteNonQuery()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
Me.Close()
Else
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
Me.Close()
End If
End If
End If
End Sub
Private Sub GantiPassword_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TextBox2.Enabled = False
TextBox3.Enabled = False
TextBox4.Enabled = False
End Sub
End Class
Imports System.Data.OleDb
Public Class Login
Sub aturform()
Me.Top = 150
Me.Left = 450
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Me.Close()
End Sub
Private Sub Login_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call aturform()
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
If e.KeyChar = Chr(13) Then TextBox2.Focus()
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then Button1.Focus()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Clear()
TextBox2.Clear()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Koneksi()
cmd = New OleDbCommand("select * from ADMIN where Nama_Admin='" & TextBox1.Text & "' and Password_Admin='" & TextBox2.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
Me.Visible = False
Master.Show()
Master.ToolStripStatusLabel1.Text = rd.GetString(0)
Master.ToolStripStatusLabel2.Text = rd.GetString(1)
Master.ToolStripStatusLabel3.Text = rd.GetString(3)
Else
MsgBox("login salah, periksan kembali user name dan password")
TextBox1.Focus()
End If
End Sub
End Class
KONEKSI MENGGUNAKAN MODUL
Imports System.Data.OleDb
Module Module1
Public Conn As OleDbConnection
Public da As OleDbDataAdapter
Public ds As DataSet
Public cmd As OleDbCommand
Public rd As OleDbDataReader
Public str As String
Public hasil As Integer
Public Sub Koneksi()
str = "provider=microsoft.jet.oledb.4.0;data source=" & Application.StartupPath & "\BKc.mdb"
Conn = New OleDbConnection(str)
If Conn.State = ConnectionState.Closed Then
Conn.Open()
End If
End Sub
End Module
Imports System.Data.OleDb
Public Class NASABAH
Sub aturform()
Me.Top = 100
Me.Left = 350
End Sub
Sub Kosongkan()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox9.Text = ""
TextBox1.Focus()
End Sub
Sub DataBaru()
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox9.Text = ""
TextBox2.Focus()
End Sub
Sub Tampilkan()
da = New OleDbDataAdapter("Select * from NASABAH", Conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "NASABAH")
DGV.DataSource = (ds.Tables("NASABAH"))
DGV.ReadOnly = True
End Sub
Private Sub Anggota_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Koneksi()
Call Tampilkan()
Call aturform()
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
TextBox1.MaxLength = 5
If e.KeyChar = Chr(13) Then
cmd = New OleDbCommand("select * from NASABAH where ID_nasabah='" & TextBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows = True Then
TextBox2.Text = rd.Item(1)
TextBox3.Text = rd.Item(2)
TextBox4.Text = rd.Item(3)
TextBox5.Text = rd.Item(4)
TextBox6.Text = rd.Item(5)
TextBox9.Text = rd.Item(6)
TextBox2.Focus()
Else
Call DataBaru()
TextBox2.Focus()
End If
End If
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then
TextBox2.Text = UCase(TextBox2.Text)
TextBox3.Focus()
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then
TextBox3.Text = UCase(TextBox3.Text)
TextBox4.Focus()
End If
End Sub
Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
If e.KeyChar = Chr(13) Then
TextBox4.Text = UCase(TextBox4.Text)
TextBox5.Focus()
End If
End Sub
Private Sub Textbox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
If e.KeyChar = Chr(13) Then
TextBox5.Text = UCase(TextBox5.Text)
TextBox6.Focus()
End If
End Sub
Private Sub Textbox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
If e.KeyChar = Chr(13) Then
TextBox9.Text = Val(TextBox6.Text)
TextBox9.Enabled = False
BTNSimpan.Focus()
End If
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
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
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox9.Text = "" Then
MsgBox("Data Belum Lengkap")
Exit Sub
Else
cmd = New OleDbCommand("Select * from NASABAH where ID_nasabah='" & TextBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
Dim sqltambah As String = "Insert into NASABAH(ID_nasabah,Nama,Nip,Alamat_Instansi,Telepon,Simpanan_Wajib,Saldo) values " & _
"('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox9.Text & "')"
cmd = New OleDbCommand(sqltambah, Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
Else
Dim sqledit As String = "Update NASABAH set " & _
"Nama='" & TextBox2.Text & "', " & _
"Nip='" & TextBox3.Text & "', " & _
"Alamat_Instansi='" & TextBox4.Text & "', " & _
"Telepon='" & TextBox5.Text & "', " & _
"Simpanan_Wajib='" & TextBox6.Text & "', " & _
"Saldo='" & TextBox9.Text & "' where ID_nasabah='" & TextBox1.Text & "'"
cmd = New OleDbCommand(sqledit, Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
End If
End If
End Sub
Private Sub BTNHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNHapus.Click
If TextBox1.Text = "" Then
MsgBox("Isi kode Anggota terlebih dahulu")
TextBox1.Focus()
Exit Sub
Else
If MessageBox.Show("Yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
cmd = New OleDbCommand("Delete * from NASABAH where ID_nasabah='" & TextBox1.Text & "'", Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
Else
Call Kosongkan()
End If
End If
End Sub
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
End Sub
End Class
Public Class NASABAH
Sub aturform()
Me.Top = 100
Me.Left = 350
End Sub
Sub Kosongkan()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox9.Text = ""
TextBox1.Focus()
End Sub
Sub DataBaru()
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox9.Text = ""
TextBox2.Focus()
End Sub
Sub Tampilkan()
da = New OleDbDataAdapter("Select * from NASABAH", Conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "NASABAH")
DGV.DataSource = (ds.Tables("NASABAH"))
DGV.ReadOnly = True
End Sub
Private Sub Anggota_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Koneksi()
Call Tampilkan()
Call aturform()
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
TextBox1.MaxLength = 5
If e.KeyChar = Chr(13) Then
cmd = New OleDbCommand("select * from NASABAH where ID_nasabah='" & TextBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows = True Then
TextBox2.Text = rd.Item(1)
TextBox3.Text = rd.Item(2)
TextBox4.Text = rd.Item(3)
TextBox5.Text = rd.Item(4)
TextBox6.Text = rd.Item(5)
TextBox9.Text = rd.Item(6)
TextBox2.Focus()
Else
Call DataBaru()
TextBox2.Focus()
End If
End If
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
If e.KeyChar = Chr(13) Then
TextBox2.Text = UCase(TextBox2.Text)
TextBox3.Focus()
End If
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If e.KeyChar = Chr(13) Then
TextBox3.Text = UCase(TextBox3.Text)
TextBox4.Focus()
End If
End Sub
Private Sub TextBox4_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox4.KeyPress
If e.KeyChar = Chr(13) Then
TextBox4.Text = UCase(TextBox4.Text)
TextBox5.Focus()
End If
End Sub
Private Sub Textbox5_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox5.KeyPress
If e.KeyChar = Chr(13) Then
TextBox5.Text = UCase(TextBox5.Text)
TextBox6.Focus()
End If
End Sub
Private Sub Textbox6_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox6.KeyPress
If e.KeyChar = Chr(13) Then
TextBox9.Text = Val(TextBox6.Text)
TextBox9.Enabled = False
BTNSimpan.Focus()
End If
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
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
If TextBox1.Text = "" Or TextBox2.Text = "" Or TextBox3.Text = "" Or TextBox4.Text = "" Or TextBox5.Text = "" Or TextBox6.Text = "" Or TextBox9.Text = "" Then
MsgBox("Data Belum Lengkap")
Exit Sub
Else
cmd = New OleDbCommand("Select * from NASABAH where ID_nasabah='" & TextBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
Dim sqltambah As String = "Insert into NASABAH(ID_nasabah,Nama,Nip,Alamat_Instansi,Telepon,Simpanan_Wajib,Saldo) values " & _
"('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & TextBox4.Text & "','" & TextBox5.Text & "','" & TextBox6.Text & "','" & TextBox9.Text & "')"
cmd = New OleDbCommand(sqltambah, Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
Else
Dim sqledit As String = "Update NASABAH set " & _
"Nama='" & TextBox2.Text & "', " & _
"Nip='" & TextBox3.Text & "', " & _
"Alamat_Instansi='" & TextBox4.Text & "', " & _
"Telepon='" & TextBox5.Text & "', " & _
"Simpanan_Wajib='" & TextBox6.Text & "', " & _
"Saldo='" & TextBox9.Text & "' where ID_nasabah='" & TextBox1.Text & "'"
cmd = New OleDbCommand(sqledit, Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
End If
End If
End Sub
Private Sub BTNHapus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNHapus.Click
If TextBox1.Text = "" Then
MsgBox("Isi kode Anggota terlebih dahulu")
TextBox1.Focus()
Exit Sub
Else
If MessageBox.Show("Yakin akan dihapus..?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then
cmd = New OleDbCommand("Delete * from NASABAH where ID_nasabah='" & TextBox1.Text & "'", Conn)
cmd.ExecuteNonQuery()
Call Kosongkan()
Call Tampilkan()
Else
Call Kosongkan()
End If
End If
End Sub
Private Sub TextBox9_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox9.TextChanged
End Sub
End Class
Imports System.Data.OleDb
Imports System.Math
Public Class Pinjaman
Sub Kosongkan()
ComboBox1.Text = ""
LblNama.Text = ""
LblSaldo.Text = ""
TxtPinjaman.Clear()
TxtBunga.Clear()
TxtCicilan.Clear()
TxtPinjaman.Clear()
LblAngsuran.Text = ""
ComboBox1.Focus()
End Sub
Sub TampilGrid()
da = New OleDbDataAdapter("select * from Pinjaman", Conn)
ds = New DataSet
da.Fill(ds, "Pinjaman")
DGV.DataSource = ds.Tables("Pinjaman")
End Sub
Sub TampilAnggota()
cmd = New OleDbCommand("Select * from NASABAH", Conn)
rd = cmd.ExecuteReader
Do While rd.Read
ComboBox1.Items.Add(rd.Item(0))
Loop
End Sub
Sub Otomatis()
cmd = New OleDbCommand("Select * from Pinjaman where IDKredit in (select max(IDKredit) from Pinjaman) order by IDKredit desc", Conn)
Dim urutan As String
Dim hitung As Long
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
urutan = "KR" + Format(Now, "yyMMdd") + "01"
Else
If Microsoft.VisualBasic.Mid(rd.GetString(0), 3, 6) <> Format(Now, "yyMMdd") Then
urutan = "KR" + Format(Now, "yyMMdd") + "01"
Else
hitung = Microsoft.VisualBasic.Right(rd.GetString(0), 8) + 1
urutan = "KR" + Format(Now, "yyMMdd") + Microsoft.VisualBasic.Right("00" & hitung, 2)
End If
End If
LblIDKredit.Text = urutan
End Sub
Private Sub Pinjaman_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call Otomatis()
LblTanggal.Text = Today()
End Sub
Private Sub Pinjaman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Koneksi()
Call TampilGrid()
Call Kosongkan()
TampilAnggota()
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 ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
If e.KeyChar = Chr(13) Then TxtPinjaman.Focus()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cmd = New OleDbCommand("select * from NASABAH where ID_nasabah='" & ComboBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
LblNama.Text = rd.Item(1)
Label11.Text = rd.Item(2)
LblSaldo.Text = rd.Item(6)
End If
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 BTNSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSimpan.Click
If ComboBox1.Text = "" Or TxtPinjaman.Text = "" Then
MsgBox("Data belum lengkap")
Exit Sub
Else
'simpan data ke tabel pinjam
Dim simpan As String = "Insert Into Pinjaman(IdKredit,Tanggal,ID_nasabah,Jumlah,bunga,lamacicilan,angsuran,sisa,keterangan,Kode_Admin) values " & _
"('" & LblIDKredit.Text & "','" & LblTanggal.Text & "','" & ComboBox1.Text & "','" & TxtPinjaman.Text & "','" & TxtBunga.Text & "','" & TxtCicilan.Text & "','" & LblAngsuran.Text & "','" & TxtPinjaman.Text & "','-','" & Master.ToolStripStatusLabel1.Text & "')"
cmd = New OleDbCommand(simpan, Conn)
cmd.ExecuteNonQuery()
Call Otomatis()
Call TampilGrid()
Call Kosongkan()
End If
End Sub
Private Sub TxtPinjaman_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtPinjaman.KeyPress
If e.KeyChar = Chr(13) Then
If Val(TxtPinjaman.Text) > Val(LblSaldo.Text) * 19999 Then
MsgBox("pinjaman maksimal 2X lipat saldo")
TxtPinjaman.Clear()
Else
TxtBunga.Focus()
End If
End If
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub TxtBunga_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtBunga.KeyPress
If e.KeyChar = Chr(13) Then TxtCicilan.Focus()
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub TxtCicilan_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtCicilan.KeyPress
If e.KeyChar = Chr(13) Then
Dim hitung As Decimal = Microsoft.VisualBasic.Pmt(Val(TxtBunga.Text) / 100 / 12, Val(TxtCicilan.Text), Val(TxtPinjaman.Text)) * -1
LblAngsuran.Text = Round(hitung, 2)
BTNSimpan.Focus()
End If
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub LblTanggal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LblTanggal.Click
End Sub
Private Sub TxtCicilan_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtCicilan.TextChanged
End Sub
Private Sub Label12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label12.Click
System.Diagnostics.Process.Start("#")
End Sub
End Class
Imports System.Math
Public Class Pinjaman
Sub Kosongkan()
ComboBox1.Text = ""
LblNama.Text = ""
LblSaldo.Text = ""
TxtPinjaman.Clear()
TxtBunga.Clear()
TxtCicilan.Clear()
TxtPinjaman.Clear()
LblAngsuran.Text = ""
ComboBox1.Focus()
End Sub
Sub TampilGrid()
da = New OleDbDataAdapter("select * from Pinjaman", Conn)
ds = New DataSet
da.Fill(ds, "Pinjaman")
DGV.DataSource = ds.Tables("Pinjaman")
End Sub
Sub TampilAnggota()
cmd = New OleDbCommand("Select * from NASABAH", Conn)
rd = cmd.ExecuteReader
Do While rd.Read
ComboBox1.Items.Add(rd.Item(0))
Loop
End Sub
Sub Otomatis()
cmd = New OleDbCommand("Select * from Pinjaman where IDKredit in (select max(IDKredit) from Pinjaman) order by IDKredit desc", Conn)
Dim urutan As String
Dim hitung As Long
rd = cmd.ExecuteReader
rd.Read()
If Not rd.HasRows Then
urutan = "KR" + Format(Now, "yyMMdd") + "01"
Else
If Microsoft.VisualBasic.Mid(rd.GetString(0), 3, 6) <> Format(Now, "yyMMdd") Then
urutan = "KR" + Format(Now, "yyMMdd") + "01"
Else
hitung = Microsoft.VisualBasic.Right(rd.GetString(0), 8) + 1
urutan = "KR" + Format(Now, "yyMMdd") + Microsoft.VisualBasic.Right("00" & hitung, 2)
End If
End If
LblIDKredit.Text = urutan
End Sub
Private Sub Pinjaman_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call Otomatis()
LblTanggal.Text = Today()
End Sub
Private Sub Pinjaman_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call Koneksi()
Call TampilGrid()
Call Kosongkan()
TampilAnggota()
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 ComboBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles ComboBox1.KeyPress
If e.KeyChar = Chr(13) Then TxtPinjaman.Focus()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cmd = New OleDbCommand("select * from NASABAH where ID_nasabah='" & ComboBox1.Text & "'", Conn)
rd = cmd.ExecuteReader
rd.Read()
If rd.HasRows Then
LblNama.Text = rd.Item(1)
Label11.Text = rd.Item(2)
LblSaldo.Text = rd.Item(6)
End If
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 BTNSimpan_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BTNSimpan.Click
If ComboBox1.Text = "" Or TxtPinjaman.Text = "" Then
MsgBox("Data belum lengkap")
Exit Sub
Else
'simpan data ke tabel pinjam
Dim simpan As String = "Insert Into Pinjaman(IdKredit,Tanggal,ID_nasabah,Jumlah,bunga,lamacicilan,angsuran,sisa,keterangan,Kode_Admin) values " & _
"('" & LblIDKredit.Text & "','" & LblTanggal.Text & "','" & ComboBox1.Text & "','" & TxtPinjaman.Text & "','" & TxtBunga.Text & "','" & TxtCicilan.Text & "','" & LblAngsuran.Text & "','" & TxtPinjaman.Text & "','-','" & Master.ToolStripStatusLabel1.Text & "')"
cmd = New OleDbCommand(simpan, Conn)
cmd.ExecuteNonQuery()
Call Otomatis()
Call TampilGrid()
Call Kosongkan()
End If
End Sub
Private Sub TxtPinjaman_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtPinjaman.KeyPress
If e.KeyChar = Chr(13) Then
If Val(TxtPinjaman.Text) > Val(LblSaldo.Text) * 19999 Then
MsgBox("pinjaman maksimal 2X lipat saldo")
TxtPinjaman.Clear()
Else
TxtBunga.Focus()
End If
End If
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub TxtBunga_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtBunga.KeyPress
If e.KeyChar = Chr(13) Then TxtCicilan.Focus()
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub TxtCicilan_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TxtCicilan.KeyPress
If e.KeyChar = Chr(13) Then
Dim hitung As Decimal = Microsoft.VisualBasic.Pmt(Val(TxtBunga.Text) / 100 / 12, Val(TxtCicilan.Text), Val(TxtPinjaman.Text)) * -1
LblAngsuran.Text = Round(hitung, 2)
BTNSimpan.Focus()
End If
If Not ((e.KeyChar >= "0" And e.KeyChar <= "9") Or e.KeyChar = vbBack) Then e.Handled() = True
End Sub
Private Sub LblTanggal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LblTanggal.Click
End Sub
Private Sub TxtCicilan_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TxtCicilan.TextChanged
End Sub
Private Sub Label12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label12.Click
System.Diagnostics.Process.Start("#")
End Sub
End Class
No comments:
Post a Comment