Form login : Dim isi As Integer Private Sub cmdclose_Click() Unload Me End Sub Private Sub cmdlogin_Click() With dbuser.Recordset If txtuser.Text = "" And txtpass.Text = "" Then MsgBox "UserName dan Password tidak boleh Kosong!", vbCritical, "Login" isi = isi - 1 Text1.SetFocus Else If Not isi = 0 Then .Find "kd_user='" & Trim(txtuser.Text) & "'", , adSearchForward, 1 If Not .EOF Then If !Password = Trim(txtpass.Text) Then Unload Me MsgBox "Selamat Menggunakan Program ini ! " & Chr(13) & _ "UserName anda : " & !kd_user & Chr(13) & "Status Anda : " & !status, vbInformation, "Login"
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Form login :
Dim isi As Integer
Private Sub cmdclose_Click()Unload MeEnd Sub
Private Sub cmdlogin_Click()With dbuser.Recordset If txtuser.Text = "" And txtpass.Text = "" Then MsgBox "UserName dan Password tidak boleh Kosong!", vbCritical, "Login" isi = isi - 1 Text1.SetFocus Else If Not isi = 0 Then .Find "kd_user='" & Trim(txtuser.Text) & "'", , adSearchForward, 1 If Not .EOF Then If !Password = Trim(txtpass.Text) Then Unload Me MsgBox "Selamat Menggunakan Program ini ! " & Chr(13) & _ "UserName anda : " & !kd_user & Chr(13) & "Status Anda : " & !status, vbInformation, "Login" status = !status user = !nama_user kode = !kd_user MDIForm1.Show MDIForm1.BackColor = vbBlack ''***add putra komandan With form_utama End With ''***add end anton
Unload Me Exit Sub Else MsgBox "UserName atau Password anda Salah !", vbCritical, "Login" isi = isi - 1 End If Else MsgBox "UserName atau Password anda Salah !", vbCritical, "Login" isi = isi - 1 Call Bersih txtuser.SetFocus txtuser.SelStart = 0 txtuser.SelLength = Len(txtuser) End If Else MsgBox "Terima Kasih Sudah Menggunakan Program Ini ! ", vbInformation, "Terima Kasih" End End If End IfEnd WithLabel4.Caption = "Kesempatan Mengulang tinggal " & isi & " lagi !"If isi = 0 Then MsgBox "Terima Kasih Sudah Menggunakan Program Ini ! ", vbInformation, "Terima Kasih" EndEnd IfEnd Sub
Private Sub dbuser_WillMove(ByVal adReason As ADODB.EventReasonEnum, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
Private Sub txtuser_KeyPress(KeyAscii As Integer)KeyAscii = Asc(UCase(Chr(KeyAscii)))If KeyAscii = 13 Then txtpass.SetFocus txtpass.SelStart = 0 txtpass.SelLength = Len(txtpass)End IfEnd Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)If KeyAscii = 13 Then cmdlogin_ClickEnd IfEnd Sub
Private Sub Form_Load()
End Sub
Private Sub Label1_Click()
End Sub
Private Sub ProgressBar1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
End Sub
Private Sub Timer1_Timer()ProgressBar1.Value = ProgressBar1.Value + 1If ProgressBar1.Value >= ProgressBar1.Max ThenTimer1.Enabled = FalseUnload Meform_login.ShowEnd IfEnd Sub
Private Sub cmdexit_Click()Unload MeEnd Sub
Private Sub Form_Load()
End Sub
Private Sub Label1_Click()
End Sub
Private Sub Label10_Click()
End Sub
Private Sub Label12_Click()
End Sub
Private Sub Label6_Click()
End Sub
Dim tambah As BooleanDim urut, urut2, urut3 As StringDim nomor As Integer
Private Sub cmdhapus_Click()Dim cari As Stringcari = InputBox("Masukan kode yang akan dihapus", "Hapus Data", "")dbbuku.Recordset.Find "kd_buku='" & cari & "'", , adSearchForward, 1If Not dbbuku.Recordset.EOF Then If dbbuku.Recordset.RecordCount = 0 Then MsgBox "Record Kosong", vbOKOnly + vbInformation, "" Else Call tampil pesan = MsgBox("Yakin akan dihapus?", vbYesNo + vbInformation, "Hapus Data") If pesan = vbYes Then dbbuku.Recordset.Delete cmdbatal_Click MsgBox "Penghapusan Berhasil", vbInformation, "" DataGrid1.Refresh cmdhapus.SetFocus Else Call kosong cmdhapus.SetFocus End If End IfElseMsgBox "Kode tidak ada", vbInformation, ""End IfEnd Sub
Private Sub cmdkeluar_Click()Unload MeEnd Sub
Private Sub cmdsimpan_Click()If txtkode.Text = "" Or txtnama.Text = "" Or txtharga.Text = "" Or txtstok.Text = "" Then MsgBox "Isi dulu field yang kosong", vbInformation, "Cek Lagi" txtkode.SetFocus Exit SubEnd IfWith dbbuku.Recordset
Private Sub cmdhapus_Click()Dim cari As StringKeyAscii = Asc(UCase(Chr(KeyAscii)))cari = InputBox("Masukan kode yang akan dihapus", "Hapus Data", "")dbuser.Recordset.Find "kd_user='" & cari & "'", , adSearchForward, 1If Not dbuser.Recordset.EOF Then If dbuser.Recordset.RecordCount = 0 Then MsgBox "Record Kosong", vbOKOnly + vbInformation, "" Else txtkode.Text = dbuser.Recordset!kd_user txtstatus.Text = dbuser.Recordset!status pass.Text = dbuser.Recordset!Password txtnama.Text = dbuser.Recordset!nama_user pesan = MsgBox("Yakin akan dihapus?", vbYesNo + vbInformation, "Hapus Data") If pesan = vbYes Then dbuser.Recordset.Delete Call Bersih MsgBox "Penghapusan Berhasil", vbInformation, "" Else Call Bersih End If End IfElseMsgBox "Kode tidak ada", vbInformation, ""End IfEnd Sub
Private Sub cmdkeluar_Click()Unload MeEnd Sub
Private Sub cmdsimpan_Click()
If txtkode.Text = "" Or txtnama.Text = "" Or txtstatus.Text = "" Or pass.Text = "" Then MsgBox "Isi dulu field yang kosong", vbInformation, "Perhatian" txtstatus.SetFocus Exit SubEnd IfWith dbuser.RecordsetIf tambah = True Then.AddNew !kd_user = txtkode.Text !nama_user = txtnama.Text !status = txtstatus.Text !Password = pass.Text .UpdateElse !nama_user = txtnama.Text !status = txtstatus.Text !Password = pass.Text .Update End If.Requerycmdsimpan.Enabled = FalseEnd WithForm_ActivateMe.Refresh
MsgBox "Data Berhasil Disimpan!!!", vbInformation, "Konfirmasi"cmdtambah.Caption = "&Add"Call BersihEnd Sub
Private Sub Form_Load()dbuser.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\penjualan.mdb;Persist Security Info=False"dbuser.RecordSource = "select *from T_User"dbuser.RefreshEnd Sub
Private Sub n_aktif()txtkode.Enabled = Falsetxtnama.Enabled = Falsetxtstatus.Enabled = Falsepass.Enabled = FalseEnd Sub
Private Sub aktif()txtkode.Enabled = Truetxtnama.Enabled = Truetxtstatus.Enabled = Truepass.Enabled = TrueEnd Sub
Private Sub Bersih()txtkode.Text = ""txtnama.Text = ""pass.Text = ""txtstatus.Text = ""End Sub
Sub nomor()Dim awal As StringDim no As DoubleDim nih As String
awal = Left(txtstatus.Text, 3)With dbuser.RecordsetIf .RecordCount = 0 Thennih = awal & "01"Else.MoveLastno = Format(Val(Right(!kd_user, 2) + 1))nih = awal & Right("00" & no, 2)End IfEnd Withtxtkode.Text = nihEnd Sub
Private Sub gelap()txtkode.BackColor = &H80000015txtstatus.BackColor = &H80000015txtnama.BackColor = &H80000015pass.BackColor = &H80000015End Sub
Private Sub terang()txtkode.BackColor = &HE0E0E0txtstatus.BackColor = &HE0E0E0txtnama.BackColor = &HE0E0E0pass.BackColor = &HE0E0E0End Sub
Private Sub Timer1_Timer()Me.Width = Me.Width + 400'tengahIf Me.Width >= 10530 Then Timer1.Enabled = False 'tengahEnd IfEnd Sub
Private Sub Form_Activate()Call n_aktifCall gelapcmdsimpan.Enabled = Falsecmdtambah.Enabled = Truecmdhapus.Enabled = Truecmdedit.Enabled = Truecmdtambah.SetFocusEnd Sub
Private Sub Form_Unload(Cancel As Integer)DoMe.Left = Me.Left + 40Me.Move Me.Left, Me.TopDoEventsLoop Until Me.Left > Screen.WidthEnd Sub
Private Sub pass_KeyPress(KeyAscii As Integer)KeyAscii = Asc(UCase(Chr(KeyAscii)))If KeyAscii = 13 ThenCall nomorcmdsimpan.Enabled = Truecmdsimpan.SetFocusEnd IfEnd Sub
Private Sub txtkode_Change()If Left(txtkode, 3) = "ADM" Thentxtstatus.Text = "ADMINISTRATOR"ElseIf Left(txtkode, 3) = "KAS" Thentxtstatus.Text = "KASIR"End IfEnd Sub
Private Sub txtkode_KeyPress(KeyAscii As Integer)KeyAscii = Asc(UCase(Chr(KeyAscii)))If KeyAscii = 13 ThenIf Len(txtkode.Text) < 5 Or Len(txtkode.Text) > 5 ThenMsgBox "Masukkan 5 Digit !", vbOKOnly + vbInformation, "Kesalahan"txtkode.Text = awal & notxtkode.Text = ""txtkode.SetFocusElsedbuser.RecordSource = "select * from T_user where kd_user='" & txtkode.Text & "'"dbuser.Refresh If dbuser.Recordset.RecordCount = 0 Then cmdsimpan.Enabled = True txtnama.SetFocus Else MsgBox "Kode sudah ada!", vbOKOnly + vbInformation, "Cek Kembali" txtkode.Text = "" txtstatus.Text = "" txtkode.Enabled = True txtkode.SetFocus tampil Exit Sub End IfEnd IfEnd IfEnd Sub
Private Sub tampil()txtkode.Text = dbuser.Recordset!kd_usertxtnama.Text = dbuser.Recordset!nama_usertxtstatus.Text = dbuser.Recordset!statuspass.Text = dbuser.Recordset!PasswordEnd Sub
Private Sub txtnama_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then pass.SetFocus End IfEnd Sub
Private Sub txtstatus_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtnama.SetFocus End IfEnd Sub
Private Sub MDIForm_Load()
End Sub
Private Sub MNABOUT_Click()If status = "KASIR" ThenMDIForm1.MNABOUT.Enabled = FalseElseform_biodata.ShowEnd IfEnd Sub
Private Sub MNBUKU_Click()If status = "KASIR" ThenMsgBox "Maaf Anda Tidak Berhak Masuk...", vbCritical, "Pesan"Elseform_buku.ShowEnd IfEnd Sub
Private Sub MNEXIT_Click()Unload MeEnd Sub
Private Sub MNLAPBRG_Click()
If status = "KASIR" ThenMsgBox "Maaf Anda Tidak Berhak Masuk...", vbCritical, "Pesan"Elselap_barang.ShowEnd IfEnd Sub
Private Sub MNLAPBUKU_Click()lap_barang.ShowEnd Sub
Private Sub MNLAPJUAL_Click()If status = "KASIR" ThenMsgBox "Maaf Anda Tidak Berhak Masuk...", vbCritical, "Pesan"Elselap_jual.ShowEnd IfEnd Sub
Private Sub MNTRANS_Click()form_transaksi.ShowEnd Sub
Private Sub MNUSER_Click()If status = "KASIR" ThenMsgBox "Maaf Anda Tidak Berhak Masuk...", vbCritical, "Pesan"Elseform_user.ShowEnd IfEnd Sub
Option ExplicitDim KdBuku As StringDim NmBuku As StringDim JmlBuku As StringDim item As IntegerPrivate Sub Form_Activate() Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Penjualan.mdb;Persist Security Info=False" Adodc1.RecordSource = "select *from T_Buku" Adodc1.Refresh Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\Penjualan.mdb;Persist Security Info=False" Adodc3.RecordSource = "select * from T_Detail_jual" Adodc3.Refresh Struk.SetFocus Call tampilEnd SubPrivate Sub Form_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then MsgBox "Printing struk done", vbInformation, "Information" End IfEnd Sub
Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer) If KeyCode = vbKeyF1 Then Unload Me form_transaksi.Show End IfEnd SubSub tampil() item = 1
Me.List1.Clear Me.List1.Font.Name = "courier new" Me.List1.AddItem "" Me.List1.AddItem " FAKTUR : " & Me.lblfaktur.Caption Me.List1.AddItem " TANGGAL : " & Me.lbltgl.Caption Me.List1.AddItem " USER : " & Me.lbluser.Caption Me.List1.AddItem " --------------------------------------" Adodc3.RecordSource = "select * from T_Detail_jual where no_faktur='" & Trim(lblfaktur.Caption) & "'" Adodc3.Refresh Do Until Adodc3.Recordset.EOF KdBuku = Adodc3.Recordset!kd_buku JmlBuku = Adodc3.Recordset!jml_beli Adodc1.Recordset.Find "kd_buku='" & KdBuku & "'", , adSearchForward, 1 If Not Adodc1.Recordset.EOF Then NmBuku = Adodc1.Recordset!nama_buku Me.List1.AddItem " Nama Barang : " & NmBuku End If Me.List1.AddItem " Jml Barang : " & JmlBuku Adodc3.Recordset.MoveNext Loop Me.List1.AddItem " --------------------------------------" Me.List1.AddItem " Total : " & Me.lbltotal.Caption Me.List1.AddItem " DiBayar : " & Me.lblbayar.Caption Me.List1.AddItem " --------------------------------------" Me.List1.AddItem " Kembali : " & Me.lblkembali.Caption Me.List1.AddItem " --------------------------------------" Me.List1.AddItem " Terima Kasih atas kunjungan Anda" Me.List1.RefreshEnd Sub
Private Sub List1_Click()
End Sub
MODULES
DESIGNERS
Private Sub DataReport_Error(ByVal JobType As MSDataReportLib.AsyncTypeConstants, ByVal Cookie As Long, ByVal ErrObj As MSDataReportLib.RptError, ShowError As Boolean)
End Sub
Private Sub DataReport_Error(ByVal JobType As MSDataReportLib.AsyncTypeConstants, ByVal Cookie As Long, ByVal ErrObj As MSDataReportLib.RptError, ShowError As Boolean)