Form Login
Form login dihubungkan dengan table user, dimana hanya user tertentu yang dapat menggunakan program ini.
Pada kode form login, ketik listing :
Private Sub CmdCancel_Click()
End
End Sub
PrivateSub CmdOK_Click()
User = T_User.text
ChkUser
End sub
Private Sub Form_Activate()
T_User.setFocus
Frm_MenuMDI.Enable=false
End sub
Private Sub Form_Load()
Public Sub ChkUser()
With Rs_User
.Find “User_Id=’” & T_User.Text&”’”,,adsearch forward,1
If.EOF Then
Form Menu
Private Sub Timer1_Timer()
Dim AHari, Hari
Lbl_Jam Caption = Format(Time, “hh:mm:ss”)
AHari = weekday(Date, vbSunday)
Select Case AHari
Case 1
Hari = “Minggu”
Case 2
Hari = “Senin’
Case 3
Hari = “Selasa”
Case 4
Hari = “ Rabu”
Case 5
Hari = ‘Kamis”
Case 6
Hari = “Jum’at”
Case 7
Hari = “Sabtu’
End Select
Lbl_User.Caption = User
Lbl_Tgl.Caption = Hari &”,”& format(Date,”dd mm yy”)
Lbl_Status.Caption = Status
End Sub
Membuka Program Crystal Report
Start, Programs, Seagate Crystal Report, 32-bit Crystal Report Designer
Membuat Crystal Report :
Prosedur untuk membuat sebuah report adalah :
1.Dari kotak dialog Welcome to pilih New Report, atau pilih File, New
2.Pada kotak dialog Report Gallery, klik Standard.
3.Maka muncul kotak dialog Standart Report Expert, klik data file dan selanjutnya akan tampil kotak dialog Choose Database File
4.Cari lokasi file database yang akan digunakan,kemudian tekan tombol add
5.Selanjutnya akan muncul kotak dialog Select Tablesm, pilih nama table yang diinginkan, tekan OK, Done
6.Kemudian pada kotak daftar, muncul table yang pilih tadi, kemudian pilih next
7.Langkah berikutnya pilih field-field yang akan dimasukan sebagai data sumber report. Tekan add all untuk semua field, atau add untuk field yang dipilh saja dan tekan next.
8. Setelah itu muncul tampilan yang digunakan untuk menentukan field kunci pengurutan, pilih fieldnya dan tekan tombol add.
9.Klik tombol next, bila melanjutkan proses, jika akan mengakhiri tekan design report.
Minggu, 22 Mei 2011
Public class loginform1
if usernametextbox.text = "Spiderman"And password textbox.text = " merah " Then MDI Parent1
show()...fungsinya menjalankan form
Me.visible = false
else
MsgBox("Login gagal silahkan ulangi lagi")
end if
end sub
private sub cancel.click...
Me.close () menutup form
end sub
Insert
Call Koneksi ()
Tampil.Connection=Database
Tampil.CommandType=CommandType.text
Tampil.Commandtext="Insert into jurusan_ (kdjur,nmjur)values('"&textbox1.text&"'"&textbox2.text&"')"
Tampil.Executenonquery ()
Call kosong ()...
if usernametextbox.text = "Spiderman"And password textbox.text = " merah " Then MDI Parent1
show()...fungsinya menjalankan form
Me.visible = false
else
MsgBox("Login gagal silahkan ulangi lagi")
end if
end sub
private sub cancel.click...
Me.close () menutup form
end sub
Insert
Call Koneksi ()
Tampil.Connection=Database
Tampil.CommandType=CommandType.text
Tampil.Commandtext="Insert into jurusan_ (kdjur,nmjur)values('"&textbox1.text&"'"&textbox2.text&"')"
Tampil.Executenonquery ()
Call kosong ()...
Form database adalah interface yang digunakan untuk menampilkan dan menyunting data, jadi form dapat difungsikan sebagai penghubung antara operator computer dengan sumber data.
Dalam kotak New Project kita dapat memilih beberapa tipe project yang diinginkan, misalnya :
1. Standar EXE : membuat file eksekusi standar
2. ActiveX EXE : membuat file eksekusi ActiveX
3. ActiveX DLL : membuat file DLL ActiveX
4. ActiveX Control : membuat control ActiveX
5. VB Application Wizard : menghasilkan kerangka aplikasi baru yang dapat anda gunakan untuk membuat aplikasi yang lebih kompleks.
Pilih standar.EXE dan tekan tombol OK, VB akan menampilkan sebuah project baru dengan satu form kosong dengan nama default (nama standart) Form1.
Membuat form menu
Jika kita menggunakan form MDI, maka atur form – form lain dengan property MDIChild = True
Untuk menambahkan form MDI, klik kanan pada jendela Project Explorer, kemudian pilih add MDI Form, kemudian atur property form MDI.
Form Login
Komponen yang ditambahkan dalam form login
Label, textbox, dan button
Membuat form laporan
Reporting, crystal report,pilih add, kemudian standart, pilih ok
oleDB, SQL server, kemudian isi servernya.
Dalam kotak New Project kita dapat memilih beberapa tipe project yang diinginkan, misalnya :
1. Standar EXE : membuat file eksekusi standar
2. ActiveX EXE : membuat file eksekusi ActiveX
3. ActiveX DLL : membuat file DLL ActiveX
4. ActiveX Control : membuat control ActiveX
5. VB Application Wizard : menghasilkan kerangka aplikasi baru yang dapat anda gunakan untuk membuat aplikasi yang lebih kompleks.
Pilih standar.EXE dan tekan tombol OK, VB akan menampilkan sebuah project baru dengan satu form kosong dengan nama default (nama standart) Form1.
Membuat form menu
Jika kita menggunakan form MDI, maka atur form – form lain dengan property MDIChild = True
Untuk menambahkan form MDI, klik kanan pada jendela Project Explorer, kemudian pilih add MDI Form, kemudian atur property form MDI.
Form Login
Komponen yang ditambahkan dalam form login
Label, textbox, dan button
Membuat form laporan
Reporting, crystal report,pilih add, kemudian standart, pilih ok
oleDB, SQL server, kemudian isi servernya.
Rabu, 18 Mei 2011
Koneksi Database
Cara koneksi database visual basic 2010 dengan ms SQL Server 2008
Pertama kita buat modul koneksi, lalu buat tombol untuk test koneksi
Imports System.Data
Imports System.Data.Sql
Module konek
Public Database As New OleDb.OleDbConnection
Public Tampil As New OleDb.OleDbCommand
Public Tampil2 As New OleDb.OleDbCommand
Pertama kita buat modul koneksi, lalu buat tombol untuk test koneksi
Imports System.Data
Imports System.Data.Sql
Module konek
Public Database As New OleDb.OleDbConnection
Public Tampil As New OleDb.OleDbCommand
Public Tampil2 As New OleDb.OleDbCommand
Public Tampilkan As OleDb.OleDbDataReader
Public Hasiljur, jur As String
Public Sub Koneksi()
Try
Database.Close()
Database.ConnectionString = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Initial Catalog=ptabc; Data Source=MUJAN-COMP\SQLEXPRESS;"
Database.Open()
'Integrated Security=True
MsgBox("konek sukses")
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End Sub
Public Sub jurusan()
Call Koneksi()
Tampil2.Connection = Database
Tampil2.CommandType = CommandType.Text
Tampil2.CommandText = "select * from table_1 where kdjur='" + Trim(jur) & "'"
Tampilkan = Tampil2.ExecuteReader
If Tampilkan.HasRows = True Then
While Tampilkan.Read
If IsDBNull(Tampilkan("kdjur")) Then
Hasiljur = "_"
Else
Hasiljur = Tampilkan("namajur")
End If
End While
End If
End Sub
End Module
'kode program di form
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call Koneksi()
jur = TextBox2.Text
jurusan()
TextBox1.Text = Hasiljur
End Sub
End Class
Kamis, 21 April 2011
Public Class Form1
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call bersih()
Call Isi_combo()
End Sub
Sub bersih()
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
ComboBox1.Text = "06 Teknik Informatika"
End Sub
Sub Isi_combo()
ComboBox1.Items.Add("06 Teknik Informatika")
ComboBox1.Items.Add("07 Sistem Informasi")
ComboBox1.Items.Add("05 Manajement Informatika")
ComboBox1.Items.Add("67 Teknik Komputer")
ComboBox1.Items.Add("26 Komputer Akuntansi")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button4.Text = "keluar" Then
Me.Close()
Else
Call normal()
Call bersih()
End If
End Sub
Sub normal()
Button1.Text = "Tambah"
Button1.Enabled = True
Button2.Text = "Ubah"
Button2.Enabled = True
Button3.Text = "Hapus"
Button3.Enabled = True
Button4.Text = "Keluar"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Tambah" Then
Button1.Text = "Simpan"
Button2.Enabled = False
Button3.Enabled = False
Button4.Text = "Batal"
TextBox1.Focus()
Else
End If
End Sub
End Class
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call bersih()
Call Isi_combo()
End Sub
Sub bersih()
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
ComboBox1.Text = "06 Teknik Informatika"
End Sub
Sub Isi_combo()
ComboBox1.Items.Add("06 Teknik Informatika")
ComboBox1.Items.Add("07 Sistem Informasi")
ComboBox1.Items.Add("05 Manajement Informatika")
ComboBox1.Items.Add("67 Teknik Komputer")
ComboBox1.Items.Add("26 Komputer Akuntansi")
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
If Button4.Text = "keluar" Then
Me.Close()
Else
Call normal()
Call bersih()
End If
End Sub
Sub normal()
Button1.Text = "Tambah"
Button1.Enabled = True
Button2.Text = "Ubah"
Button2.Enabled = True
Button3.Text = "Hapus"
Button3.Enabled = True
Button4.Text = "Keluar"
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Button1.Text = "Tambah" Then
Button1.Text = "Simpan"
Button2.Enabled = False
Button3.Enabled = False
Button4.Text = "Batal"
TextBox1.Focus()
Else
End If
End Sub
End Class
Rabu, 20 April 2011
Public Class Form1
Dim listitem As ListViewItem
Dim listtxt(5) As String
Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label1.Click
End Sub
Private Sub Form1_d(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call bersih()
End Sub
Sub bersih()
TextBox1.Text = " "
TextBox2.Text = " "
TextBox3.Text = " "
TextBox4.Text = " "
TextBox5.Text = " "
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Call setlistview()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
listtxt(0) = Trim(TextBox1.Text)
listtxt(1) = Trim(TextBox2.Text)
listtxt(2) = Trim(TextBox3.Text)
listtxt(3) = Trim(TextBox4.Text)
listtxt(4) = Trim(TextBox5.Text)
listitem = New ListViewItem(listtxt)
ListView1.Items.Add(listitem)
End Sub
Sub setlistview()
ListView1.View = View.Details
ListView1.Columns.Add("Nama", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("NPM", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Alamat", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("Telepon", 100, HorizontalAlignment.Center)
ListView1.Columns.Add("E-mail", 100, HorizontalAlignment.Center)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
Minggu, 17 April 2011
Source kode sederana untuk menampilkan data
Public Class Fpesanan
Dim listtxt(9) As String
Dim listitem As ListViewItem
Private Sub Fpesanan_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call kodemakanan()
Call setlisttview()
End Sub
Private Sub Fpesanan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label10.Text = Format(Now(), "dddd, d MMM yyyy")
End Sub
Sub setlisttview()
ListView1.View = View.Details
ListView1.Columns.Add("No Nota", 60, HorizontalAlignment.Center)
ListView1.Columns.Add("Kode Makanan", 90, HorizontalAlignment.Left)
ListView1.Columns.Add("Kode Pelanggan", 90, HorizontalAlignment.Left)
ListView1.Columns.Add("Kode Petugas", 90, HorizontalAlignment.Left)
ListView1.Columns.Add("Satuan", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("Tgl Nota", 60, HorizontalAlignment.Left)
ListView1.Columns.Add("Qty", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("Harga", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("Jumlah", 50, HorizontalAlignment.Left)
End Sub
Sub simpan()
listtxt(0) = Trim(TextBox1.Text)
listtxt(1) = Trim(ComboBox1.Text)
listtxt(2) = Trim(ComboBox2.Text)
listtxt(3) = Trim(ComboBox3.Text)
listtxt(4) = Trim(ComboBox4.Text)
listtxt(5) = Trim(TextBox2.Text)
listtxt(6) = Trim(TextBox3.Text)
listtxt(7) = Trim(TextBox4.Text)
listtxt(8) = Trim(TextBox5.Text)
listitem = New ListViewItem(listtxt)
ListView1.Items.Add(listitem)
End Sub
Sub bersih()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
ComboBox1.Text = "Select"
ComboBox2.Text = "Select"
ComboBox3.Text = "Select"
ComboBox4.Text = "Select"
TextBox1.Focus()
End Sub
Sub kodemakanan()
'Mengisi Kode Makanan'
ComboBox1.Items.Add("K001")
ComboBox1.Items.Add("K002")
ComboBox1.Items.Add("S001")
ComboBox1.Items.Add("S001")
ComboBox1.Items.Add("G001")
ComboBox1.Items.Add("R001")
'Mengisi Code Pelanggan'
ComboBox2.Items.Add("P001")
ComboBox2.Items.Add("P002")
ComboBox2.Items.Add("P003")
ComboBox2.Items.Add("P004")
ComboBox2.Items.Add("P005")
ComboBox2.Items.Add("P006")
'Mengisi Code Petugas'
ComboBox3.Items.Add("T001")
ComboBox3.Items.Add("T002")
ComboBox3.Items.Add("T003")
ComboBox3.Items.Add("T004")
ComboBox3.Items.Add("T005")
ComboBox3.Items.Add("T006")
'Mengisi Code Petugas'
ComboBox4.Items.Add("KG")
ComboBox4.Items.Add("PCS")
ComboBox4.Items.Add("Dus")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Fmenu.Show()
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call simpan()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Call bersih()
End Sub
End Class
Dim listtxt(9) As String
Dim listitem As ListViewItem
Private Sub Fpesanan_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Call kodemakanan()
Call setlisttview()
End Sub
Private Sub Fpesanan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Label10.Text = Format(Now(), "dddd, d MMM yyyy")
End Sub
Sub setlisttview()
ListView1.View = View.Details
ListView1.Columns.Add("No Nota", 60, HorizontalAlignment.Center)
ListView1.Columns.Add("Kode Makanan", 90, HorizontalAlignment.Left)
ListView1.Columns.Add("Kode Pelanggan", 90, HorizontalAlignment.Left)
ListView1.Columns.Add("Kode Petugas", 90, HorizontalAlignment.Left)
ListView1.Columns.Add("Satuan", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("Tgl Nota", 60, HorizontalAlignment.Left)
ListView1.Columns.Add("Qty", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("Harga", 50, HorizontalAlignment.Left)
ListView1.Columns.Add("Jumlah", 50, HorizontalAlignment.Left)
End Sub
Sub simpan()
listtxt(0) = Trim(TextBox1.Text)
listtxt(1) = Trim(ComboBox1.Text)
listtxt(2) = Trim(ComboBox2.Text)
listtxt(3) = Trim(ComboBox3.Text)
listtxt(4) = Trim(ComboBox4.Text)
listtxt(5) = Trim(TextBox2.Text)
listtxt(6) = Trim(TextBox3.Text)
listtxt(7) = Trim(TextBox4.Text)
listtxt(8) = Trim(TextBox5.Text)
listitem = New ListViewItem(listtxt)
ListView1.Items.Add(listitem)
End Sub
Sub bersih()
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox5.Clear()
ComboBox1.Text = "Select"
ComboBox2.Text = "Select"
ComboBox3.Text = "Select"
ComboBox4.Text = "Select"
TextBox1.Focus()
End Sub
Sub kodemakanan()
'Mengisi Kode Makanan'
ComboBox1.Items.Add("K001")
ComboBox1.Items.Add("K002")
ComboBox1.Items.Add("S001")
ComboBox1.Items.Add("S001")
ComboBox1.Items.Add("G001")
ComboBox1.Items.Add("R001")
'Mengisi Code Pelanggan'
ComboBox2.Items.Add("P001")
ComboBox2.Items.Add("P002")
ComboBox2.Items.Add("P003")
ComboBox2.Items.Add("P004")
ComboBox2.Items.Add("P005")
ComboBox2.Items.Add("P006")
'Mengisi Code Petugas'
ComboBox3.Items.Add("T001")
ComboBox3.Items.Add("T002")
ComboBox3.Items.Add("T003")
ComboBox3.Items.Add("T004")
ComboBox3.Items.Add("T005")
ComboBox3.Items.Add("T006")
'Mengisi Code Petugas'
ComboBox4.Items.Add("KG")
ComboBox4.Items.Add("PCS")
ComboBox4.Items.Add("Dus")
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Fmenu.Show()
Me.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Call simpan()
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Call bersih()
End Sub
End Class
Langganan:
Postingan (Atom)