Aplikasi Penyewaan Alat Resepsi

(Pesta Pernikahan)

 

 

 

 

 

 

Module :

 

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 cryRpt As New ReportDocument

    Public crtableLogoninfos As New TableLogOnInfos

    Public crtableLogoninfo As New TableLogOnInfo

    Public crConnectionInfo As New ConnectionInfo

    Public CrTables As Tables

 

    Public Sub SetingLaporan()

        With crConnectionInfo

            .ServerName = (Application.StartupPath.ToString & "\dbwedding.mdb")

            .DatabaseName = (Application.StartupPath.ToString & "\dbwedding.mdb")

            .UserID = ""

            .Password = ""

        End With

 

        CrTables = cryRpt.Database.Tables

        For Each CrTable In CrTables

            crtableLogoninfo = CrTable.LogOnInfo

            crtableLogoninfo.ConnectionInfo = crConnectionInfo

            CrTable.ApplyLogOnInfo(crtableLogoninfo)

        Next

    End Sub

 

    Public Sub Koneksi()

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

        Conn.Open()

 

        For Each frm As Form In My.Application.OpenForms

            If frm.Name = "MasterMenu" Then

                frm.Text = "Menu Utama Aplikasi Absensi dan Penggajian - Uus Rusmawan"

            Else

                If Microsoft.VisualBasic.Right(frm.Text, 18) = "- Konsultasivb.com" Then

                    frm.Text = ""

                    frm.Text = frm.Name + " - Uus Rusmawan"

                End If

            End If

        Next

    End Sub

End Module

 

 

Imports System.Data.OleDb

 

Public Class Login

 

    Dim Hitung As Integer = 0

 

    Private Sub OK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK.Click

        Call Koneksi()

        CMD = New OleDbCommand("select * from tbluser where nama_user='" & Tnama.Text & "' and pwd_user='" & Tpassword.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            MsgBox("Login gagal")

            Hitung = Hitung + 1

            If Hitung > 2 Then

                End

            End If

            Exit Sub

        Else

            If Tpassword.Text <> DR.Item("pwd_user") Then

                MsgBox("password salah")

                Tpassword.Focus()

                Exit Sub

            End If

            Me.Visible = False

            MenuUtama.Show()

 

            MenuUtama.Panelkode.Text = DR.Item("KODE_user")

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

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

 

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

                MenuUtama.Button1.Visible = False

            End If

        End If

    End Sub

 

    Private Sub Cancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel.Click

        Me.Close()

    End Sub

 

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

        Me.CenterToScreen()

    End Sub

End Class

 

 

 

 

Imports System.Data.OleDb

 

Public Class User

 

    Sub Kosongkan()

        TextBox1.Clear()

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox5.Clear()

        TextBox1.Focus()

    End Sub

 

    Sub DataBaru()

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox5.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        On Error Resume Next

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

        ComboBox1.Text = DR.Item(2)

        TextBox3.Text = DR.Item(3)

        TextBox2.Focus()

    End Sub

 

    Sub TampilStatus_user()

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

        DR = CMD.ExecuteReader

        ComboBox1.Items.Clear()

        Do While DR.Read

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

        Loop

    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 CariKode()

        CMD = New OleDbCommand("select * from tblUser where kode_user='" & TextBox1.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()

        Call TampilStatus_user()

        Call TampilGrid()

    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

            Call CariKode()

            If DR.HasRows Then

                Call Ketemu()

            Else

                Call DataBaru()

            End If

        End If

    End Sub

 

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

        If TextBox1.Text = "" Or TextBox2.Text = "" Or ComboBox1.Text = "" Or TextBox3.Text = "" Then

            MsgBox("data belum lengkap")

            Exit Sub

        Else

            Try

                Call CariKode()

                If Not DR.HasRows Then

                    Dim simpan As String = "insert into tblUser values('" & TextBox1.Text & "','" & TextBox2.Text & "','" & ComboBox1.Text & "','" & TextBox3.Text & "')"

                    CMD = New OleDbCommand(simpan, Conn)

                    CMD.ExecuteNonQuery()

                Else

                    Dim edit As String = "update tblUser set nama_User='" & TextBox2.Text & "',Status_user='" & ComboBox1.Text & "',PWD_user='" & TextBox3.Text & "' where kode_user='" & TextBox1.Text & "'"

                    CMD = New OleDbCommand(edit, Conn)

                    CMD.ExecuteNonQuery()

                End If

                Call Kosongkan()

                Call TampilGrid()

                Call TampilStatus_user()

            Catch ex As Exception

                MsgBox(ex.Message)

            End Try

        End If

    End Sub

 

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

        If TextBox1.Text = "" Then

            MsgBox("Kode harus diisi")

            TextBox1.Focus()

            Exit Sub

        End If

 

        Call CariKode()

        If Not DR.HasRows Then

            MsgBox("Kode User tidak terdaftar")

            TextBox1.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 kode_user='" & TextBox1.Text & "'"

            CMD = New OleDbCommand(hapus, Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

            Call TampilGrid()

            Call TampilStatus_user()

        Else

            Call Kosongkan()

        End If

    End Sub

 

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

        Call Kosongkan()

    End Sub

 

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

        Me.Close()

    End Sub

 

    Private Sub TextBox5_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox5.TextChanged

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

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

        On Error Resume Next

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

        Call CariKode()

        If DR.HasRows Then

            Call Ketemu()

        End If

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class Customer

 

    Sub Kosongkan()

        TXTKodeCustomer.Clear()

        TXTNamaCustomer.Clear()

        TXTAlamat.Clear()

        TXTTelepon.Clear()

        TextBox6.Clear()

        TXTKodeCustomer.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        TXTNamaCustomer.Clear()

        TXTAlamat.Clear()

        TXTTelepon.Clear()

        TextBox6.Clear()

        TXTNamaCustomer.Focus()

    End Sub

 

    Sub Ketemu()

        TXTNamaCustomer.Text = DR.Item("nama_customer")

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

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

        TXTNamaCustomer.Focus()

    End Sub

 

    Sub TampilGrid()

        DA = New OleDbDataAdapter("select * from tblcustomer", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub customer_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 Button3.Click

        Call Kosongkan()

    End Sub

 

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

        Me.Close()

    End Sub

 

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

        CMD = New OleDbCommand("select * from tblcustomer where kode_customer='" & TXTKodeCustomer.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                Dim simpan As String = "insert into tblcustomer values ('" & TXTKodeCustomer.Text & "','" & TXTNamaCustomer.Text & "','" & TXTAlamat.Text & "','" & TXTTelepon.Text & "')"

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

            Else

                Dim edit As String = "update tblcustomer set nama_customer='" & TXTNamaCustomer.Text & "',alamat='" & TXTAlamat.Text & "',telepon='" & TXTTelepon.Text & "' where kode_customer='" & TXTKodeCustomer.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

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

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

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

        TXTTelepon.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 Button2.Click

        If TXTKodeCustomer.Text = "" Then

            MsgBox("Kode customer harus diisi")

            TXTKodeCustomer.Focus()

            Exit Sub

        End If

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

            Dim hapus As String = "delete * from tblcustomer where kode_customer='" & TXTKodeCustomer.Text & "'"

            CMD = New OleDbCommand(hapus, Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    End Sub

 

    Private Sub TextBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles TXTKodeCustomer.LostFocus

        CMD = New OleDbCommand("select * from tblcustomer where kode_customer='" & TXTKodeCustomer.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            Call DataBaru()

        Else

            Call Ketemu()

        End If

    End Sub

 

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

        DA = New OleDbDataAdapter("select * from tblcustomer where nama_customer like '%" & TextBox6.Text & "%'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class Paket

 

    Sub Kosongkan()

        tkode.Clear()

        tnama.Clear()

        TLokasi.Text = ""

        tharga.Text = 0

        tcaridata.Clear()

        tstok.Clear()

        tkode.Focus()

    End Sub

 

    Sub DataBaru()

        tnama.Clear()

        TLokasi.Text = ""

        tharga.Text = 0

        tcaridata.Clear()

        tstok.Clear()

        tnama.Focus()

    End Sub

 

    Sub Tampilgrid()

        DA = New OleDbDataAdapter("select * from tblpaket", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call Tampilgrid()

    End Sub

 

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

        tkode.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            CMD = New OleDbCommand("select * from tblpaket where kode_paket='" & tkode.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                tnama.Text = DR.Item("Nama_paket")

                TLokasi.Text = DR(2)

                tharga.Text = DR(3)

                Filepdf.src = TLokasi.Text

                tstok.Text = DR(4)

                tnama.Focus()

            Else

                Call DataBaru()

            End If

        End If

    End Sub

 

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

        tnama.MaxLength = 30

        If e.KeyChar = Chr(13) Then

            Button1.Focus()

        End If

    End Sub

 

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

        'TLokasi.Text = TLokasi.Text.Replace("\", "\\")

        If tkode.Text = "" Or tnama.Text = "" Or tharga.Text = 0 Or TLokasi.Text = "" Or tstok.Text = "" Then

            MsgBox("data belum lengkap")

            Exit Sub

        Else

            CMD = New OleDbCommand("select * from tblpaket where kode_paket='" & tkode.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If Not DR.HasRows Then

 

                Dim simpan As String = "insert into tblpaket values('" & UCase(tkode.Text) & "','" & tnama.Text & "','" & TLokasi.Text & "','" & tharga.Text & "','" & tstok.Text & "')"

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

            Else

                Dim edit As String = "update tblpaket set nama_paket='" & tnama.Text & "',detail_paket='" & TLokasi.Text & "',harga_paket='" & tharga.Text & "', stok='" & tstok.Text & "' where kode_paket='" & tkode.Text & "'"

                CMD = New OleDbCommand(edit, Conn)

                CMD.ExecuteNonQuery()

            End If

            Call Kosongkan()

            Call Tampilgrid()

        End If

    End Sub

 

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

        If tkode.Text = "" Then

            MsgBox("kode user harus diisi dulu")

            tkode.Focus()

            Exit Sub

        Else

            If MessageBox.Show("hapus data ini...?", "", MessageBoxButtons.YesNo) = Windows.Forms.DialogResult.Yes Then

                Dim hapus As String = "delete * from tblpaket where kode_paket='" & tkode.Text & "'"

                CMD = New OleDbCommand(hapus, Conn)

                CMD.ExecuteNonQuery()

 

                Call Kosongkan()

                Call Tampilgrid()

            Else

                Call Kosongkan()

            End If

        End If

    End Sub

 

 

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

        Call Kosongkan()

    End Sub

 

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

        Me.Close()

    End Sub

 

    Private Sub TextBox4_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tcaridata.TextChanged

        CMD = New OleDbCommand("select * from tblpaket where nama_paket like '%" & tcaridata.Text & "%'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            DA = New OleDbDataAdapter("select * from tblpaket where nama_paket like '%" & tcaridata.Text & "%'", Conn)

            DS = New DataSet

            DA.Fill(DS)

            DGV.DataSource = DS.Tables(0)

        Else

            MsgBox("Nama paket tidak ditemukan")

        End If

    End Sub

 

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

        On Error Resume Next

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

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

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

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

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

        Filepdf.src = TLokasi.Text

 

    End Sub

 

 

    Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

 

        On Error Resume Next

        OpenFileDialog1.InitialDirectory = Application.StartupPath

        OpenFileDialog1.ShowDialog()

        OpenFileDialog1.Filter = "(*.pdf)|*.pdf|"

        TLokasi.Text = (OpenFileDialog1.FileName)

        Filepdf.src = (OpenFileDialog1.FileName)

        'PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

    End Sub

End Class

 

 

Imports System.Data.OleDb

 

Public Class Transaksi

 

    Sub Notis()

        CMD = New OleDbCommand("select kode_transaksi from tbltransaksi order by kode_transaksi desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            Tkode.Text = "00001"

        Else

            Tkode.Text = Format(Microsoft.VisualBasic.Right(DR.Item("kode_transaksi"), 5) + 1, "00000")

        End If

        Tkode.Enabled = False

    End Sub

 

    Sub tampilcustomer()

        CMD = New OleDbCommand("select kode_customer from tblcustomer", Conn)

        DR = CMD.ExecuteReader

        cmbcustomer.Items.Clear()

        Do While DR.Read

            cmbcustomer.Items.Add(DR.Item("kode_customer"))

        Loop

    End Sub

 

    Sub TampilPaket()

        CMD = New OleDbCommand("select kode_paket from tblpaket where  stok>0", Conn)

        DR = CMD.ExecuteReader

        cmbpaket.Items.Clear()

        Do While DR.Read

            cmbpaket.Items.Add(DR.Item("kode_paket"))

        Loop

    End Sub

 

    Sub Kosongkan()

        cmbcustomer.Text = "-"

        tcustomer.Text = "-"

        cmbpaket.Text = "-"

        tpaket.Text = "-"

        ttanggalkembali.Text = "-"

        thargapaket.Text = 0

        tuangmuka.Text = 0

        tlamapinjam.Text = 1

        tsisapembayaran.Text = 0

        tpelunasan.Text = 0

        Lstatuspembayaran.Text = "BELUM LUNAS"

        Call Notis()

        Call tampilcustomer()

        Call TampilPaket()

    End Sub

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call Kosongkan()

        ttanggalkembali.Text = DateAdd(DateInterval.Day, Val(tlamapinjam.Text), (Ttanggal.Value))

        ttanggalkembali.Text = Format(DateValue(ttanggalkembali.Text), "dd-MMMM-yyyy")

    End Sub

 

    Private Sub cmbcustomer_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbcustomer.SelectedIndexChanged

        CMD = New OleDbCommand("select nama_customer from tblcustomer where kode_customer='" & cmbcustomer.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            tcustomer.Text = DR(0)

        End If

    End Sub

 

    Private Sub cmbpaket_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbpaket.SelectedIndexChanged

        CMD = New OleDbCommand("select * from tblpaket where kode_paket='" & cmbpaket.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            tpaket.Text = DR(1)

            Filepdf.src = DR(2)

            thargapaket.Text = DR(3)

        End If

 

        ttanggalkembali.Text = DateAdd(DateInterval.Day, Val(tlamapinjam.Text), (Ttanggal.Value))

        ttanggalkembali.Text = Format(DateValue(ttanggalkembali.Text), "dd-MMMM-yyyy")

        tsisapembayaran.Text = thargapaket.Text

 

        If Val(tuangmuka.Text) >= Val(thargapaket.Text) Then

            tsisapembayaran.Text = 0

            tpelunasan.Text = 0

            Lstatuspembayaran.Text = "LUNAS"

        Else

            Lstatuspembayaran.Text = "BELUM LUNAS"

            tsisapembayaran.Text = Val(thargapaket.Text) - Val(tuangmuka.Text)

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            ttanggalkembali.Text = DateAdd(DateInterval.Day, Val(tlamapinjam.Text), (Ttanggal.Value))

            ttanggalkembali.Text = Format(DateValue(ttanggalkembali.Text), "dd-MMMM-yyyy")

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            If Val(tuangmuka.Text) >= Val(thargapaket.Text) Then

                tsisapembayaran.Text = 0

                tpelunasan.Text = 0

                Lstatuspembayaran.Text = "LUNAS"

            Else

                Lstatuspembayaran.Text = "BELUM LUNAS"

                tsisapembayaran.Text = Val(thargapaket.Text) - Val(tuangmuka.Text)

            End If

        End If

    End Sub

 

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

        If cmbcustomer.Text = "" Or cmbpaket.Text = "" Or ttanggalkembali.Text = "-" Then

            MsgBox("data belum lengkap")

            Exit Sub

        End If

 

        Dim simpan As String = "insert into tbltransaksi values ('" & Tkode.Text & "','" & Ttanggal.Text & "','" & cmbcustomer.Text & "','" & cmbpaket.Text & "','" & tlamapinjam.Text & "','" & ttanggalkembali.Text & "','" & thargapaket.Text & "','" & tuangmuka.Text & "','" & tsisapembayaran.Text & "','" & tpelunasan.Text & "','" & MenuUtama.Panelkode.Text & "','DIPINJAM','" & Lstatuspembayaran.Text & "')"

        CMD = New OleDbCommand(simpan, Conn)

        CMD.ExecuteNonQuery()

 

        CMD = New OleDbCommand("select * from tblpaket where kode_paket='" & cmbpaket.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim editpaket As String = "update tblpaket set stok='" & DR("stok") - 1 & "' WHERE KODE_PAKET='" & cmbpaket.Text & "'"

            CMD = New OleDbCommand(editpaket, Conn)

            CMD.ExecuteNonQuery()

 

        End If

        Call Kosongkan()

    End Sub

 

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

        Call Kosongkan()

    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

 

 

Imports System.Data.OleDb

 

Public Class Pengembalian

 

    Sub Kosongkan()

        cmbkode.Text = ""

        cmbcustomer.Text = "-"

        tcustomer.Text = "-"

        cmbpaket.Text = "-"

        tpaket.Text = "-"

        ttanggalkembali.Text = "-"

        thargapaket.Text = 0

        tuangmuka.Text = 0

        tlamapinjam.Text = 0

        tsisapembayaran.Text = 0

        tpelunasan.Text = 0

 

        cmbcustomer.Enabled = False

        'Ttanggal.Enabled = False

        tcustomer.Enabled = False

        cmbpaket.Enabled = False

        tpaket.Enabled = False

        ttanggalkembali.Enabled = False

        thargapaket.Enabled = False

        tuangmuka.Enabled = False

        tlamapinjam.Enabled = False

        tsisapembayaran.Enabled = False

        Call tampilkodetransaksi()

    End Sub

 

    Sub tampilkodetransaksi()

        CMD = New OleDbCommand("select kode_transaksi from tbltransaksi where status_pembayaran='BELUM LUNAS'", Conn)

        DR = CMD.ExecuteReader

        cmbkode.Items.Clear()

        Do While DR.Read

            cmbkode.Items.Add(DR.Item("kode_transaksi"))

        Loop

    End Sub

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call Kosongkan()

 

    End Sub

 

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

        If cmbkode.Text = "" Or Val(tpelunasan.Text) < Val(tsisapembayaran.Text) Then

            MsgBox("data belum lengkap")

            Exit Sub

        End If

 

        Dim edittransaksi As String = "update tbltransaksi set pelunasan='" & tpelunasan.Text & "', SISA=0,status_peminjaman='SELESAI',STATUS_PEMBAYARAN='LUNAS' WHERE KODE_transaksi='" & cmbkode.Text & "'"

        CMD = New OleDbCommand(edittransaksi, Conn)

        CMD.ExecuteNonQuery()

 

        CMD = New OleDbCommand("select * from tblpaket where kode_paket='" & cmbpaket.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim editpaket As String = "update tblpaket set stok='" & DR("stok") + 1 & "' WHERE KODE_PAKET='" & cmbpaket.Text & "'"

            CMD = New OleDbCommand(editpaket, Conn)

            CMD.ExecuteNonQuery()

        End If

        Call Kosongkan()

    End Sub

 

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

        Call Kosongkan()

    End Sub

 

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

        Me.Close()

    End Sub

 

    Private Sub cmbkode_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmbkode.SelectedIndexChanged

        CMD = New OleDbCommand("select * from tbltransaksi where kode_transaksi='" & cmbkode.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Ttanggal.Text = DR("tanggal_transaksi")

            cmbcustomer.Text = DR("kode_customer")

            cmbpaket.Text = DR("kode_paket")

            tlamapinjam.Text = DR("lama_pinjam")

            ttanggalkembali.Text = DR("tanggal_kembali")

            tuangmuka.Text = DR("uang_muka")

            tsisapembayaran.Text = DR("sisa")

            tpelunasan.Text = tsisapembayaran.Text '("pelunasan")

            tpelunasan.Enabled = True

            tpelunasan.Focus()

        End If

 

        CMD = New OleDbCommand("select nama_customer from tblcustomer where kode_customer='" & cmbcustomer.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            tcustomer.Text = DR(0)

        End If

 

        CMD = New OleDbCommand("select * from tblpaket where kode_paket='" & cmbpaket.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            tpaket.Text = DR(1)

            Filepdf.src = DR(2)

            thargapaket.Text = DR(3)

        End If

 

        If Val(tpelunasan.Text) >= Val(tsisapembayaran.Text) Then

            Lstatuspembayaran.Text = "LUNAS"

            'MsgBox("Uang Kembali " & Val(tpelunasan.Text) - Val(tsisapembayaran.Text) & "")

            Button1.Focus()

        Else

            MsgBox("Pembayaran kurang")

            tpelunasan.Focus()

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            If Val(tpelunasan.Text) >= Val(tsisapembayaran.Text) Then

                Lstatuspembayaran.Text = "LUNAS"

                MsgBox("Uang Kembali " & Val(tpelunasan.Text) - Val(tsisapembayaran.Text) & "")

                Button1.Focus()

            Else

                MsgBox("Pembayaran kurang")

                tpelunasan.Focus()

            End If

        End If

    End Sub

End Class

 

 

 

 

Imports System.Data.OleDb

 

Public Class Laporan

 

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

 

        Call Koneksi()

        CMD = New OleDbCommand("select distinct tanggal_transaksi from tbltransaksi", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox1.Items.Add(DR(0))

        Loop

 

        CMD = New OleDbCommand("select distinct tanggal_kembali from tbltransaksi", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox2.Items.Add(DR(0))

        Loop

    End Sub

 

    Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

        CRV.SelectionFormula = "{TBLTRANSAKSI.TANGGAL_TRANSaksi}= date ('" & ListBox1.Text & "')"

        cryRpt.Load("peminjaman.rpt")

        Call SetingLaporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

 

    End Sub

 

    Private Sub ListBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox2.SelectedIndexChanged

        CRV.SelectionFormula = "{TBLTRANSAKSI.TANGGAL_kembali}= date ('" & ListBox2.Text & "')"

        cryRpt.Load("pengembalian.rpt")

        Call SetingLaporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

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

        CRV.SelectionFormula = "month({tbltransaksi.tanggal_transaksi})=(" & Month(DTP1.Text) & ") and  year({tbltransaksi.tanggal_transaksi})=(" & Year(DTP1.Text) & ")"

        cryRpt.Load("peminjaman.rpt")

        Call SetingLaporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

 

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

        CRV.SelectionFormula = "month({tbltransaksi.tanggal_KEMBALI})=(" & Month(DTP2.Text) & ") and  year({tbltransaksi.tanggal_KEMBALI})=(" & Year(DTP2.Text) & ")"

        cryRpt.Load("pengembalian.rpt")

        Call SetingLaporan()

        CRV.ReportSource = cryRpt

        CRV.RefreshReport()

    End Sub

End Class