You are on page 1of 8

[Home Logout]

1 Private Sub LogOutToolStripMenuItem_Click


(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles LogOutToolStripMenuItem.Click
2 Dim response As MsgBoxResult
3 response = MsgBox("Apakah anda yakin akan
keluar dari akun?", MsgBoxStyle.Question
+ MsgBoxStyle.YesNo,"Information")
4 If response = MsgBoxResult.Yes Then
5 Me.Dispose()
6 login.Show()
7 login.TextBox1.Text = ""
8 login.TextBox2.Text = ""
9 ElseIf response = MsgBoxResult.No Then
10 Exit Sub
11 End If
12 End Sub

[Input]
1 Private Sub Button1_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
2 Try
3 T_bukuTableAdapter.simpan
(Id_bukuTextBox.Text, JudulTextBox.Text,
PengarangTextBox.Text, PenerbitTextBox.Text,
Tahun_terbitDateTimePicker.Text,
Kd_isbnTextBox.Text,
JumlahTextBox.Text, LokasiTextBox.Text)
4 Me.T_bukuTableAdapter.Fill
(Me.PerpustakaanDataSet.t_buku)
5 MsgBox("data berhasil disimpan")
6 Catch ex As Exception
7 MsgBox("data tidak tersimpan",
MsgBoxStyle.Critical, "information")
8 End Try
9 End Sub
[Hapus]
1 Private Sub Button2_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
2 Try
3 T_bukuTableAdapter.hapus
(Id_bukuTextBox.Text)
4 Me.T_bukuTableAdapter.Fill
(Me.PerpustakaanDataSet.t_buku)
5 MsgBox("data berhasil dihapus")
6 Catch ex As Exception
7 MsgBox("data tidak terhapus",
MsgBoxStyle.Critical,"information")
8 End Try
9 End Sub
[Edit]
1 Private Sub Button3_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
2 Try
3 T_bukuTableAdapter.edit
(Id_bukuTextBox.Text,
JudulTextBox.Text,
PengarangTextBox.Text,
PenerbitTextBox.Text,
Tahun_terbitDateTimePicker.Text,
Kd_isbnTextBox.Text, JumlahTextBox.Text,
LokasiTextBox.Text, Id_bukuTextBox.Text)
4 Me.T_bukuTableAdapter.Fill
(Me.PerpustakaanDataSet.t_buku)
5 MsgBox("data berhasil diubah")
6 Catch ex As Exception
7 MsgBox("data tidak terubah",
MsgBoxStyle.Critical, "information")
8 End Try
9 End Sub
[Cari]
1 Private Sub TextBox1_KeyDown(ByVal sender
As System.Object, ByVal e As
System.Windows.Forms.KeyEventArgs)
Handles TextBox1.KeyDown
2 If e.KeyCode = Keys.Enter Then
3 Dim dt = T_bukuTableAdapter.
GetDataBy3cari_buku
(TextBox1.Text)
4 If dt.Rows.Count = 0 Then
5 MsgBox("data tidak ditemukan",
MsgBoxStyle.Critical,
"information")
6 Else
7 Me.T_bukuTableAdapter.FillBycari_buku
(Me.PerpustakaanDataSet.t_buku, TextBox1.Text)

8 End If
9 End If
10 End Sub
[Login]
1 Private Sub Button1_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles Button1.Click
2 Call koneksi()
3 cmd = New SqlCommand("select * from t_login
where Username = '" & TextBox1.Text
& "' and Password = '" & TextBox2.Text
& "'", conn)
4 dr = cmd.ExecuteReader
5 dr.Read()

6 If Not dr.HasRows Then


7 MsgBox("login gagal",
MsgBoxStyle.Critical, "information")
8 TextBox1.Clear()
9 TextBox2.Clear()
10 Else
11 Beranda.panel1.Text = dr.Item("Username")
12 Beranda.panel2.Text = dr.Item("hak_akses")
13 Beranda.Label5.Text = dr.Item("Username")
14 If Beranda.panel2.Text = ("admin") Then
15 Me.Hide()
16 Beranda.Show()
17 MsgBox("Anda berhasil login
sebagai admin")
18 Beranda.Text = "admin"
19 ElseIf Beranda.panel2.Text = ("user") Then
20 Me.Hide()
21 Beranda.Show()
22 MsgBox("Anda berhasil login
sebagai user")
23 Beranda.Text = "user"
24 Beranda.InputBukuToolStripMenuItem.
Enabled= False
25 Beranda.InputAnggotaToolStrip
MenuItem.Enabled = False
26 Beranda.UserToolStripMenuItem.Enabled
= False
27 End If
28 End If
29 End Sub
[Kembali]

1 Private Sub Button2_Click(ByVal sender


As System.Object, ByVal e As System.EventArgs)
Handles Button2.Click
2 Try
3 T_transaksi_masterTableAdapter.
edit_kembalikan_buku(DendaLabel1.
Text, Nmr_transaksiTextBox.Text)
4 T_transaksi_detailTableAdapter.
UpdateQueryketerangan("dikembalikan",
Id_transaksiLabel1.Text)
5 T_bukuTableAdapter.nambah_stok("1",
Kd_bukuLabel1.Text)
6 If Me.View_pengembalianTableAdapter.
FillByketerangan(Me.Perpus1DataSet.
View_pengembalian,
Nmr_transaksiTextBox.Text) Then
7 Me.View_perpusTableAdapter.
testketrangan(Me.Perpus1DataSet.
view_perpus,
Nmr_transaksiTextBox.Text)
8 MsgBox("berhasil")
9 Nmr_transaksiTextBox.Text =
View_pengembalianDataGridView.
SelectedCells(1).Value
10 Me.View_perpusTableAdapter.
testketrangan(Me.Perpus1DataSet.
view_perpus,
Nmr_transaksiTextBox.Text)
11 Label6.Text = View_perpusTableAdapter.

total_buku(Nmr_transaksiTextBox.Text)
12 Label12.Text =
View_pengembalianTableAdapter.

totaldenda(View_pengembalianDataGridView.
SelectedCells(1).Value)
13 End If
'Me.View_perpusTableAdapter.testketrangan
(Me.Perpus1DataSet.view_perpus,
Nmr_transaksiTextBox.Text)
'Me.View_perpusTableAdapter.
FillByketeranganperpus
(Me.Perpus1DataSet.
view_perpus, Nmr_transaksiTextBox.Text,
Label8.Text)
14 Catch ex As Exception
15 Label6.Text = "0"
16 End Try
17 End Sub
[Pinjam Buku]
1 Private Sub Button3_Click(ByVal sender
As System.Object, ByVal e As System.EventArgs)
Handles Button3.Click
2 Try
3 Dim stok = cekbuku(Kd_bukuTextBox.Text)
4 If stok <= 0 Then
5 MsgBox("stok habis")
6 Else
7 T_transaksi_detailTableAdapter.
simpan_detail(Kd_bukuTextBox.Text,
JudulLabel1.Text, "1",
Nmr_transaksiTextBox.Text,"dipinjam")
8 MsgBox("berhasil meminjam")
9 T_transaksi_masterTableAdapter.
edit_transaksi(NisLabel1.Text,
Tgl_pinjamDateTimePicker.
Value, Tgl_kembaliDateTimePicker.
Value, Nmr_transaksiTextBox.Text)
10 Me.View_perpusTableAdapter.

FillBycari_nmr_transaksi(Me.Perpus1DataSet.
view_perpus,
Nmr_transaksiTextBox.Text)
11 T_bukuTableAdapter.kurang_stok("1",
Kd_bukuTextBox.Text)
12 End If
13 Catch ex As Exception
14 MsgBox(ex.Message)
15 End Try
16 End Sub

You might also like