VERSION 5.00
Object = "{D76D7128-4A96-11D3-BD95-D296DC2DD072}#1.0#0"; "Vsflex7.ocx"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Object = "{5734474E-78D3-4254-99B9-C35F31BDF509}#63.0#0"; "vbskpro2.ocx"
Begin VB.Form frmDokter 
   BorderStyle     =   0  'None
   Caption         =   "Dokter"
   ClientHeight    =   7500
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   11715
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MDIChild        =   -1  'True
   ScaleHeight     =   7500
   ScaleWidth      =   11715
   ShowInTaskbar   =   0   'False
   Tag             =   "mPhotographer"
   Begin VB.PictureBox picBG 
      Appearance      =   0  'Flat
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   6975
      Left            =   300
      ScaleHeight     =   6975
      ScaleWidth      =   11085
      TabIndex        =   11
      TabStop         =   0   'False
      Top             =   300
      Width           =   11085
      Begin VB.OptionButton optJK 
         Caption         =   "Wanita"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Index           =   1
         Left            =   7770
         TabIndex        =   3
         Top             =   3060
         Width           =   885
      End
      Begin VB.OptionButton optJK 
         Caption         =   "Pria"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   315
         Index           =   0
         Left            =   7050
         TabIndex        =   2
         Top             =   3060
         Value           =   -1  'True
         Width           =   885
      End
      Begin VB.TextBox txtNmDokter 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   7050
         MaxLength       =   20
         TabIndex        =   1
         Top             =   2620
         Width           =   3375
      End
      Begin VB.TextBox txtAlmt 
         Appearance      =   0  'Flat
         BackColor       =   &H00FFFFFF&
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   330
         Left            =   7050
         MaxLength       =   50
         TabIndex        =   4
         Top             =   3450
         Width           =   3375
      End
      Begin VB.CommandButton cmdClear 
         Caption         =   "&Batal"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5250
         TabIndex        =   6
         Top             =   6315
         Width           =   1275
      End
      Begin VB.CommandButton cmdSave 
         Caption         =   "&Simpan"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   3900
         TabIndex        =   5
         Top             =   6315
         Width           =   1305
      End
      Begin VB.CommandButton cmdRefresh 
         Caption         =   "&Refresh"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   7890
         TabIndex        =   8
         Top             =   6315
         Width           =   1275
      End
      Begin VB.CommandButton cmdDelete 
         Caption         =   "&Hapus"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   6570
         TabIndex        =   7
         Top             =   6315
         Width           =   1275
      End
      Begin VB.CommandButton cmdQuit 
         Caption         =   "&Tutup Form"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   9210
         TabIndex        =   9
         Top             =   6315
         Width           =   1275
      End
      Begin MSDataListLib.DataCombo cboKdDokter 
         Height          =   330
         Left            =   7050
         TabIndex        =   0
         Top             =   2200
         Width           =   1335
         _ExtentX        =   2355
         _ExtentY        =   582
         _Version        =   393216
         Appearance      =   0
         Text            =   ""
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   9
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
      End
      Begin VSFlex7Ctl.VSFlexGrid grdList 
         Height          =   5325
         Left            =   450
         TabIndex        =   10
         Top             =   630
         Width           =   3825
         _cx             =   6747
         _cy             =   9393
         _ConvInfo       =   1
         Appearance      =   0
         BorderStyle     =   1
         Enabled         =   -1  'True
         BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         MousePointer    =   0
         BackColor       =   15989246
         ForeColor       =   -2147483640
         BackColorFixed  =   -2147483633
         ForeColorFixed  =   -2147483630
         BackColorSel    =   16572883
         ForeColorSel    =   0
         BackColorBkg    =   -2147483633
         BackColorAlternate=   15333630
         GridColor       =   -2147483633
         GridColorFixed  =   -2147483632
         TreeColor       =   -2147483632
         FloodColor      =   192
         SheetBorder     =   -2147483642
         FocusRect       =   1
         HighLight       =   2
         AllowSelection  =   0   'False
         AllowBigSelection=   0   'False
         AllowUserResizing=   1
         SelectionMode   =   3
         GridLines       =   1
         GridLinesFixed  =   2
         GridLineWidth   =   1
         Rows            =   22
         Cols            =   2
         FixedRows       =   1
         FixedCols       =   0
         RowHeightMin    =   0
         RowHeightMax    =   0
         ColWidthMin     =   0
         ColWidthMax     =   0
         ExtendLastCol   =   -1  'True
         FormatString    =   $"frmDokter.frx":0000
         ScrollTrack     =   0   'False
         ScrollBars      =   3
         ScrollTips      =   0   'False
         MergeCells      =   0
         MergeCompare    =   0
         AutoResize      =   -1  'True
         AutoSizeMode    =   0
         AutoSearch      =   2
         AutoSearchDelay =   2
         MultiTotals     =   -1  'True
         SubtotalPosition=   1
         OutlineBar      =   0
         OutlineCol      =   0
         Ellipsis        =   0
         ExplorerBar     =   5
         PicturesOver    =   0   'False
         FillStyle       =   0
         RightToLeft     =   0   'False
         PictureType     =   0
         TabBehavior     =   0
         OwnerDraw       =   0
         Editable        =   0
         ShowComboButton =   -1  'True
         WordWrap        =   0   'False
         TextStyle       =   0
         TextStyleFixed  =   0
         OleDragMode     =   0
         OleDropMode     =   0
         DataMode        =   0
         VirtualData     =   -1  'True
         DataMember      =   ""
         ComboSearch     =   3
         AutoSizeMouse   =   -1  'True
         FrozenRows      =   0
         FrozenCols      =   0
         AllowUserFreezing=   0
         BackColorFrozen =   0
         ForeColorFrozen =   0
         WallPaperAlignment=   9
      End
      Begin VB.Label Label19 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00C0FFC0&
         BackStyle       =   0  'Transparent
         Caption         =   "Jenis Kelamin"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   195
         Left            =   5250
         TabIndex        =   16
         Top             =   3060
         Width           =   1155
      End
      Begin VB.Label Label2 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00C0FFC0&
         BackStyle       =   0  'Transparent
         Caption         =   "Kode Dokter"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   195
         Index           =   1
         Left            =   5250
         TabIndex        =   15
         Top             =   2200
         Width           =   1050
      End
      Begin VB.Label Label3 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00C0FFC0&
         BackStyle       =   0  'Transparent
         Caption         =   "Alamat"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   195
         Left            =   5250
         TabIndex        =   14
         Top             =   3450
         Width           =   615
      End
      Begin VB.Label Label1 
         Appearance      =   0  'Flat
         AutoSize        =   -1  'True
         BackColor       =   &H00C0FFC0&
         BackStyle       =   0  'Transparent
         Caption         =   "Nama Dokter"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   195
         Index           =   0
         Left            =   5250
         TabIndex        =   13
         Top             =   2620
         Width           =   1110
      End
      Begin VB.Line ln 
         BorderColor     =   &H00FFFFFF&
         Index           =   1
         Tag             =   "1"
         X1              =   390
         X2              =   10465
         Y1              =   6150
         Y2              =   6150
      End
      Begin VB.Shape shp 
         BorderColor     =   &H00C0C0C0&
         Height          =   315
         Index           =   2
         Left            =   180
         Tag             =   "2"
         Top             =   150
         Width           =   2625
      End
      Begin VB.Shape shp 
         BorderColor     =   &H00FFFFFF&
         Height          =   6765
         Index           =   1
         Left            =   150
         Tag             =   "1"
         Top             =   120
         Width           =   10785
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H00E0E0E0&
         Caption         =   "D o k t e r"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H80000008&
         Height          =   255
         Index           =   0
         Left            =   210
         TabIndex        =   12
         Top             =   180
         Width           =   2565
      End
      Begin VB.Line ln 
         BorderColor     =   &H00808080&
         BorderWidth     =   2
         Index           =   0
         Tag             =   "2"
         X1              =   390
         X2              =   10465
         Y1              =   6150
         Y2              =   6150
      End
      Begin VB.Shape shp 
         BorderColor     =   &H00808080&
         BorderWidth     =   2
         Height          =   6765
         Index           =   0
         Left            =   150
         Tag             =   "2"
         Top             =   120
         Width           =   10785
      End
   End
   Begin vbskpro.Skinner Skinner 
      Left            =   0
      Top             =   0
      _ExtentX        =   1270
      _ExtentY        =   1270
      CloseButton     =   0
      MaxButton       =   0
      MinButton       =   0
      TitleBarSkin    =   3
      BodySkin        =   5
      Skin            =   98
      ChangeSkinButton=   0   'False
      SkinPicture     =   "frmDokter.frx":0056
      SysDisableSkinCaption=   "&Disable Skin"
   End
   Begin VB.Image Image1 
      Height          =   525
      Left            =   5340
      Top             =   3510
      Width           =   1245
   End
End
Attribute VB_Name = "frmDokter"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private cSQL As String
Private rsList As ADODB.Recordset
Private rsKdDokter As ADODB.Recordset
Private rsSQL As ADODB.Recordset

Private Sub cboKdDokter_Change()
  With cboKdDokter
    If Len(.Text) > 10 Then .Text = Left(.Text, 10)
    Call lCheckData
  End With
End Sub

Private Sub cboKdDokter_Click(Area As Integer)
    Call lCheckData
End Sub

Private Sub cboKdDokter_KeyPress(KeyAscii As Integer)
  With Screen.ActiveControl
    Select Case KeyAscii
    Case vbKeyReturn
      KeyAscii = 0
      SendKeys "{TAB}"
    Case vbKeySpace
      KeyAscii = 0
      SendKeys "{F4}"
    Case Else
      If Len(.Text) = 10 And .SelLength = 0 And Not _
      (KeyAscii = vbKeyReturn Or KeyAscii = vbKeyDelete Or KeyAscii = vbKeyBack) Then KeyAscii = 0
    End Select
  End With
End Sub

Private Sub cboKdDokter_Validate(Cancel As Boolean)
  cboKdDokter.Text = UCase(Trim(cboKdDokter.Text))
End Sub

Private Sub cmdClear_Click()
  Call lClr(True)
End Sub

Private Sub cmdDelete_Click()
  Call lDel
End Sub

Private Sub cmdQuit_Click()
  Unload Me
End Sub

Private Sub cmdRefresh_Click()
  rsList.Requery
  rsKdDokter.Requery
  DoEvents
  grdList.ColWidth(0) = 1515
End Sub

Private Sub cmdSave_Click()
  Call lSave
End Sub

Private Sub Form_Load()
  Call lSetCombo
  Call lInitObj
  Call lList
End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
  Call lUnload
End Sub

Private Sub Form_Resize()
  Center picBG
  CenterForm Me, MDI
End Sub

Private Sub lList()
  cSQL = "SELECT KdDokter AS [Kode Dokter], NmDokter as [Nama Dokter] " & _
          "FROM Dokter ORDER BY KdDokter"
  goConn.OpenRS rsList, cSQL
  With grdList
    Set .DataSource = rsList
    .ColWidth(0) = 1515
'    .colwidth(1).Width = 2100
  End With
End Sub

Private Sub lInitObj()
  Screen.MousePointer = vbHourglass
  goConn.ChangeLayout (Me)
  BackColor = MDI.BackColor
  Screen.MousePointer = vbDefault
End Sub

Private Function lSave() As Boolean
  With grdList
    Dim csfKdDokter As String, csfNmDokter As String
    Dim csfAlmt As String
    Dim bsfJK  As Byte
    
    csfKdDokter = SafeChar(cboKdDokter.Text)
    csfNmDokter = SafeChar(txtNmDokter.Text)
    csfAlmt = SafeChar(txtAlmt.Text)
    bsfJK = optJK(0).Value * -1
    
    '~ validate correct data
    If Len(csfKdDokter) = 0 Then
      MsgBox "Kode Dokter harus diisi.", vbInformation, "Data Tidak Lengkap"
      cboKdDokter.SetFocus: Exit Function
    End If
    If Len(csfNmDokter) = 0 Then
      MsgBox "Nama Dokter harus diisi.", vbInformation, "Data Tidak Lengkap"
      txtNmDokter.SetFocus: Exit Function
    End If
    If Len(csfAlmt) = 0 Then
      MsgBox "Alamat harus diisi.", vbInformation, "Data Tidak Lengkap"
      txtAlmt.SetFocus: Exit Function
    End If
    '~
    
    cSQL = "SELECT KdDokter FROM Dokter where KdDokter = '" & csfKdDokter & "'"
    If goConn.OpenRSFO(rsSQL, cSQL) Then
      cSQL = " UPDATE Dokter Set NmDokter = '" & csfNmDokter & _
      "', Almt = '" & csfAlmt & _
      "', Jk = " & bsfJK & _
      " Where KdDokter = '" & csfKdDokter & "'"
    Else
      cSQL = "INSERT INTO Dokter(KdDokter, NmDokter, JK, Almt) VALUES ( '" & _
              csfKdDokter & "', '" & csfNmDokter & "'," & bsfJK & _
              ",'" & csfAlmt & "')"
    End If
    
    On Error GoTo ErrorHandler
    MousePointer = vbHourglass
    cmdSave.Enabled = False
    goConn.Conn.BeginTrans
    goConn.Conn.Execute cSQL
    goConn.Conn.CommitTrans
    MousePointer = vbDefault
  
    Call lClr(True)
    Call cmdRefresh_Click
    cmdSave.Enabled = True
  End With
  lSave = True
Exit Function

ErrorHandler:
  goConn.Conn.RollbackTrans
  MousePointer = vbDefault
  MsgBox "No Kesalahan : " & Err.Number & vbCrLf & "Deskripsi Kesalahan : " & Err.Description, vbOKOnly, "Save Error"
  lSave = False
  cmdSave.Enabled = True
  Call lList
End Function

Private Function lDel() As Boolean
  With grdList
    If Len(Trim(cboKdDokter.Text)) > 0 Then
      If MsgBox("Hapus data ini dari database?", vbQuestion + vbYesNo, "Konfirmasi") = vbYes Then
        Dim csfKdDokter As String
        csfKdDokter = SafeChar(cboKdDokter.Text)
        
        cSQL = "SELECT KdDokter FROM Kunjungan WHERE KdDokter = '" & csfKdDokter & "'"
        If goConn.OpenRSFO(rsSQL, cSQL) Then
          MsgBox "Data tidak dapat dihapus karena telah dipakai!", vbExclamation, "Data telah dipakai"
        Else
          cSQL = "DELETE FROM Dokter WHERE KdDokter = '" & csfKdDokter & "'"
          
          On Error GoTo ErrorHandler
          MousePointer = vbHourglass
          cmdDelete.Enabled = False
          goConn.Conn.BeginTrans
          goConn.Conn.Execute cSQL
          goConn.Conn.CommitTrans
          MousePointer = vbDefault
          Call lClr(True)
          Call cmdRefresh_Click
          cmdDelete.Enabled = True
        lDel = True
        End If
      End If
    End If
  End With
  Exit Function
    
ErrorHandler:
  goConn.Conn.RollbackTrans
  MousePointer = vbDefault
  MsgBox "No Kesalahan : " & Err.Number & vbCrLf & "Deskripsi Kesalahan : Data tidak dapat dihapus karena telah dipakai!", vbOKOnly, "Delete Error"
  lDel = False
  cmdDelete.Enabled = True
  Call lList: grdList.SetFocus
End Function

Public Sub lCheckData()
  cSQL = "SELECT * FROM Dokter WHERE KdDokter = '" & SafeChar(cboKdDokter.Text) & "'"
  goConn.OpenRS rsSQL, cSQL
  With rsSQL
    If .EOF Then
      Call lClr(False)
    Else
      MousePointer = vbHourglass
      txtNmDokter.Text = !NmDokter
      txtAlmt.Text = !Almt
      If !JK = True Then optJK(0).Value = True Else optJK(1).Value = True
      MousePointer = Default
    End If
  End With
End Sub

Private Sub lClr(pbWithPK As Boolean)
  If pbWithPK Then cboKdDokter.Text = "": cboKdDokter.SetFocus
  txtAlmt.Text = ""
  optJK(0).Value = True
  txtNmDokter.Text = ""
End Sub

Private Sub lSetCombo()
  '~ set combo
  cSQL = "SELECT KdDokter  FROM Dokter " & _
          "ORDER BY KdDokter"
  goConn.SetCbo2 cboKdDokter, rsKdDokter, cSQL, "KdDokter"
End Sub

Private Sub grdList_AfterRowColChange(ByVal OldRow As Long, ByVal OldCol As Long, ByVal NewRow As Long, ByVal NewCol As Long)
  Call grdList_Click
End Sub

Private Sub grdList_Click()
  With grdList
    If .Rows > .FixedRows Then
      cboKdDokter.Text = .TextMatrix(.Row, 0)
      Call lCheckData
    End If
  End With
End Sub

Private Sub txtAlmt_GotFocus()
  If Len(Trim(cboKdDokter.Text)) = 0 Then cboKdDokter.SetFocus
End Sub

Private Sub txtNmDokter_GotFocus()
  If Len(Trim(cboKdDokter.Text)) = 0 Then cboKdDokter.SetFocus
End Sub

Private Sub txtNmDokter_KeyPress(KeyAscii As Integer)
  If KeyAscii = vbKeyReturn Then SendKeys "{TAB}"
End Sub

Private Sub txtAlmt_KeyPress(KeyAscii As Integer)
  If KeyAscii = vbKeyReturn Then SendKeys "{TAB}"
End Sub

Private Sub lUnload()
  Set rsList = Nothing
  Set rsKdDokter = Nothing
  Set rsSQL = Nothing
  Set frmDokter = Nothing
End Sub
