frmTMPEGAWAI.frm

 VERSION 5.00
Begin VB.Form frmTMPEGAWAI
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "MASTER - PEGAWAI"
   ClientHeight    =   3945
   ClientLeft      =   45
   ClientTop       =   435
   ClientWidth     =   8505
   ControlBox      =   0   'False
   KeyPreview      =   -1  'True
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3945
   ScaleWidth      =   8505
   ShowInTaskbar   =   0   'False
   Begin VB.Frame frmDTKNTRL
      Caption         =   "Data Kontrol"
      Height          =   1215
      Left            =   240
      TabIndex        =   16
      Top             =   2400
      Width           =   7935
      Begin VB.CommandButton cmdFIRST
         Caption         =   "<<"
         Height          =   615
         Left            =   240
         TabIndex        =   3
         Top             =   360
         Width           =   735
      End
      Begin VB.CommandButton cmdPREV
         Caption         =   "<"
         Height          =   615
         Left            =   960
         TabIndex        =   4
         Top             =   360
         Width           =   735
      End
      Begin VB.CommandButton cmdNEXT
         Caption         =   ">"
         Height          =   615
         Left            =   1680
         TabIndex        =   5
         Top             =   360
         Width           =   735
      End
      Begin VB.CommandButton cmdLAST
         Caption         =   ">>"
         Height          =   615
         Left            =   2400
         TabIndex        =   6
         Top             =   360
         Width           =   735
      End
      Begin VB.CommandButton cmdEXIT
         Caption         =   "Keluar"
         Height          =   615
         Left            =   6960
         TabIndex        =   11
         Top             =   360
         Width           =   735
      End
      Begin VB.CommandButton cmdTMBH
         Caption         =   "Tambah Data"
         Height          =   615
         Left            =   3120
         TabIndex        =   7
         Top             =   360
         Width           =   855
      End
      Begin VB.CommandButton cmdUBAH
         Caption         =   "Ubah Data"
         Height          =   615
         Left            =   3960
         TabIndex        =   8
         Top             =   360
         Width           =   1215
      End
      Begin VB.CommandButton cmdHAPUS
         Caption         =   "Hapus Data"
         Height          =   615
         Left            =   6120
         TabIndex        =   10
         Top             =   360
         Width           =   855
      End
      Begin VB.CommandButton cmdSIMPAN
         Caption         =   "Simpan"
         Height          =   615
         Left            =   5160
         TabIndex        =   9
         Top             =   360
         Width           =   975
      End
   End
   Begin VB.Frame frmeData
      Height          =   1935
      Left            =   240
      TabIndex        =   12
      Top             =   240
      Width           =   7935
      Begin VB.TextBox txtBagian
         BeginProperty Font
            Name            =   "Comic Sans MS"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2040
         MaxLength       =   20
         TabIndex        =   2
         Top             =   1320
         Width           =   2655
      End
      Begin VB.TextBox txtKode
         BeginProperty Font
            Name            =   "Comic Sans MS"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2040
         MaxLength       =   3
         TabIndex        =   0
         Top             =   360
         Width           =   495
      End
      Begin VB.TextBox txtNama
         BeginProperty Font
            Name            =   "Comic Sans MS"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   2040
         MaxLength       =   20
         TabIndex        =   1
         Top             =   840
         Width           =   2655
      End
      Begin VB.Label lblBagian
         AutoSize        =   -1  'True
         Caption         =   "Bagian"
         BeginProperty Font
            Name            =   "Comic Sans MS"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   360
         TabIndex        =   15
         Top             =   1320
         Width           =   600
      End
      Begin VB.Label lblKode
         AutoSize        =   -1  'True
         Caption         =   "Kode Pegawai"
         BeginProperty Font
            Name            =   "Comic Sans MS"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   360
         TabIndex        =   14
         Top             =   360
         Width           =   1245
      End
      Begin VB.Label lblNama
         AutoSize        =   -1  'True
         Caption         =   "Nama Pegawai"
         BeginProperty Font
            Name            =   "Comic Sans MS"
            Size            =   9.75
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   270
         Left            =   360
         TabIndex        =   13
         Top             =   840
         Width           =   1290
      End
   End
End
Attribute VB_Name = "frmTMPEGAWAI"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Dim rstTMPEGAWAI As ADODB.Recordset

Private Sub cmdEXIT_Click()
    Unload Me
End Sub

Private Sub cmdTMBH_Click()
    If cmdTMBH.Caption = "Tambah Data" Then
        cmdTMBH.Caption = "Batal Tambah"
       
        IsiData
       
        txtKode.SetFocus
    Else
        Kunci_Data
       
        TampilkanData
       
        cmdTMBH.Caption = "Tambah Data"
    End If
End Sub

Private Sub Form_Load()
   
    Set rstTMPEGAWAI = New ADODB.Recordset
    rstTMPEGAWAI.CursorLocation = adUseClient
    rstTMPEGAWAI.Open "SELECT * FROM TMPEGAWAI ORDER BY Kd_Pgw", Cn, adOpenDynamic, adLockOptimistic
   
    If rstTMPEGAWAI.EOF Then
        RECKOS
    Else
        rstTMPEGAWAI.MoveFirst
       
        Kunci_Data
       
        TampilkanData
    End If
End Sub

Private Sub IsiData()
    txtKode.Text = ""
    txtNama.Text = ""
    txtBagian.Text = ""
   
    Buka_Kunci_Text
   
    cmdSIMPAN.Enabled = True
   
    Kunci_Tombol
   
    cmdUBAH.Enabled = False
    cmdHAPUS.Enabled = False
End Sub

Private Sub Kunci_Text()
    txtKode.Locked = True
    txtNama.Locked = True
    txtBagian.Locked = True
End Sub

Private Sub Kunci_Tombol()
    cmdPREV.Enabled = False
    cmdNEXT.Enabled = False
    cmdFIRST.Enabled = False
    cmdLAST.Enabled = False
End Sub

Private Sub Buka_Kunci_Text()
    txtKode.Locked = False
    txtNama.Locked = False
    txtBagian.Locked = False
End Sub

Private Sub Buka_Kunci_Tombol()
    cmdPREV.Enabled = True
    cmdNEXT.Enabled = True
    cmdFIRST.Enabled = True
    cmdLAST.Enabled = True
End Sub

Private Sub Kunci_Data()
    Kunci_Text
   
    cmdSIMPAN.Enabled = False
    cmdTMBH.Enabled = True
   
    Buka_Kunci_Tombol
   
    cmdUBAH.Enabled = True
    cmdHAPUS.Enabled = True
End Sub

Private Sub TampilkanData()
    txtKode.Text = rstTMPEGAWAI.Fields("Kd_Pgw")
    txtNama.Text = rstTMPEGAWAI.Fields("Nm_Pgw")
    txtBagian.Text = rstTMPEGAWAI.Fields("Bagian")
End Sub

Private Sub cmdFIRST_Click()
    If rstTMPEGAWAI.RecordCount <> 0 Then
        rstTMPEGAWAI.MoveFirst
        If Not rstTMPEGAWAI.EOF Then
            TampilkanData
        End If
    End If
End Sub

Private Sub cmdLAST_Click()
    If rstTMPEGAWAI.RecordCount <> 0 Then
        rstTMPEGAWAI.MoveLast
        If Not rstTMPEGAWAI.BOF Then
            TampilkanData
        End If
    End If
End Sub

Private Sub cmdNEXT_Click()
    If Not rstTMPEGAWAI.EOF Then
        rstTMPEGAWAI.MoveNext
        If Not rstTMPEGAWAI.EOF Then
            TampilkanData
        End If
    End If
End Sub

Private Sub cmdPREV_Click()
    If Not rstTMPEGAWAI.BOF Then
        rstTMPEGAWAI.MovePrevious
        If Not rstTMPEGAWAI.BOF Then
            TampilkanData
        End If
    End If
End Sub

Private Sub cmdHAPUS_Click()
    If rstTMPEGAWAI.RecordCount <> 0 Then
        rstTMPEGAWAI.Delete
        rstTMPEGAWAI.MoveNext
        If rstTMPEGAWAI.EOF Then
            rstTMPEGAWAI.MovePrevious
            If rstTMPEGAWAI.BOF Then
               
                cmdTMBH.Enabled = False
               
                IsiData
            Else
           
                TampilkanData
            End If
        Else
            TampilkanData
        End If
    End If
End Sub

Private Sub RECKOS()
    Buka_Kunci_Text
   
    Kunci_Tombol
   
    cmdUBAH.Enabled = False
    cmdTMBH.Enabled = False
    cmdHAPUS.Enabled = False
    cmdSIMPAN.Enabled = True
End Sub

Private Sub KUNCI()
    Kunci_Tombol
   
    cmdUBAH.Enabled = False
    cmdTMBH.Enabled = False
    cmdHAPUS.Enabled = False
End Sub

Private Sub cmdUBAH_Click()
    If cmdUBAH.Caption = "Ubah Data" Then
        cmdUBAH.Caption = "Batal Ubah"
        Buka_Kunci_Text
       
        KUNCI
       
        cmdSIMPAN.Enabled = True
       
        txtKode.SetFocus
    Else
        cmdUBAH.Caption = "Ubah Data"
       
        Kunci_Data
    End If
   
    cmdUBAH.Enabled = True
End Sub
Private Sub cmdSIMPAN_Click()
    If Trim(txtKode) = "" Or Trim(txtNama) = "" Or Trim(txtBagian) = "" Then
        MsgBox "Isi field anda", vbCritical, "666"
       
        txtKode.SetFocus
       
        Exit Sub
    End If
   
    If rstTMPEGAWAI.RecordCount > 0 Then
        rstTMPEGAWAI.MoveFirst
    End If
   
    rstTMPEGAWAI.Find "Kd_Pgw='" & txtKode.Text & "'"
   
    If rstTMPEGAWAI.EOF Then
        rstTMPEGAWAI.AddNew
    End If
   
    rstTMPEGAWAI.Fields("Kd_Pgw") = txtKode.Text
    rstTMPEGAWAI.Fields("Nm_Pgw") = txtNama.Text
    rstTMPEGAWAI.Fields("Bagian") = txtBagian.Text
   
    rstTMPEGAWAI.Update
   
    If rstTMPEGAWAI.RecordCount > 0 Then
        rstTMPEGAWAI.MoveFirst
    End If
   
    If cmdUBAH.Caption = "Batal Ubah" Then
        cmdUBAH.Caption = "Ubah Data"
    End If
   
    If cmdTMBH.Caption = "Batal Tambah" Then
        cmdTMBH.Caption = "Tambah Data"
    End If
   
    Kunci_Data
   
    TampilkanData
   
    Me.SetFocus
End Sub

Private Sub txtKode_GotFocus()
    txtKode.SelStart = 0
    txtKode.SelLength = Len(Trim(txtKode.Text))
End Sub

Private Sub txtNama_GotFocus()
    txtNama.SelStart = 0
    txtNama.SelLength = Len(Trim(txtNama.Text))
End Sub

Private Sub txtBagian_GotFocus()
    txtBagian.SelStart = 0
    txtBagian.SelLength = Len(Trim(txtBagian.Text))
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        SendKeys "{TAB}"
    End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set rstTMPEGAWAI = Nothing
    Set frmTMPEGAWAI = Nothing
End Sub


Project Homepage: