0% found this document useful (0 votes)
4 views

Coding Public Class Frmkontak

The document is a Visual Basic class for a contact management form, which includes methods to clear, enable, and disable form fields, as well as to display, add, edit, and save contact data to a database. It handles user interactions such as loading the form, adding new contacts, editing existing ones, and displaying data in a DataGridView. The form ensures data integrity by checking for completeness before saving or updating records.

Uploaded by

mu13ni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Coding Public Class Frmkontak

The document is a Visual Basic class for a contact management form, which includes methods to clear, enable, and disable form fields, as well as to display, add, edit, and save contact data to a database. It handles user interactions such as loading the form, adding new contacts, editing existing ones, and displaying data in a DataGridView. The form ensures data integrity by checking for completeness before saving or updating records.

Uploaded by

mu13ni
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Public Class frmkontak

Sub kosongkanform()
txtKode.Text = ""
txtNama.Text = ""
txtTelp.Text = ""
txtGmail.Text = ""
txtAlamat.text = ""
txtKode.Focus()
End Sub

Sub Matikanform()
txtKode.Enabled = False
txtNama.Enabled = False
cmbKelamin.Enabled = False
txtTelp.Enabled = False
txtGmail.Enabled = False
txtAlamat.Enabled = False
End Sub

Sub Hidupkanform()
txtKode.Enabled = True
txtNama.Enabled = True
cmbKelamin.Enabled = True
txtTelp.Enabled = True
txtGmail.Enabled = True
txtAlamat.Enabled = True
End Sub

Sub tampilkandata()
Call KoneksiDB()
DA = New OleDb.OleDbDataAdapter("select * from Kontak", CONN)
DS = New DataSet
DA.Fill(DS)
DGV.DataSource = DS.Tables(0)
DGV.ReadOnly = True
End Sub

Private Sub frmkontak_Load(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MyBase.Load
Call Matikanform()
Call tampilkandata()

End Sub

Private Sub btnKeluar_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnKeluar.Click
Me.Close()
End Sub

Private Sub btnTambah_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnTambah.Click
Call Hidupkanform()
Call kosongkanform()

End Sub

Private Sub btnBatal_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnBatal.Click
Call Matikanform()
Call kosongkanform()

End Sub
Private Sub btnSimpan_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSimpan.Click
If txtKode.Text = "" Or txtNama.Text = "" Or cmbKelamin.Text = "" Then
MsgBox("Data Belum Lengkap")
Exit Sub
Else
Call KoneksiDB()
CMD = New OleDb.OleDbCommand("select * from kontak where kode='" &
txtKode.Text & "'", CONN)
DR = CMD.ExecuteReader
DR.Read()
If Not DR.HasRows Then
Call KoneksiDB()
Dim simpan As String
simpan = "insert into kontak values('" & txtKode.Text & "', '" &
txtNama.Text & "','" & cmbKelamin.Text & "','" & txtTelp.Text & "','" &
txtGmail.Text & "','" & txtAlamat.Text & "') "
CMD = New OleDb.OleDbCommand(simpan, CONN)
CMD.ExecuteNonQuery()
MsgBox("InputBox Data Sukses")
Else
MsgBox("Kode teman Sudah ada")
End If
Call Matikanform()
Call kosongkanform()
Call tampilkandata()

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
txtKode.Text = DGV.Rows(e.RowIndex).Cells(0).Value
txtNama.Text = DGV.Rows(e.RowIndex).Cells(1).Value
cmbKelamin.Text = DGV.Rows(e.RowIndex).Cells(2).Value
txtTelp.Text = DGV.Rows(e.RowIndex).Cells(3).Value
txtGmail.Text = DGV.Rows(e.RowIndex).Cells(4).Value
txtAlamat.Text = DGV.Rows(e.RowIndex).Cells(5).Value
Call Hidupkanform()
txtKode.Enabled = False
End Sub

Private Sub btnEdit_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles btnEdit.Click
If txtKode.Text = "" Or txtNama.Text = "" Or cmbKelamin.Text = "" Then
MsgBox("Data Belum Lengkap")
Exit Sub
Else
Call KoneksiDB()
CMD = New OleDb.OleDbCommand("update kontak set nama_teman='" &
txtNama.Text & "',jenis_kelamin='" & cmbKelamin.Text & "',n0_telepon='" &
txtTelp.Text & "',gmail='" & txtGmail.Text & "',alamat_rumah='" & txtAlamat.Text
& "' where kode='" & txtKode.Text & "'", CONN)
CMD.ExecuteNonQuery()
MsgBox(" Update Data Sukses")
End If
Call Matikanform()
Call kosongkanform()
Call tampilkandata()

End Sub
End Class

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy