Selasa, 27 Maret 2012

VISUAL BASIC MELALUI SQL SERVER


"FRMMENU"


RUMUS:


Private Sub Form_Load()
MDATA.Visible = False
MLAPORAN.Visible = False
MTRANSAKSI.Visible = False
End Sub


Private Sub MDOSEN_Click()
FrmDosen.Show
End Sub

Private Sub MLAT1_Click()
frmlat1.Show
End Sub

Private Sub MLAT2_Click()
Frmlat2.Show
End Sub

Private Sub MLAT3_Click()
frmlat3.Show
End Sub

Private Sub MLAT4_Click()
Frmlat4.Show
End Sub

Private Sub MLAT5_Click()
FrmLat5.Show
End Sub

Private Sub MLAT6_Click()
FRMLAT6.Show
End Sub

Private Sub MLAT7_Click()
Frmlat7.Show
End Sub

Private Sub MLOGIN_Click()
Frmlogin.Show

End Sub

Private Sub MLOGOUT_Click()
MDATA.Visible = False
MTRANSAKSI.Visible = False
MLAPORAN.Visible = False
Load Me

FRMMENU.MLOGIN.Visible = True
FRMMENU.MLOGOUT.Visible = False 
End Sub

Private Sub MMAHASISWA_Click()
FrmMahasiswa.Show
End Sub

Private Sub MMATAKULIAH_Click()
FrmMatakuliyah.Show
End Sub
Private Sub Timer1_Timer()
Text3 = Format(Now, "DD/MM/YY")
Text4 = Format(Now, "HH:MM:SS")
End Sub

"FRMLOGIN"



RUMUS:

Private Sub Command1_Click()
If Text1 = "" Then
MsgBox ("user name tidak boleh kosong")
Text1.SetFocus
Exit Sub
End If

If Text2 = "" Then
MsgBox ("password tidak boleh di kosongkan")
Text2.SetFocus
Exit Sub
End If

rslogin.CommandType = adCmdText
rslogin.RecordSource = "select * from bagian where username='" & Text1 & " ' and Password =  '" & Text2 & "'"

rslogin.Refresh
If rslogin.Recordset.EOF Then
MsgBox ("username atau password ada kesalahan")
Text1 = Clear
Text2 = Clear
Text1.SetFocus
Else
MsgBox ("vertifikasi password benar")

Unload Me

FRMMENU.MDATA.Visible = True
FRMMENU.MTRANSAKSI.Visible = True
FRMMENU.MLAPORAN.Visible = True
End If

FRMMENU.Text5 = rslogin.Recordset.Fields(1)
FRMMENU.Text6 = rslogin.Recordset.Fields(2)

End Sub

Private Sub Command2_Click()
Frmlogin.Hide
End Sub

Private Sub Form_Load()
Text1 = Clear
Text2 = Clear
rslogin.Refresh
End Sub


"FRMMATAKULIAH"












RUMUS:

Private Sub CETAK_Click()
tri.ReportFileName = App.Path + "/lapmatakuliyah.RPT"
tri.RetrieveDataFiles
tri.WindowState = crptMaximized
tri.Action = 1
End Sub

Private Sub CMDBARU_Click()
BERSIH
Text1 = Clear
Text1.SetFocus

End Sub

Private Sub CMDBATAL_Click()
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
CMDSIMPAN.Enabled = False
BERSIH
TAMPILDATA
End Sub

Private Sub CMDEDIT_Click()
RSMatakuliyah.Recordset.Fields(1) = Combo1
RSMatakuliyah.Recordset.Fields(2) = Combo2
RSMatakuliyah.Recordset.Update
MsgBox ("Data telah di perbaiki")
RSMatakuliyah.Refresh
TAMPILDATA
End Sub

Private Sub CMDHAPUS_Click()
A = MsgBox("YAKINKAH INGIN DI HAPUS?", vbYesNo, "")
If A = vbYes Then
    RSMAHASISWA.Recordset.Delete
    RSMAHASISWA.Refresh
Else
Cancel = True
End If
Text1 = Clear
Combo1.SetFocus
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
CMDSIMPAN.Enabled = False
BERSIH
TAMPILDATA
End Sub

Private Sub CMDSIMPAN_Click()
If Text1 = "" Then
MsgBox (" NID SKUL harap di isi")
Exit Sub
End If
If Combo1 = "" Then
MsgBox (" MATAKULIYAH harap di isi")
Exit Sub
End If
If Combo2 = "" Then
MsgBox ("JENIS harap di isi")
Exit Sub
End If
RSMatakuliyah.Recordset.AddNew
RSMatakuliyah.Recordset.Fields(0) = Text1
RSMatakuliyah.Recordset.Fields(1) = Combo1
RSMatakuliyah.Recordset.Fields(2) = Combo2
RSMatakuliyah.Recordset.Update
MsgBox ("DATA BERHASIL DI SIMPAN")
RSMatakuliyah.Refresh
BERSIH
TAMPILDATA
End Sub

Private Sub Form_Load()
RSMatakuliyah.Refresh
Text1.MaxLength = 3
BERSIH
End Sub
Private Sub TAMPILDATA()
RSMatakuliyah.CommandType = adCmdText
RSMatakuliyah.RecordSource = "Select * from MATAKULIYAH"
RSMatakuliyah.Refresh
DataGrid1.Refresh
End Sub

Private Sub BERSIH()
Text1 = Clear
Combo2 = Clear
Combo1 = Clear

End Sub

Private Sub Label1_Click()

End Sub

Private Sub Text1_Change()
Dim panjang As Byte
panjang = Len(Text1)
If panjang < 3 Then
    Exit Sub
End If
RSMatakuliyah.CommandType = adCmdText
RSMatakuliyah.RecordSource = "select*from matakuliyah Where IDSKUL ='" & Text1 & "'"

RSMatakuliyah.Refresh

If Not RSMatakuliyah.Recordset.EOF Then
MsgBox ("ID SKUL SUDAH ADA")

Combo1 = RSMatakuliyah.Recordset.Fields(1)
Combo2 = RSMatakuliyah.Recordset.Fields(2)

CMDSIMPAN.Enabled = False
CMDHAPUS.Enabled = True
CMDEDIT.Enabled = True
Else
BERSIH
Combo1.SetFocus
CMDSIMPAN.Enabled = True
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
End If
End Sub


"FRMMAHASISWA"









RUMUS:


Private Sub CETAK_Click()
x
End Sub

Private Sub CMDBARU_Click()
BERSIH
Text1 = Clear
Text1.SetFocus

End Sub

Private Sub CMDBATAL_Click()
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
CMDSIMPAN.Enabled = False
BERSIH
TAMPILDATA
End Sub
Private Sub TAMPILDATA()
RSMAHASISWA.CommandType = adCmdText
RSMAHASISWA.RecordSource = "Select * from MAHASISWA"
RSMAHASISWA.Refresh
DataGrid1.Refresh
End Sub

Private Sub CMDCETAK_Click()
tri.ReportFileName = App.Path + "/lapmahasiswa.RPT"
tri.RetrieveDataFiles
tri.WindowState = crptMaximized
tri.Action = 1
End Sub

Private Sub CMDEDIT_Click()
RSMAHASISWA.Recordset.Fields(1) = Text2
RSMAHASISWA.Recordset.Fields(2) = Text3
RSMAHASISWA.Recordset.Fields(3) = Text4
RSMAHASISWA.Recordset.Fields(4) = DTPicker1.Value
RSMAHASISWA.Recordset.Fields(5) = Text6
RSMAHASISWA.Recordset.Fields(6) = Text7
RSMAHASISWA.Recordset.Fields(7) = Text8
RSMAHASISWA.Recordset.Fields(8) = Text9
RSMAHASISWA.Recordset.Update
MsgBox ("Data Telah DiPerbaiki")
RSMAHASISWA.Refresh
TAMPILDATA
End Sub

Private Sub CMDHAPUS_Click()
A = MsgBox("YAKINKAH INGIN DI HAPUS?", vbYesNo, "")
If A = vbYes Then
    RSMAHASISWA.Recordset.Delete
    RSMAHASISWA.Refresh
Else
Cancel = True
End If
Text1 = Clear
Text2.SetFocus
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
CMDSIMPAN.Enabled = False
BERSIH
TAMPILDATA

End Sub

Private Sub CMDSIMPAN_Click()
If Text1 = "" Then
    MsgBox ("NS Harap Di isi")
    Exit Sub
End If
If Text2 = "" Then
    MsgBox ("Nama Harap Di isi")
    Exit Sub
End If
RSMAHASISWA.Recordset.AddNew
RSMAHASISWA.Recordset.Fields(0) = Text1
RSMAHASISWA.Recordset.Fields(1) = Text2
RSMAHASISWA.Recordset.Fields(2) = Text3
RSMAHASISWA.Recordset.Fields(3) = Text4
RSMAHASISWA.Recordset.Fields(4) = DTPicker1.Value
RSMAHASISWA.Recordset.Fields(5) = Text6
RSMAHASISWA.Recordset.Fields(6) = Text7
RSMAHASISWA.Recordset.Fields(7) = Text8
RSMAHASISWA.Recordset.Fields(8) = Text9
RSMAHASISWA.Recordset.Update
MsgBox ("Data Telah Disimpan")
RSMAHASISWA.Refresh
TAMPILDATA
End Sub

Private Sub Form_Load()
BERSIH
RSMAHASISWA.Refresh
Text1.MaxLength = 8
CMDSIMPAN.Enabled = False
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
Text1 = Clear
End Sub

Private Sub BERSIH()
Text2 = Clear
Text3 = Clear
Text4 = Clear
Text6 = Clear
Text7 = Clear
Text8 = Clear
Text9 = Clear
End Sub

Private Sub Text1_Change()
Dim panjang As Byte
panjang = Len(Text1)
If panjang < 7 Then
    Exit Sub
End If
RSMAHASISWA.CommandType = adCmdText
RSMAHASISWA.RecordSource = "select*from mahasiswa Where NIS ='" & Text1 & "'"

RSMAHASISWA.Refresh

If Not RSMAHASISWA.Recordset.EOF Then
MsgBox ("NIS SUDAH ADA")

Text2 = RSMAHASISWA.Recordset.Fields(1)
Text3 = RSMAHASISWA.Recordset.Fields(2)
Text4 = RSMAHASISWA.Recordset.Fields(3)
DTPicker1.Value = RSMAHASISWA.Recordset.Fields(4)
Text6 = RSMAHASISWA.Recordset.Fields(5)
Text7 = RSMAHASISWA.Recordset.Fields(6)
Text8 = RSMAHASISWA.Recordset.Fields(7)
Text9 = RSMAHASISWA.Recordset.Fields(8)

CMDSIMPAN.Enabled = False
CMDHAPUS.Enabled = True
CMDEDIT.Enabled = True
Else
BERSIH
Text2.SetFocus
CMDSIMPAN.Enabled = True
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
End If

End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text3.SetFocus
End If

End Sub

Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text4.SetFocus
End If
End Sub

Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text6.SetFocus
End If
End Sub

Private Sub Text6_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text7.SetFocus
End If
End Sub

Private Sub Text7_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text8.SetFocus
End If
End Sub

Private Sub Text8_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text9.SetFocus
End If
End Sub



"FRMDOSEN"



Private Sub CETAK_Click()
tri.ReportFileName = App.Path + "/lapdosen.RPT"
tri.RetrieveDataFiles
tri.WindowState = crptMaximized
tri.Action = 1
End Sub

Private Sub CMDBARU_Click()
BERSIH
Text1 = Clear
Text1.SetFocus
End Sub

Private Sub CMDBATAL_Click()
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
CMDSIMPAN.Enabled = False
BERSIH
TAMPILDATA
End Sub

Private Sub CMDEDIT_Click()
RSDOSEN.Recordset.Fields(1) = Text2
RSDOSEN.Recordset.Fields(2) = Text3
RSDOSEN.Recordset.Fields(3) = Text4
RSDOSEN.Recordset.Update
MsgBox ("Data Telah DIPerbaiki")
RSDOSEN.Refresh
TAMPILDATA
End Sub

Private Sub CMDHAPUS_Click()
A = MsgBox("YAKINKAH INGIN DI HAPUS?", vbYesNo, "")
If A = vbYes Then
    RSDOSEN.Recordset.Delete
    RSDOSEN.Refresh
Else
Cancel = True
End If
Text1 = Clear
Text2.SetFocus
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
CMDSIMPAN.Enabled = False
BERSIH
TAMPILDATA
End Sub

Private Sub CMDSIMPAN_Click()
If Text1 = "" Then
    MsgBox ("ND Harap Di isi")
    Exit Sub
End If
If Text2 = "" Then
    MsgBox ("Nama Harap Di isi")
    Exit Sub
End If
RSDOSEN.Recordset.AddNew
RSDOSEN.Recordset.Fields(0) = Text1
RSDOSEN.Recordset.Fields(1) = Text2
RSDOSEN.Recordset.Fields(2) = Text3
RSDOSEN.Recordset.Fields(3) = Text4
RSDOSEN.Recordset.Update
MsgBox ("Data Telah Disimpan")
RSDOSEN.Refresh
TAMPILDATA
End Sub

Private Sub Form_Load()
BERSIH
RSDOSEN.Refresh
Text1.MaxLength = 7
End Sub
Private Sub TAMPILDATA()
RSDOSEN.CommandType = adCmdText
RSDOSEN.RecordSource = "Select * from DOSEN"
RSDOSEN.Refresh
DataGrid1.Refresh
End Sub
Private Sub BERSIH()
Text1 = Clear
Text2 = Clear
Text3 = Clear
Text4 = Clear
End Sub

Private Sub Text1_Change()
Dim panjang As Byte
panjang = Len(Text1)
If panjang < 7 Then
    Exit Sub
End If
RSDOSEN.CommandType = adCmdText
RSDOSEN.RecordSource = "select*from dosen Where NID ='" & Text1 & "'"

RSDOSEN.Refresh

If Not RSDOSEN.Recordset.EOF Then
MsgBox ("NID SUDAH ADA")

Text2 = RSDOSEN.Recordset.Fields(1)
Text3 = RSDOSEN.Recordset.Fields(2)
Text4 = RSDOSEN.Recordset.Fields(3)

CMDSIMPAN.Enabled = False
CMDHAPUS.Enabled = True
CMDEDIT.Enabled = True
Else
BERSIH
Text2.SetFocus
CMDSIMPAN.Enabled = True
CMDHAPUS.Enabled = False
CMDEDIT.Enabled = False
End If
End Sub

"FRMLAT1 (RSMATAKULIAH)"






RUMUS:


Private Sub Form_Load()
frmlat1.Show

End Sub


"FRMLAT2(MAHASISWA)"






RUMUS:




Private Sub Command1_Click()
RSMAHASISWA.Recordset.MoveFirst
TAMPIL
End Sub
Private Sub Command2_Click()
RSMAHASISWA.Recordset.MovePrevious
If RSMAHASISWA.Recordset.BOF Then
    MsgBox ("ini data awal")
    RSMAHASISWA.Recordset.MoveFirst
End If
TAMPIL
End Sub

Private Sub Command3_Click()
RSMAHASISWA.Recordset.MoveNext
If RSMAHASISWA.Recordset.EOF Then
MsgBox ("ini data terakhir")
    RSMAHASISWA.Recordset.MoveLast
End If
TAMPIL
End Sub

Private Sub Command4_Click()
RSMAHASISWA.Recordset.MoveLast
TAMPIL
End Sub

Private Sub Command5_Click()
RSMAHASISWA.Refresh
TAMPIL
End Sub

Private Sub Form_Load()
RSMAHASISWA.Refresh
TAMPIL
End Sub

Private Sub TAMPIL()
Text1 = RSMAHASISWA.Recordset.Fields(0)
Text2 = RSMAHASISWA.Recordset.Fields(1)
Text3 = RSMAHASISWA.Recordset.Fields(2)
Text4 = RSMAHASISWA.Recordset.Fields(3)
Text5 = RSMAHASISWA.Recordset.Fields(4)
Text6 = RSMAHASISWA.Recordset.Fields(5)
Text7 = RSMAHASISWA.Recordset.Fields(6)
Text8 = RSMAHASISWA.Recordset.Fields(7)
Text9 = RSMAHASISWA.Recordset.Fields(8)
End Sub

"FRMLATLAT3(MAHASISWA)"







"FRMLAT4(DOSEN)"






RUMUS:

Private Sub Command1_Click()RSDOSEN.Recordset.MoveFirstTAMPILEnd SubPrivate Sub Command2_Click()RSDOSEN.Recordset.MovePreviousIf RSDOSEN.Recordset.BOF Then    MsgBox ("ini data awal")    RSDOSEN.Recordset.MoveFirstEnd IfTAMPILEnd SubPrivate Sub Command3_Click()RSDOSEN.Recordset.MoveNextIf RSDOSEN.Recordset.EOF ThenMsgBox ("ini data terakhir")    RSDOSEN.Recordset.MoveLastEnd IfTAMPILEnd SubPrivate Sub Command4_Click()RSDOSEN.Recordset.MoveLastTAMPILEnd SubPrivate Sub Command5_Click()RSDOSEN.RefreshTAMPILEnd SubPrivate Sub Form_Load()RSDOSEN.RefreshTAMPILEnd SubPrivate Sub TAMPIL()Text1 = RSDOSEN.Recordset.Fields(0)Text2 = RSDOSEN.Recordset.Fields(1)taxt3 = RSDOSEN.Recordset.Fields(2)Text4 = RSDOSEN.Recordset.Fields(3)End Sub

"FRMLAT5(MAHASISWA)"








RUMUS:

Private Sub Command1_Click()
On Error Resume Next
RSMAHASISWA.CommandType = adCmdText
RSMAHASISWA.RecordSource = Text1
RSMAHASISWA.Refresh
Text2 = RSMAHASISWA.Recordset.RecordCount

End Sub

"FRMLAT6(MATAKULIAH)"






RUMUS:



Private Sub Command1_Click()
On Error Resume Next
RSMAHASISWA.CommandType = adCmdText
RSMAHASISWA.RecordSource = Text1
RSMAHASISWA.Refresh
Text2 = RSMAHASISWA.Recordset.RecordCount

End Sub

"FRMLAT7(MATAKULIAH)"







RUMUS:

Private Sub Command1_Click()
On Error Resume Next
RSMatakuliyah.CommandType = adCmdText
RSMatakuliyah.RecordSource = Text1
RSMatakuliyah.Refresh
Text2 = RSMatakuliyah.Recordset.RecordCount

End Sub


"FRMLAT8(MATAKULIAH)"





RUMUS:


Private Sub Command1_Click()On Error Resume NextRSMATAKULIAH.CommandType = adCmdTextRSMATAKULIAH.RecordSource = Text1RSMATAKULIAH.RefreshText2 = RSMATAKULIAH.Recordset.RecordCountEnd Sub


"FRMLAT9(DOSEN)"


RUMUS:



0 komentar:

Poskan Komentar