PROGRAM APLIKASI ABSENSI GURU-DOSEN

KONSULTASIVB.COM

 

 

 

 

 

 

 

 

 

 

 

Imports System.Data.OleDb

 

Public Class MasterLogin

   

    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 password_user='" & tpassword.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Me.Visible = False

            Mastermenu.Show()

            Mastermenu.Panelkode.Text = DR(0)

            Mastermenu.Panelnama.Text = DR(1)

            Mastermenu.Panelstatus.Text = DR(2)

        Else

            CMD = New OleDbCommand("select * from tblguru where username='" & tnama.Text & "' and pswd='" & tpassword.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            If DR.HasRows Then

                Me.Visible = False

                TRAbsen.Show()

            Else

                MsgBox("login gagal")

            End If

        End If

 

        Call Koneksi()

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

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Mastermenu.Panelsekolah.Text = DR(0)

        Else      

            MsgBox("silakan isi data profil sekolah")

            Mastersekolah.Show()

        End If

        Mastermenu.Paneljam.Text = TimeOfDay

        Mastermenu.Paneltanggal.Text = Today

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

        If e.KeyCode = Keys.Enter Then

            tpassword.Focus()

        End If

    End Sub

 

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

        If e.KeyCode = Keys.Enter Then

            OK.Focus()

        End If

    End Sub

 

End Class

 

 

 

 

Imports System.Data.OleDb

 

Public Class Mastersekolah

 

    Sub Ketemu()

        'On Error Resume Next

        TextBox2.Enabled = False

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

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

        TextBox4.Text = Microsoft.VisualBasic.Mid(DR.Item("telepon"), 9, 20)

        TextBox5.Text = Microsoft.VisualBasic.Mid(DR.Item("fax"), 5, 20)

        TextBox7.Text = Microsoft.VisualBasic.Mid(DR.Item("email"), 7, 43)

        TextBox8.Text = Microsoft.VisualBasic.Mid(DR.Item("website"), 9, 41)

        TextBox2.Focus()

    End Sub

 

 

    Sub Tampilsekolah()

 

        CMD = New OleDbCommand("select * from tblsekolah WHERE kode_sekolah='01'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            'TextBox2.Enabled = False

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

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

            TextBox4.Text = Microsoft.VisualBasic.Mid(DR.Item("telepon"), 9, 21)

            TextBox5.Text = Microsoft.VisualBasic.Mid(DR.Item("fax"), 5, 25)

            TextBox7.Text = Microsoft.VisualBasic.Mid(DR.Item("email"), 7, 43)

            TextBox8.Text = Microsoft.VisualBasic.Mid(DR.Item("website"), 9, 41)

        End If

    End Sub

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call Tampilsekolah()

    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 tblsekolah where kode_sekolah='01'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

 

                Dim simpan As String = "insert into tblsekolah values ('01','" & TextBox2.Text & "','" & TextBox3.Text & "','" & Label4.Text & Space(1) & TextBox4.Text & "','" & Label5.Text & Space(1) & TextBox5.Text & "','" & Label6.Text & Space(1) & TextBox7.Text & "','" & Label7.Text & Space(1) & TextBox8.Text & "')"

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

                MsgBox("Data berhasil disimpan")

                TextBox2.Enabled = False

            Else

                CMD = New OleDbCommand("delete * from tblsekolah", Conn)

                CMD.ExecuteNonQuery()

 

                Dim simpan As String = "insert into tblsekolah values ('01','" & TextBox2.Text & "','" & TextBox3.Text & "','" & Label4.Text & Space(1) & TextBox4.Text & "','" & Label5.Text & Space(1) & TextBox5.Text & "','" & Label6.Text & Space(1) & TextBox7.Text & "','" & Label7.Text & Space(1) & TextBox8.Text & "')"

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

                TextBox2.Enabled = False

                MsgBox("Data berhasil diedit")

            End If

 

        Catch ex As Exception

            MsgBox(ex.Message)

        End Try

    End Sub

 

End Class

 

 

 

Imports System.Data.OleDb

 

Public Class MasterUser

 

    Sub Kosongkan()

        TextBox1.Enabled = True

        TextBox1.Clear()

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox1.Focus()

        Call TampilStatus_user()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        'TextBox1.Enabled = False

        TextBox2.Clear()

        ComboBox1.Text = ""

        TextBox3.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox1.Enabled = False

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

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

        ComboBox1.Text = DR.Item("Status_user")

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

 

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Sub TampilStatus_user()

 

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

        DR = CMD.ExecuteReader

        ComboBox1.Items.Clear()

        Do While DR.Read

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

        Loop

    End Sub

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call Kosongkan()

    End Sub

 

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

        If ((e.KeyChar >= "0" And e.KeyChar <= "9") And e.KeyChar <> vbBack) Then e.Handled = True

    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

 

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

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

 

                Dim simpan As String = "insert into tblUser values ('" & TextBox1.Text & "','" & TextBox2.Text & "','" & TextBox3.Text & "','" & ComboBox1.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

        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

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

        Else

            Call Kosongkan()

        End If

    End Sub

 

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

 

        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 Sub

 

 

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

 

        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 MasterPelajaran

 

    Sub Kosongkan()

        TextBox1.Enabled = True

        TextBox1.Clear()

        TextBox2.Clear()

        TextBox6.Clear()

        TextBox1.Focus()

        Call TampilGrid()

    End Sub

 

    Sub DataBaru()

        'TextBox1.Enabled = False

        TextBox2.Clear()

        TextBox6.Clear()

        TextBox2.Focus()

    End Sub

 

    Sub Ketemu()

        TextBox1.Enabled = False

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

        TextBox2.Focus()

    End Sub

 

    Sub TampilGrid()

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

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

        DGV.ReadOnly = True

    End Sub

 

    Private Sub MasterPelajaran_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 tblPelajaran where kode_Pelajaran='" & TextBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Try

            If Not DR.HasRows Then

 

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

                CMD = New OleDbCommand(simpan, Conn)

                CMD.ExecuteNonQuery()

            Else

 

                Dim edit As String = "update tblPelajaran set nama_Pelajaran='" & TextBox2.Text & "' where kode_Pelajaran='" & 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 Pelajaran harus diisi")

            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 tblPelajaran where kode_Pelajaran='" & TextBox1.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 TextBox1.LostFocus

 

        CMD = New OleDbCommand("select * from tblPelajaran where kode_Pelajaran='" & TextBox1.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 tblPelajaran where nama_Pelajaran 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 Masterguruok

 

    Dim jumlahdata As Integer

    Dim tglsekarang As Date = Today

 

    Sub Kosongkan()

        tkodeguru.Text = "-" : tnamaguru.Text = "-"

        talamat.Text = "-" : ttelepon.Text = "-"

        temail.Text = "-" : tusername.Text = "-"

        tpassword.Text = "-" : cbostatus.Text = "-"

        tkodeguru.Focus() : DGVJadwal.Columns.Clear()

 

    End Sub

 

    Sub DataBaru()

        tnamaguru.Text = "-" : talamat.Text = "-"

        ttelepon.Text = "-" : temail.Text = "-"

        tusername.Text = "-" : tpassword.Text = "-"

        cbostatus.Text = "-"

        tnamaguru.Focus()

    End Sub

 

    Sub tampilgridguru()

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

        DS = New DataSet

        DA.Fill(DS)

        DGVGuru.DataSource = DS.Tables(0)

        DGVGuru.ReadOnly = True

    End Sub

 

    Sub tampilgridpelajaran()

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

        DS = New DataSet

        DA.Fill(DS)

        DGVPelajaran.DataSource = DS.Tables(0)

        DGVPelajaran.ReadOnly = True

    End Sub

 

 

    Sub BuatKolomJadwal()

        DGVJadwal.Columns.Clear()

        DGVJadwal.Columns.Add("Nomor", "Nomor")

        DGVJadwal.Columns.Add("Kode", "Kode Pelajaran")

        DGVJadwal.Columns.Add("Nama", "Nama Pelajaran")

        DGVJadwal.Columns.Add("Hari", "Hari")

        DGVJadwal.Columns.Add("Ruang", "Ruang")

        DGVJadwal.Columns.Add("Kelas", "Kelas")

        DGVJadwal.Columns.Add("Mulai", "Jam Mulai")

        DGVJadwal.Columns.Add("Selesai", "Jam Selesai")

        DGVJadwal.RowsDefaultCellStyle.BackColor = Color.AliceBlue

        DGVJadwal.AlternatingRowsDefaultCellStyle.BackColor = Color.AntiqueWhite

    End Sub

 

    Sub CariKodeguru()

        CMD = New OleDbCommand("select * from tblguru where kode_guru='" & tkodeguru.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

    End Sub

 

    Sub Ketemu()

        On Error Resume Next

        tnamaguru.Text = DR(1) : talamat.Text = DR(2)

        ttelepon.Text = DR(3) : temail.Text = DR(4)

        cbostatus.Text = DR(5) : tusername.Text = DR(6)

        tpassword.Text = DR(7) : tnamaguru.Focus()

    End Sub

 

 

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

        Me.CenterToScreen()

        Call Koneksi()

        Call tampilgridguru()

        tampilgridpelajaran()

    End Sub

 

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

        On Error Resume Next

        tkodeguru.Text = DGVGuru.Rows(e.RowIndex).Cells(0).Value

        Call CariKodeguru()

        If DR.HasRows Then

            Call Ketemu()

        End If

 

        Call BuatKolomJadwal()

 

        CMD = New OleDbCommand("select count(*)  from tblgurudetail where kode_guru='" & tkodeguru.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        jumlahdata = DR(0)

 

        CMD = New OleDbCommand("select tblgurudetail.kode_pelajaran,tblpelajaran.nama_pelajaran,tblgurudetail.hari,ruang,kelas,jam_mulai,jam_selesai from tblgurudetail,tblpelajaran,tblguru where tblgurudetail.kode_pelajaran=tblpelajaran.kode_pelajaran and tblgurudetail.kode_guru=tblguru.kode_guru and tblguru.kode_guru='" & tkodeguru.Text & "' order by 1", Conn)

        DR = CMD.ExecuteReader

        If DR.HasRows Then

            For baris As Integer = 0 To jumlahdata - 1

                DR.Read()

                DGVJadwal.RowCount = DGVJadwal.RowCount + 1

                DGVJadwal.Rows(baris).Cells("nomor").Value = DGVJadwal.RowCount - 1

                DGVJadwal.Rows(baris).Cells("Kode").Value = DR("Kode_pelajaran")

                DGVJadwal.Rows(baris).Cells("Nama").Value = DR("Nama_Pelajaran")

                DGVJadwal.Rows(baris).Cells("Hari").Value = DR("hari")

                DGVJadwal.Rows(baris).Cells("Ruang").Value = DR("ruang")

                DGVJadwal.Rows(baris).Cells("Kelas").Value = DR("kelas")

                DGVJadwal.Rows(baris).Cells("Mulai").Value = Format(DR("Jam_mulai"), "hh:mm")

                DGVJadwal.Rows(baris).Cells("Selesai").Value = Format(DR("Jam_selesai"), "hh:mm")

            Next

        Else

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

                DGVJadwal.Rows(baris).Cells("Kode").Value = "-"

                DGVJadwal.Rows(baris).Cells("Nama").Value = "-"

                DGVJadwal.Rows(baris).Cells("Hari").Value = "-"

                DGVJadwal.Rows(baris).Cells("Ruang").Value = "-"

                DGVJadwal.Rows(baris).Cells("Kelas").Value = "-"

                DGVJadwal.Rows(baris).Cells("Mulai").Value = "-"

                DGVJadwal.Rows(baris).Cells("Selesai").Value = "-"

            Next

        End If

    End Sub

 

 

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

        tkodeguru.MaxLength = 5

        If e.KeyChar = Chr(13) Then

            Call CariKodeguru()

            If DR.HasRows Then

                Call Ketemu()

            End If

 

            Call BuatKolomJadwal()

 

            CMD = New OleDbCommand("select count(*)  from tblgurudetail where kode_guru='" & tkodeguru.Text & "'", Conn)

            DR = CMD.ExecuteReader

            DR.Read()

            jumlahdata = DR(0)

 

            CMD = New OleDbCommand("select tblgurudetail.kode_pelajaran,tblpelajaran.nama_pelajaran,tblgurudetail.hari,ruang,kelas,jam_mulai,jam_selesai from tblgurudetail,tblpelajaran,tblguru where tblgurudetail.kode_pelajaran=tblpelajaran.kode_pelajaran and tblgurudetail.kode_guru=tblguru.kode_guru and tblguru.kode_guru='" & tkodeguru.Text & "' order by 1", Conn)

            DR = CMD.ExecuteReader

            If DR.HasRows Then

                For baris As Integer = 0 To jumlahdata - 1

                    DR.Read()

                    DGVJadwal.RowCount = DGVJadwal.RowCount + 1

                    DGVJadwal.Rows(baris).Cells("nomor").Value = DGVJadwal.RowCount - 1

                    DGVJadwal.Rows(baris).Cells("Kode").Value = DR("Kode_pelajaran")

                    DGVJadwal.Rows(baris).Cells("Nama").Value = DR("Nama_Pelajaran")

                    DGVJadwal.Rows(baris).Cells("Hari").Value = DR("hari")

                    DGVJadwal.Rows(baris).Cells("Ruang").Value = DR("ruang")

                    DGVJadwal.Rows(baris).Cells("Kelas").Value = DR("kelas")

                    DGVJadwal.Rows(baris).Cells("Mulai").Value = Format(DR("Jam_mulai"), "hh:mm")

                    DGVJadwal.Rows(baris).Cells("Selesai").Value = Format(DR("Jam_selesai"), "hh:mm")

                Next

            Else

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

                    DGVJadwal.Rows(baris).Cells("Kode").Value = "-"

                    DGVJadwal.Rows(baris).Cells("Nama").Value = "-"

                    DGVJadwal.Rows(baris).Cells("Hari").Value = "-"

                    DGVJadwal.Rows(baris).Cells("Ruang").Value = "-"

                    DGVJadwal.Rows(baris).Cells("Kelas").Value = "-"

                    DGVJadwal.Rows(baris).Cells("Mulai").Value = "-"

                    DGVJadwal.Rows(baris).Cells("Selesai").Value = "-"

                Next

            End If

        End If

    End Sub

 

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

        tnamaguru.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

 

        Dim BARIS1 As Integer = DGVGuru.RowCount - 1

        If tkodeguru.Text = "" Or tnamaguru.Text = "" Or talamat.Text = "" Or ttelepon.Text = "" Or temail.Text = "" Or tusername.Text = "" Or tpassword.Text = "" Or cbostatus.Text = "" Or tjumlahpertemuan.Text = "" Then

            MsgBox("data belum lengkap")

            Exit Sub

        End If

 

        Call CariKodeguru()

        If Not DR.HasRows Then

            Dim simpan As String = "insert into tblguru values('" & UCase(tkodeguru.Text) & "','" & tnamaguru.Text & "','" & talamat.Text & "','" & ttelepon.Text & "','" & temail.Text & "','" & cbostatus.Text & "','" & tusername.Text & "','" & tpassword.Text & "','" & Mastermenu.Panelsekolah.Text & "','" & Mastermenu.Panelkode.Text & "')"

            CMD = New OleDbCommand(simpan, Conn)

            CMD.ExecuteNonQuery()

 

            For i As Integer = 1 To Val(tjumlahpertemuan.Text)

                Dim tanggaljadwal As Date = DateAdd(DateInterval.Day, i + (7 * i), DateValue(Ttanggal.Text))

                For aa As Integer = 0 To DGVJadwal.RowCount - 2

                    Dim simpandetail2 As String = "insert into TBLabsen(kode_guru,kode_pelajaran,tanggal_jadwal,hari_absen,ruang_absen,kelas_absen,jadwal_mulai,jadwal_selesai,masuk,catatan_masuk,keluar,catatan_keluar,tanggal_absen) values ('" & tkodeguru.Text & "','" & DGVJadwal.Rows(aa).Cells("kode").Value & "','" & tanggaljadwal & "','" & DGVJadwal.Rows(aa).Cells("hari").Value & "','" & DGVJadwal.Rows(aa).Cells("ruang").Value & "','" & DGVJadwal.Rows(aa).Cells("kelas").Value & "','" & DGVJadwal.Rows(aa).Cells("mulai").Value & "','" & DGVJadwal.Rows(aa).Cells("selesai").Value & "',0,'-',0,'-','" & tanggaljadwal & "')"

                    CMD = New OleDbCommand(simpandetail2, Conn)

                    CMD.ExecuteNonQuery()

                Next

            Next

        Else

 

            Dim edit As String = "update tblguru set nama_guru='" & tnamaguru.Text & "',alamat_guru='" & talamat.Text & "',telepon_guru='" & ttelepon.Text & "',email_guru='" & temail.Text & "',status_guru='" & cbostatus.Text & "',username='" & tusername.Text & "',pswd='" & tpassword.Text & "',kode_user='" & Mastermenu.Panelkode.Text & "' where kode_guru='" & tkodeguru.Text & "'"

            CMD = New OleDbCommand(edit, Conn)

            CMD.ExecuteNonQuery()

 

            CMD = New OleDbCommand("delete * from tblabsen where kode_guru='" & tkodeguru.Text & "'", Conn)

            CMD.ExecuteNonQuery()

 

            For i As Integer = 1 To Val(tjumlahpertemuan.Text)

                Dim tanggaljadwal As Date = DateAdd(DateInterval.Day, i + (7 * i), DateValue(Ttanggal.Text))

                For aa As Integer = 0 To DGVJadwal.RowCount - 2

                    Dim simpandetail2 As String = "insert into TBLabsen(kode_guru,kode_pelajaran,tanggal_jadwal,hari_absen,ruang_absen,kelas_absen,jadwal_mulai,jadwal_selesai,masuk,catatan_masuk,keluar,catatan_keluar,tanggal_absen) values ('" & tkodeguru.Text & "','" & DGVJadwal.Rows(aa).Cells("kode").Value & "','" & tanggaljadwal & "','" & DGVJadwal.Rows(aa).Cells("hari").Value & "','" & DGVJadwal.Rows(aa).Cells("ruang").Value & "','" & DGVJadwal.Rows(aa).Cells("kelas").Value & "','" & DGVJadwal.Rows(aa).Cells("mulai").Value & "','" & DGVJadwal.Rows(aa).Cells("selesai").Value & "',0,'-',0,'-','" & tanggaljadwal & "')"

                    CMD = New OleDbCommand(simpandetail2, Conn)

                    CMD.ExecuteNonQuery()

                Next

            Next

        End If

 

 

        CMD = New OleDbCommand("delete * from tblgurudetail where kode_guru='" & tkodeguru.Text & "'", Conn)

        CMD.ExecuteNonQuery()

 

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

            Dim simpandetail As String = "insert into tblgurudetail values ('" & tkodeguru.Text & "','" & DGVJadwal.Rows(baris).Cells("kode").Value & "','" & DGVJadwal.Rows(baris).Cells("Hari").Value & "','" & DGVJadwal.Rows(baris).Cells("Ruang").Value & "','" & DGVJadwal.Rows(baris).Cells("kelas").Value & "','" & DGVJadwal.Rows(baris).Cells("Mulai").Value & "','" & DGVJadwal.Rows(baris).Cells("selesai").Value & "','" & Ttanggal.Text & "','" & tjumlahpertemuan.Text & "')"

            CMD = New OleDbCommand(simpandetail, Conn)

            CMD.ExecuteNonQuery()

        Next

 

        Call Kosongkan()

        Call tampilgridguru()

    End Sub

 

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

        If tkodeguru.Text = "" Then

            MsgBox("kode user harus diisi dulu")

            tkodeguru.Focus()

            Exit Sub

        Else

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

                Dim hapus As String = "delete * from tblguru where kode_guru='" & tkodeguru.Text & "'"

                CMD = New OleDbCommand(hapus, Conn)

                CMD.ExecuteNonQuery()

 

                Dim hapusdetail As String = "delete * from tblgurudetail where kode_guru='" & tkodeguru.Text & "'"

                CMD = New OleDbCommand(hapusdetail, Conn)

                CMD.ExecuteNonQuery()

                Call Kosongkan()

                Call tampilgridguru()

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

        DGVJadwal.Columns.Clear()

 

    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 DGVPelajaran_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles DGVPelajaran.CellMouseClick

        On Error Resume Next

        Dim baris As Integer = DGVJadwal.RowCount - 1

        If DGVJadwal.RowCount - 1 = 0 Then

            DGVJadwal.Rows.Add(DGVJadwal.Rows(baris).Cells(0).Value + 1, DGVPelajaran.Rows(e.RowIndex).Cells(0).Value, DGVPelajaran.Rows(e.RowIndex).Cells(1).Value)

        Else

            DGVJadwal.Rows.Add(DGVJadwal.Rows(baris - 1).Cells(0).Value + 1, DGVPelajaran.Rows(e.RowIndex).Cells(0).Value, DGVPelajaran.Rows(e.RowIndex).Cells(1).Value)

        End If

    End Sub

 

  

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

        CMD = New OleDbCommand("delete * from tblguru", Conn)

        CMD.ExecuteNonQuery()

 

        CMD = New OleDbCommand("delete * from tblgurudetail", Conn)

        CMD.ExecuteNonQuery()

 

        CMD = New OleDbCommand("delete * from tblabsen", Conn)

        CMD.ExecuteNonQuery()

 

        MsgBox("OK")

        Call tampilgridguru()

    End Sub

 

    Private Sub tnamaguru_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tnamaguru.TextChanged

        tusername.Text = tnamaguru.Text

        tpassword.Text = tnamaguru.Text

    End Sub

End Class

 

 

Imports System.Data.OleDb

 

Public Class TRAbsen

 

    Dim kodepelajaran As String

    Dim namapelajaran As String

 

    Sub tampilkelas()

        CMD = New OleDbCommand("select distinct kelas_absen from tblabsen where kode_guru='" & Tkodeguru.Text & "'", Conn)

        DR = CMD.ExecuteReader

        Do While DR.Read

            ComboBox1.Items.Add(DR(0))

        Loop

    End Sub

 

    Sub tampilPelajaran()

        CMD = New OleDbCommand("select distinct tblpelajaran.kode_pelajaran,nama_pelajaran from tblpelajaran,tblabsen where tblpelajaran.kode_pelajaran=tblabsen.kode_Pelajaran and tblabsen.kelas_absen='" & ComboBox1.Text & "' and tblabsen.kode_guru='" & Tkodeguru.Text & "'", Conn)

        DR = CMD.ExecuteReader

        ComboBox2.Items.Clear()

        Do While DR.Read

            ComboBox2.Items.Add(DR(0) & Space(2) & DR(1))

        Loop

 

    End Sub

 

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

        Me.CenterToScreen()

        ttanggal.Text = Today

        Call Koneksi()

 

        CMD = New OleDbCommand("select * from tblguru where username='" & MasterLogin.tnama.Text & "' and pswd='" & MasterLogin.tpassword.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            Tkodeguru.Text = DR(0)

            tnamaguru.Text = DR(1)

        End If

        Call tampilkelas()

    End Sub

 

 

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

 

        CMD = New OleDbCommand("select * from tblabsen where kode_guru='" & Tkodeguru.Text & "' and kelas_absen='" & ComboBox1.Text & "'", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        Call tampilPelajaran()

 

        ComboBox2.Text = ""

        thari.Text = ""

        truang.Text = ""

        tmulai.Text = ""

        tselesai.Text = ""

        DGV.Columns.Clear()

    End Sub

 

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

        Me.Close()

        MasterLogin.Show()

        MasterLogin.tnama.Clear()

        MasterLogin.tpassword.Clear()

        MasterLogin.tnama.Focus()

    End Sub

 

    Private Sub ComboBox2_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox2.SelectedIndexChanged

 

        CMD = New OleDbCommand("select *  from tblabsen where kode_guru='" & Tkodeguru.Text & "' and kelas_absen='" & ComboBox1.Text & "' and kode_pelajaran='" & Microsoft.VisualBasic.Left(ComboBox2.Text, 5) & "' order by 1", Conn)

        DR = CMD.ExecuteReader

        DR.Read()

        If DR.HasRows Then

            thari.Text = DR("hari_absen")

            truang.Text = DR("ruang_absen")

            tmulai.Text = DR("jadwal_mulai")

            tselesai.Text = DR("jadwal_selesai")

        End If

 

        DGV.Columns.Clear()

        DA = New OleDbDataAdapter("select *  from tblabsen where kode_guru='" & Tkodeguru.Text & "' and kelas_absen='" & ComboBox1.Text & "' and kode_pelajaran='" & Microsoft.VisualBasic.Left(ComboBox2.Text, 5) & "' order by 1", Conn)

 

        DS = New DataSet

        DA.Fill(DS)

        DGV.DataSource = DS.Tables(0)

     DGV.Columns("Jadwal_Mulai").DefaultCellStyle.Format = "H:mm:ss"

        DGV.Columns("Jadwal_Selesai").DefaultCellStyle.Format = "H:mm:ss"

 

        DGV.Columns("Masuk").DefaultCellStyle.Format = "H:mm:ss"

        DGV.Columns("Keluar").DefaultCellStyle.Format = "H:mm:ss"

        DGV.Columns("tanggal_jadwal").DefaultCellStyle.Format = "dd/MMMM/yyyy"

        DGV.Columns("tanggal_ABSEN").DefaultCellStyle.Format = "dd/MMMM/yyyy"

        DGV.Columns(1).Visible = False

        DGV.Columns(2).Visible = False

        'DGV.Columns(3).Visible = False

        DGV.Columns(4).Visible = False

        DGV.Columns(5).Visible = False

        DGV.Columns(6).Visible = False

        DGV.Columns(7).Visible = False

        DGV.Columns(8).Visible = False

 

        For kolom As Integer = 0 To DGV.ColumnCount - 2

            DGV.Columns(kolom).ReadOnly = True

        Next

    End Sub

 

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

        tkodeabsen.Text = DGV.Rows(e.RowIndex).Cells("kode_absen").Value

        If DGV.Rows(e.RowIndex).Cells("catatan_masuk").Value = "-" Then

            btnmulai.Enabled = True

            btnselesai.Enabled = False

        ElseIf DGV.Rows(e.RowIndex).Cells("catatan_keluar").Value = "-" Then

            btnmulai.Enabled = False

            btnselesai.Enabled = True

        End If

    End Sub

 

    Sub Kendalibutton()

        Dim baris As Integer = DGV.RowCount - 1

        If DGV.Rows(DGV.CurrentCell.RowIndex).Cells("catatan_masuk").Value = "-" Then

            btnmulai.Enabled = True

            btnselesai.Enabled = False

        ElseIf DGV.Rows(DGV.CurrentCell.RowIndex).Cells("catatan_keluar").Value = "-" Then

            btnmulai.Enabled = False

            btnselesai.Enabled = True

        ElseIf DGV.Rows(DGV.CurrentCell.RowIndex).Cells("catatan_masuk").Value <> "-" And DGV.Rows(DGV.CurrentCell.RowIndex).Cells("catatan_keluar").Value <> "-" Then

            btnmulai.Enabled = False

            btnselesai.Enabled = False

        End If

    End Sub

 

    Private Sub btnmulai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmulai.Click

 

        Dim jadwalmulai As DateTime = TimeValue(tmulai.Text)

        DGV.Rows(DGV.CurrentCell.RowIndex).Cells("masuk").Value = TimeValue(tjam.Text)

        DGV.Columns("masuk").DefaultCellStyle.Format = "H:mm:ss"

 

        DGV.Rows(DGV.CurrentCell.RowIndex).Cells("tanggal_absen").Value = DateValue(ttanggal.Text)

        If TimeValue(DGV.Rows(DGV.CurrentCell.RowIndex).Cells("masuk").Value) <= jadwalmulai.AddMinutes(-15) Then

            DGV.Rows(DGV.CurrentCell.RowIndex).Cells("Catatan_Masuk").Value = "Masuk lebih awal"

        ElseIf TimeValue(DGV.Rows(DGV.CurrentCell.RowIndex).Cells("masuk").Value) >= jadwalmulai.AddMinutes(16) Then

            DGV.Rows(DGV.CurrentCell.RowIndex).Cells("Catatan_Masuk").Value = "Masuk melewati batas jadwal"

        Else

            DGV.Rows(DGV.CurrentCell.RowIndex).Cells("Catatan_Masuk").Value = "Masuk tepat Waktu"

        End If

 

        Dim edit As String = "update tblabsen set masuk= '" & DGV.Rows(DGV.CurrentCell.RowIndex).Cells("masuk").Value & "',catatan_masuk= '" & DGV.Rows(DGV.CurrentCell.RowIndex).Cells("catatan_masuk").Value & "',tanggal_absen= '" & CDate(DGV.Rows(DGV.CurrentCell.RowIndex).Cells("tanggal_absen").Value) & "' where val(kode_absen)='" & Val(tkodeabsen.Text) & "' and kode_guru='" & Tkodeguru.Text & "' and kelas_absen='" & ComboBox1.Text & "' and kode_pelajaran='" & Microsoft.VisualBasic.Left(ComboBox2.Text, 5) & "' and hari_absen='" & thari.Text & "'"

        CMD = New OleDbCommand(edit, Conn)

        CMD.ExecuteNonQuery()

 

        Call Kendalibutton()

    End Sub

 

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

        tjam.Text = TimeOfDay

    End Sub

 

    Private Sub btnselesai_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnselesai.Click

 

        Dim jadwalselesai As DateTime = TimeValue(tselesai.Text)

        DGV.Rows(DGV.CurrentCell.RowIndex).Cells("keluar").Value = tjam.Text

        DGV.Columns("keluar").DefaultCellStyle.Format = "H:mm:ss"

 

        If TimeValue(DGV.Rows(DGV.CurrentCell.RowIndex).Cells("Keluar").Value) <= jadwalselesai.AddMinutes(-15) Then

            DGV.Rows(DGV.CurrentCell.RowIndex).Cells("Catatan_Keluar").Value = "Keluar lebih cepat"

        ElseIf TimeValue(DGV.Rows(DGV.CurrentCell.RowIndex).Cells("Keluar").Value) >= jadwalselesai.AddMinutes(15) Then

            DGV.Rows(DGV.CurrentCell.RowIndex).Cells("Catatan_Keluar").Value = "Keluar melewati batas jadwal"

        Else

            DGV.Rows(DGV.CurrentCell.RowIndex).Cells("Catatan_Keluar").Value = "Keluar tepat Waktu"

        End If

 

        CMD = New OleDbCommand("update tblabsen set keluar= '" & DGV.Rows(DGV.CurrentCell.RowIndex).Cells("keluar").Value & "',catatan_keluar= '" & DGV.Rows(DGV.CurrentCell.RowIndex).Cells("catatan_keluar").Value & "' where val(kode_absen)='" & Val(tkodeabsen.Text) & "' and kode_guru='" & Tkodeguru.Text & "' and kelas_absen='" & ComboBox1.Text & "' and kode_pelajaran='" & Microsoft.VisualBasic.Left(ComboBox2.Text, 5) & "' and hari_absen='" & thari.Text & "'", Conn)

 

        CMD.ExecuteNonQuery()

        Call Kendalibutton()

    End Sub

End Class