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

Default CLSKTP Eventargs

This code defines functions to perform CRUD (create, read, update, delete) operations on province and identity card (KTP) data stored in a SQL database. It includes functions to search for, save, update, delete province records, as well as save KTP records and calculate answers to a math quiz. Based on a parameter passed in the request, the appropriate function is called to perform the requested operation and return the output.

Uploaded by

Lutfi Bahri
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views

Default CLSKTP Eventargs

This code defines functions to perform CRUD (create, read, update, delete) operations on province and identity card (KTP) data stored in a SQL database. It includes functions to search for, save, update, delete province records, as well as save KTP records and calculate answers to a math quiz. Based on a parameter passed in the request, the appropriate function is called to perform the requested operation and return the output.

Uploaded by

Lutfi Bahri
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 2

Partial Class _Default

Inherits System.Web.UI.Page
Dim c As New ClsKTP

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles


Me.Load
Dim tampilkan As String = Request("buka") & ""

Select Case tampilkan


Case "cari_provinsi"
Response.Write(SEARCH_PROV)
Case "simpan_provinsi"
Response.Write(SAVE_PROV)
Case "hapus_provinsi"
Response.Write(DELETE_PROV)
Case "ubah_provinsi"
Response.Write(UPDATE_PROV)
Case "jawabanuts"
Response.Write(JAWABAN_UTS)

Case "simpan_ktp"
Response.Write(SAVE_KTP)
End Select
End Sub
Function SEARCH_PROV() As String
Dim aISI As String = ""
c.dbs = New System.Data.SqlClient.SqlConnection(c.strCon)
c.cmd.Connection = c.dbs
c.cmd.CommandType = Data.CommandType.Text
c.cmd.CommandText = "select * from tblProvinsi"

c.cmd.Connection.Open()

c.rst = c.cmd.ExecuteReader()
Do While c.rst.Read
aISI = aISI & c.rst!KDPROV & "|" & c.rst!nmprv & ";"
Loop
c.cmd.Connection.Close()
Return aISI
End Function
Function JAWABAN_UTS() As String
Dim unit As Integer = Request("unit")
Dim satuan As Long = Request("harga")
Dim bunga As Double = Request("bunga")
Dim lama As Integer = Request("lama")
Dim total As Double

Dim crBunga As Double


crBunga = (unit * satuan) * (bunga / 12 / 100)
crBunga = crBunga * lama
total = (unit * satuan) + crBunga

Return "Jumlah Pembelian= " & unit * satuan & " Total Bunga = " & crBunga & "
Total Pembelian = " & total

End Function
Function SAVE_PROV() As String
c.dbs = New System.Data.SqlClient.SqlConnection(c.strCon)
c.cmd.Connection = c.dbs
c.cmd.CommandType = Data.CommandType.Text
c.cmd.CommandText = "insert INTO tblProvinsi values(" & Request("idpro") & _
",'" & Request("nama") & "')"
c.cmd.Connection.Open()
c.cmd.ExecuteNonQuery()
c.cmd.Connection.Close()
Return "SUKSES"

End Function
Function UPDATE_PROV() As String
c.dbs = New System.Data.SqlClient.SqlConnection(c.strCon)
c.cmd.Connection = c.dbs
c.cmd.CommandType = Data.CommandType.Text
c.cmd.CommandText = "update tblProvinsi set nmprov='" & Request("nama") & _
"' WHERE KDPROV=" & Request("idpro")
c.cmd.Connection.Open()
c.cmd.ExecuteNonQuery()
c.cmd.Connection.Close()
Return "SUKSES"
End Function
Function DELETE_PROV() As String
c.dbs = New System.Data.SqlClient.SqlConnection(c.strCon)
c.cmd.Connection = c.dbs
c.cmd.CommandType = Data.CommandType.Text
c.cmd.CommandText = "delete tblProvinsi where kdprov=" & Request("idpro")
c.cmd.Connection.Open()
c.cmd.ExecuteNonQuery()
c.cmd.Connection.Close()
Return "SUKSES"
End Function
Function SAVE_KTP() As String
c.dbs = New System.Data.SqlClient.SqlConnection(c.strCon)
c.cmd.Connection = c.dbs
c.cmd.CommandType = Data.CommandType.Text
c.cmd.CommandText = "insert INTO
tblKTP(nik,nama.tmplahir,tgllahir,alamat,kelamin,darah,agama,status,kerja,warga,berlaku
values('" & _
Request("p1") & "','" & Request("p2") & "','" & Request("p3")
& "','" & Request("p4") & "','" & Request("p5")& _
"','" & Request("p6") & "','" & Request("p7") & "','" &
Request("p8") & "','" & Request("p9") & "','" & Request("p10") & _
"','" & Request("p11") & "','" & Request("p12") &")"
c.cmd.Connection.Open()
c.cmd.ExecuteNonQuery()
c.cmd.Connection.Close()
Return "SUKSES"

End Function

End Class

You might also like