kursus

3
Ahmad Mustaqim | 12100408 kursus 1 MODUL Public dbado As New ADODB.Connection Public rssiswa As New ADODB.Recordset Public rsbayar As New ADODB.Recordset Public rsdetail As New ADODB.Recordset Public Sub koneksi() If dbado.State = adStateOpen Then dbado.Close End If dbado.ConnectionString = "provider=MSDASQL.1;persist security info=false;data source=kursus" dbado.Open End Sub LISTING Sub nonaktif() tkode.Enabled = False tnis.Enabled = False tnama.Enabled = False cmapel.Enabled = False tnominal.Enabled = False binputlagi.Enabled = False bcancel.Enabled = False bsave.Enabled = False End Sub Sub aktif() tkode.Enabled = True tnis.Enabled = True tnama.Enabled = True cmapel.Enabled = True tnominal.Enabled = True binputlagi.Enabled = True bcancel.Enabled = True bsave.Enabled = True End Sub Sub bersih() tkode = "" tnis = "" tnama = "" cmapel.Text = "" tnominal = "" End Sub Sub kd() Dim code, a, b As String code = "SELECT * from bayar" Set rsbayar = dbado.Execute(code, , adCmdText) If rsbayar.BOFAndrsbayar.EOF Then tkode.Text = "B" &Format(Date, "yymm") & "001" Else a = 0 rsbayar.MoveFirst Do Until rsbayar.EOF a = a + 1

Upload: ahmad-mustaqim

Post on 12-Jul-2015

527 views

Category:

Education


2 download

TRANSCRIPT

Page 1: Kursus

Ahmad Mustaqim | 12100408 kursus

1

MODUL

Public dbado As New ADODB.Connection

Public rssiswa As New ADODB.Recordset

Public rsbayar As New ADODB.Recordset

Public rsdetail As New ADODB.Recordset

Public Sub koneksi()

If dbado.State = adStateOpen Then

dbado.Close

End If

dbado.ConnectionString = "provider=MSDASQL.1;persist security info=false;data source=kursus"

dbado.Open

End Sub

LISTING

Sub nonaktif()

tkode.Enabled = False

tnis.Enabled = False

tnama.Enabled = False

cmapel.Enabled = False

tnominal.Enabled = False

binputlagi.Enabled = False

bcancel.Enabled = False

bsave.Enabled = False

End Sub

Sub aktif()

tkode.Enabled = True

tnis.Enabled = True

tnama.Enabled = True

cmapel.Enabled = True

tnominal.Enabled = True

binputlagi.Enabled = True

bcancel.Enabled = True

bsave.Enabled = True

End Sub

Sub bersih()

tkode = ""

tnis = ""

tnama = ""

cmapel.Text = ""

tnominal = ""

End Sub

Sub kd()

Dim code, a, b As String

code = "SELECT * from bayar"

Set rsbayar = dbado.Execute(code, , adCmdText)

If rsbayar.BOFAndrsbayar.EOF Then

tkode.Text = "B" &Format(Date, "yymm") & "001"

Else

a = 0

rsbayar.MoveFirst

Do Until rsbayar.EOF

a = a + 1

Page 2: Kursus

Ahmad Mustaqim | 12100408 kursus

2

rsbayar.MoveNext

Loop

a = a + 1

b = Len(Str(a))

tkode.Text = "B" &Format(Date, "yymm") & Mid$("000", 1, 4 - b) & a

End If

End Sub

Sub tabel()

sqlbayar = "select * from detail_bayar"

Set rsdetail = dbado.Execute(sqlbayar, , adCmdText)

Set Grid1.DataSource = rsdetail

End Sub

Private Sub bcancel_Click()

sqldel = "delete from detail_bayar where kode='" &tkode.Text& "'"

Set rsdetail = dbado.Execute(sqldel, , adCmdText)

tabel

bersih

nonaktif

End Sub

Private Sub bclose_Click()

X = MsgBox("YAkinmaukeluar form?", vbYesNo, "konfirmasi")

If X = vbYes Then

End

End If

End Sub

Private Sub binputlagi_Click()

sdetail = "insert into detail_bayar ()values('" &tkode.Text& "','" &cmapel.Text& "','" &tnominal.Text& "')"

Set rsdetail = dbado.Execute(sdetail, , adCmdText)

tabel

cmapel.Text = ""

tnominal.Text = ""

cmapel.SetFocus

End Sub

Private Sub bnew_Click()

aktif

bersih

kd

tnis.SetFocus

End Sub

Private Sub bsave_Click()

Dim save As String

If tnis.Text = "" Then

MsgBox ("DATA BELUNG LENGKAP!Silahkan input nislalu ENTER")

tnis.SetFocus

Else

If tnama.Text = "" Then

MsgBox ("DATA BELUNG LENGKAP!Silahkan input nislalu ENTER")

tnis.SetFocus

Else

If cmapel.Text = "" Then

MsgBox ("DATA BELUNG LENGKAP")

cmapel.SetFocus

Else

Page 3: Kursus

Ahmad Mustaqim | 12100408 kursus

3

If tnominal.Text = "" Then

MsgBox" DATA BELUNG LENGKAP"

tnominal.SetFocus

Else

save = "insert into bayar ()values('" &tkode.Text& "','" &tnis.Text& "','" &LBLTANGGAL.Caption& "')"

Set rsbayar = dbado.Execute(save, , adCmdText)

sdetail = "insert into detail_bayar ()values('" &tkode.Text& "','" &cmapel.Text& "','" &tnominal.Text& "')"

Set rsdetail = dbado.Execute(sdetail, , adCmdText)

MsgBox "Data Tersimpan"

tabel

nonaktif

End If

End If

End If

End If

End Sub

Private Sub cmapel_Click()

ck = "select * from detail_bayar where kode='" &tkode.Text& "' and matpel='" &cmapel.Text& "'"

Set rsdetail = dbado.Execute(ck, , adCmdText)

If rsdetail.BOFAndrsdetail.EOF Then

tnominal.SetFocus

Else

MsgBox " Mapel '" &cmapel.Text& "' SUDAH Di bayar!"

cmapel.SetFocus

End If End Sub

Private Sub Form_Activate()

nonaktif

LBLTANGGAL.Caption = Format(Date, "yyyy-mm-dd")

cmapel.AddItem ("Matematika")

cmapel.AddItem ("B.Inggris")

cmapel.AddItem ("B.Indonesia")

cmapel.AddItem ("Komputer")

cmapel.AddItem ("IPA")

cmapel.AddItem ("IPS")

tabel

End Sub

Private Sub Form_Load()

koneksi

End Sub

Private Sub tnis_KeyPress(KeyAscii As Integer)

If KeyAscii = 13 Then

nis = "select*from siswa where nis='" &tnis.Text& "'"

Set rssiswa = dbado.Execute(nis, , adCmdText)

If rssiswa.EOF Then

MsgBox "NIS "&tnis.Text& " tidakditemukan! Silahkancoba NIS lain!"

tnis = ""

tnis.SetFocus

Else

tnama = rssiswa!nama

cmapel.SetFocus

End If

End If

End Sub