You are on page 1of 36

MODULE 1

Imports System.Data
Imports System.Data.Sql
Imports System.Data.SqlClient

Module Module1
Public comSQL As New SqlClient.SqlCommand
Public sql As String
Public conn As New SqlConnection
Public str As String = ("Data Source = DESKTOP-1VIE8U5\SQLEXPRESS;initial
catalog=db_Library1; trusted_connection = true")

Public Sub bukakoneksi()


If conn.State = ConnectionState.Closed Then
conn.ConnectionString = str
Try
conn.Open()
'MsgBox("Koneksi Berhasil")
Catch ex As Exception
MsgBox("Koneksi Gagl " & ex.ToString)
End Try
End If
End Sub

Public Sub tutupkoneksi()


If conn.State = ConnectionState.Open Then
Try
conn.Close()
Catch ex As Exception
MsgBox("Gagal Menutup Koneksi " & ex.ToString)
End Try
End If
End Sub
End Module
Imports System.Data.SqlClient

Public Class Book


Sub tampildata()
bukakoneksi()
sql = "select * from tb_book"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Sub bersihkandata()
txtBookID.Text = ""
txtTitle.Text = ""
txtCategory.Text = ""
txtAuthor.Text = ""
txtPublisher.Text = ""
txtYear.Text = ""
txtStock.Text = ""
End Sub

Sub kodeotomatis()
bukakoneksi()
sql = "select max(book_id) as book_id from tb_book"

comSQL = New SqlCommand(sql, conn)

Dim ds = comSQL.ExecuteReader
ds.Read()

If ds.HasRows = 0 Then
txtBookID.Text = "BOOK-000001"
ds.Close()
End If

If Not ds.HasRows Then


txtBookID.Text = "BOOK-" + "000001"
ds.Close()

Else

txtBookID.Text =
Val(Microsoft.VisualBasic.Mid(ds.Item("book_id").ToString, 6, 6)) + 1
If Len(txtBookID.Text) = 1 Then
txtBookID.Text = "BOOK-00000" & txtBookID.Text & ""
ElseIf Len(txtBookID.Text) = 2 Then
txtBookID.Text = "BOOK-0000" & txtBookID.Text & ""
ElseIf Len(txtBookID.Text) = 3 Then
txtBookID.Text = "BOOK-000" & txtBookID.Text & ""
ElseIf Len(txtBookID.Text) = 4 Then
txtBookID.Text = "BOOK-00" & txtBookID.Text & ""
ElseIf Len(txtBookID.Text) = 5 Then
txtBookID.Text = "BOOK-0" & txtBookID.Text & ""
End If
ds.Close()
End If
tutupkoneksi()
End Sub

Sub tombolaktif()
btnCancel.Enabled = True
btnDelete.Enabled = True
btnExit.Enabled = True
btnInsert.Enabled = True
btnUpdate.Enabled = True
End Sub

Sub tombolnonaktif()
btnCancel.Enabled = False
btnDelete.Enabled = False
btnExit.Enabled = False
btnInsert.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub Book_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnInsert_Click(sender As Object, e As EventArgs) Handles


btnInsert.Click
If txtTitle.Text = "" Or
txtCategory.Text = "" Or
txtAuthor.Text = "" Or
txtPublisher.Text = "" Or
txtYear.Text = "" Or
txtStock.Text = "" Then

MsgBox("Data Tidak Boleh Kosong!")

Else

bukakoneksi()
sql = "INSERT INTO tb_book (book_id, title, category, author, publisher,
year, stock) VALUES (" &
"'" & txtBookID.Text & "', " &
"'" & txtTitle.Text & "', " &
"'" & txtCategory.Text & "', " &
"'" & txtAuthor.Text & "', " &
"'" & txtPublisher.Text & "', " &
"'" & txtYear.Text & "', " &
"'" & txtStock.Text & "' )"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Simpan Berhasil")
Catch ex As Exception
MsgBox("Simpan Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End If
End Sub

Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles


btnUpdate.Click
bukakoneksi()
sql = "update tb_book set " &
"title='" & txtTitle.Text & "', " &
"category='" & txtCategory.Text & "', " &
"author='" & txtAuthor.Text & "', " &
"publisher='" & txtPublisher.Text & "', " &
"year='" & txtYear.Text & "', " &
"stock='" & txtStock.Text & "'" &
"where book_id='" & txtBookID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Ubah Data Berhasil")
Catch ex As Exception
MsgBox("Ubah Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")
Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
txtBookID.Text = DataGridView1.Item(0, i).Value.ToString
txtTitle.Text = DataGridView1.Item(1, i).Value.ToString
txtCategory.Text = DataGridView1.Item(2, i).Value.ToString
txtAuthor.Text = DataGridView1.Item(3, i).Value.ToString
txtPublisher.Text = DataGridView1.Item(4, i).Value.ToString
txtYear.Text = DataGridView1.Item(5, i).Value.ToString
txtStock.Text = DataGridView1.Item(6, i).Value.ToString

End If
tombolaktif()
btnInsert.Enabled = False
End Sub

Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles


btnDelete.Click
bukakoneksi()
sql = "delete from tb_book where book_id='" & txtBookID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Hapus Data Berhasil")
Catch ex As Exception
MsgBox("Hapus Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles


btnCancel.Click
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


Me.Close()
End Sub

Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles


txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_book where title like '%" & txtSearch.Text & "%'" &
"OR book_id like '%" & txtSearch.Text & "%'" &
"OR category like '%" & txtSearch.Text & "%'" &
"OR author like '%" & txtSearch.Text & "%'" &
"OR publisher like '%" & txtSearch.Text & "%'" &
"OR year like '%" & txtSearch.Text & "%'" &
"OR stock like '%" & txtSearch.Text & "%'"
Dim da As New SqlDataAdapter(sql, conn)
Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub
End Class
Imports System.Data.SqlClient

Public Class Member


Sub tampildata()
bukakoneksi()
sql = "select * from tb_member"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Sub bersihkandata()
txtMemberID.Text = ""
txtMemberName.Text = ""
txtAddress.Text = ""
txtHP.Text = ""
txtEmail.Text = ""
End Sub

Sub kodeotomatis()
bukakoneksi()
sql = "select max(member_id) as member_id from tb_member"

comSQL = New SqlCommand(sql, conn)

Dim ds = comSQL.ExecuteReader
ds.Read()

If ds.HasRows = 0 Then
txtMemberID.Text = "M-00001"
ds.Close()
End If

If Not ds.HasRows Then


txtMemberID.Text = "M-" + "00001"
ds.Close()

Else
txtMemberID.Text =
Val(Microsoft.VisualBasic.Mid(ds.Item("member_id").ToString, 5, 3)) + 1
If Len(txtMemberID.Text) = 1 Then
txtMemberID.Text = "M-0000" & txtMemberID.Text & ""
ElseIf Len(txtMemberID.Text) = 2 Then
txtMemberID.Text = "M-000" & txtMemberID.Text & ""
ElseIf Len(txtMemberID.Text) = 3 Then
txtMemberID.Text = "M-00" & txtMemberID.Text & ""
ElseIf Len(txtMemberID.Text) = 4 Then
txtMemberID.Text = "M-0" & txtMemberID.Text & ""
End If
ds.Close()
End If
tutupkoneksi()
End Sub

Sub tombolaktif()
btnCancel.Enabled = True
btnDelete.Enabled = True
btnExit.Enabled = True
btnInsert.Enabled = True
btnUpdate.Enabled = True
End Sub

Sub tombolnonaktif()
btnCancel.Enabled = False
btnDelete.Enabled = False
btnExit.Enabled = False
btnInsert.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub Member_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnInsert_Click(sender As Object, e As EventArgs) Handles


btnInsert.Click
If txtMemberName.Text = "" Or
txtAddress.Text = "" Or
txtHP.Text = "" Or
txtEmail.Text = "" Then

MsgBox("Data Tidak Boleh Kosong!")

Else

bukakoneksi()
sql = "INSERT INTO tb_member (member_id, member_name, address, hp, email)
VALUES (" &
"'" & txtMemberID.Text & "', " &
"'" & txtMemberName.Text & "', " &
"'" & txtAddress.Text & "', " &
"'" & txtHP.Text & "', " &
"'" & txtEmail.Text & "' )"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Simpan Berhasil")
Catch ex As Exception
MsgBox("Simpan Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End If
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
txtMemberID.Text = DataGridView1.Item(0, i).Value.ToString
txtMemberName.Text = DataGridView1.Item(1, i).Value.ToString
txtAddress.Text = DataGridView1.Item(2, i).Value.ToString
txtHP.Text = DataGridView1.Item(3, i).Value.ToString
txtEmail.Text = DataGridView1.Item(4, i).Value.ToString

End If
tombolaktif()
btnInsert.Enabled = False
End Sub

Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles


btnUpdate.Click
bukakoneksi()
sql = "update tb_member set " &
"member_name='" & txtMemberName.Text & "', " &
"address='" & txtAddress.Text & "', " &
"hp='" & txtHP.Text & "', " &
"email='" & txtEmail.Text & "'" &
"where member_id='" & txtMemberID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Ubah Data Berhasil")
Catch ex As Exception
MsgBox("Ubah Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles


btnDelete.Click
bukakoneksi()
sql = "delete from tb_member where member_id='" & txtMemberID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Hapus Data Berhasil")
Catch ex As Exception
MsgBox("Hapus Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles


btnCancel.Click
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


Me.Close()
End Sub

Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles


txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_member where member_name like '%" & txtSearch.Text &
"%'" &
"OR member_id like '%" & txtSearch.Text & "%'" &
"OR address like '%" & txtSearch.Text & "%'" &
"OR hp like '%" & txtSearch.Text & "%'" &
"OR email like '%" & txtSearch.Text & "%'"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

End Class
Imports System.Data.SqlClient

Public Class Employee


Sub tampildata()
bukakoneksi()
sql = "select * from tb_employee"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Sub bersihkandata()
txtEmployeeID.Text = ""
txtEmployeeName.Text = ""
txtUsername.Text = ""
txtPassword.Text = ""
End Sub

Sub kodeotomatis()
bukakoneksi()
sql = "select max(employee_id) as employee_id from tb_employee"

comSQL = New SqlCommand(sql, conn)

Dim ds = comSQL.ExecuteReader
ds.Read()

If ds.HasRows = 0 Then
txtEmployeeID.Text = "E-00001"
ds.Close()
End If

If Not ds.HasRows Then


txtEmployeeID.Text = "E-" + "00001"
ds.Close()

Else
txtEmployeeID.Text =
Val(Microsoft.VisualBasic.Mid(ds.Item("employee_id").ToString, 5, 3)) + 1
If Len(txtEmployeeID.Text) = 1 Then
txtEmployeeID.Text = "E-0000" & txtEmployeeID.Text & ""
ElseIf Len(txtEmployeeID.Text) = 2 Then
txtEmployeeID.Text = "E-000" & txtEmployeeID.Text & ""
ElseIf Len(txtEmployeeID.Text) = 3 Then
txtEmployeeID.Text = "E-00" & txtEmployeeID.Text & ""
ElseIf Len(txtEmployeeID.Text) = 4 Then
txtEmployeeID.Text = "E-0" & txtEmployeeID.Text & ""
End If
ds.Close()
End If
tutupkoneksi()
End Sub

Sub tombolaktif()
btnCancel.Enabled = True
btnDelete.Enabled = True
btnExit.Enabled = True
btnInsert.Enabled = True
btnUpdate.Enabled = True
End Sub

Sub tombolnonaktif()
btnCancel.Enabled = False
btnDelete.Enabled = False
btnExit.Enabled = False
btnInsert.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub Employee_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnInsert_Click(sender As Object, e As EventArgs) Handles


btnInsert.Click
If txtEmployeeName.Text = "" Or
txtUsername.Text = "" Or
txtPassword.Text = "" Then

MsgBox("Data Tidak Boleh Kosong!")

Else

bukakoneksi()
sql = "INSERT INTO tb_employee (employee_id, employee_name, username,
password) VALUES (" &
"'" & txtEmployeeID.Text & "', " &
"'" & txtEmployeeName.Text & "', " &
"'" & txtUsername.Text & "', " &
"'" & txtPassword.Text & "' )"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Simpan Berhasil")
Catch ex As Exception
MsgBox("Simpan Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End If
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
txtEmployeeID.Text = DataGridView1.Item(0, i).Value.ToString
txtEmployeeName.Text = DataGridView1.Item(1, i).Value.ToString
txtUsername.Text = DataGridView1.Item(2, i).Value.ToString
txtPassword.Text = DataGridView1.Item(3, i).Value.ToString

End If
tombolaktif()
btnInsert.Enabled = False
End Sub

Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles


btnUpdate.Click
bukakoneksi()
sql = "update tb_employee set " &
"employee_name='" & txtEmployeeName.Text & "', " &
"username='" & txtUsername.Text & "', " &
"password='" & txtPassword.Text & "'" &
"where employee_id='" & txtEmployeeID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Ubah Data Berhasil")
Catch ex As Exception
MsgBox("Ubah Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub
Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles
btnDelete.Click
bukakoneksi()
sql = "delete from tb_employee where employee_id='" & txtEmployeeID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Hapus Data Berhasil")
Catch ex As Exception
MsgBox("Hapus Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles


btnCancel.Click
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


Me.Close()
End Sub
End Class
Imports System.Data.SqlClient

Public Class LoanTransaction


Sub tampildata()
bukakoneksi()
sql = "select * from tb_loan"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Sub bersihkandata()
txtLoanID.Text = ""
txtBookID.Text = ""
txtTitle.Text = ""
txtStock.Text = ""
txtLoanQuantity.Text = ""
txtMemberID.Text = ""
txtMemberName.Text = ""
txtEmployeeID.Text = ""
txtEmployeeName.Text = ""
End Sub

Sub kodeotomatis()
bukakoneksi()
sql = "select max(loan_id) as loan_id from tb_loan"

comSQL = New SqlCommand(sql, conn)

Dim ds = comSQL.ExecuteReader
ds.Read()

If ds.HasRows = 0 Then
txtLoanID.Text = "LOAN-000001"
ds.Close()
End If

If Not ds.HasRows Then


txtLoanID.Text = "LOAN-" + "000001"
ds.Close()
Else

txtLoanID.Text =
Val(Microsoft.VisualBasic.Mid(ds.Item("loan_id").ToString, 6, 6)) + 1
If Len(txtLoanID.Text) = 1 Then
txtLoanID.Text = "LOAN-00000" & txtLoanID.Text & ""
ElseIf Len(txtLoanID.Text) = 2 Then
txtLoanID.Text = "LOAN-0000" & txtLoanID.Text & ""
ElseIf Len(txtLoanID.Text) = 3 Then
txtLoanID.Text = "LOAN-000" & txtLoanID.Text & ""
ElseIf Len(txtLoanID.Text) = 4 Then
txtLoanID.Text = "LOAN-00" & txtLoanID.Text & ""
ElseIf Len(txtLoanID.Text) = 5 Then
txtLoanID.Text = "LOAN-0" & txtLoanID.Text & ""
End If
ds.Close()
End If
tutupkoneksi()
End Sub

Sub tombolaktif()
btnCancel.Enabled = True
btnDelete.Enabled = True
btnExit.Enabled = True
btnInsert.Enabled = True
btnUpdate.Enabled = True
End Sub

Sub tombolnonaktif()
btnCancel.Enabled = False
btnDelete.Enabled = False
btnExit.Enabled = False
btnInsert.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub LoanTransaction_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnInsert_Click(sender As Object, e As EventArgs) Handles


btnInsert.Click
If dtpLoanDate.Text = "" Or
txtBookID.Text = "" Or
txtTitle.Text = "" Or
txtStock.Text = "" Or
txtLoanQuantity.Text = "" Or
txtMemberID.Text = "" Or
txtMemberName.Text = "" Or
txtEmployeeID.Text = "" Or
txtEmployeeName.Text = "" Or
dtpDueDate.Text = "" Then

MsgBox("Data Tidak Boleh Kosong!")

Else

bukakoneksi()
Dim loandate = Format(dtpLoanDate.Value, "yyyy-MM-dd")
Dim duedate = Format(dtpDueDate.Value, "yyyy-MM-dd")
sql = "INSERT INTO tb_loan (loan_id, loan_date, book_id, title, stock,
qty, member_id, member_name, employee_id, employee_name, due_date) VALUES (" &
"'" & txtLoanID.Text & "', " &
"'" & loandate & "', " &
"'" & txtBookID.Text & "', " &
"'" & txtTitle.Text & "', " &
"'" & txtStock.Text & "', " &
"'" & txtLoanQuantity.Text & "', " &
"'" & txtMemberID.Text & "', " &
"'" & txtMemberName.Text & "', " &
"'" & txtEmployeeID.Text & "', " &
"'" & txtEmployeeName.Text & "', " &
"'" & duedate & "' )"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Simpan Berhasil")
Catch ex As Exception
MsgBox("Simpan Gagal" & ex.Message.ToString)
End Try

sql = "update tb_book set " &


"stock=stock-'" & txtLoanQuantity.Text & "'where book_id='" &
txtBookID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Ubah Data Berhasil")
Catch ex As Exception
MsgBox("Ubah Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End If
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
txtLoanID.Text = DataGridView1.Item(0, i).Value.ToString
dtpLoanDate.Text = DataGridView1.Item(1, i).Value.ToString
txtBookID.Text = DataGridView1.Item(2, i).Value.ToString
txtTitle.Text = DataGridView1.Item(3, i).Value.ToString
txtStock.Text = DataGridView1.Item(4, i).Value.ToString
txtLoanQuantity.Text = DataGridView1.Item(5, i).Value.ToString
txtMemberID.Text = DataGridView1.Item(6, i).Value.ToString
txtMemberName.Text = DataGridView1.Item(7, i).Value.ToString
txtEmployeeID.Text = DataGridView1.Item(8, i).Value.ToString
txtEmployeeName.Text = DataGridView1.Item(9, i).Value.ToString
dtpDueDate.Text = DataGridView1.Item(10, i).Value.ToString

End If
tombolaktif()
btnInsert.Enabled = False
End Sub

Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles


btnUpdate.Click
bukakoneksi()
Dim loandate = Format(dtpLoanDate.Value, "yyyy-MM-dd")
Dim duedate = Format(dtpDueDate.Value, "yyyy-MM-dd")
sql = "update tb_loan set " &
"loan_date='" & loandate & "', " &
"book_id='" & txtBookID.Text & "', " &
"title='" & txtTitle.Text & "', " &
"stock='" & txtStock.Text & "', " &
"qty='" & txtLoanQuantity.Text & "', " &
"member_id='" & txtMemberID.Text & "', " &
"member_name='" & txtMemberName.Text & "', " &
"employee_id='" & txtEmployeeID.Text & "', " &
"employee_name='" & txtEmployeeName.Text & "', " &
"due_date='" & duedate & "'" &
"where loan_id='" & txtBookID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Ubah Data Berhasil")
Catch ex As Exception
MsgBox("Ubah Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles


btnDelete.Click
bukakoneksi()
sql = "delete from tb_loan where loan_id='" & txtLoanID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Hapus Data Berhasil")
Catch ex As Exception
MsgBox("Hapus Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles


btnCancel.Click
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


Me.Close()
End Sub

Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles


txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_loan where loan_date like '%" & txtSearch.Text & "%'"
&
"OR loan_id like '%" & txtSearch.Text & "%'" &
"OR book_id like '%" & txtSearch.Text & "%'" &
"OR title like '%" & txtSearch.Text & "%'" &
"OR stock like '%" & txtSearch.Text & "%'" &
"OR qty like '%" & txtSearch.Text & "%'" &
"OR member_id like '%" & txtSearch.Text & "%'" &
"OR member_name like '%" & txtSearch.Text & "%'" &
"OR employee_id like '%" & txtSearch.Text & "%'" &
"OR employee_name like '%" & txtSearch.Text & "%'" &
"OR due_date like '%" & txtSearch.Text & "%'"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Private Sub txtBookID_Click(sender As Object, e As EventArgs) Handles


txtBookID.Click
caribook.Show()
End Sub

Private Sub txtMemberID_Click(sender As Object, e As EventArgs) Handles


txtMemberID.Click
carimember.Show()
End Sub

Private Sub txtEmployeeID_Click(sender As Object, e As EventArgs) Handles


txtEmployeeID.Click
cariemployee.Show()
End Sub
End Class
Imports System.Data.SqlClient

Public Class caribook


Sub tampildata()
bukakoneksi()
sql = "select * from tb_book"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()

End Sub

Private Sub caribook_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
LoanTransaction.txtBookID.Text = DataGridView1.Item(0, i).Value.ToString
LoanTransaction.txtTitle.Text = DataGridView1.Item(1, i).Value.ToString
LoanTransaction.txtStock.Text = DataGridView1.Item(6, i).Value.ToString

End If
Me.Close()
End Sub

Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles


txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_book where title like '%" & txtSearch.Text & "%'" &
"OR book_id like '%" & txtSearch.Text & "%'" &
"OR category like '%" & txtSearch.Text & "%'" &
"OR author like '%" & txtSearch.Text & "%'" &
"OR publisher like '%" & txtSearch.Text & "%'" &
"OR year like '%" & txtSearch.Text & "%'" &
"OR stock like '%" & txtSearch.Text & "%'"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Private Sub DataGridView1_CellContentClick(sender As Object, e As


DataGridViewCellEventArgs) Handles DataGridView1.CellContentClick

End Sub
End Class
Imports System.Data.SqlClient

Public Class cariemployee


Sub tampildata()
bukakoneksi()
sql = "select * from tb_employee"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Private Sub cariemployee_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
LoanTransaction.txtEmployeeID.Text = DataGridView1.Item(0,
i).Value.ToString
LoanTransaction.txtEmployeeName.Text = DataGridView1.Item(1,
i).Value.ToString

End If
Me.Hide()
End Sub

Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles


txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_employee where employee_name like '%" & txtSearch.Text
& "%'" &
"OR employee_id like '%" & txtSearch.Text & "%'" &
"OR username like '%" & txtSearch.Text & "%'" &
"OR password like '%" & txtSearch.Text & "%'"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub
End Class
Imports System.Data.SqlClient

Public Class carimember


Sub tampildata()
bukakoneksi()
sql = "select * from tb_member"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Private Sub carimember_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
LoanTransaction.txtMemberID.Text = DataGridView1.Item(0, i).Value.ToString
LoanTransaction.txtMemberName.Text = DataGridView1.Item(1,
i).Value.ToString

End If
Me.Hide()
End Sub
Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles
txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_member where member_name like '%" & txtSearch.Text &
"%'" &
"OR member_id like '%" & txtSearch.Text & "%'" &
"OR address like '%" & txtSearch.Text & "%'" &
"OR hp like '%" & txtSearch.Text & "%'" &
"OR email like '%" & txtSearch.Text & "%'"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub
End ClassImports System.Data.SqlClient

Public Class carimember


Sub tampildata()
bukakoneksi()
sql = "select * from tb_member"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Private Sub carimember_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
LoanTransaction.txtMemberID.Text = DataGridView1.Item(0, i).Value.ToString
LoanTransaction.txtMemberName.Text = DataGridView1.Item(1,
i).Value.ToString

End If
Me.Hide()
End Sub
Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles
txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_member where member_name like '%" & txtSearch.Text &
"%'" &
"OR member_id like '%" & txtSearch.Text & "%'" &
"OR address like '%" & txtSearch.Text & "%'" &
"OR hp like '%" & txtSearch.Text & "%'" &
"OR email like '%" & txtSearch.Text & "%'"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub
End Class
Imports System.Data.SqlClient

Public Class ReturnTransaction


Sub tampildata()
bukakoneksi()
sql = "select * from tb_return"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Sub bersihkandata()
txtReturnID.Text = ""
txtLoanID.Text = ""
txtBookID.Text = ""
txtTitle.Text = ""
txtMemberID.Text = ""
txtMemberName.Text = ""
txtEmployeeID.Text = ""
txtEmployeeName.Text = ""
txtReturnQty.Text = ""
txtMoneyFine.Text = ""
End Sub

Sub kodeotomatis()
bukakoneksi()
sql = "select max(return_id) as return_id from tb_return"
comSQL = New SqlCommand(sql, conn)

Dim ds = comSQL.ExecuteReader
ds.Read()

If ds.HasRows = 0 Then
txtReturnID.Text = "LOAN-000001"
ds.Close()
End If

If Not ds.HasRows Then


txtReturnID.Text = "RTN-" + "000001"
ds.Close()

Else

txtReturnID.Text =
Val(Microsoft.VisualBasic.Mid(ds.Item("return_id").ToString, 6, 5)) + 1
If Len(txtReturnID.Text) = 1 Then
txtReturnID.Text = "RTN-00000" & txtReturnID.Text & ""
ElseIf Len(txtReturnID.Text) = 2 Then
txtReturnID.Text = "RTN-0000" & txtReturnID.Text & ""
ElseIf Len(txtReturnID.Text) = 3 Then
txtReturnID.Text = "RTN-000" & txtReturnID.Text & ""
ElseIf Len(txtReturnID.Text) = 4 Then
txtReturnID.Text = "RTN-00" & txtReturnID.Text & ""
ElseIf Len(txtReturnID.Text) = 5 Then
txtReturnID.Text = "RTN-0" & txtReturnID.Text & ""
End If
ds.Close()
End If
tutupkoneksi()
End Sub

Sub tombolaktif()
btnCancel.Enabled = True
btnDelete.Enabled = True
btnExit.Enabled = True
btnInsert.Enabled = True
btnUpdate.Enabled = True
End Sub

Sub tombolnonaktif()
btnCancel.Enabled = False
btnDelete.Enabled = False
btnExit.Enabled = False
btnInsert.Enabled = False
btnUpdate.Enabled = False
End Sub

Sub telat()
If dtpReturnDate.Value > dtpLoanDate.Value Then
Dim haritelat = DateDiff(DateInterval.Day, CDate(dtpDueDate.Value),
CDate(dtpReturnDate.Value))
txtLate.Text = haritelat
txtMoneyFine.Text = haritelat * 1000

Else

txtLate.Text = 0
txtMoneyFine.Text = 0
End If
End Sub

Private Sub ReturnTransaction_Load(sender As Object, e As EventArgs) Handles


Me.Load
tampildata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnInsert_Click(sender As Object, e As EventArgs) Handles


btnInsert.Click
If txtLoanID.Text = "" Or
txtBookID.Text = "" Or
txtTitle.Text = "" Or
txtMemberID.Text = "" Or
txtMemberName.Text = "" Or
txtEmployeeID.Text = "" Or
txtEmployeeName.Text = "" Or
dtpReturnDate.Text = "" Or
txtReturnQty.Text = "" Or
txtMoneyFine.Text = "" Then

MsgBox("Data Tidak Boleh Kosong!")

Else

bukakoneksi()
Dim returndate = Format(dtpReturnDate.Value, "yyyy-MM-dd")
sql = "INSERT INTO tb_return (return_id, loan_id, book_id, title,
member_id, member_name, employee_id, employee_name, return_date, return_qty,
money_fine) VALUES (" &
"'" & txtReturnID.Text & "', " &
"'" & txtLoanID.Text & "', " &
"'" & txtBookID.Text & "', " &
"'" & txtTitle.Text & "', " &
"'" & txtMemberID.Text & "', " &
"'" & txtMemberName.Text & "', " &
"'" & txtEmployeeID.Text & "', " &
"'" & txtEmployeeName.Text & "', " &
"'" & returndate & "', " &
"'" & txtReturnQty.Text & "', " &
"'" & txtMoneyFine.Text & "' )"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Simpan Berhasil")
Catch ex As Exception
MsgBox("Simpan Gagal" & ex.Message.ToString)
End Try

sql = "update tb_book set " &


"stock=stock+'" & txtReturnQty.Text & "'where book_id='" &
txtBookID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Ubah Data Berhasil")
Catch ex As Exception
MsgBox("Ubah Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End If
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
txtReturnID.Text = DataGridView1.Item(0, i).Value.ToString
txtLoanID.Text = DataGridView1.Item(1, i).Value.ToString
txtBookID.Text = DataGridView1.Item(2, i).Value.ToString
txtTitle.Text = DataGridView1.Item(3, i).Value.ToString
txtMemberID.Text = DataGridView1.Item(4, i).Value.ToString
txtMemberName.Text = DataGridView1.Item(5, i).Value.ToString
txtEmployeeID.Text = DataGridView1.Item(6, i).Value.ToString
txtEmployeeName.Text = DataGridView1.Item(7, i).Value.ToString
dtpReturnDate.Text = DataGridView1.Item(8, i).Value.ToString
txtReturnQty.Text = DataGridView1.Item(9, i).Value.ToString
txtMoneyFine.Text = DataGridView1.Item(10, i).Value.ToString

End If
tombolaktif()
btnInsert.Enabled = False
End Sub

Private Sub btnUpdate_Click(sender As Object, e As EventArgs) Handles


btnUpdate.Click
bukakoneksi()
Dim returndate = Format(dtpReturnDate.Value, "yyyy-MM-dd")
sql = "update tb_return set " &
"loan_id='" & txtLoanID.Text & "', " &
"book_id='" & txtBookID.Text & "', " &
"title='" & txtTitle.Text & "', " &
"member_id='" & txtMemberID.Text & "', " &
"member_name='" & txtMemberName.Text & "', " &
"employee_id='" & txtEmployeeID.Text & "', " &
"employee_name='" & txtEmployeeName.Text & "', " &
"return_date='" & returndate & "', " &
"return_qty='" & txtReturnQty.Text & "', " &
"money_fine='" & txtMoneyFine.Text & "'" &
"where return_id='" & txtReturnID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Ubah Data Berhasil")
Catch ex As Exception
MsgBox("Ubah Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnDelete_Click(sender As Object, e As EventArgs) Handles


btnDelete.Click
bukakoneksi()
sql = "delete from tb_return where return_id='" & txtReturnID.Text & "'"

comSQL = New SqlCommand(sql, conn)


Try
comSQL.ExecuteNonQuery()
MsgBox("Hapus Data Berhasil")
Catch ex As Exception
MsgBox("Hapus Data Gagal" & ex.Message.ToString)
End Try
tutupkoneksi()
tampildata()
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub btnCancel_Click(sender As Object, e As EventArgs) Handles


btnCancel.Click
bersihkandata()
kodeotomatis()
tombolaktif()
btnDelete.Enabled = False
btnUpdate.Enabled = False
End Sub

Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles


txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_return where loan_id like '%" & txtSearch.Text & "%'"
&
"OR return_id like '%" & txtSearch.Text & "%'" &
"OR book_id like '%" & txtSearch.Text & "%'" &
"OR title like '%" & txtSearch.Text & "%'" &
"OR member_id like '%" & txtSearch.Text & "%'" &
"OR member_name like '%" & txtSearch.Text & "%'" &
"OR employee_id like '%" & txtSearch.Text & "%'" &
"OR employee_name like '%" & txtSearch.Text & "%'" &
"OR return_date like '%" & txtSearch.Text & "%'" &
"OR return_qty like '%" & txtSearch.Text & "%'" &
"OR money_fine like '%" & txtSearch.Text & "%'"
Dim da As New SqlDataAdapter(sql, conn)
Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Private Sub txtLoanID_Click(sender As Object, e As EventArgs) Handles


txtLoanID.Click
cariloan.Show()
End Sub

Private Sub dtpReturnDate_ValueChanged(sender As Object, e As EventArgs) Handles


dtpReturnDate.ValueChanged
telat()
End Sub

Private Sub btnExit_Click(sender As Object, e As EventArgs) Handles btnExit.Click


Me.Close()
End Sub
End Class
Imports System.Data.SqlClient

Public Class cariloan


Sub tampildata()
bukakoneksi()
sql = "select * from tb_loan where loan_id not in(select loan_id from
tb_return)"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub

Private Sub cariloan_Load(sender As Object, e As EventArgs) Handles Me.Load


tampildata()
End Sub

Private Sub DataGridView1_Click(sender As Object, e As EventArgs) Handles


DataGridView1.Click
Dim jumlahdata
jumlahdata = DataGridView1.RowCount

If jumlahdata = 0 Then
MsgBox("Data Kosong")

Else

Dim i As Integer
i = DataGridView1.CurrentRow.Index
ReturnTransaction.txtLoanID.Text = DataGridView1.Item(0, i).Value.ToString
ReturnTransaction.dtpLoanDate.Text = DataGridView1.Item(1,
i).Value.ToString
ReturnTransaction.txtBookID.Text = DataGridView1.Item(2, i).Value.ToString
ReturnTransaction.txtTitle.Text = DataGridView1.Item(3, i).Value.ToString
ReturnTransaction.txtReturnQty.Text = DataGridView1.Item(5,
i).Value.ToString
ReturnTransaction.txtMemberID.Text = DataGridView1.Item(6,
i).Value.ToString
ReturnTransaction.txtMemberName.Text = DataGridView1.Item(7,
i).Value.ToString
ReturnTransaction.txtEmployeeID.Text = DataGridView1.Item(8,
i).Value.ToString
ReturnTransaction.txtEmployeeName.Text = DataGridView1.Item(9,
i).Value.ToString
ReturnTransaction.dtpDueDate.Text = DataGridView1.Item(10,
i).Value.ToString

End If
ReturnTransaction.telat()
Me.Close()
End Sub

Private Sub txtSearch_TextChanged(sender As Object, e As EventArgs) Handles


txtSearch.TextChanged
bukakoneksi()
sql = "select * from tb_loan where loan_id like '%" & txtSearch.Text & "%'" &
"AND loan_id not in (select loan_id from tb_return)"

Dim da As New SqlDataAdapter(sql, conn)


Dim ds As New DataSet
da.Fill(ds)
Dim dt As New DataTable

For Each dt In ds.Tables


DataGridView1.DataSource = dt
Next
tutupkoneksi()
End Sub
End Class
Imports System.Data.SqlClient

Public Class Login

Private Sub btnEnter_Click(sender As Object, e As EventArgs) Handles


btnEnter.Click
If txtUsername.Text = "" Or
txtPassword.Text = "" Then

MsgBox("Data Tidak Boleh Kosong!")

Else

bukakoneksi()
sql = "select * from tb_employee where username='" & txtUsername.Text &
"'AND password='" & txtPassword.Text & "'"

comSQL = New SqlCommand(sql, conn)

Dim ds = comSQL.ExecuteReader
ds.Read()

If ds.HasRows = 0 Then
MsgBox("Username atau Password Salah")
End If

MainMenu.Show()
Me.Hide()
tutupkoneksi()
End If
End Sub

Private Sub cbShowPassword_CheckedChanged(sender As Object, e As EventArgs)


Handles cbShowPassword.CheckedChanged
If cbShowPassword.Checked = True Then
txtPassword.PasswordChar = ""

Else

cbShowPassword.Checked = False
txtPassword.PasswordChar = "*"
End If
End Sub

End Class
Imports System.Data.SqlClient
Public Class MainMenu
Sub aplikasikeluar()
Member.Close()
Employee.Close()
Book.Close()
LoanTransaction.Close()
ReturnTransaction.Close()
End Sub

Private Sub MenuMember_Click(sender As Object, e As EventArgs) Handles


MenuMember.Click
aplikasikeluar()
Member.MdiParent = Me
Member.Show()
End Sub

Private Sub MenuEmployee_Click(sender As Object, e As EventArgs) Handles


MenuEmployee.Click
aplikasikeluar()
Employee.MdiParent = Me
Employee.Show()
End Sub

Private Sub MenuBook_Click(sender As Object, e As EventArgs) Handles


MenuBook.Click
aplikasikeluar()
Book.MdiParent = Me
Book.Show()
End Sub

Private Sub MenuLoan_Click(sender As Object, e As EventArgs) Handles


MenuLoan.Click
aplikasikeluar()
LoanTransaction.MdiParent = Me
LoanTransaction.Show()
End Sub

Private Sub MenuReturn_Click(sender As Object, e As EventArgs) Handles


MenuReturn.Click
aplikasikeluar()
ReturnTransaction.MdiParent = Me
ReturnTransaction.Show()
End Sub

Private Sub MenuExit_Click(sender As Object, e As EventArgs) Handles


MenuExit.Click
Me.Close()
End Sub
End Class

You might also like