Payroll system

  • 1,950 views
Uploaded on

The way you start learning VB.Net

The way you start learning VB.Net

More in: Education , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
1,950
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
229
Comments
0
Likes
1

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. 2011 STEP BY STEP TO BUILD PAYROLL SYSTEM 2011 USING VB.NET & SQL 2005 In this presentation we will guide you to how to build your first application in VB.Net. we will show you step by step until the program is running well at your PC. So please read and understand it carefully to finished this system. B.WIRATMOJO Work for Bridgestone Tire Indonesia, PT 6/11/2011
  • 2. 2Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniPrakata PenulisDear all, Ini diperuntukan untuk semua kalangan yang sedang beralih dari VB 6.0 ke VB.Net ataumemang sedang belajar dari nol VB.Net. ini adalah tugas UAS pada saat Penulis menjalanikuliahnya di STMIK Bina Insani Bekasi pada jenjang Strata 1. Tulisan ini pun di dedikasikansebagai sumbangsih Penulis kepada teman-teman semua yang ingin belajar, yang diharapkanmenjadi pahala yang auto debet, sebagaimana kata orang jaman dulu, “ilmu yang bermanfaat”adalah termasuk dari 3 amalan yang pahalanya tidak terputus walaupun orang itu sudahmeninggal dunia. Sebuah CATATAN penting !! disini Penulis menganggap bahwa semua pembaca sudahmengetahui dasar-dasar penggunaan VB.Net dan Database SQL Server 2005. Pada systemaplikasi Payroll ini Penulis menggunakan VB.Net 2008. Karena Penulis tidak menjelaskanbagaimana Instalasi SQL Server 2005 dan VB.Net itu sendiri.Note : SQL Server 2005 ada beberapa versi, yaitu untuk computer 32 bit dan 64 bit, jadisebelum install silahkan lihat PC anda support untuk yang mana. Bagi yang tidak menggunakan SQL Server 2005 dapat menggunakan SQL Server 2000,Penulis pastikan semua pembuatan Query sama persis !! karena Syntax SQL adalah bahasaumum yang dapat di pakai hampir di semua Aplikasi Database.Bekasi, 11 Juni 2011
  • 3. 3Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani MEMBUAT DATABASE Nah tentunya sebelum membuat aplikasi apapun kita perlu untuk mendesain Databasesebaik-baiknya, karena disinilah data-data yang kita proses dengan query DML (DataManipulation Language) akan di sajikan, relasi atar data, antar table yang ada haruslah relevan.Klik kanan pada folder “Database” pilih “New Database…”
  • 4. 4Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Pada Text “Database name” isikan dengan “PAYROL_DB” atau dengan nama databaseyang kawan inginkan, TAPI.. harus di ingat benar-benar hingga applikasi selesai dibuat, karenapenamaan apapun saat memrogram adalah sangat penting untuk di ingat.. Pada Grid “Path” Ubahlah direktorinya sesuai yang anda inginkan, disini Penulis sudahmembuatkan “Folder” khusus pada drive D: untuk semua Database SQL 2005 yang dimiliki.Untuk mengamankan data bila terjadi masalah dengan system windows yang secara defaultterinstal pada drive C:Klik button “OK” maka database “PAYROL_DB” sudah terbentuk !!WELL DONE to Create Database Application !!
  • 5. 5 Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat Tabel-Tabel Pilih “New Query” untuk membuat table pada system kita. Execute SyntaxNama Database Cek Syntax
  • 6. 6Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Pastikan nama database yang akan kita buatkan table didalamnya “Cloud NamaDatabase” lalu ketikan syntax Create Database didalamnya sbb :Membuat TABEL_LOGINCreate Table TABEL_LOGIN(IDUSER Varchar(2) Not Null Primary Key,USERNAMELOG Varchar(25),ACCESS Varchar (5),PASSWORDLOG Varchar(25)) Cek kebenaran pada penulisan syntax SQL Query anda tersebut dengan klik “Cloud CekSyntax”. Seharusnya pada kolon “Message” dibawahnya tertulis “Command(s) completedsuccessfully.” Ini artinya syntax BENAR. Bila “Message” error pastikan kembali syntax anda,karena sudah pasti ada kesalahan yang terjadi. Klik “! Execute” untuk menjadikan tabel pada database PAYROL_DB dengan syntaxtersebut.WELL DONE TABEL_LOGIN has been createdMembuat TABEL_CITYLakukanlah hal yang sama saat membuat tabel sebelumnya lalu ketikan sytax sbb:Create Table TABEL_CITY(IDCITY Varchar(2) Not Null Primary Key, NAMACITYVarchar(25))WELL DONE TABEL_CITY has been createdMembuat TABEL_PEGAWAILakukanlah hal yang sama saat membuat tabel sebelumnya lalu ketikan sytax sbb:Create Table TABEL_PEGAWAI(NIP Varchar(10) Not Null Primary Key,NAMAPEGAWAI Varchar(25),TGLLAHIR Varchar(10), ALAMAT varchar(50), IDCITY varchar(2), KODEPOSvarchar(5))WELL DONE TABEL_PEGAWAI has been createdMembuat TABEL_UASLakukanlah hal yang sama saat membuat tabel sebelumnya lalu ketikan sytax sbb:Create Table TABEL_UAS(NOPAYROLL Varchar(7) Not Null Primary Key, IDUSERVarchar(2),NIP Varchar(10), NPWP varchar(15), GAJIBULAN varchar(15), JABATANnchar(10),GOLONGAN nchar(10),GAJI decimal (18,0), TUNJANGAN decimal(18,0), POTONGAN decimal (18,0),SEBULANLEMBUR varchar(5),UANGLEMBURAN decimal(18,0), GAJIBERSIH decimal (18,0), TAHUN nchar (10))WELL DONE TABEL_UAS has been created
  • 7. 7Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat User LoginSelamat anda saat ini sudah menjajaki step berikutnya yaitu membuat User Login untukdigunakan saat aplikasi nanti di run, karena sebelumnya anda sudah berjibaku dengan syntaxdasar Query SQL untuk membuat tabel-tabel pada system ini.Pada View Database SQL Server 2005 pilih folder “Security” – “Logins” – klik kanan – “NewLogin”. Lalu perhatikan dengan seksama setting user anda ini ya pada gambar dan penjelasanberikutnya??
  • 8. 8Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniPada Page “General”Login Name : uasPassword : 123Confirm Password : 123Default database : PAYROL_DBDefault language : EnglishPada Page “Server Role”Centang “sysadmin”Pada Page “User Mapping”Centang “PAYROL_DB”Pada Page “Status”Permission to connect to databaseengine pilih “Grant”Login pilih “Enabled”OKWELL DONE your user login to the database system has been created !
  • 9. 9Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat Stored ProcedureSELAMAT !! akhirnya anda sampai pada step yang lebih menantang anda dan menguji semangatprogramming anda, yaitu pembuatan Stored Procedure. Yuk mari lanjut mang…Nah masih sama saat membuat tabel, bukalah “New Query” pastikan nama databasenya untukdibuatkan Stored ProcedurenyaMembuat Stored Procedure INPUT TABEL LOGINKetikan syntax SQL sbb:Create Procedure StoreINPUT_TABEL_LOGIN@IDUSER Varchar(02),@USERNAMELOG Varchar(25),@ACCESS Varchar(05),@PASSWORDLOG Varchar(25)AsInsert TABEL_LOGIN Values(@IDUSER,@USERNAMELOG,@ACCESS,@PASSWORDLOG)Membuat Stored Procedure DELETE TABEL LOGINKetikan syntax SQL sbb:Create Procedure StoreDELETE_TABEL_LOGIN@IDUSER Varchar(02)AsDelete From TABEL_LOGIN Where IDUSER=@IDUSERMembuat Stored Procedure UPDATE TABEL LOGINKetikan syntax SQL sbb:Create Procedure StoreUPDATE_TABEL_LOGIN@IDUSER Varchar(02),@USERNAMELOG Varchar(25),@ACCESS Varchar(05),@PASSWORDLOG Varchar(25)AsUpdate TABEL_LOGINSet USERNAMELOG=@USERNAMELOG, ACCESS=@ACCESS, PASSWORDLOG=@PASSWORDLOGWhere IDUSER=@IDUSERMembuat Stored Procedure SPI PEGAWAIKetikan syntax SQL sbb:Create Procedure SPI_PEGAWAI@NIP Varchar(10),@NAMAPEGAWAI Varchar(25),@TGLLAHIR Varchar(10),@ALAMAT Varchar(50),@IDCITY Varchar(02),@KODEPOS Varchar(5)AsInsert TABEL_PEGAWAI Values (@NIP, @NAMAPEGAWAI, @TGLLAHIR, @ALAMAT,@IDCITY, @KODEPOS)
  • 10. 10Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniMembuat Stored Procedure SPD PEGAWAIKetikan syntax SQL sbb:Create Procedure SPD_PEGAWAI@NIP Varchar(10)AsDelete From TABEL_PEGAWAI Where NIP = @NIPMembuat Stored Procedure SPU PEGAWAIKetikan syntax SQL sbb:Create Procedure SPU_PEGAWAI@NIP Varchar(10),@NAMAPEGAWAI Varchar(25),@TGLLAHIR Varchar(10),@ALAMAT Varchar(50),@IDCITY Varchar(02),@KODEPOS Varchar(5)AsUpdate TABEL_PEGAWAISet NAMAPEGAWAI = @NAMAPEGAWAI, TGLLAHIR = @TGLLAHIR,ALAMAT = @ALAMAT, IDCITY = @IDCITY, KODEPOS = @KODEPOSWhere NIP = @NIPNote : pada saat pembuatan ini pastikan semua Data Type dan Character adalah sesuai denganyang ada pada database, juga perintah SQL untuk DML (Data Manipulation Language) apa ituINSERT, DELETE dan UPDATE, jadi intinya bukan hanya sekedar copy, paste. Tapi pemahamantentu jauh lebih penting !!WELL DONE your Stored Procedures have been created !!
  • 11. 11Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat Aplikasi PAYROLL SYSTEMNnaaahh.. step ini akan semakin menantang, karena disinilah kita akan berkoding-koding ria,siapkan minuman anda juga cemilan, cepuluh, cebelas (lho?? Ngitung??) [intermezzo].Bukalah project VB.Net anda dan beri nama aplikasinya “NEW-PAYROLL-SYSTEM”. Lalu pada“Solution Explorer” klik kanan pada project “NEW-PAYROLL-SYSTEM” dan tambahkanbeberapa folder (APPLICATION FORM, CLASS, MODULE, REPORT, REPORT FORM) sepertigambar dibawah.
  • 12. 12Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniFolder-folder yang sudah kita buat tersebut akan mempermudah kita saat membuat aplikasi,karena disini kita secara tidak langsung sudah menerapkan konsep OOP sederhana.. yaituENKAPSULASI.. (wiidiih bahasanya..??). intinya akan lebih tertata rapi aja sih hehehe..
  • 13. 13Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat References dan SettingsBab ini akan sangat membantu kita saat berinteraksi dengan database SQL dan Crystal Reportnantinya. Dengan men=setting 2 hal ini maka data koneksi dan penggunaan tools untuk saatINHERITANCE system VB.Net itu sendiri.ReferencesKlik kanan pada “My Project” di “Solution Explorer” – “Open”. Pada tab “References” tambahkanbeberapa referensi system turunananya dengan klik “Add” dan pilih tab “.NET” sbb :
  • 14. 14Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniSettingsPilih tab “Settings”Isi grid “Name”  KONEKSI_DBASE, “Type”  (Connection string), “Scope”  ApplicationNamun untuk “Value” ini ada spesialisasi khusus, klik saja ujung grid Value tersebut sepertiterlihat pada gambar disamping.
  • 15. 15Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniDatasource : Microsoft SQL Server (SqlClient)  bila belum sesuai klik button “Change”Server Name : WIRAT-KOMP (ini adalah nama server SQL 2005 anda)  bila tidak suka, maka ada 2 cara, 1. Isikan “Localhost”, 2. Isikan “./SQLEXPRESS”Log on to the server : Pilih “Use Windows Authentification”Connect to a database : Pilih “Select or enter a database name  PAYROL_DB atau isi dengan nama database yang akan di kunci koneksinya.Test Connection : Message-nya harus “ Test connection succeeded”  bila error, wah itu artinya anda harus mengulangi setting hingga koneksi OK, dan jangan pernah lanjut ke step berikutnya bila ini tidak sesuai !!!
  • 16. 16Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat CLASSPada bab pembuatan Class PAYROL SYSTEM akan memiliki 3 CLASSES, yaitu Class KoneksiDatabase, Class Manipulasi Data atau DML dan Class Terbilang. Untuk dapat membuat Class-Class tersebut ikutilah langkahnya berikut ini.Klik kanan pada folder “CLASS” di dalam “Solution Explorer” tambahakanlah sebuah Class sbb :Class Pertama, beri nama class ini dengan “ClassKONEKSIDATABASE”Dan isilah syntaxnya sbb :Imports System.DataImports System.Data.SqlClientNamespace AKSESDATA Public Class ClassKONEKSIDATABASE Dim KONEKSI As SqlConnection = NewSqlConnection(My.Settings.KONEKSI_DBASE) Public Function BukaKoneksi() As SqlConnection KONEKSI.Open() Return KONEKSI End Function Public Function TutupKoneksi() As SqlConnection KONEKSI.Close()
  • 17. 17Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Return KONEKSI End Function End ClassEnd NamespaceClass Kedua, beri nama class ini dengan “CLASS_TERBILANG”Dan isilah syntaxnya sbb :Public Class CLASS_TERBILANG Public Function ANGKA_TERBILANG(ByVal N As Double) As String Dim SATUAN As String() = {"", "SATU", "DUA", "TIGA", "EMPAT","LIMA", _ "ENAM", "TUJUH", "DELAPAN", "SEMBILAN", "SEPULUH", "SEBELAS"} Select Case n Case 0 To 11 ANGKA_TERBILANG = " " + SATUAN(Fix(n)) Case 12 To 19 ANGKA_TERBILANG = ANGKA_TERBILANG(N Mod 10) + " BELAS" Case 20 To 99 ANGKA_TERBILANG = ANGKA_TERBILANG(Fix(N / 10)) + " PULUH" +_ ANGKA_TERBILANG(N Mod 10) Case 100 To 199 ANGKA_TERBILANG = " SERATUS" + ANGKA_TERBILANG(N - 100) Case 200 To 999 ANGKA_TERBILANG = ANGKA_TERBILANG(Fix(N / 100)) + " RATUS"+ _ ANGKA_TERBILANG(N Mod 100) Case 1000 To 1999 ANGKA_TERBILANG = " SERIBU" + ANGKA_TERBILANG(N - 1000) Case 2000 To 999999 ANGKA_TERBILANG = ANGKA_TERBILANG(Fix(N / 1000)) + " RIBU"+ _ ANGKA_TERBILANG(N Mod 1000) Case 1000000 To 999999999 ANGKA_TERBILANG = ANGKA_TERBILANG(Fix(N / 1000000)) + "JUTA" + _ ANGKA_TERBILANG(N Mod 1000000) Case 1000000000 To 999999999999 ANGKA_TERBILANG = ANGKA_TERBILANG(Fix(N / 1000000000)) + "MILYAR" + _ ANGKA_TERBILANG(N Mod 1000000000) Case Else ANGKA_TERBILANG = ANGKA_TERBILANG(Fix(N / 1000000000000)) +" TRILYUN" + _ ANGKA_TERBILANG(N Mod 1000000000000) End Select End FunctionEnd Class
  • 18. 18Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniClass Kedua, beri nama class ini dengan “Class_MANIPULASIDATA”Dan isilah syntaxnya sbb :Imports System.DataImports System.Data.SqlClientNamespace AKSESDATA Public Class ClassMANIPULASIDATA Public Function AddDATA(ByVal IDUSER As String, ByVal USERNAMELOGAs String, ByVal ACCESS As String, ByVal PASSWORDLOG As String) AsSqlCommand Dim KoneksiKU As New AKSESDATA.ClassKONEKSIDATABASE Command = New SqlCommand("StoreINPUT_TABEL_LOGIN",KoneksiKU.BukaKoneksi) Command.CommandType = CommandType.StoredProcedure Dim PRM_IDUSER As New SqlParameter("@IDUSER",SqlDbType.VarChar, 2) PRM_IDUSER.Value = IDUSER Dim PRM_USERNAME As New SqlParameter("@USERNAMELOG",SqlDbType.VarChar, 25) PRM_USERNAME.Value = USERNAMELOG Dim PRM_ACCESS As New SqlParameter("@ACCESS",SqlDbType.VarChar, 5) PRM_ACCESS.Value = ACCESS Dim PRM_PASSWORD As New SqlParameter("@PASSWORDLOG",SqlDbType.VarChar, 25) PRM_PASSWORD.Value = PASSWORDLOG With Command.Parameters .Add(PRM_IDUSER) .Add(PRM_USERNAME) .Add(PRM_ACCESS) .Add(PRM_PASSWORD) End With Command.ExecuteNonQuery() Dim HASIL As New SqlCommand("", KoneksiKU.TutupKoneksi) Return HASIL End Function Public Function UpdateDATA(ByVal IDUSER As String, ByValUSERNAMELOG As String, ByVal ACCESS As String, ByVal PASSWORDLOG As String)As SqlCommand Dim KoneksiKU As New AKSESDATA.ClassKONEKSIDATABASE Command = New SqlCommand("StoreUPDATE_TABEL_LOGIN",KoneksiKU.BukaKoneksi) Command.CommandType = CommandType.StoredProcedure
  • 19. 19Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Dim PRM_IDUSER As New SqlParameter("@IDUSER",SqlDbType.VarChar, 2) PRM_IDUSER.Value = IDUSER Dim PRM_USERNAME As New SqlParameter("@USERNAMELOG",SqlDbType.VarChar, 25) PRM_USERNAME.Value = USERNAMELOG Dim PRM_ACCESS As New SqlParameter("@ACCESS",SqlDbType.VarChar, 5) PRM_ACCESS.Value = ACCESS Dim PRM_PASSWORD As New SqlParameter("@PASSWORDLOG",SqlDbType.VarChar, 25) PRM_PASSWORD.Value = PASSWORDLOG With Command.Parameters .Add(PRM_IDUSER) .Add(PRM_USERNAME) .Add(PRM_ACCESS) .Add(PRM_PASSWORD) End With Command.ExecuteNonQuery() Dim HASIL As New SqlCommand("", KoneksiKU.TutupKoneksi) Return HASIL End Function Public Function DeleteDATA(ByVal IDUSER As String) As SqlCommand Dim KoneksiKU As New AKSESDATA.ClassKONEKSIDATABASE Command = New SqlCommand("StoreDELETE_TABEL_LOGIN",KoneksiKU.BukaKoneksi) Command.CommandType = CommandType.StoredProcedure Dim PRM_IDUSER As New SqlParameter("IDUSER", SqlDbType.VarChar,2) PRM_IDUSER.Value = IDUSER Command.Parameters.Add(PRM_IDUSER) Command.ExecuteNonQuery() Dim HASIL As New SqlCommand("", KoneksiKU.TutupKoneksi) Return HASIL End Function Public Function TambahData(ByVal NIP As String, ByVal Nama AsString, _ ByVal TglLahir As String, ByVal AlamatAs String, ByVal IdCity As String, _ ByVal KodePos As String) As SqlCommand Dim Koneksiku As New AKSESDATA.ClassKONEKSIDATABASE Command = New SqlCommand("SPI_PEGAWAI", Koneksiku.BukaKoneksi) Command.CommandType = CommandType.StoredProcedure Dim PRM1 As New SqlParameter("@NIP", SqlDbType.VarChar, 10) PRM1.Value = NIP
  • 20. 20Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Dim PRM2 As New SqlParameter("@NAMAPEGAWAI", SqlDbType.VarChar,25) PRM2.Value = Nama Dim PRM3 As New SqlParameter("@TGLLAHIR", SqlDbType.VarChar,10) PRM3.Value = TglLahir Dim PRM4 As New SqlParameter("@ALAMAT", SqlDbType.VarChar, 50) PRM4.Value = Alamat Dim PRM5 As New SqlParameter("@IDCITY", SqlDbType.VarChar, 20) PRM5.Value = IdCity Dim PRM6 As New SqlParameter("@KODEPOS", SqlDbType.VarChar, 5) PRM6.Value = KodePos With Command.Parameters .Add(PRM1) .Add(PRM2) .Add(PRM3) .Add(PRM4) .Add(PRM5) .Add(PRM6) End With Command.ExecuteNonQuery() Dim Hasil As New SqlCommand("", Koneksiku.TutupKoneksi) Return Hasil End Function Public Function UbahData(ByVal NIP As String, ByVal Nama As String,_ ByVal TglLahir As String, ByVal AlamatAs String, ByVal IdCity As String, _ ByVal KodePos As String) As SqlCommand Dim Koneksiku As New AKSESDATA.ClassKONEKSIDATABASE Command = New SqlCommand("SPU_PEGAWAI", Koneksiku.BukaKoneksi) Command.CommandType = CommandType.StoredProcedure Dim PRM1 As New SqlParameter("@NIP", SqlDbType.VarChar, 10) PRM1.Value = NIP Dim PRM2 As New SqlParameter("@NAMAPEGAWAI", SqlDbType.VarChar,25) PRM2.Value = Nama Dim PRM3 As New SqlParameter("@TGLLAHIR", SqlDbType.VarChar,10) PRM3.Value = TglLahir Dim PRM4 As New SqlParameter("@ALAMAT", SqlDbType.VarChar, 50) PRM4.Value = Alamat Dim PRM5 As New SqlParameter("@IDCITY", SqlDbType.VarChar, 20) PRM5.Value = IdCity Dim PRM6 As New SqlParameter("@KODEPOS", SqlDbType.VarChar, 5)
  • 21. 21Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani PRM6.Value = KodePos With Command.Parameters .Add(PRM1) .Add(PRM2) .Add(PRM3) .Add(PRM4) .Add(PRM5) .Add(PRM6) End With Command.ExecuteNonQuery() Dim Hasil As New SqlCommand("", Koneksiku.TutupKoneksi) Return Hasil End Function Public Function HapusData(ByVal NIP As String) As SqlCommand Dim Koneksiku As New AksesData.ClassKONEKSIDATABASE Command = New SqlCommand("SPD_PEGAWAI", koneksiku.BukaKoneksi) Command.CommandType = CommandType.StoredProcedure Dim PRM1 As New SqlParameter("@NIP", SqlDbType.VarChar, 10) PRM1.Value = NIP Command.Parameters.Add(PRM1) Command.ExecuteNonQuery() Dim Hasil As New SqlCommand("", Koneksiku.TutupKoneksi) Return Hasil End Function End ClassEnd Namespace
  • 22. 22Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat ModuleUntuk Module pada aplikasi PAYROLL akan menggunakan 2 Module. Caranya? Ikuti stepnya.Klik kanan pada folder “MODULE” tambahkan sebuah Module.Module Pertama, beri nama dengan “ModuleKONEKSI”Lalu isikan koding berikut :Imports System.Data.OleDbModule ModuleKONEKSI Public CONN As ADODB.Connection Public Sub KONEKSI_DATABASE() CONN = New ADODB.Connection CONN.Open("Provider=SQLOLEDB; Data Source=WIRAT-KOMP; User Id=uas;Password=123; Initial Catalog=PAYROL_DB;") End SubEnd ModuleModule Kedua, beri nama dengan “ModuleUMUM”Lalu isikan koding berikut :Imports System.Data.SqlClientModule ModuleUMUM Public MSG As Integer Public intResponse As SqlCommand Public Command As SqlCommand Public DataAdapter As SqlDataAdapter Public DataReader As SqlDataReader Public strSQL As String Public Username, Password, Access, IdUser As String Public DS As New DataSet Public DT As New DataTableEnd Module
  • 23. 23Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat Form AplikasiSalut for everybody sekarang saatnya kita untuk lanjut ke step berikutnya yaitu pembuatanForm Aplikasi. Akan ada 11 Form Aplikasi (FormTESKONEKSI_ADODB_SQL, FormSPLASH,FormUSER, FormLISTUSERSYSTEM, FormLOGIN, FormUTAMA, FormPROGRAMMER,FormCITY, FormPEGAWAI, FormTRANSAKSI, FormSLIPGAJI)FormTESKONEKSI_ADODB_SQLTambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,beri nama form tersebut dengan “FormTESKONEKSI_ADODB_SQL”Buatlah form dengan setting seperti dibawahKeterangan Toolbox :2 buah LabelBeri nama salah satu label dengan “LblSTATUS”  bold  perbesar font-nyaForm ini akan berfungsi sebagai langkah awal anda sebelum ngoding lebih jauh. Dan janganpernah coba ke step berikutnya bila koneksi database GAGAL disini, karena akan percuma, pastihanya masalah demi masalah yang terjadi nantinya…
  • 24. 24Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniLalu isikan syntax berikut :Imports System.DataImports System.Data.SqlClientPublic Class FormTESKONEKSI_ADODB_SQL Private Sub FormTESKONEKSI_ADODB_SQL_Load(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) Handles MyBase.Load Try Dim Conn As New SqlConnection("Server=WIRAT-KOMP;Uid=uas;Pwd=123;Database=PAYROL_DB") Conn.Open() If (Conn.State = ConnectionState.Open) Then LblSTATUS.Text = "SELAMAT !!! ANDA BERHASIL KONEK KE SQLSERVER DI JARINGAN ANDA" End If Conn.Close() Catch ex As Exception LblSTATUS.Text = "KONEKSI GAGAL TOTAL !!!!!, SILAHKAN KONTAKADMINISTRATOR ANDA" End Try End SubEnd ClassFormUSERTambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormUSER”
  • 25. 25Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniKeterangan Toolbox :2 GroupBox5 Button4 TextBox1 ComboBox5 Label2 GroupBox :GroupBox Button dan GroupBox Data5 Button :BtnINSERT, BtnDELETE, BtnUPDATE, BtnCLOSE, BtnLISTDATA4 TextBox :TxtIDUSER, TxtUSERNAME, TxtPASSWORD, TxtVERIFYPASSWORD1 ComboBox :CmbACCESS5 Label :IDUSER, USERNAME, ACCESS, PASSWORD, VERIFY PASSWORDLalu isikan syntax-nya sbb :Public Class FormUSER Private Sub FormUSER_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load Call KONEKSI_DATABASE() Call HURUF() Call TEXT_TIDAK_AKTIF() Call COMBOACCESS() End Sub Private Sub COMBOACCESS() CmbACCESS.Items.Clear() CmbACCESS.Items.Add("ADMIN") CmbACCESS.Items.Add("USER") End Sub Private Sub HURUF() TxtUSERNAME.CharacterCasing = CharacterCasing.Upper TxtPASSWORD.CharacterCasing = CharacterCasing.Upper TxtVERIFYPASSWORD.CharacterCasing = CharacterCasing.Upper End Sub Private Sub TEXT_TIDAK_AKTIF() TxtIDUSER.Enabled = False TxtUSERNAME.Enabled = False
  • 26. 26Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani CmbACCESS.Enabled = False TxtPASSWORD.Enabled = False TxtVERIFYPASSWORD.Enabled = False End Sub Private Sub TEXT_AKTIF() TxtUSERNAME.Enabled = True CmbACCESS.Enabled = True TxtPASSWORD.Enabled = True TxtVERIFYPASSWORD.Enabled = True End Sub Private Sub TEXT_KOSONG() TxtIDUSER.Text = "" TxtUSERNAME.Text = "" CmbACCESS.Text = "" TxtPASSWORD.Text = "" TxtVERIFYPASSWORD.Text = "" End Sub Private Sub BtnINSERT_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnINSERT.Click If BtnINSERT.Text = "&ADD NEW" Then BtnINSERT.Text = "&SAVE" BtnCLOSE.Text = "&CANCEL" Call TEXT_AKTIF() Call TEXT_KOSONG() Call ID_LOGIN() TxtUSERNAME.Focus() BtnUPDATE.Enabled = False BtnDELETE.Enabled = False ElseIf BtnINSERT.Text = "&SAVE" Then BtnINSERT.Text = "&ADD NEW" BtnCLOSE.Text = "&CLOSE" Call SAVE_DATA() End If End Sub Private Sub BtnCLOSE_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnCLOSE.Click If BtnCLOSE.Text = "&CANCEL" Then BtnINSERT.Text = "&ADD NEW" BtnCLOSE.Text = "&CLOSE" BtnUPDATE.Text = "&UPDATE" BtnDELETE.Text = "&DELETE" BtnINSERT.Enabled = True BtnUPDATE.Enabled = True BtnDELETE.Enabled = True BtnCLOSE.Enabled = True Call TEXT_TIDAK_AKTIF()
  • 27. 27Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Call TEXT_KOSONG() Else Me.Close() End If End Sub Private Sub TxtUSERNAME_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtUSERNAME.KeyPress If e.KeyChar = Chr(13) Then CmbACCESS.Focus() End If End Sub Private Sub TxtPASSWORD_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtPASSWORD.KeyPress If e.KeyChar = Chr(13) Then TxtVERIFYPASSWORD.Focus() End If End Sub Private Sub TxtVERIFYPASSWORD_KeyPress(ByVal sender As Object, ByVal eAs System.Windows.Forms.KeyPressEventArgs) HandlesTxtVERIFYPASSWORD.KeyPress If e.KeyChar = Chr(13) Then If TxtVERIFYPASSWORD.Text <> TxtPASSWORD.Text Then MessageBox.Show("PASSWORD VERIFICATION IS MISTAKE !!!","WIRATMOJO", MessageBoxButtons.OK, MessageBoxIcon.Error) TxtVERIFYPASSWORD.Text = "" TxtVERIFYPASSWORD.Focus() Else If BtnINSERT.Enabled = False Then BtnUPDATE.Focus() ElseIf BtnINSERT.Enabled = True Then BtnINSERT.Focus() End If End If End If End Sub Private Sub ID_LOGIN() Dim rsIDLogin As ADODB.Recordset Dim strIDLogin As String rsIDLogin = New ADODB.Recordset rsIDLogin = CONN.Execute("Select Max(IDUSER) As IDUSER FromTABEL_LOGIN") If Not rsIDLogin.EOF Then If rsIDLogin.Fields("IDUSER").Value.ToString <> "" Then strIDLogin =Format(Val(Microsoft.VisualBasic.Left(rsIDLogin.Fields("IDUSER").Value.ToString, 2) + 1), "0#") Else strIDLogin = Format(1, "0#") End If rsIDLogin.Close() TxtIDUSER.Text = strIDLogin
  • 28. 28Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani End If End Sub Private Sub UPDATE_DATA() Dim MyCOMMAND As New AKSESDATA.ClassMANIPULASIDATA If TxtUSERNAME.Text = "" Or TxtPASSWORD.Text = "" Then MessageBox.Show("NO DATA TO BE UPDATED !! PLEASE CHOOSE ANYITEM", "WIRATMOJO", MessageBoxButtons.OK) Call TEXT_KOSONG() Call TEXT_TIDAK_AKTIF() Else Dim TANYA As String TANYA = MessageBox.Show("YAKIN MENGUBAH DATA - " &TxtUSERNAME.Text & " - ??", "WIRATMOJO", MessageBoxButtons.YesNo,MessageBoxIcon.Question) If TANYA = vbYes Then MyCOMMAND.UpdateDATA(TxtIDUSER.Text, TxtUSERNAME.Text,CmbACCESS.Text, TxtPASSWORD.Text) MessageBox.Show("DATA TELAH DIUBAH !!", "WIRATMOJO",MessageBoxButtons.OK) Call TEXT_KOSONG() Call TEXT_TIDAK_AKTIF() BtnUPDATE.Text = "&UPDATE" BtnCLOSE.Text = "&CLOSE" End If End If End Sub Private Sub SAVE_DATA() Dim MyCOMMAND As New AKSESDATA.ClassMANIPULASIDATA If TxtUSERNAME.Text = "" Or TxtPASSWORD.Text = "" Then MessageBox.Show("NO DATA TO BE SAVE !!", "WIRATMOJO",MessageBoxButtons.OK) Call TEXT_KOSONG() Call TEXT_TIDAK_AKTIF() Else If DT.Rows.Count <= 0 Then MyCOMMAND.AddDATA(TxtIDUSER.Text, TxtUSERNAME.Text,CmbACCESS.Text, TxtPASSWORD.Text) MessageBox.Show("DATA TERSIMPAN !!", "WIRATMOJO",MessageBoxButtons.OK, MessageBoxIcon.Information) Call TEXT_TIDAK_AKTIF() Call TEXT_KOSONG() Else
  • 29. 29Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani MessageBox.Show("DATA SUDAH ADA !!, SILAHKAN PAKAI IDLAIN", "WIRATMOJO", MessageBoxButtons.OK) End If End If End Sub Private Sub CmbACCESS_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles CmbACCESS.KeyPress If e.KeyChar = Chr(13) Then TxtPASSWORD.Focus() End If End Sub Private Sub BtnUPDATE_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnUPDATE.Click If BtnUPDATE.Text = "&UPDATE" Then BtnUPDATE.Text = "&OK" BtnCLOSE.Text = "&CANCEL" Call TEXT_AKTIF() TxtUSERNAME.Focus() ElseIf BtnUPDATE.Text = "&OK" Then Call UPDATE_DATA() End If End Sub Private Sub BtnLISTDATA_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnLISTDATA.Click Me.Hide() FormLISTUSERSYSTEM.ShowDialog() End Sub Private Sub BtnDELETE_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnDELETE.Click Dim MyCOMMAND As New AKSESDATA.ClassMANIPULASIDATA If TxtUSERNAME.Text = "" Or TxtPASSWORD.Text = "" Then MessageBox.Show("NO DATA TO BE DELETED !! PLEASE CHOOSE ANYITEM", "WIRATMOJO", MessageBoxButtons.OK) Call TEXT_KOSONG() Call TEXT_TIDAK_AKTIF() Else Dim TANYA As String TANYA = MessageBox.Show("YAKIN MENGHAPUS DATA - " &TxtUSERNAME.Text & " - ??", "WIRATMOJO", MessageBoxButtons.YesNo,MessageBoxIcon.Question) If TANYA = vbYes Then MyCOMMAND.DeleteDATA(TxtIDUSER.Text) MessageBox.Show("DATA TELAH DIHAPUS !!", "WIRATMOJO",MessageBoxButtons.OK)
  • 30. 30Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Call TEXT_KOSONG() Call TEXT_TIDAK_AKTIF() BtnDELETE.Text = "&DELETE" BtnCLOSE.Text = "&CLOSE" End If End If End SubEnd ClassFormLISTUSERTambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormLISTUSER”Keterangan Toolbox :1 DataGridView  GridUSERLalu isikan syntax sbb :Imports System.DataImports System.Data.SqlClientPublic Class FormLISTUSERSYSTEM Private Sub DATAGRID() Dim Koneksi As New SqlConnection("Data Source=WIRAT-KOMP; UserId=uas; Password=123; Initial Catalog=PAYROL_DB;") Dim Query As New SqlCommand("Select * From TABEL_LOGIN", Koneksi) Dim Reader As SqlDataReader Try Koneksi.Open() Reader = Query.ExecuteReader Dim Data As New DataTable Data.Load(Reader) GridUSER.DataSource = Data Reader.Close()
  • 31. 31Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Catch ex As Exception MessageBox.Show(ex.ToString) End Try End Sub Private Sub FormLISTUSERSYSTEM_FormClosed(ByVal sender As Object, ByVale As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed FormUSER.Show() End Sub Private Sub FormLISTUSERSYSTEM_Load(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles MyBase.Load Call DATAGRID() End Sub Private Sub GridUSER_DoubleClick(ByVal sender As Object, ByVal e AsSystem.EventArgs) Handles GridUSER.DoubleClick FormUSER.TxtIDUSER.Text = GridUSER.Item(0,GridUSER.CurrentRow.Index).Value FormUSER.TxtUSERNAME.Text = GridUSER.Item(1,GridUSER.CurrentRow.Index).Value FormUSER.CmbACCESS.Text = GridUSER.Item(2,GridUSER.CurrentRow.Index).Value FormUSER.TxtPASSWORD.Text = GridUSER.Item(3,GridUSER.CurrentRow.Index).Value Me.Hide() FormUSER.Show() End Sub Private Sub GridUSER_KeyDown(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyEventArgs) Handles GridUSER.KeyDown If e.KeyCode = Keys.Enter Then FormUSER.TxtIDUSER.Text = GridUSER.Item(0,GridUSER.CurrentRow.Index).Value FormUSER.TxtUSERNAME.Text = GridUSER.Item(1,GridUSER.CurrentRow.Index).Value FormUSER.CmbACCESS.Text = GridUSER.Item(2,GridUSER.CurrentRow.Index).Value FormUSER.TxtPASSWORD.Text = GridUSER.Item(3,GridUSER.CurrentRow.Index).Value Me.Hide() FormUSER.Show() End If End SubEnd Class
  • 32. 32Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniFormLOGINTambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormLOGIN”Keterangan Toolbox :1 GroupBox2 Label2 TextBox2 Button1 PictureBox1 GroupBox :GroupBox Data2 Label :USERNAME, PASSWORD2 TextBox :TxtUSERNAME, TxtPASSWORD2 Button :BtnLOGIN, BtnCANCEL1 PictureBox :Silahkan pilih gambar anda sendiriLalu isikan syntax sbb :Imports System.DataImports System.Data.SqlClientPublic Class FormLOGIN Inherits System.Windows.Forms.Form
  • 33. 33Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Dim FrmUTAMA As New FormUTAMA Dim Koneksiku As New AksesData.ClassKONEKSIDATABASE Sub CekUSER() DT.Clear() strSQL = "Select * From TABEL_LOGIN Where USERNAMELOG=" &TxtUSERNAME.Text.Trim & "" DataAdapter = New SqlDataAdapter(strSQL, Koneksiku.BukaKoneksi) DS = New DataSet DataAdapter.Fill(DS, "TABEL_LOGIN") DT = DS.Tables("TABEL_LOGIN") Koneksiku.TutupKoneksi() End Sub Sub CariUSER() strSQL = "Select * From TABEL_LOGIN Where USERNAMELOG = " &TxtUSERNAME.Text.Trim & "" Command = New SqlCommand(strSQL, Koneksiku.BukaKoneksi) DataReader = Command.ExecuteReader While DataReader.Read Username = DataReader.Item("USERNAMELOG") Password = DataReader.Item("PASSWORDLOG") Access = DataReader.Item("ACCESS") IdUser = DataReader.Item("IDUSER") End While Koneksiku.TutupKoneksi() End Sub Private Sub BtnCANCEL_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnCANCEL.Click MSG = MessageBox.Show("SURE WANT TO EXIT PAYROLL SYSTEM ??","WIRATMOJO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If MSG = vbYes Then End Else Exit Sub End If End Sub Private Sub BtnLOGIN_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnLOGIN.Click If TxtUSERNAME.Text.Trim = "" Then MessageBox.Show("USERNAME, CANNOT BE EMPTY FIELD", "WIRATMOJO",MessageBoxButtons.OK, MessageBoxIcon.Information) TxtUSERNAME.Focus() ElseIf TxtPASSWORD.Text.Trim = "" Then
  • 34. 34Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani MessageBox.Show("PASSWORD, CANNOT BE EMPTY FIELD", "WIRATMOJO",MessageBoxButtons.OK, MessageBoxIcon.Information) TxtPASSWORD.Focus() Else Try Call CekUSER() If DT.Rows.Count <= 0 Then MessageBox.Show("USERNAME ISNT RECOGNIZED, " & vbCrLf& _ "PLEASE USE VALID DATA !!","WIRATMOJO", MessageBoxButtons.OK, MessageBoxIcon.Error) TxtUSERNAME.Text = "" TxtUSERNAME.Focus() Else Call CariUSER() If Password <> TxtPASSWORD.Text.Trim Then MessageBox.Show("PASSWORD ISNT RECOGNIZED, " &vbCrLf & _ "PLEASE USE VALID DATA !!","WIRATMOJO", MessageBoxButtons.OK, MessageBoxIcon.Error) TxtPASSWORD.Text = "" TxtPASSWORD.Focus() Else FrmUTAMA.Show() Me.Hide() TxtUSERNAME.Text = "" TxtPASSWORD.Text = "" End If End If Catch When Err.Number <> 0 MessageBox.Show("SYSTEM CANT REACHED DATABASE, " & vbCrLf& _ "PLEASE CONTACT YOUR ADMINISTRATOR !!","ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End If End Sub Private Sub FormLOGIN_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load TxtUSERNAME.CharacterCasing = CharacterCasing.Upper TxtPASSWORD.CharacterCasing = CharacterCasing.Upper End Sub Private Sub TxtUSERNAME_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtUSERNAME.KeyPress
  • 35. 35Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani If e.KeyChar = Chr(13) Then TxtPASSWORD.Focus() End If End Sub Private Sub TxtPASSWORD_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtPASSWORD.KeyPress If e.KeyChar = Chr(13) Then BtnLOGIN.Focus() End If End SubEnd ClassFormSPLASHTambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormSPLASH”Keterangan Toolbox :5 Label1 ProgressBar1 PictureBox2 Timer5 Label :LOADING DATABASE CONNECTION, PAYROLL SYSTEM 2011, LblANGKA, %1 ProgressBar :BAR
  • 36. 36Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani1 PictureBox :Gambar uang atau silahkan pilih gambar anda sendiri, BEBAS daaag..2 Timer :TimerSPLASH, TimerLABELLalu isikan syntax sbb :Public Class FormSPLASH Dim FRM As New FormLOGIN Dim BARIS As Integer Private Sub TimerSPLASH_Tick(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles TimerSPLASH.Tick BARIS = BARIS + 1 BAR.Value = BARIS LblANGKA.Text = BARIS If LblANGKA.Text = 100 Then TimerSPLASH.Dispose() Me.Hide() FRM.Show() End If End Sub Private Sub TimerLABEL_Tick(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles TimerLABEL.Tick If Label1.Visible = True Then Label1.Visible = False ElseIf Label1.Visible = False Then Label1.Visible = True End If End SubEnd Class
  • 37. 37Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniFormUTAMATambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormUTAMA”Keterangan Toolbox :1 MenuStrip1 Statusbar2 Timer1 Statusbar1 MenuStrip :FILEToolStripMenuItem  PROGRAMMERToolStripMenuItem, EXITToolStripMenuItem
  • 38. 38Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniMASTERDATAToolMenuItem  USERSYSTEM, EMPLOToolStripMenuItem,CITYToolStripMenuItem1, PAYROLLToolStripMenuItem1REPORTINGToolStripMenuItem  USERDATAToolStripMenuItem,EMPLOYEEDATAToolStripMenuItem, CITYToolStripMenuItem, PAYROLLToolStripMenuItem,PRINTSLIPGAJIToolStripMenuItem1 ToolStrip :BtnToolUSER, BtnToolEMPLOYEE, BtnToolCITY, BtnToolPAYROLL, BtnToolEXIT2 Timer :TimerStsLISENSI, TimerJAM1 StatusBar :StsIDUSER, Username :.:, StsUSER, Access :.:, StsACCESS, Date :.:, StsDATE, Jam :.:, StsJAM,StsLISENSI
  • 39. 39Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniLalu isikan syntax sbb :Imports System.DataImports System.Data.SqlClientImports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.SharedPublic Class FormUTAMA Inherits System.Windows.Forms.Form#Region "JAM" Dim lpT As CLASS_SISTEM Dim dateUTC As Date Dim WTime As Date#End Region Private Declare Sub GetSystemTime Lib "kernel32" (ByRef lpSystemTime AsCLASS_SISTEM) Private Structure CLASS_SISTEM Public wYear As Short Public wMonth As Short Public wDayOfWeek As Short Public wDay As Short Public wHour As Short Public wMinute As Short Public wSecond As Short Public wMiliSeconds As Short End Structure Private Sub RUNJAM() Try Call GetSystemTime(lpT) Indonesia dateUTC = Date.UtcNow().AddHours(7.0) WTime = CDate(lpT.wHour & ":" & lpT.wMinute & ":" &lpT.wSecond).AddHours(7.0) StsJAM.Text = WTime.ToLongTimeString Catch ex As Exception MsgBox(ex.ToString) End Try End Sub Dim myTabel As CrystalDecisions.CrystalReports.Engine.Table Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo Dim ObjDoc As New ReportDocument Dim ObjCon As New ConnectionInfo Dim ObjLog As New TableLogOnInfo Dim Formula AsCrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition
  • 40. 40Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Dim RptUSER As New RptDATAUSER Dim RptPEGAWAI As New RptEMPLOYEE Dim RptCITY As New RptDDATACITY Dim RptGAJIAN As New RptSLIPGAJI Private Sub PROGRAMMERToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesPROGRAMMERToolStripMenuItem.Click FormPROGRAMMER.ShowDialog() End Sub Private Sub EXITToolStripMenuItem_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles EXITToolStripMenuItem.Click MSG = MessageBox.Show("ARE YOU SURE WANT TO EXIT PAYROLL SYSTEM??","WIRATMOJO", _ MessageBoxButtons.YesNo, MessageBoxIcon.Question) If MSG = vbYes Then End Else Exit Sub End If End Sub Private Sub EMPLOToolStripMenuItem_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles EMPLOToolStripMenuItem.Click FormPEGAWAI.ShowDialog() End Sub Private Sub FormUTAMA_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load StsIDUSER.Text = IdUser StsUSER.Text = Username StsACCESS.Text = Access StsDATE.Text = Today.Date.ToLongDateString If StsACCESS.Text = "USER" Then USERSYSTEM.Enabled = False BtnToolUSER.Enabled = False USERDATAToolStripMenuItem.Enabled = False Else USERSYSTEM.Enabled = True BtnToolUSER.Enabled = True USERDATAToolStripMenuItem.Enabled = True End If End Sub Private Sub USERDATAToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesUSERDATAToolStripMenuItem.Click Dim Koneksi As New AksesData.ClassKONEKSIDATABASE() Koneksi.BukaKoneksi() Dim B As New FormRptDATAUSER RptUSER = New RptDATAUSER For Each myTable In RptUSER.Database.Tables
  • 41. 41Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani myLogin = myTable.LogOnInfo myLogin.ConnectionInfo.UserID = "uas" myLogin.ConnectionInfo.Password = "123" myLogin.ConnectionInfo.ServerName = "Localhost" myLogin.ConnectionInfo.DatabaseName = "PAYROL_DB" myTable.ApplyLogOnInfo(myLogin) Next B.ReportDATAUSER.ReportSource = RptUSER B.ReportDATAUSER.RefreshReport() B.ShowDialog() End Sub Private Sub EMPLOYEEDATAToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesEMPLOYEEDATAToolStripMenuItem.Click Dim Koneksi As New AksesData.ClassKONEKSIDATABASE() Koneksi.BukaKoneksi() Dim A As New FormRptPEGAWAI RptPEGAWAI = New RptEMPLOYEE For Each myTable In RptPEGAWAI.Database.Tables myLogin = myTable.LogOnInfo myLogin.ConnectionInfo.UserID = "uas" myLogin.ConnectionInfo.Password = "123" myLogin.ConnectionInfo.ServerName = "Localhost" myLogin.ConnectionInfo.DatabaseName = "PAYROL_DB" myTable.ApplyLogOnInfo(myLogin) Next A.REPORTPEGAWAI.ReportSource = RptPEGAWAI A.REPORTPEGAWAI.RefreshReport() A.ShowDialog() End Sub Private Sub CITYToolStripMenuItem_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles CITYToolStripMenuItem.Click Dim Koneksi As New AksesData.ClassKONEKSIDATABASE() Koneksi.BukaKoneksi() Dim D As New FormRptCITY RptCITY = New RptDDATACITY For Each myTable In RptCITY.Database.Tables myLogin = myTable.LogOnInfo myLogin.ConnectionInfo.UserID = "uas" myLogin.ConnectionInfo.Password = "123" myLogin.ConnectionInfo.ServerName = "Localhost" myLogin.ConnectionInfo.DatabaseName = "PAYROL_DB" myTable.ApplyLogOnInfo(myLogin)
  • 42. 42Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Next D.RptViewerCITY.ReportSource = RptCITY D.RptViewerCITY.RefreshReport() D.ShowDialog() End Sub Private Sub CITYToolStripMenuItem1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles CITYToolStripMenuItem1.Click FormCITY.ShowDialog() End Sub Private Sub TimerStsLISENSI_Tick(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles TimerStsLISENSI.Tick If StsLISENSI.Visible = True Then StsLISENSI.Visible = False ElseIf StsLISENSI.Visible = False Then StsLISENSI.Visible = True End If End Sub Private Sub TimerJAM_Tick(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles TimerJAM.Tick Call RUNJAM() End Sub Private Sub USERSYSTEM_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles USERSYSTEM.Click FormUSER.ShowDialog() End Sub Private Sub BtnToolUSER_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnToolUSER.Click FormUSER.ShowDialog() End Sub Private Sub BtnToolEMPLOYEE_Click(ByVal sender As System.Object, ByVale As System.EventArgs) Handles BtnToolEMPLOYEE.Click FormPEGAWAI.ShowDialog() End Sub Private Sub BtnToolCITY_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnToolCITY.Click FormCITY.ShowDialog() End Sub Private Sub BtnToolEXIT_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnToolEXIT.Click MSG = MessageBox.Show("ARE YOU SURE WANT TO EXIT PAYROLL SYSTEM??","WIRATMOJO", _ MessageBoxButtons.YesNo, MessageBoxIcon.Question) If MSG = vbYes Then End Else Exit Sub End If End Sub
  • 43. 43Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Private Sub BtnToolPAYROLL_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles BtnToolPAYROLL.Click FormTRANSAKSI.ShowDialog() End Sub Private Sub PAYROLLToolStripMenuItem1_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesPAYROLLToolStripMenuItem1.Click FormTRANSAKSI.ShowDialog() End Sub Private Sub PAYROLLToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesPAYROLLToolStripMenuItem.Click Dim Koneksi As New AKSESDATA.ClassKONEKSIDATABASE() Koneksi.BukaKoneksi() Dim F As New FormRptPAYROLL RptGAJIAN = New RptSLIPGAJI For Each myTable In RptGAJIAN.Database.Tables myLogin = myTable.LogOnInfo myLogin.ConnectionInfo.UserID = "uas" myLogin.ConnectionInfo.Password = "123" myLogin.ConnectionInfo.ServerName = "Localhost" myLogin.ConnectionInfo.DatabaseName = "PAYROL_DB" myTable.ApplyLogOnInfo(myLogin) Next F.ReportViewPAYROLL.ReportSource = RptGAJIAN F.ReportViewPAYROLL.RefreshReport() F.ShowDialog() End Sub Private Sub PRINTSLIPGAJIToolStripMenuItem_Click(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesPRINTSLIPGAJIToolStripMenuItem.Click FormSLIPGAJI_UAS.ShowDialog() End SubEnd Class
  • 44. 44Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniFormCITYTambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormCITY”Keterangan ToolBox :2 Label2 TextBox1 Button1 DataGridView2 Label :KODE KOTA, NAMA KOTA2 TextBox :TxtKODEKOTA, TxtNAMAKOTA1 Button :BtnKOTA1 DataGridView :GridKOTALalu isikan syntax sbb :Imports System.DataImports System.Data.SqlClientImports System.Windows.Forms.FormPublic Class FormCITY Dim rsGRID As ADODB.Recordset
  • 45. 45Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Private Sub BtnKOTA_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnKOTA.Click If BtnKOTA.Text = "&Item Baru" Then BtnKOTA.Text = "&Insert Data Seksi" Call ID_KOTA() TxtNAMAKOTA.Focus() Else If TxtNAMAKOTA.Text = "" Then MessageBox.Show("TIDAK ADA DATA!!, SILAHKAN INPUT TERLEBIHDULU", "WIRAT INFO", MessageBoxButtons.OK) TxtNAMAKOTA.Focus() Else Call SIMPAN() BtnKOTA.Text = "&Item Baru" End If End If End Sub Private Sub SIMPAN() CONN.Execute("Insert Into TABEL_CITY Values (" & TxtKODEKOTA.Text& "," & TxtNAMAKOTA.Text & ")") MessageBox.Show("DATA TELAH TERSIMPAN !!", "WIRAT INFO",MessageBoxButtons.OK) TxtKODEKOTA.Text = "" TxtNAMAKOTA.Text = "" BtnKOTA.Focus() Call DATABARU() End Sub Private Sub DATABARU() rsGRID = New ADODB.Recordset rsGRID.Open("Select * From TABEL_CITY", CONN,ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) Call DATAGRID() End Sub Private Sub DATAGRID() Dim Koneksi As New SqlConnection("Data Source=WIRAT-KOMP; UserId=uas; Password=123; Initial Catalog=PAYROL_DB;") Dim Query As New SqlCommand("Select * From TABEL_CITY", Koneksi) Dim Reader As SqlDataReader Try Koneksi.Open() Reader = Query.ExecuteReader Dim Data As New DataTable Data.Load(Reader) GridKOTA.DataSource = Data Reader.Close() Catch ex As Exception
  • 46. 46Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani MessageBox.Show(ex.ToString) End Try End Sub Private Sub ID_KOTA() Dim rsIDSeksi As ADODB.Recordset Dim strIDSeksi As String rsIDSeksi = New ADODB.Recordset rsIDSeksi = CONN.Execute("Select Max(IDCITY) as IDCITY FROMTABEL_CITY") If Not rsIDSeksi.EOF Then If rsIDSeksi.Fields("IDCITY").Value.ToString <> "" Then strIDSeksi =Format(Val(Microsoft.VisualBasic.Right(rsIDSeksi.Fields("IDCITY").Value.ToString, 2) + 1), "0#") Else strIDSeksi = Format(1, "0#") End If rsIDSeksi.Close() TxtKODEKOTA.Text = strIDSeksi End If End Sub Private Sub FormKOTA_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load Call KONEKSI_DATABASE() Call DATAGRID() TxtNAMAKOTA.CharacterCasing = CharacterCasing.Upper End Sub Private Sub TxtNAMAKOTA_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtNAMAKOTA.KeyPress If e.KeyChar = Chr(13) Then BtnKOTA.Focus() End If End SubEnd Class
  • 47. 47Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniFormPROGRAMMERTambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormPROGRAMMER” untuk form aplikasi ini, anda bisasaja mengganti gambarnya pada PictureBox.FormPEGAWAITambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormPEGAWAI”
  • 48. 48Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniKeterangan ToolBox :7 Button1 DataGridView4 TextBox1 DateTimePicker1 ComboBox2 GroupBox6 Label7 Button :BtnFIRST, BtnPREVIOUS, BtnNEXT, BtnLAST, BtnADD, BtnEDIT, BtnSAVE, BtnCANCEL,BtnDELETE, BtnREPORT, BtnCLOSE1 DataGridView :GridPEGAWAI4 TextBox :TxtNIP, TxtNAMA, TxtALAMAT, TxtKODEPOS1 DateTimePicker :DtLAHIR1 ComboBox :CmbKOTA2 GroupBox :GroupBox Data Employee, GroupBox Button6 Label :NIP, NAME, BIRTH, CITY, ADDRESS, ZIP CODELalu isikan koding berikut :Imports System.DataImports System.Data.SqlClientImports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.SharedPublic Class FormPEGAWAI Dim myTabel As CrystalDecisions.CrystalReports.Engine.Table Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo Dim ObjDoc As New ReportDocument Dim ObjCon As New ConnectionInfo Dim ObjLog As New TableLogOnInfo Dim RptPEGAWAI As New RptEMPLOYEE Dim Formula AsCrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition
  • 49. 49Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Dim Status As Boolean Dim KodeSeksi As String Private Sub DataComboKOTA() Dim rsKOTA As ADODB.Recordset Dim A As String Dim B As String rsKOTA = New ADODB.Recordset rsKOTA.Open("Select * From TABEL_CITY Order By IDCITY ASC", CONN,ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) With rsKOTA CmbKOTA.Items.Clear() Do Until .EOF A = rsKOTA.Fields("IDCITY").Value B = rsKOTA.Fields("NAMACITY").Value CmbKOTA.Items.Add(A & " - " & B) .MoveNext() Loop .MoveLast() End With End Sub Sub Validasi(ByVal Bool As Boolean) With Me .TxtALAMAT.Enabled = Not Bool .TxtKODEPOS.Enabled = Not Bool .TxtKOTA.Enabled = Not Bool CmbKOTA.Enabled = Not Bool .TxtNAMA.Enabled = Not Bool .TxtNIP.Enabled = Not Bool .DtLAHIR.Enabled = Not Bool .BtnADD.Enabled = Bool .BtnCANCEL.Enabled = Not Bool .BtnCLOSE.Enabled = Bool .BtnDELETE.Enabled = Bool .BtnEDIT.Enabled = Bool .BtnREPORT.Enabled = Bool .BtnSAVE.Enabled = Not Bool .GridPEGAWAI.Enabled = Bool .BtnFIRST.Enabled = Bool .BtnLAST.Enabled = Bool .BtnNEXT.Enabled = Bool .BtnPREVIOUS.Enabled = Bool End With End Sub Sub TampilkanData()
  • 50. 50Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Call Validasi(True) DT.Clear() Dim KoneksiKu As New AksesData.ClassKONEKSIDATABASE DataAdapter = New SqlDataAdapter("Select * From TABEL_PEGAWAI",KoneksiKu.BukaKoneksi) DS = New DataSet DataAdapter.Fill(DS, "TbPegawai") DT = DS.Tables("TbPegawai") GridPEGAWAI.DataSource = DT TxtNIP.DataBindings.Add("TEXT", DT, "NIP") TxtNAMA.DataBindings.Add("TEXT", DT, "NAMAPEGAWAI") DtLAHIR.DataBindings.Add("VALUE", DT, "TGLLAHIR") TxtALAMAT.DataBindings.Add("TEXT", DT, "ALAMAT") TxtKOTA.DataBindings.Add("TEXT", DT, "IDCITY") CmbKOTA.DataBindings.Add("TEXT", DT, "IDCITY") TxtKODEPOS.DataBindings.Add("TEXT", DT, "KODEPOS") End Sub Sub LepasBinding() With Me .TxtALAMAT.DataBindings.Clear() .TxtKODEPOS.DataBindings.Clear() .TxtKOTA.DataBindings.Clear() .CmbKOTA.DataBindings.Clear() .TxtNAMA.DataBindings.Clear() .TxtNIP.DataBindings.Clear() .DtLAHIR.DataBindings.Clear() End With End Sub Sub KosongkanNilai() With Me .TxtALAMAT.Text = "" .TxtKODEPOS.Text = "" .TxtKOTA.Text = "" .CmbKOTA.Text = "" .TxtNAMA.Text = "" .TxtNIP.Text = "" .DtLAHIR.Value = Today.Date End With End Sub Sub CekNIP() DT.Clear() Dim KoneksiKu As New AksesData.ClassKONEKSIDATABASE
  • 51. 51Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Dim CMD As New SqlCommand("Select * From TABEL_PEGAWAI Where NIP=" & _ TxtNIP.Text & "",KoneksiKu.BukaKoneksi) DataAdapter = New SqlDataAdapter(CMD) DS = New DataSet DataAdapter.Fill(DS, "CariNIP") DT = DS.Tables("CariNIP") End Sub Private Sub FormPEGAWAI_Load(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles MyBase.Load Call KONEKSI_DATABASE() Call TampilkanData() Call DataComboKOTA() TxtKODEPOS.MaxLength = 5 End Sub Private Sub BtnCLOSE_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnCLOSE.Click Call LepasBinding() Me.Close() End Sub Private Sub Huruf() TxtNAMA.CharacterCasing = CharacterCasing.Upper TxtALAMAT.CharacterCasing = CharacterCasing.Upper End Sub Private Sub BtnADD_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnADD.Click Status = True Call Validasi(False) Call LepasBinding() Call KosongkanNilai() Call Huruf() Call ID_PEGAWAI() TxtNAMA.Focus() End Sub Private Sub BtnEDIT_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnEDIT.Click Status = False Call Validasi(False) Call LepasBinding() Call Huruf()
  • 52. 52Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani TxtNIP.Enabled = False TxtNAMA.Focus() End Sub Private Sub BtnSAVE_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnSAVE.Click Dim MyCommand As New AKSESDATA.ClassMANIPULASIDATA Dim KODEKOTA As String KODEKOTA = Format(Microsoft.VisualBasic.Left(CmbKOTA.Text.ToString,2)) If Status = True Then Call CekNIP() If DT.Rows.Count <= 0 Then MyCommand.TambahData(TxtNIP.Text, TxtNAMA.Text,DtLAHIR.Value, _ TxtALAMAT.Text, KODEKOTA,TxtKODEPOS.Text) Call TampilkanData() Else MessageBox.Show("DATA HAS BEEN INPUTED," & vbCrLf & _ "PLEASE USE ANOTHER NIP", "WIRATMOJO",MessageBoxButtons.OK, MessageBoxIcon.Information) End If Else MyCommand.UbahData(TxtNIP.Text, TxtNAMA.Text, DtLAHIR.Value, _ TxtALAMAT.Text, KODEKOTA,TxtKODEPOS.Text) Call TampilkanData() End If End Sub Private Sub BtnCANCEL_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnCANCEL.Click Call TampilkanData() End Sub Private Sub BtnDELETE_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnDELETE.Click Dim MyCommand As New AKSESDATA.ClassMANIPULASIDATA MSG = MessageBox.Show("SURE WANT TO DELETE THIS DATA ??","WIRATMOJO", MessageBoxButtons.YesNo, MessageBoxIcon.Question) If MSG = vbYes Then MyCommand.HapusData(TxtNIP.Text) Call LepasBinding() Call TampilkanData() End If
  • 53. 53Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani End Sub Private Sub BtnFIRST_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnFIRST.Click BindingContext(DT).Position = 0 End Sub Private Sub BtnPREVIOUS_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnPREVIOUS.Click BindingContext(DT).Position = BindingContext(DT).Position - 1 End Sub Private Sub BtnNEXT_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnNEXT.Click BindingContext(DT).Position = BindingContext(DT).Position + 1 End Sub Private Sub BtnLAST_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnLAST.Click BindingContext(DT).Position = DT.Rows.Count - 1 End Sub Private Sub BtnREPORT_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnREPORT.Click Dim Koneksi As New AksesData.ClassKONEKSIDATABASE() Koneksi.BukaKoneksi() Dim A As New FormRptPEGAWAI RptPEGAWAI = New RptEMPLOYEE For Each myTable In RptPEGAWAI.Database.Tables myLogin = myTable.LogOnInfo myLogin.ConnectionInfo.UserID = "uas" myLogin.ConnectionInfo.Password = "123" myLogin.ConnectionInfo.ServerName = "Localhost" myLogin.ConnectionInfo.DatabaseName = "PAYROL_DB" myTable.ApplyLogOnInfo(myLogin) Next A.REPORTPEGAWAI.ReportSource = RptPEGAWAI A.REPORTPEGAWAI.RefreshReport() A.ShowDialog() End Sub Private Sub ID_PEGAWAI() Dim rsIDPegawai As ADODB.Recordset Dim StrIDPegawai As String rsIDPegawai = New ADODB.Recordset rsIDPegawai = CONN.Execute("Select Max(NIP) as NIP FROMTABEL_PEGAWAI") If Not rsIDPegawai.EOF Then If rsIDPegawai.Fields("NIP").Value.ToString <> "" Then
  • 54. 54Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani StrIDPegawai =Format(Val(Microsoft.VisualBasic.Left(rsIDPegawai.Fields("NIP").Value.ToString, _ 5) + 1), "0####") & "-" & Format(Now, "yyyy") Else StrIDPegawai = Format(1, "0####") & "-" & Format(Now,"yyyy") End If rsIDPegawai.Close() TxtNIP.Text = StrIDPegawai End If End Sub Private Sub TxtNAMA_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtNAMA.KeyPress If e.KeyChar = Chr(13) Then DtLAHIR.Focus() End If End Sub Private Sub DtLAHIR_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles DtLAHIR.KeyPress If e.KeyChar = Chr(13) Then CmbKOTA.Focus() End If End Sub Private Sub CmbKOTA_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles CmbKOTA.KeyPress If e.KeyChar = Chr(13) Then TxtALAMAT.Focus() End If End Sub Private Sub TxtALAMAT_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtALAMAT.KeyPress If e.KeyChar = Chr(13) Then TxtKODEPOS.Focus() End If End Sub Private Sub TxtKODEPOS_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtKODEPOS.KeyPress SUPAYA PADA TxtANGKA HANYA BISA DI INPUT ANGKA (1234567890) SAJA Dim INPUT_ANGKA As Integer =Char.ConvertToUtf32(e.KeyChar.ToString(), 0) If Not (((INPUT_ANGKA >= 48) And (INPUT_ANGKA <= 57)) Or(INPUT_ANGKA = 8)) Then e.Handled = True JADI KALO TEKAN KEYBOARD BUKAN ANGKA PC BUNYI (TUNG!!) Beep() End If End SubEnd Class
  • 55. 55Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniFormTRANSAKSITambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormTRANSAKSI”2 GroupBox26 Label12 TextBox4 ComboBox1 DateTimePicker2 Button2 GroupBox :26 Label :NO PAYROLL, NIP, NAMA PEGAWAI, TGL LAHIR, ALAMAT, KOTA, KODE POS, GAJI BERSIH, GAJIBULAN, JABATAN, GOLONGAN, GAJI, TUNJANGAN, LEMBURAN, JAM, UANG LEMBUR, NPWP,POTONGAN, UANG LEMBUR 30,000/JAM, LblTERBILANGGAJIBERSIH, LblTAHUN,LblTERBILANGGAJI, LblTERBILANGTUNJANGAN, LblTERBILANGLEMBUR,LblTERBILANGPOTONGAN12 TextBox :TxtNOPAYROLL, TxtNAMAPEGAWAI, TxtKOTA, TxtKODEPOS, TxtGAJIBERSIH, TxtGAJI,TxtTUNJANGAN, TxtLEMBURAN, TxtUANGLEMBUR, TxtNPWP, TxtPOTONGAN4 ComboBox :CmbNIP, CmbBULAN, CmbJABATAN, CmbGOLONGAN,
  • 56. 56Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani1 DateTimePicker :DtLAHIR2 Button :BtnINPUT, BtnCLOSELalu isikan koding sbb :Imports System.DataImports System.Data.SqlClientImports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.SharedPublic Class FormTRANSAKSI Inherits System.Windows.Forms.Form Dim rsCARI As ADODB.Recordset Dim rsSIMPAN As ADODB.Recordset Dim TERBILANG As CLASS_TERBILANG = New CLASS_TERBILANG Dim myTabel As CrystalDecisions.CrystalReports.Engine.Table Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo Dim ObjDoc As New ReportDocument Dim ObjCon As New ConnectionInfo Dim ObjLog As New TableLogOnInfo Dim RptPAYROLL As New RptPAYROLL Dim RptGAJIAN As New RptSLIPGAJI Dim Formula AsCrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition Private Sub CARINIP() Dim cNIP As String rsCARI = New ADODB.Recordset rsCARI.Open("Select Distinct NIP From TABEL_PEGAWAI Order By NIPAsc", CONN, ADODB.CursorTypeEnum.adOpenDynamic,ADODB.LockTypeEnum.adLockOptimistic) With rsCARI CmbNIP.Items.Clear() Do Until .EOF cNIP = rsCARI.Fields("NIP").Value CmbNIP.Items.Add(cNIP) .MoveNext() Loop .MoveFirst() End With End Sub Private Sub BtnCLOSE_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnCLOSE.Click If BtnINPUT.Text = "&SIMPAN" Then BtnINPUT.Text = "&INPUT"
  • 57. 57Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Call KOSONG() Call KUNCI(False) Else Me.Close() End If End Sub Private Sub BtnINPUT_Click(ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles BtnINPUT.Click If BtnINPUT.Text = "&INPUT" Then BtnINPUT.Text = "&SIMPAN" Call BUKAKUNCI(True) Call CARINIP() Call PAYROLLNUMBER() CmbNIP.Focus() ElseIf BtnINPUT.Text = "&SIMPAN" Then Call SIMPAN() End If End Sub Private Sub KOSONG() With Me .TxtNOPAYROLL.Text = "" .CmbNIP.Text = "" .TxtNAMAPEGAWAI.Text = "" .DTLahir.Text = Today.Date .TxtALAMAT.Text = "" .TxtKOTA.Text = "" .TxtKODEPOS.Text = "" .CmbBULAN.Text = "" .CmbJABATAN.Text = "" .CmbGOLONGAN.Text = "" .TxtGAJI.Text = "" .TxtTUNJANGAN.Text = "" .TxtLEMBURAN.Text = "" .TxtUANGLEMBUR.Text = "" .TxtNPWP.Text = "" .TxtPOTONGAN.Text = "" .TxtGAJIBERSIH.Text = "" End With End Sub Private Sub KUNCI(ByVal MATI As Boolean) With Me .TxtNOPAYROLL.Enabled = MATI .CmbNIP.Enabled = MATI .TxtNAMAPEGAWAI.Enabled = MATI .DTLahir.Enabled = MATI .TxtALAMAT.Enabled = MATI .TxtKOTA.Enabled = MATI .TxtKODEPOS.Enabled = MATI .CmbBULAN.Enabled = MATI .CmbJABATAN.Enabled = MATI .CmbGOLONGAN.Enabled = MATI .TxtGAJI.Enabled = MATI .TxtTUNJANGAN.Enabled = MATI .TxtLEMBURAN.Enabled = MATI .TxtUANGLEMBUR.Enabled = MATI
  • 58. 58Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani .TxtNPWP.Enabled = MATI .TxtPOTONGAN.Enabled = MATI .TxtGAJIBERSIH.Enabled = MATI End With End Sub Private Sub BUKAKUNCI(ByVal NYALA As Boolean) With Me .CmbNIP.Enabled = NYALA .CmbBULAN.Enabled = NYALA .CmbJABATAN.Enabled = NYALA .CmbGOLONGAN.Enabled = NYALA .TxtLEMBURAN.Enabled = NYALA .TxtNPWP.Enabled = NYALA .TxtPOTONGAN.Enabled = NYALA End With End Sub Private Sub FormTRANSAKSI_Load(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles MyBase.Load Call KONEKSI_DATABASE() Call KUNCI(False) Call KOSONG() Call DataCOMBO() TxtNPWP.MaxLength = 15 LblTAHUN.Text = Format(Now, "yyyy") End Sub Private Sub CmbNIP_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles CmbNIP.KeyPress If e.KeyChar = Chr(13) Then CmbBULAN.Focus() End If End Sub Private Sub CmbNIP_SelectedIndexChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles CmbNIP.SelectedIndexChanged rsCARI = New ADODB.Recordset rsCARI.Open("Select * From TABEL_PEGAWAI Where NIP=" & CmbNIP.Text& "", _ CONN, ADODB.CursorTypeEnum.adOpenDynamic,ADODB.LockTypeEnum.adLockOptimistic) While rsCARI.EOF <> True TxtNAMAPEGAWAI.Text = rsCARI.Fields("NAMAPEGAWAI").Value DTLahir.Text = rsCARI.Fields("TGLLAHIR").Value TxtALAMAT.Text = rsCARI.Fields("ALAMAT").Value TxtKOTA.Text = rsCARI.Fields("IDCITY").Value TxtKODEPOS.Text = rsCARI.Fields("KODEPOS").Value rsCARI.MoveNext() End While End Sub Private Sub DataCOMBO() With CmbJABATAN
  • 59. 59Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani .Items.Clear() .Items.Add("MANAGER") .Items.Add("SUPERVISOR") .Items.Add("STAFF") End With With CmbBULAN .Items.Clear() .Items.Add("JANUARI") .Items.Add("FEBRUARI") .Items.Add("MARET") .Items.Add("APRIL") .Items.Add("MEI") .Items.Add("JUNI") .Items.Add("JULI") .Items.Add("AGUSTUS") .Items.Add("SEPTEMBER") .Items.Add("OKTOBER") .Items.Add("NOVEMBER") .Items.Add("DESEMBER") End With End Sub Private Sub CmbGOLONGAN_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles CmbGOLONGAN.KeyPress If e.KeyChar = Chr(13) Then TxtLEMBURAN.Focus() End If End Sub Private Sub TxtGAJI_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtGAJI.KeyPress SUPAYA PADA TxtANGKA HANYA BISA DI INPUT ANGKA (1234567890) SAJA Dim INPUT_ANGKA As Integer =Char.ConvertToUtf32(e.KeyChar.ToString(), 0) If e.KeyChar = Chr(13) Then TxtTUNJANGAN.Focus() TxtGAJI.Text = Format(TxtGAJI.Text, "#,#") Else If Not (((INPUT_ANGKA >= 48) And (INPUT_ANGKA <= 57)) Or(INPUT_ANGKA = 8)) Then e.Handled = True JADI KALO TEKAN KEYBOARD BUKAN ANGKA PC BUNYI (TUNG!!) Beep() End If End If End Sub Private Sub CmbJABATAN_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles CmbJABATAN.KeyPress If e.KeyChar = Chr(13) Then CmbGOLONGAN.Focus() End If
  • 60. 60Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani End Sub Private Sub TxtTUNJANGAN_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtTUNJANGAN.KeyPress SUPAYA PADA TxtANGKA HANYA BISA DI INPUT ANGKA (1234567890) SAJA Dim INPUT_ANGKA As Integer =Char.ConvertToUtf32(e.KeyChar.ToString(), 0) If e.KeyChar = Chr(13) Then TxtLEMBURAN.Focus() TxtTUNJANGAN.Text = Format(TxtTUNJANGAN.Text, "#,#") Else If Not (((INPUT_ANGKA >= 48) And (INPUT_ANGKA <= 57)) Or(INPUT_ANGKA = 8)) Then e.Handled = True JADI KALO TEKAN KEYBOARD BUKAN ANGKA PC BUNYI (TUNG!!) Beep() End If End If End Sub Private Sub TxtLEMBURAN_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtLEMBURAN.KeyPress SUPAYA PADA TxtANGKA HANYA BISA DI INPUT ANGKA (1234567890) SAJA Dim INPUT_ANGKA As Integer =Char.ConvertToUtf32(e.KeyChar.ToString(), 0) If e.KeyChar = Chr(13) Then Dim UANGLEMBUR As String UANGLEMBUR = TxtLEMBURAN.Text * 30000 TxtUANGLEMBUR.Text = UANGLEMBUR TxtNPWP.Focus() Else If Not (((INPUT_ANGKA >= 48) And (INPUT_ANGKA <= 57)) Or(INPUT_ANGKA = 8)) Then e.Handled = True JADI KALO TEKAN KEYBOARD BUKAN ANGKA PC BUNYI (TUNG!!) Beep() End If End If End Sub Private Sub TxtNPWP_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtNPWP.KeyPress SUPAYA PADA TxtANGKA HANYA BISA DI INPUT ANGKA (1234567890) SAJA Dim INPUT_ANGKA As Integer =Char.ConvertToUtf32(e.KeyChar.ToString(), 0)
  • 61. 61Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani If e.KeyChar = Chr(13) Then TxtPOTONGAN.Focus() Else If Not (((INPUT_ANGKA >= 48) And (INPUT_ANGKA <= 57)) Or(INPUT_ANGKA = 8)) Then e.Handled = True JADI KALO TEKAN KEYBOARD BUKAN ANGKA PC BUNYI (TUNG!!) Beep() End If End If End Sub Private Sub SIMPAN() Dim TANYA As Integer TANYA = MsgBox("SURE TO SAVE DATA??", MsgBoxStyle.Question,"WIRATMOJO") If TANYA = 7 Then Exit Sub Else rsSIMPAN = New ADODB.Recordset rsSIMPAN.Open("Select * From TABEL_UAS", CONN,ADODB.CursorTypeEnum.adOpenDynamic, ADODB.LockTypeEnum.adLockOptimistic) rsSIMPAN.AddNew() rsSIMPAN.Fields(0).Value = TxtNOPAYROLL.Text rsSIMPAN.Fields(1).Value = IdUser Deklarasi ModulUmum Fielddari TabelLogin rsSIMPAN.Fields(2).Value = CmbNIP.Text rsSIMPAN.Fields(3).Value = TxtNPWP.Text rsSIMPAN.Fields(4).Value = CmbBULAN.Text rsSIMPAN.Fields(5).Value = CmbJABATAN.Text rsSIMPAN.Fields(6).Value = CmbGOLONGAN.Text rsSIMPAN.Fields(7).Value = TxtGAJI.Text rsSIMPAN.Fields(8).Value = TxtTUNJANGAN.Text rsSIMPAN.Fields(9).Value = TxtPOTONGAN.Text rsSIMPAN.Fields(10).Value = TxtLEMBURAN.Text rsSIMPAN.Fields(11).Value = TxtUANGLEMBUR.Text rsSIMPAN.Fields(12).Value = TxtGAJIBERSIH.Text rsSIMPAN.Fields(13).Value = LblTAHUN.Text rsSIMPAN.Update() MessageBox.Show("DATA TERSIMPAN !!!", "WIRATMOJO",MessageBoxButtons.OK, MessageBoxIcon.Information) Dim Koneksi As New AKSESDATA.ClassKONEKSIDATABASE() Koneksi.BukaKoneksi() Dim F As New FormRptPAYROLL RptPAYROLL = New RptPAYROLL RptGAJIAN = New RptSLIPGAJI
  • 62. 62Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani For Each myTable In RptGAJIAN.Database.Tables myLogin = myTable.LogOnInfo myLogin.ConnectionInfo.UserID = "uas" myLogin.ConnectionInfo.Password = "123" myLogin.ConnectionInfo.ServerName = "Localhost" myLogin.ConnectionInfo.DatabaseName = "PAYROL_DB" myTable.ApplyLogOnInfo(myLogin) Next F.ReportViewPAYROLL.SelectionFormula ="{TABEL_UAS.NOPAYROLL}=" + TxtNOPAYROLL.Text + "" F.ReportViewPAYROLL.ReportSource = RptGAJIAN F.ReportViewPAYROLL.RefreshReport() F.ShowDialog() Call KUNCI(False) Call KOSONG() BtnINPUT.Text = "&INPUT" End If End Sub Private Sub TxtPOTONGAN_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles TxtPOTONGAN.KeyPress SUPAYA PADA TxtANGKA HANYA BISA DI INPUT ANGKA (1234567890) SAJA Dim INPUT_ANGKA As Integer =Char.ConvertToUtf32(e.KeyChar.ToString(), 0) If e.KeyChar = Chr(13) Then BtnINPUT.Focus() Dim GAJIBERSIH As String GAJIBERSIH = (Val(TxtGAJI.Text) + Val(TxtTUNJANGAN.Text) +Val(TxtUANGLEMBUR.Text) - Val(TxtPOTONGAN.Text)) TxtGAJIBERSIH.Text = GAJIBERSIH Else If Not (((INPUT_ANGKA >= 48) And (INPUT_ANGKA <= 57)) Or(INPUT_ANGKA = 8)) Then e.Handled = True JADI KALO TEKAN KEYBOARD BUKAN ANGKA PC BUNYI (TUNG!!) Beep() End If End If End Sub Private Sub CmbJABATAN_SelectedIndexChanged(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesCmbJABATAN.SelectedIndexChanged If CmbJABATAN.Text = "MANAGER" Then CmbGOLONGAN.Items.Clear()
  • 63. 63Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani CmbGOLONGAN.Items.Add("S1") CmbGOLONGAN.Items.Add("S2") ElseIf CmbJABATAN.Text = "SUPERVISOR" Then CmbGOLONGAN.Items.Clear() CmbGOLONGAN.Items.Add("M1") CmbGOLONGAN.Items.Add("M2") ElseIf CmbJABATAN.Text = "STAFF" Then CmbGOLONGAN.Items.Clear() CmbGOLONGAN.Items.Add("J1") CmbGOLONGAN.Items.Add("J2") End If End Sub Private Sub CmbGOLONGAN_SelectedIndexChanged(ByVal sender AsSystem.Object, ByVal e As System.EventArgs) HandlesCmbGOLONGAN.SelectedIndexChanged If CmbGOLONGAN.Text = "S1" Then TxtGAJI.Text = "18000000" TxtTUNJANGAN.Text = "700000" ElseIf CmbGOLONGAN.Text = "S2" Then TxtGAJI.Text = "16000000" TxtTUNJANGAN.Text = "600000" ElseIf CmbGOLONGAN.Text = "M1" Then TxtGAJI.Text = "9000000" TxtTUNJANGAN.Text = "400000" ElseIf CmbGOLONGAN.Text = "M2" Then TxtGAJI.Text = "7000000" TxtTUNJANGAN.Text = "300000" ElseIf CmbGOLONGAN.Text = "J1" Then TxtGAJI.Text = "5000000" TxtTUNJANGAN.Text = "500000" ElseIf CmbGOLONGAN.Text = "J2" Then TxtGAJI.Text = "4000000" TxtTUNJANGAN.Text = "200000" End If End Sub Private Sub TxtGAJI_TextChanged(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles TxtGAJI.TextChanged If TxtGAJI.Text <> "" Then LblTERBILANGGAJI.Text = TERBILANG.ANGKA_TERBILANG(TxtGAJI.Text)+ " RUPIAH" Else LblTERBILANGGAJI.Text = "TERBILANG GAJI" End If End Sub Private Sub TxtTUNJANGAN_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles TxtTUNJANGAN.TextChanged If TxtTUNJANGAN.Text <> "" Then LblTERBILANGTUNJANGAN.Text =TERBILANG.ANGKA_TERBILANG(TxtTUNJANGAN.Text) + " RUPIAH" Else LblTERBILANGTUNJANGAN.Text = "TERBILANG TUNJANGAN" End If End Sub
  • 64. 64Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Private Sub TxtUANGLEMBUR_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles TxtUANGLEMBUR.TextChanged If TxtUANGLEMBUR.Text <> "" Then LblTERBILANGLEMBUR.Text =TERBILANG.ANGKA_TERBILANG(TxtUANGLEMBUR.Text) + " RUPIAH" Else LblTERBILANGLEMBUR.Text = "TERBILANG LEMBUR" End If End Sub Private Sub TxtPOTONGAN_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles TxtPOTONGAN.TextChanged If TxtPOTONGAN.Text <> "" Then LblTERBILANGPOTONGAN.Text =TERBILANG.ANGKA_TERBILANG(TxtPOTONGAN.Text) + " RUPIAH" Else LblTERBILANGPOTONGAN.Text = "TERBILANG POTONGAN" End If End Sub Private Sub TxtGAJIBERSIH_TextChanged(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles TxtGAJIBERSIH.TextChanged If TxtGAJIBERSIH.Text <> "" Then LblTERBILANGGAJIBERSIH.Text =TERBILANG.ANGKA_TERBILANG(TxtGAJIBERSIH.Text) + " RUPIAH" Else LblTERBILANGGAJIBERSIH.Text = "TERBILANG GAJIBERSIH" End If End Sub Private Sub CmbBULAN_KeyPress(ByVal sender As Object, ByVal e AsSystem.Windows.Forms.KeyPressEventArgs) Handles CmbBULAN.KeyPress If e.KeyChar = Chr(13) Then CmbJABATAN.Focus() End If End Sub Private Sub PAYROLLNUMBER() Dim rsIDPayroll As ADODB.Recordset Dim strIDPayroll As String rsIDPayroll = New ADODB.Recordset rsIDPayroll = CONN.Execute("Select Max(NOPAYROLL) as NOPAYROLLFROM TABEL_PAYROLL") rsIDPayroll = CONN.Execute("Select Max(NOPAYROLL) as NOPAYROLL FROMTABEL_UAS") If Not rsIDPayroll.EOF Then If rsIDPayroll.Fields("NOPAYROLL").Value.ToString <> "" Then strIDPayroll =Format(Val(Microsoft.VisualBasic.Right(rsIDPayroll.Fields("NOPAYROLL").Value.ToString, 7) + 1), "0######") Else strIDPayroll = Format(1, "0######") End If rsIDPayroll.Close() TxtNOPAYROLL.Text = strIDPayroll
  • 65. 65Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani End If End SubEnd ClassFormSLIPGAJITambahkan sebuah form dengan klik kanan folder “APPLICATION FORM” pilih “Windows form”,dan beri nama form tersebut dengan “FormSLIPGAJI”Keterangan ToolBox :3 ComboBox1 Button3 ComboBox :CmbNIP, CmbGAJIBULAN, CmbTAHUN1 Button :BtnCETAKSLIPLalu isikan koding berikut :Imports System.DataImports System.Data.SqlClientImports CrystalDecisions.CrystalReports.EngineImports CrystalDecisions.SharedPublic Class FormSLIPGAJI_UAS Dim myTabel As CrystalDecisions.CrystalReports.Engine.Table Dim myLogin As CrystalDecisions.Shared.TableLogOnInfo Dim ObjDoc As New ReportDocument Dim ObjCon As New ConnectionInfo Dim ObjLog As New TableLogOnInfo
  • 66. 66Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Dim Formula AsCrystalDecisions.CrystalReports.Engine.FormulaFieldDefinition Dim rsCARI As ADODB.Recordset Dim RptGAJIAN As New RptSLIPGAJI Private Sub IsiComboBox() With CmbGAJIBULAN .Items.Clear() .Items.Add("JANUARI") .Items.Add("FEBRUARI") .Items.Add("MARET") .Items.Add("APRIL") .Items.Add("MEI") .Items.Add("JUNI") .Items.Add("JULI") .Items.Add("AGUSTUS") .Items.Add("SEPTEMBER") .Items.Add("OKTOBER") .Items.Add("NOVEMBER") .Items.Add("DESEMBER") End With With CmbTAHUN .Items.Clear() .Items.Add("2011") .Items.Add("2012") .Items.Add("2013") End With End Sub Private Sub CARINIP() Dim cNIP As String rsCARI = New ADODB.Recordset rsCARI.Open("Select Distinct NIP From TABEL_PEGAWAI Order By NIPAsc", CONN, ADODB.CursorTypeEnum.adOpenDynamic,ADODB.LockTypeEnum.adLockOptimistic) With rsCARI CmbNIP.Items.Clear() Do Until .EOF cNIP = rsCARI.Fields("NIP").Value CmbNIP.Items.Add(cNIP) .MoveNext() Loop .MoveFirst() End With End Sub Private Sub FormSLIPGAJI_UAS_Load(ByVal sender As System.Object, ByVale As System.EventArgs) Handles MyBase.Load Call KONEKSI_DATABASE() Call CARINIP() Call IsiComboBox()
  • 67. 67Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani End Sub Private Sub BtnCETAKSLIP_Click(ByVal sender As System.Object, ByVal eAs System.EventArgs) Handles BtnCETAKSLIP.Click Dim Koneksi As New AKSESDATA.ClassKONEKSIDATABASE() Koneksi.BukaKoneksi() Dim F As New FormRptPAYROLL RptGAJIAN = New RptSLIPGAJI For Each myTable In RptGAJIAN.Database.Tables myLogin = myTable.LogOnInfo myLogin.ConnectionInfo.UserID = "uas" myLogin.ConnectionInfo.Password = "123" myLogin.ConnectionInfo.ServerName = "Localhost" myLogin.ConnectionInfo.DatabaseName = "PAYROL_DB" myTable.ApplyLogOnInfo(myLogin) Next F.ReportViewPAYROLL.SelectionFormula = "{TABEL_UAS.NIP}=" +CmbNIP.Text + " And {TABEL_UAS.GAJIBULAN}=" + CmbGAJIBULAN.Text + " And{TABEL_UAS.TAHUN}=" + CmbTAHUN.Text + "" F.ReportViewPAYROLL.ReportSource = RptGAJIAN F.ReportViewPAYROLL.RefreshReport() F.ShowDialog() End SubEnd Class
  • 68. 68Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani Membuat REPORTKita hampir tiba di penghujung pembuatan aplikasi PAYROLL, yaitu pembuatan report.Tambahkan sebuah report dengan klik kanan pada folder “REPORT”  New Item  Reporting Crystal Report  beri nama RptDATAUSER
  • 69. 69Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani
  • 70. 70Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniPilih TABEL_LOGIN, karena memang data dari table tersebut yang akan ditampilkan
  • 71. 71Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniPilih field mana saja yang akan ditampilkan pada Report tersebut. Berikutnya pada sesi“Grouping” dan “Record Selection” lewatkan saja karena belum akan dipakai. Dan pada sesi“Report Style”Lalu settinglah layout Report anda sbb :
  • 72. 72Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniSehingga bila di running reportnya sbb :Lakukanlah hal yang sama untuk menbuat Report lainnya (RptDATACITY, RptEMPLOYEE)namun khusus pada RptSlip Gaji tambahkan sesi “Grouping” pada pembuatan Reportnyadengan Field “NOPAYROLL”. Dan setting reportnya sbb :
  • 73. 73Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniSehingga layout reportnya sbb :Lalu buatlah form untuk menampilkan report-report tersebut. Dengan hanya menambahkanCrystalReportViewer pada masing-masing form tersebut. Buatlah 4 Form Viewer Report(FormRptDATAUSER, FormRptCITY, FormRptPEGAWAI, FormRptPAYROLL).
  • 74. 74Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniFormRptDATAUSER  beri nama CrystalReportViewer  ReportDATAUSERFormRptCITY  beri nama CrystalReportViewer  RptViewerCITYFormRptPEGAWAI  beri nama CrystalReportViewer  REPORTPEGAWAIFormRptPAYROLL  beri nama CrystalReportViewer  ReportViewPAYROLLMembuat Setup Aplikasi PAYROLLFile  Add  New Project
  • 75. 75Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniIsikan data dengan benar sbb :Projec t types  Other Project Types  Setup and DeploymentNama Setup  Setup PAYROLL-SYSTEM 2011Setup yang telah kita create tersebut akan tampil dibawah project dan database yang telah kitarapikan sebelumnya. Klik kanan pada Setup PAYROLL-SYSTEM 2011  Properties Prerequisites
  • 76. 76Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniChoose which prerequisites to install  .NET Framework 2.0 (x86)  Windows Installer 3.1  .NET Framework 3.0 (x86)  .NET Framework 3.5  Crystal Reports Basic for Visual Studio 2008 (x68, x64  Microsoft Visual Studio 2008 Report ViewerLalu pilih Download prerequisites from the same location as my applicationOKLangkah selajutnya adalah memastikan seluruh aplikasi sudah berjalan dengan lancar tanpamasalah dan juga sesuai denga algoritma yang di inginkan dengan menjadi “FormSPLASH” yangpertama kali di run dari sistem aplikasi ini.
  • 77. 77Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniUser’s Programs Menu  klik kanan  Add  Tab Browse  File .exe aplikasi, cari dalamfolder “bin” sistem aplikasi PAYROLL andaLakukan hal yang sama pada folder “Application Folder” dengan menambahkan sebuah file“.ico” untuk dijadikan icon aplikasi. Juga jangan lupa buatlah “Shortcut” dengan settingpropertiesnya menggunakan icon tersebut. Dan kemudian “Cut” Shortcut tersebut dandipindahkan ke dalam folder “User’s Desktop”Dan langkah terakhir adalah BUILD file Setup ini
  • 78. 78Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina InsaniPastikan pesan Building setup Succeeded yang tertera pada pojok kiri bawahWELL DONE GOOD JOB MISSION COMPLETED !!!
  • 79. 79Step By Step Build Payroll System 2011 By B.Wiratmojo – STMIK Bina Insani B.Wiratmojo Kuliah D3nya diselesaikan pada tahun 2008 lalu di Kampus STMIK Bina Insani, Jurusan Teknik Informatika dan kemudian kembali melanjutkan Program Strata 1 pada tahun 2011 ditempat dan jurusan yang sama. Bekerja di PT Bridgestone Tire Indonesia sejak 2008. Bercita-cita dapat selalu mendedikasikan dirinya dalam bidang IT Indonesia dan Dunia. illuminator372@gmail.com or bambang.wiratmojo@bridgestone.co.id bambangwiratmojo.blogspot.com PAYROLL SYSTEM 2011 Materi UAS Visual Basic.NET