Aplikasi Penginapan (Hotel) Menggunakan VB.Net

 

 

 

Modeule 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 & "\penginapan.mdb"

                .UserID = ""

                .Password = ""

                .DatabaseName = ""

            End With

            BacaTabel.ApplyLogOnInfo(TabelLogon)

        Next BacaTabel

    End Sub

 

    Public Sub Koneksi()

        Try

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

            Conn.Open()

        Catch ex As Exception

            MsgBox(ex.Message)

            End

        End Try

    End Sub

End Module

 

 

 

 

Imports System.Data.OleDb

 

Public Class MasterLogin

 

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

        If e.KeyChar = Chr(13) Then

            TPassword.Focus()

        End If

    End Sub

 

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

        If e.KeyChar = Chr(13) Then

            OK.Focus()

        End If

    End Sub

 

    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='" & TUser.Text & "' and pwd='" & Tpassword.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            MsgBox("Login gagal")

            TUser.Focus()

            Exit Sub

        Else

            Me.Visible = False

            MenuUtama.Show()

 

            MenuUtama.Panel1.Text = DR.Item("kode_user")

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

            MenuUtama.Panel3.Text = DR.Item("Status_user")

 

            If MenuUtama.Panel1.Text = "ADMIN" Then

                MenuUtama.UserToolStripMenuItem.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()

        Call Koneksi()

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class MenuUtama

 

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

        MasterUser.Show()

    End Sub

 

    Private Sub FasilitasToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles FasilitasToolStripMenuItem.Click

        MasterFasilitas.Show()

    End Sub

 

    Private Sub LayananToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LayananToolStripMenuItem.Click

        MasterLayanan.Show()

    End Sub

 

    Private Sub KamarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KamarToolStripMenuItem.Click

        MasterKamar.Show()

    End Sub

 

    Private Sub BookingToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BookingToolStripMenuItem.Click

        TRBooking.Show()

    End Sub

 

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

        End

    End Sub

 

    Private Sub LogOutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LogOutToolStripMenuItem.Click

        Me.Close()

        MasterLogin.Show()

        MasterLogin.TUser.Clear()

        MasterLogin.Tpassword.Clear()

        MasterLogin.TUser.Focus()

    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

            End

        End If

    End Sub

 

    Private Sub UjiSqlToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UjiSqlToolStripMenuItem.Click

        ujisql.Show()

    End Sub

 

    Private Sub LayananToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles LayananToolStripMenuItem1.Click

        TRLayanan.Show()

    End Sub

 

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

        On Error Resume Next

        Call Koneksi()

        PictureBox1.Load("8.jpg")

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

    End Sub

 

    Private Sub InfoKamarToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InfoKamarToolStripMenuItem.Click

        MasterInfoKamar.Show()

    End Sub

 

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

        TRPembayaran.Show()

    End Sub

 

    Private Sub BackGroundToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BackGroundToolStripMenuItem.Click

        On Error Resume Next

        OpenFileDialog1.InitialDirectory = Application.StartupPath

        OpenFileDialog1.ShowDialog()

      

        PictureBox1.Load(OpenFileDialog1.FileName)

        PictureBox1.SizeMode = PictureBoxSizeMode.StretchImage

    End Sub

 

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

        MasterUser.Show()

    End Sub

 

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

        MasterFasilitas.Show()

    End Sub

 

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

        MasterLayanan.Show()

    End Sub

 

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

        MasterKamar.Show()

    End Sub

 

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

        MasterInfoKamar.Show()

    End Sub

 

    Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click

        TRBooking.Show()

    End Sub

 

    Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click

        TRLayanan.Show()

    End Sub

 

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

        TRPembayaran.Show()

    End Sub

 

    Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click

        LaporanMaster.Show()

    End Sub

 

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

        LaporanTransaksi.Show()

    End Sub

 

    Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click

        Me.Close()

        MasterLogin.Show()

        MasterLogin.TUser.Clear()

        MasterLogin.Tpassword.Clear()

        MasterLogin.TUser.Focus()

    End Sub

 

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

        End

    End Sub

End Class

 

 

Imports System.Data.OleDb

 

Public Class MasterUser

 

    Sub Notis()

        CMD = New OleDbCommand("select kode_User from tblUser order by kode_User desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            TextBox1.Text = "USR01"

        Else

            TextBox1.Text = "USR" + Format(Microsoft.VisualBasic.Right(DR("kode_User"), 2) + 1, "00")

        End If

    End Sub

 

    Sub Kosongkan()

        Call Notis()

        TextBox1.Enabled = False

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

        Call Tampilstatususer()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox1.Enabled = False

        TextBox2.Text = DR("nama_user")

        TextBox3.Text = DR("pwd")

        ComboBox1.Text = DR("status_user")

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

        'Call Koneksi()

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub Tampilstatususer()

        'Call Koneksi()

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

        DR = CMD.ExecuteReader

        ComboBox1.Items.Clear()

        Do While DR.Read

            ComboBox1.Items.Add(DR("status_user"))

        Loop

    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 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 ComboBox1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.LostFocus

        ComboBox1.Text = UCase(ComboBox1.Text)

    End Sub

 

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

        'Call Koneksi()

        CMD = New OleDbCommand("select * from tblUser where kode_user='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                'Call Koneksi()

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

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

            Else

                'Call Koneksi()

                Dim edit As String = "update tblUser set nama_user='" & TextBox2.Text & "',status_user='" & ComboBox1.Text & "',pwd='" & TextBox3.Text & "' where kode_user='" & TextBox1.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

        TextBox1.Enabled = False

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

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

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

        ComboBox1.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 TextBox1.Text = "" Then

            MsgBox("Kode User harus diisi")

            TextBox1.Focus()

            Exit Sub

        End If

 

        CMD = New OleDbCommand("select distinct kode_user from tbltransaksi where kode_user='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            MsgBox("data tidak dapat dihapus karena sudah ada dalam transaksi")

            Exit Sub

        End If

 

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

            'Call Koneksi()

            Dim hapus As String = "delete  from tblUser where kode_user='" & TextBox1.Text & "'"

            CMD = New OleDbCommand(hapus, Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    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 tblUser where kode_user='" & TextBox1.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If Not DR.HasRows Then

                Call DataBaru()

            Else

                Call Ketemu()

            End If

        End If

    End Sub

 

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

        'TextBox1.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            TextBox3.Focus()

        End If

    End Sub

 

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

        'TextBox1.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            ComboBox1.Focus()

        End If

    End Sub

 

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

        'TextBox1.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            Button1.Focus()

        End If

    End Sub

 

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

        'Call Koneksi()

    End Sub

 

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

        'Call Koneksi()

        DA = New OleDbDataAdapter("select * from tblUser where nama_user 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 MasterFasilitas

 

    Sub Notis()

        CMD = New OleDbCommand("select kode_fasilitas from tblfasilitas order by kode_fasilitas desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            TextBox1.Text = "F01"

        Else

            TextBox1.Text = "F" + Format(Microsoft.VisualBasic.Right(DR("kode_fasilitas"), 2) + 1, "00")

        End If

    End Sub

 

    Sub Kosongkan()

        Call Notis()

        TextBox1.Enabled = False

        TextBox2.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        TextBox2.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox1.Enabled = False

        TextBox2.Text = DR("Fasilitas")

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

        'Call Koneksi()

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub Fasilitas_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

        'Call Koneksi()

        CMD = New OleDbCommand("select * from tblFasilitas where kode_Fasilitas='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                'Call Koneksi()

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

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

            Else

                'Call Koneksi()

                Dim edit As String = "update tblFasilitas set Fasilitas='" & TextBox2.Text & "' where kode_Fasilitas='" & TextBox1.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

        TextBox1.Enabled = False

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

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

    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 Fasilitas harus diisi")

            TextBox1.Focus()

            Exit Sub

        End If

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

            'Call Koneksi()

            Dim hapus As String = "delete  from tblFasilitas where kode_Fasilitas='" & TextBox1.Text & "'"

            CMD = New OleDbCommand(hapus, Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    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 tblFasilitas where kode_Fasilitas='" & TextBox1.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If Not DR.HasRows Then

                Call DataBaru()

            Else

                Call Ketemu()

            End If

        End If

    End Sub

 

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

        'TextBox1.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            Button1.Focus()

        End If

    End Sub

 

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

        'Call Koneksi()

        DA = New OleDbDataAdapter("select * from tblFasilitas where Fasilitas 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 MasterLayanan

 

    Sub Notis()

        CMD = New OleDbCommand("select kode_layanan from tbllayanan order by kode_layanan desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            TextBox1.Text = "L01"

        Else

            TextBox1.Text = "L" + Format(Microsoft.VisualBasic.Right(DR("kode_layanan"), 2) + 1, "00")

        End If

    End Sub

 

    Sub Kosongkan()

        Call Notis()

        TextBox1.Enabled = False

        TextBox2.Clear()

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        TextBox2.Clear()

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox1.Enabled = False

        TextBox2.Text = DR("Layanan")

        TextBox3.Text = DR("Tarif_layanan")

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

        'Call Koneksi()

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.Columns(2).DefaultCellStyle.Format = "#,###"

        DGV.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.ReadOnly = True

    End Sub

 

    Private Sub Layanan_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

        'Call Koneksi()

        CMD = New OleDbCommand("select * from tblLayanan where kode_Layanan='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

                'Call Koneksi()

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

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

            Else

                'Call Koneksi()

                Dim edit As String = "update tblLayanan set Layanan='" & TextBox2.Text & "',Tarif_layanan='" & TextBox3.Text & "' where kode_Layanan='" & TextBox1.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

        TextBox1.Enabled = False

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

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

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

    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 Layanan harus diisi")

            TextBox1.Focus()

            Exit Sub

        End If

 

        CMD = New OleDbCommand("select distinct kode_layanan from tbltransaksilayanan where kode_layanan='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            MsgBox("data tidak dapat dihapus karena sudah ada dalam transaksi")

            Exit Sub

        End If

 

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

            'Call Koneksi()

            Dim hapus As String = "delete  from tblLayanan where kode_Layanan='" & TextBox1.Text & "'"

            CMD = New OleDbCommand(hapus, Conn)

            CMD.ExecuteNonQuery()

            Call Kosongkan()

        Else

            Call Kosongkan()

        End If

    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 tblLayanan where kode_Layanan='" & TextBox1.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If Not DR.HasRows Then

                Call DataBaru()

            Else

                Call Ketemu()

            End If

        End If

    End Sub

 

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

        'TextBox1.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            TextBox3.Focus()

        End If

    End Sub

 

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

        'TextBox1.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            Button1.Focus()

        End If

    End Sub

 

 

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

        'Call Koneksi()

        DA = New OleDbDataAdapter("select * from tblLayanan where Layanan 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 MasterKamar

 

    Sub Notis()

        CMD = New OleDbCommand("select kode_kamar from tblkamar order by kode_kamar desc", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            TextBox1.Text = "K001"

        Else

            TextBox1.Text = "K" + Format(Microsoft.VisualBasic.Right(DR("kode_kamar"), 3) + 1, "000")

        End If

    End Sub

 

    Sub Kosongkan()

        Call Notis()

        TextBox1.Enabled = False

        TextBox2.Clear()

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

        Call TampilGrid()

        Call BersihkanPilihan()

    End Sub

 

    Sub DataBaru()

        TextBox2.Clear()

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox1.Enabled = False

        TextBox2.Text = DR("Kapasitas")

        TextBox3.Text = DR("tarif_kamar")

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

        'Call Koneksi()

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.Columns(2).DefaultCellStyle.Format = "#,###"

        DGV.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        DGV.ReadOnly = True

    End Sub

 

    Sub BersihkanPilihan()

        For baris As Integer = 0 To DGV1.RowCount - 2

            DGV1.Rows(baris).Cells(2).Value = "NO"

        Next

    End Sub

 

    Sub TampilFasilitas()

        On Error Resume Next

        DGV1.Columns.Clear()

        DA = New OleDbDataAdapter("select * from tblfasilitas order by 1", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV1.DataSource = DS.Tables(0)

        DGV1.Columns(0).ReadOnly = True

        DGV1.Columns(1).ReadOnly = True

        Dim cbo As New DataGridViewComboBoxColumn

        DGV1.Columns.Add(cbo)

        cbo.HeaderText = "Pilih [Y/N]"

        cbo.Items.Add("YES")

        cbo.Items.Add("NO")

        Call BersihkanPilihan()

    End Sub

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call Kosongkan()

        Call TampilFasilitas()

    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

        'Call Koneksi()

 

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

            MsgBox("data belum lengkap")

            Exit Sub

        End If

 

        CMD = New OleDbCommand("select * from tblkamar where kode_kamar='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

       

        If Not DR.HasRows Then

            'Call Koneksi()

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

            CMD = New OleDbCommand(simpan, Conn)

            CMD.ExecuteNonQuery()

 

            For baris As Integer = 0 To DGV1.Rows.Count - 2

                CMD = New OleDbCommand("select * from TBLkamarfasilitas where kode_kamar='" & TextBox1.Text & "' and kode_fasilitas='" & DGV1.Rows(baris).Cells(0).Value & "'", Conn)

                DR = CMD.ExecuteReader

                DR.Read()

                If Not DR.HasRows Then

                    If DGV1.Rows(baris).Cells(2).Value = "YES" Then

                        Dim simpandetail As String = "insert into tblkamarfasilitas values ('" & TextBox1.Text & "','" & DGV1.Rows(baris).Cells(0).Value & "')"

                        CMD = New OleDbCommand(simpandetail, Conn)

                        CMD.ExecuteNonQuery()

                    End If

                End If

 

            Next

            'Call BersihkanPilihan()

            Call Kosongkan()

        Else

            'Call Koneksi()

            Dim edit As String = "update tblkamar set tarif_kamar='" & TextBox3.Text & "' where kode_kamar='" & TextBox1.Text & "'"

            CMD = New OleDbCommand(edit, Conn)

            CMD.ExecuteNonQuery()

 

            For baris As Integer = 0 To DGV1.Rows.Count - 2

                CMD = New OleDbCommand("select * from TBLkamarfasilitas where kode_kamar='" & TextBox1.Text & "' and kode_fasilitas='" & DGV1.Rows(baris).Cells(0).Value & "'", Conn)

                DR = CMD.ExecuteReader

                DR.Read()

                If Not DR.HasRows Then

                    If DGV1.Rows(baris).Cells(2).Value = "YES" Then

                        Dim simpandetail As String = "insert into tblkamarfasilitas values ('" & TextBox1.Text & "','" & DGV1.Rows(baris).Cells(0).Value & "')"

                        CMD = New OleDbCommand(simpandetail, Conn)

                        CMD.ExecuteNonQuery()

                    End If

                End If

            Next

            Call BersihkanPilihan()

            Call Kosongkan()

        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

        TextBox1.Enabled = False

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

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

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

        Call BersihkanPilihan()

        For baris As Integer = 0 To DGV1.Rows.Count - 2

            CMD = New OleDbCommand("select * from tblkamarfasilitas where kode_kamar='" & TextBox1.Text & "' and kode_fasilitas='" & DGV1.Rows(baris).Cells(0).Value & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                DGV1.Rows(baris).Cells(2).Value = "YES"

            End If

        Next

    End Sub

 

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

        TextBox1.MaxLength = 4

        If e.KeyChar = Chr(13) Then

            CMD = New OleDbCommand("select * from tblkamar where kode_kamar='" & TextBox1.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If Not DR.HasRows Then

                Call DataBaru()

            Else

                Call Ketemu()

            End If

        End If

    End Sub

 

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

        'TextBox1.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            TextBox3.Focus()

        End If

    End Sub

 

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

        'TextBox1.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            Button1.Focus()

        End If

    End Sub

 

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

        'Call Koneksi()

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

    End Sub

 

 

    Private Sub DGV1_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV1.CellEndEdit

        If DGV1.Rows(e.RowIndex).Cells(2).Value = "NO" Then

            Dim hapusdetail As String = "delete * from tblkamarfasilitas where kode_kamar='" & TextBox1.Text & "' and kode_fasilitas='" & DGV1.Rows(e.RowIndex).Cells(0).Value & "'"

            CMD = New OleDbCommand(hapusdetail, Conn)

            CMD.ExecuteNonQuery()

        End If

    End Sub

End Class

 

 

Imports System.Data.OleDb

 

Public Class MasterInfoKamar

 

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

        Me.CenterToScreen()

        Call Koneksi()

        DA = New OleDbDataAdapter("select * from tblkamar where status_kamar='KOSONG'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV1.DataSource = DS.Tables(0)

        DGV1.ReadOnly = True

    End Sub

 

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

 

        DA = New OleDbDataAdapter("select fasilitas from tblfasilitas,tblkamar,tblkamarfasilitas where tblkamar.kode_kamar='" & DGV1.Rows(e.RowIndex).Cells(0).Value & "' and tblkamar.kode_kamar=tblkamarfasilitas.kode_kamar and tblkamarfasilitas.kode_fasilitas=tblfasilitas.kode_fasilitas", Conn)

 

        DS = New DataSet

        DA.Fill(DS)

        DGV2.DataSource = DS.Tables(0)

        DGV2.ReadOnly = True

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class TRBooking

 

    Sub Notistrasaksi()

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

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            LNomor.Text = "00001"

        Else

            LNomor.Text = Format(Microsoft.VisualBasic.Right(DR("nomor_transaksi"), 5) + 1, "00000")

        End If

    End Sub

 

    Sub Kosongkan()

        Call Notistrasaksi()

        Call Notistamu()

        Tnamatamu.Text = "-"

        TNoKTP.Text = "-"

        TLamaInap.Text = 1

        TglKeluar.Text = DateAdd(DateInterval.Day, Val(TLamaInap.Text), DateValue(TGLMasuk.Value))

        LTotalBiaya.Text = 0

        TJumlahDP.Text = 0

        LsisaPembayaran.Text = 0

        LTotalkapasitas.Text = 0

        Call TampilKamarKosong()

        ListBox1.Items.Clear()

        DGV1.Columns.Clear()

    End Sub

 

    Sub Notistamu()

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

        DR = CMD.ExecuteReader

        DR.Read()

        If Not DR.HasRows Then

            LkodeTamu.Text = "T0001"

        Else

            LkodeTamu.Text = "T" + Format(Microsoft.VisualBasic.Right(DR("kode_tamu"), 4) + 1, "0000")

        End If

    End Sub

 

    Sub BersihkanPilihan()

        For baris As Integer = 0 To DGV.RowCount - 2

            DGV.Rows(baris).Cells(4).Value = "NO"

        Next

    End Sub

 

    Sub TampilKamarKosong()

        'On Error Resume Next

        DGV.Columns.Clear()

        DA = New OleDbDataAdapter("select * from tblkamar where status_kamar='KOSONG'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.Columns(2).DefaultCellStyle.Format = "#,###"

        DGV.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

        '=================================

        Dim cbo As New DataGridViewComboBoxColumn

        DGV.Columns.Add(cbo)

        cbo.HeaderText = "Pilih [B/N]"

        cbo.Items.Add("BOOKING")

        cbo.Items.Add("NO")

        Call BersihkanPilihan()

    End Sub

 

    Sub HitungBiaya()

        Dim hitungbiaya As Double

        For baris As Integer = 0 To DGV.RowCount - 2

            If DGV.Rows(baris).Cells(4).Value = "BOOKING" Then

                hitungbiaya = (hitungbiaya + DGV.Rows(DGV.CurrentCell.RowIndex).Cells(2).Value)

            End If

        Next

        LTotalBiaya.Text = hitungbiaya * Val(TLamaInap.Text)

        LTotalBiaya.Text = FormatNumber(LTotalBiaya.Text, 0)

        LsisaPembayaran.Text = hitungbiaya * Val(TLamaInap.Text)

        LsisaPembayaran.Text = FormatNumber(LsisaPembayaran.Text, 0)

    End Sub

 

    Sub Hitungkapasitas()

        Dim hitungtamu As Double

        For baris As Integer = 0 To DGV.RowCount - 2

            If DGV.Rows(baris).Cells(4).Value = "BOOKING" Then

                hitungtamu = hitungtamu + DGV.Rows(DGV.CurrentCell.RowIndex).Cells(1).Value

            End If

        Next

        LTotalkapasitas.Text = hitungtamu

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

        Call Notistrasaksi()

        Call Notistamu()

        Call TampilKamarKosong()

    End Sub

 

    Private Sub DGV_CellEndEdit(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles DGV.CellEndEdit

        If e.ColumnIndex = 4 Then

            Call HitungBiaya()

            Call Hitungkapasitas()

            If LsisaPembayaran.Text > 0 Then

                Lstatuspembayaran.Text = "BELUM LUNAS"

            End If

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            TglKeluar.Text = DateAdd(DateInterval.Day, Val(TLamaInap.Text), DateValue(TGLMasuk.Value))

            Call HitungBiaya()

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            TJumlahDP.Text = FormatNumber(TJumlahDP.Text, 0)

            If Val(Microsoft.VisualBasic.Str(TJumlahDP.Text)) >= Val(Microsoft.VisualBasic.Str(LTotalBiaya.Text)) Then

                LsisaPembayaran.Text = 0

            Else

                LsisaPembayaran.Text = Val(Microsoft.VisualBasic.Str(LTotalBiaya.Text)) - Val(Microsoft.VisualBasic.Str(TJumlahDP.Text))

                LsisaPembayaran.Text = FormatNumber(LsisaPembayaran.Text, 0)

            End If

 

            If Val(LsisaPembayaran.Text) > 0 Then

                Lstatuspembayaran.Text = "BELUM LUNAS"

            Else

                Lstatuspembayaran.Text = "LUNAS"

            End If

            Button1.Focus()

        End If

    End Sub

 

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

 

        Dim simpan As String = "insert into tbltransaksi values ('" & LNomor.Text & "','" & TGLBooking.Text & "','" & LkodeTamu.Text & "','" & Tnamatamu.Text & "','" & TNoKTP.Text & "','" & TGLMasuk.Text & "','" & TLamaInap.Text & "','" & TglKeluar.Text & "','" & LTotalBiaya.Text & "','" & TJumlahDP.Text & "','" & LsisaPembayaran.Text & "',0,0,0,'" & Lstatuspembayaran.Text & "','ISI','USR01')"

        CMD = New OleDbCommand(simpan, Conn)

        CMD.ExecuteNonQuery()

 

        For baris As Integer = 0 To DGV.RowCount - 2

 

            If DGV.Rows(baris).Cells(4).Value = "BOOKING" Then

                Dim simpankamar As String = "insert into tbltransaksikamar values ('" & LNomor.Text & "','" & DGV.Rows(baris).Cells(0).Value & "')"

                CMD = New OleDbCommand(simpankamar, Conn)

                CMD.ExecuteNonQuery()

 

                CMD = New OleDbCommand("select * from tblkamar where kode_kamar='" & DGV.Rows(baris).Cells(0).Value & "'", Conn)

                DR = CMD.ExecuteReader

                DR.Read()

                If DR.HasRows Then

                    Dim editkamar As String = "update tblkamar set status_kamar='ISI' where kode_kamar='" & DGV.Rows(baris).Cells(0).Value & "'"

                    CMD = New OleDbCommand(editkamar, Conn)

                    CMD.ExecuteNonQuery()

                End If

            End If

        Next

 

        Call Kosongkan()

 

    End Sub

 

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

        CMD = New OleDbCommand("select fasilitas from tblfasilitas,tblkamar,tblkamarfasilitas where tblkamar.kode_kamar='" & DGV.Rows(e.RowIndex).Cells(0).Value & "' and tblkamar.kode_kamar=tblkamarfasilitas.kode_kamar and tblkamarfasilitas.kode_fasilitas=tblfasilitas.kode_fasilitas", Conn)

        DR = CMD.ExecuteReader

        ListBox1.Items.Clear()

        Do While DR.Read

            ListBox1.Items.Add(DR(0))

        Loop

 

        DA = New OleDbDataAdapter("select Fasilitas from tblfasilitas,tblkamar,tblkamarfasilitas where tblkamar.kode_kamar='" & DGV.Rows(e.RowIndex).Cells(0).Value & "' and tblkamar.kode_kamar=tblkamarfasilitas.kode_kamar and tblkamarfasilitas.kode_fasilitas=tblfasilitas.kode_fasilitas", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV1.DataSource = DS.Tables(0)

        DGV1.ReadOnly = True

    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 Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

        Call Kosongkan()

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

 

            DGV.Columns.Clear()

            DA = New OleDbDataAdapter("select distinct tblkamar.Kode_kamar,Kapasitas,tarif_kamar,Status_kamar from tblkamar,tblkamarfasilitas,tblfasilitas where tblkamar.status_kamar='KOSONG' and tblkamar.kode_kamar=tblkamarfasilitas.kode_kamar and tblkamarfasilitas.kode_fasilitas=tblfasilitas.kode_fasilitas and tblfasilitas.fasilitas like '%" & TcariKamar.Text & "%'", Conn)

            DS = New DataSet

            DA.Fill(DS)

            DGV.DataSource = DS.Tables(0)

            DGV.Columns(2).DefaultCellStyle.Format = "#,###"

            DGV.Columns(2).DefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleRight

            '===============================

            Dim cbo As New DataGridViewComboBoxColumn

            DGV.Columns.Add(cbo)

            cbo.HeaderText = "Pilih [B/N]"

            cbo.Items.Add("BOOKING")

            cbo.Items.Add("NO")

            Call BersihkanPilihan()

            ListBox1.Items.Clear()

            DGV1.Columns.Clear()

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            Tnamatamu.Focus()

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            TNoKTP.Focus()

        End If

    End Sub

 

 

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

        If e.KeyCode = Keys.Enter Then

            TGLMasuk.Focus()

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            TLamaInap.Focus()

        End If

    End Sub 

End Class

 

 

Imports System.Data.OleDb

 

Public Class TRLayanan

 

    Sub Kosongkan()

        ComboBox1.Text = ""

        LkodeTamu.Text = ""

        Lnamatamu.Text = ""

        Lnoktp.Text = ""

        LtotalBiaya.Text = 0

        DGV1.Rows.Clear()

        ListBox1.Items.Clear()

    End Sub

 

    Sub Tampillayanan()

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

        DS = New DataSet

        DA.Fill(DS)

        DGV2.DataSource = DS.Tables(0)

        DGV2.ReadOnly = True

    End Sub

 

    Sub TampilNomortransaksi()

        CMD = New OleDbCommand("select Nomor_transaksi from tbltransaksi where status_tamu='ISI'", Conn)

        DR = CMD.ExecuteReader

        ComboBox1.Items.Clear()

        Do While DR.Read

            ComboBox1.Items.Add(DR(0))

        Loop

    End Sub

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call Tampillayanan()

        Call TampilNomortransaksi()

    End Sub

 

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

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

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            LkodeTamu.Text = DR("kode_tamu")

            Lnamatamu.Text = DR("nama_tamu")

            Lnoktp.Text = DR("ktp")

        End If

 

        CMD = New OleDbCommand("select kode_kamar from tbltransaksikamar where nomor_transaksi='" & ComboBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        ListBox1.Items.Clear()

        Do While DR.Read

            ListBox1.Items.Add(DR(0))

        Loop

    End Sub

 

    Sub Hitungbiaya()

        Dim x As Integer

        For baris As Integer = 0 To DGV1.RowCount - 1

            x = x + DGV1.Rows(baris).Cells(4).Value

        Next

        LtotalBiaya.Text = x

    End Sub

 

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

 

        Dim baris As Integer = DGV1.RowCount - 1

        DGV1.Rows.Add(DGV2.Rows(e.RowIndex).Cells(0).Value, DGV2.Rows(e.RowIndex).Cells(1).Value, DGV2.Rows(e.RowIndex).Cells(2).Value, 1)

 

        For barisatas As Integer = 0 To DGV1.RowCount - 1

            For barisbawah As Integer = barisatas + 1 To DGV1.RowCount - 1

                If DGV1.Rows(barisbawah).Cells(0).Value = DGV1.Rows(barisatas).Cells(0).Value Then

                    DGV1.Rows(barisatas).Cells(3).Value = DGV1.Rows(barisatas).Cells(3).Value + 1

                    DGV1.Rows(barisatas).Cells(4).Value = DGV1.Rows(barisatas).Cells(2).Value * DGV1.Rows(barisatas).Cells(3).Value

                    DGV1.Rows.RemoveAt(barisbawah)

                    Call Hitungbiaya()

                    Exit Sub

                End If

            Next

        Next

       

        DGV1.Rows(baris).Cells(4).Value = DGV1.Rows(baris).Cells(2).Value * DGV1.Rows(baris).Cells(3).Value

        Call Hitungbiaya()

 

    End Sub

 

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

        Call Kosongkan()

    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 Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

 

        If ComboBox1.Text = "" Or LtotalBiaya.Text = 0 Or ListBox1.Text = "" Then

            MsgBox("Transaksi belum lengkap")

            Exit Sub

        End If

 

        CMD = New OleDbCommand("select biaya_layanan from tbltransaksi where nomor_transaksi='" & ComboBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Dim edit As String = "update tbltransaksi set biaya_layanan='" & DR("biaya_layanan") + Val(LtotalBiaya.Text) & "' where nomor_transaksi='" & ComboBox1.Text & "'"

            CMD = New OleDbCommand(edit, Conn)

            CMD.ExecuteNonQuery()

        End If

 

 

        For baris As Integer = 0 To DGV1.RowCount - 2

            Dim simpankamar As String = "insert into tbltransaksilayanan values ('" & ComboBox1.Text & "','" & DGV1.Rows(baris).Cells(0).Value & "','" & DGV1.Rows(baris).Cells(3).Value & "','" & DGV1.Rows(baris).Cells(4).Value & "','" & ListBox1.Text & "','" & TglLayanan.Text & "')"

            CMD = New OleDbCommand(simpankamar, Conn)

            CMD.ExecuteNonQuery()

        Next

 

        Call Kosongkan()

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class TRPembayaran

 

    Sub Kosongkan()

        ComboBox1.Text = ""

        Ltglbooking.Text = ""

        Lkodetamu.Text = ""

        Lnamatamu.Text = ""

        Lnoktp.Text = ""

        Ltglmasuk.Text = ""

        Llamainap.Text = ""

        LtglKeluar.Text = ""

        Lbiayakamar.Text = ""

        Ldp.Text = ""

        Lbiayapelayanan.Text = ""

        Lsisa.Text = ""

        Lsisadanlayanan.Text = ""

        Tjumlahbayar.Clear()

        Lkembali.Text = ""

        DGV1.Columns.Clear()

    End Sub

 

    Sub TampilNomor()

        CMD = New OleDbCommand("select nomor_transaksi from tbltransaksi where status_tamu='ISI'", Conn)

        DR = CMD.ExecuteReader

        ComboBox1.Items.Clear()

        Do While DR.Read

            ComboBox1.Items.Add(DR(0))

        Loop

    End Sub

 

    Sub TampilGrid()

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call TampilNomor()

        Call TampilGrid()

    End Sub

 

 

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

        'On Error Resume Next

        Tjumlahbayar.Clear()

        Lkembali.Text = ""

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

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Ltglbooking.Text = DR("tanggal_booking")

            Lkodetamu.Text = DR("kode_tamu")

            Lnamatamu.Text = DR("nama_tamu")

            Lnoktp.Text = DR("ktp")

            Ltglmasuk.Text = DR("tanggal_masuk")

            Llamainap.Text = DR("lama_inap")

            LtglKeluar.Text = Today()

            Lbiayakamar.Text = FormatNumber(DR("biaya_kamar"), 0)

            Ldp.Text = FormatNumber(DR("dp"), 0)

            Lsisa.Text = FormatNumber(DR("sisa"), 0)

            Lbiayapelayanan.Text = FormatNumber(DR("biaya_layanan"), 0)

            Lsisadanlayanan.Text = Val(Microsoft.VisualBasic.Str(Lsisa.Text)) + Val(Microsoft.VisualBasic.Str(Lbiayapelayanan.Text))

            Lsisadanlayanan.Text = FormatNumber(Lsisadanlayanan.Text, 0)

        End If

 

        DA = New OleDbDataAdapter("select Kode_kamar from tbltransaksikamar where nomor_transaksi='" & ComboBox1.Text & "'", Conn)

        DS = New DataSet

        DA.Fill(DS)

        DGV1.DataSource = DS.Tables(0)

        DGV1.ReadOnly = True

    End Sub

 

  

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

        Call Kosongkan()

    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 Tjumlahbayar_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Tjumlahbayar.KeyDown

        If e.KeyCode = Keys.Enter Then

            Tjumlahbayar.Text = FormatNumber(Tjumlahbayar.Text, 0)

            If Val(Microsoft.VisualBasic.Str(Tjumlahbayar.Text)) < Val(Microsoft.VisualBasic.Str(Lsisadanlayanan.Text)) Then

                MsgBox("jumlah pembayaran kurang")

                Exit Sub

            ElseIf Val(Microsoft.VisualBasic.Str(Tjumlahbayar.Text)) >= Val(Microsoft.VisualBasic.Str(Lsisadanlayanan.Text)) Then

                Lkembali.Text = Val(Microsoft.VisualBasic.Str(Tjumlahbayar.Text)) - Val(Microsoft.VisualBasic.Str(Lsisadanlayanan.Text))

                Lkembali.Text = FormatNumber(Lkembali.Text, 0)

                Button1.Focus()

            End If

        End If

    End Sub

 

   

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

        If ComboBox1.Text = "" Or Tjumlahbayar.Text = "" Then

            MsgBox("Trnasaksi belum lengkap")

            Exit Sub

        End If

 

        Dim edittransaksi As String = "update tbltransaksi set pelunasan='" & Tjumlahbayar.Text & "',kembali='" & Lkembali.Text & "',status_pembayaran='LUNAS',status_tamu='SELESAI' where nomor_transaksi='" & ComboBox1.Text & "'"

        CMD = New OleDbCommand(edittransaksi, Conn)

        CMD.ExecuteNonQuery()

 

        For baris As Integer = 0 To DGV1.RowCount - 2

            Dim editkamar As String = "update tblkamar set status_kamar='KOSONG' where kode_kamar='" & DGV1.Rows(baris).Cells(0).Value & "'"

            CMD = New OleDbCommand(editkamar, Conn)

            CMD.ExecuteNonQuery()

        Next

 

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

            Cetak.Show()

            Cetak.CRV.SelectionFormula = "{TBLTransaksi.nomor_transaksi} ='" & ComboBox1.Text & "'"

            laporan.Load("pembayaran.rpt")

            Call SetingLaporan()

            Cetak.CRV.ReportSource = laporan

            Cetak.CRV.RefreshReport()

        End If

        Call Kosongkan()

        Call TampilNomor()

        Call TampilGrid()

    End Sub

End Class

 

 

 

 

 

 

Public Class LaporanMaster

 

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

        Me.WindowState = FormWindowState.Maximized

    End Sub

 

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

        laporan.Load("fasilitas.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

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

        laporan.Load("layanan.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

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

        laporan.Load("kamar.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

        Me.Close()

    End Sub

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class LaporanTransaksi

 

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

        Me.WindowState = FormWindowState.Maximized

        Call Koneksi()

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

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox1.Items.Add(DR(0))

        Loop

 

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

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox2.Items.Add(DR(0))

        Loop

 

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

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox3.Items.Add(DR(0))

        Loop

 

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

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox4.Items.Add(DR(0))

        Loop

 

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

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox5.Items.Add(DR(0))

        Loop

 

        CMD = New OleDbCommand("select distinct tanggal_layanan from tbltransaksilayanan", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox6.Items.Add(DR(0))

        Loop

 

        CMD = New OleDbCommand("select distinct kode_kamar from tbltransaksilayanan", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            ListBox7.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.nomor_transaksi} ='" & ListBox1.Text & "'"

        laporan.Load("transaksi.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

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

        CRV.SelectionFormula = "totext({TBLTransaksi.tanggal_masuk}) ='" & ListBox2.Text & "'"

        laporan.Load("transaksi.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

    Private Sub ListBox3_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox3.SelectedIndexChanged

        CRV.SelectionFormula = "totext({TBLTransaksi.tanggal_keluar}) ='" & ListBox3.Text & "'"

        laporan.Load("transaksi.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

    Private Sub ListBox4_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox4.SelectedIndexChanged

        CRV.SelectionFormula = "{TBLTransaksi.status_pembayaran} ='" & ListBox4.Text & "'"

        laporan.Load("transaksi.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

    Private Sub ListBox5_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox5.SelectedIndexChanged

        CRV.SelectionFormula = "{TBLTransaksi.status_tamu} ='" & ListBox5.Text & "'"

        laporan.Load("transaksi.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

    Private Sub ListBox6_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox6.SelectedIndexChanged

        CRV.SelectionFormula = "totext({TBLTransaksilayanan.tanggal_layanan}) ='" & ListBox6.Text & "'"

        laporan.Load("transaksi layanan.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

 

    Private Sub ListBox7_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox7.SelectedIndexChanged

        CRV.SelectionFormula = "{TBLTransaksilayanan.kode_kamar} ='" & ListBox7.Text & "'"

        laporan.Load("transaksi layanan.rpt")

        Call SetingLaporan()

        CRV.ReportSource = laporan

        CRV.RefreshReport()

    End Sub

End Class