VERSION 5.00
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Object = "{F0D2F211-CCB0-11D0-A316-00AA00688B10}#1.0#0"; "MSDATLST.OCX"
Begin VB.Form rfKunjungan 
   BorderStyle     =   0  'None
   Caption         =   "Laporan Kunjungan"
   ClientHeight    =   7500
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   11865
   LinkTopic       =   "Form1"
   LockControls    =   -1  'True
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   7500
   ScaleWidth      =   11865
   ShowInTaskbar   =   0   'False
   Begin VB.PictureBox picBG 
      Appearance      =   0  'Flat
      BorderStyle     =   0  'None
      ForeColor       =   &H80000008&
      Height          =   6975
      Left            =   0
      ScaleHeight     =   6975
      ScaleWidth      =   11085
      TabIndex        =   10
      TabStop         =   0   'False
      Top             =   0
      Width           =   11085
      Begin VB.CommandButton cmdPrint 
         Caption         =   "&Cetak"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   375
         Left            =   5190
         TabIndex        =   8
         Top             =   6330
         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            =   6540
         TabIndex        =   9
         Top             =   6330
         Width           =   1275
      End
      Begin VB.Frame Frame1 
         Caption         =   "Kriteria Pencetakan"
         BeginProperty Font 
            Name            =   "Tahoma"
            Size            =   8.25
            Charset         =   0
            Weight          =   400
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         Height          =   3645
         Left            =   3030
         TabIndex        =   11
         Top             =   1320
         Width           =   4815
         Begin MSDataListLib.DataCombo cboDokter 
            Height          =   315
            Index           =   0
            Left            =   330
            TabIndex        =   4
            Top             =   2220
            Width           =   1785
            _ExtentX        =   3149
            _ExtentY        =   556
            _Version        =   393216
            Appearance      =   0
            Text            =   "<SEMUA>"
            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
         End
         Begin MSDataListLib.DataCombo cboDokter 
            Height          =   315
            Index           =   1
            Left            =   2520
            TabIndex        =   5
            Top             =   2220
            Width           =   1785
            _ExtentX        =   3149
            _ExtentY        =   556
            _Version        =   393216
            Appearance      =   0
            Text            =   "<SEMUA>"
            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
         End
         Begin MSDataListLib.DataCombo cboNoKunjungan 
            Height          =   315
            Index           =   0
            Left            =   330
            TabIndex        =   0
            Top             =   660
            Width           =   1785
            _ExtentX        =   3149
            _ExtentY        =   556
            _Version        =   393216
            Appearance      =   0
            Text            =   "<SEMUA>"
            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
         End
         Begin MSDataListLib.DataCombo cboNoKunjungan 
            Height          =   315
            Index           =   1
            Left            =   2520
            TabIndex        =   1
            Top             =   660
            Width           =   1785
            _ExtentX        =   3149
            _ExtentY        =   556
            _Version        =   393216
            Appearance      =   0
            Text            =   "<SEMUA>"
            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
         End
         Begin MSComCtl2.DTPicker dtpTglKunjungan 
            Height          =   315
            Index           =   1
            Left            =   2520
            TabIndex        =   3
            Top             =   1470
            Width           =   1815
            _ExtentX        =   3201
            _ExtentY        =   556
            _Version        =   393216
            CustomFormat    =   "dd/MM/yy"
            Format          =   43319299
            CurrentDate     =   37838
         End
         Begin MSComCtl2.DTPicker dtpTglKunjungan 
            Height          =   315
            Index           =   0
            Left            =   330
            TabIndex        =   2
            Top             =   1470
            Width           =   1815
            _ExtentX        =   3201
            _ExtentY        =   556
            _Version        =   393216
            CheckBox        =   -1  'True
            CustomFormat    =   "dd/MM/yy"
            DateIsNull      =   -1  'True
            Format          =   43319299
            CurrentDate     =   37838
         End
         Begin MSDataListLib.DataCombo cboPasien 
            Height          =   315
            Index           =   0
            Left            =   330
            TabIndex        =   6
            Top             =   3000
            Width           =   1785
            _ExtentX        =   3149
            _ExtentY        =   556
            _Version        =   393216
            Appearance      =   0
            Text            =   "<SEMUA>"
            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
         End
         Begin MSDataListLib.DataCombo cboPasien 
            Height          =   315
            Index           =   1
            Left            =   2520
            TabIndex        =   7
            Top             =   3000
            Width           =   1785
            _ExtentX        =   3149
            _ExtentY        =   556
            _Version        =   393216
            Appearance      =   0
            Text            =   "<SEMUA>"
            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
         End
         Begin VB.Label Label1 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BackStyle       =   0  'Transparent
            Caption         =   "Dari Pasien"
            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           =   2
            Left            =   360
            TabIndex        =   20
            Top             =   2730
            Width           =   945
         End
         Begin VB.Label Label1 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BackStyle       =   0  'Transparent
            Caption         =   "Sampai Pasien"
            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            =   2520
            TabIndex        =   19
            Top             =   2730
            Width           =   1230
         End
         Begin VB.Label Label1 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BackStyle       =   0  'Transparent
            Caption         =   "Sampai No Kunjungan"
            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           =   7
            Left            =   2520
            TabIndex        =   18
            Top             =   360
            Width           =   1830
         End
         Begin VB.Label Label1 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BackStyle       =   0  'Transparent
            Caption         =   "Dari No Kunjungan"
            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           =   5
            Left            =   360
            TabIndex        =   17
            Top             =   360
            Width           =   1545
         End
         Begin VB.Label Label1 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BackStyle       =   0  'Transparent
            Caption         =   "Sampai 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           =   4
            Left            =   2520
            TabIndex        =   15
            Top             =   1950
            Width           =   1260
         End
         Begin VB.Label Label1 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BackStyle       =   0  'Transparent
            Caption         =   "Dari 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           =   3
            Left            =   360
            TabIndex        =   14
            Top             =   1950
            Width           =   975
         End
         Begin VB.Label Label1 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BackStyle       =   0  'Transparent
            Caption         =   "Dari Tgl Kunjungan"
            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            =   360
            TabIndex        =   13
            Top             =   1200
            Width           =   1590
         End
         Begin VB.Label Label1 
            Appearance      =   0  'Flat
            AutoSize        =   -1  'True
            BackColor       =   &H80000005&
            BackStyle       =   0  'Transparent
            Caption         =   "Sampai Tgl Kunjungan"
            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           =   6
            Left            =   2520
            TabIndex        =   12
            Top             =   1200
            Width           =   1875
         End
      End
      Begin VB.Shape shp 
         BorderColor     =   &H00C0C0C0&
         Height          =   315
         Index           =   2
         Left            =   180
         Tag             =   "2"
         Top             =   150
         Width           =   2625
      End
      Begin VB.Label Label2 
         Alignment       =   2  'Center
         Appearance      =   0  'Flat
         BackColor       =   &H00E0E0E0&
         Caption         =   "Laporan Kunjungan"
         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
         Left            =   210
         TabIndex        =   16
         Top             =   180
         Width           =   2565
      End
      Begin VB.Shape shp 
         BorderColor     =   &H00FFFFFF&
         Height          =   6765
         Index           =   1
         Left            =   150
         Tag             =   "1"
         Top             =   120
         Width           =   10785
      End
      Begin VB.Line ln 
         BorderColor     =   &H00FFFFFF&
         Index           =   1
         Tag             =   "1"
         X1              =   3000
         X2              =   7800
         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
      Begin VB.Line ln 
         BorderColor     =   &H00808080&
         BorderWidth     =   2
         Index           =   0
         Tag             =   "2"
         X1              =   3000
         X2              =   7800
         Y1              =   6150
         Y2              =   6150
      End
   End
End
Attribute VB_Name = "rfKunjungan"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private cSQL As String, nI As Byte
Private rsSQL As ADODB.Recordset
Private rsNoKunjungan As ADODB.Recordset
Private rsDokter As ADODB.Recordset
Private rsPasien As ADODB.Recordset


Private Sub cboDokter_Click(Index As Integer, Area As Integer)
  If Index = 0 Then
    If cboDokter(Index).Text = "<SEMUA>" Then
      cboDokter(1).Text = "<SEMUA>"
    Else
      If cboDokter(1).Text = "<SEMUA>" Or Len(Trim(cboDokter(1).Text)) = 0 Then cboDokter(1).Text = cboDokter(0).Text
    End If
  Else
    If cboDokter(Index).Text = "<SEMUA>" Then
      cboDokter(0).Text = "<SEMUA>"
    Else
      If cboDokter(0).Text = "<SEMUA>" Or Len(Trim(cboDokter(0).Text)) = 0 Then cboDokter(0).Text = cboDokter(1).Text
    End If
  End If
End Sub

Private Sub cboDokter_KeyPress(Index As Integer, KeyAscii As Integer)
  With Screen.ActiveControl
    Select Case KeyAscii
    Case vbKeyReturn
      KeyAscii = 0
      SendKeys "{TAB}"
    Case vbKeySpace
      KeyAscii = 0
      SendKeys "{F4}"
    End Select
  End With
End Sub

Private Sub cboNoKunjungan_Click(Index As Integer, Area As Integer)
  If Index = 0 Then
    If cboNoKunjungan(Index).Text = "<SEMUA>" Then
      cboNoKunjungan(1).Text = "<SEMUA>"
    Else
      If cboNoKunjungan(1).Text = "<SEMUA>" Or Len(Trim(cboNoKunjungan(1).Text)) = 0 Then cboNoKunjungan(1).Text = cboNoKunjungan(0).Text
    End If
  Else
    If cboNoKunjungan(Index).Text = "<SEMUA>" Then
      cboNoKunjungan(0).Text = "<SEMUA>"
    Else
      If cboNoKunjungan(0).Text = "<SEMUA>" Or Len(Trim(cboNoKunjungan(0).Text)) = 0 Then cboNoKunjungan(0).Text = cboNoKunjungan(1).Text
    End If
  End If
End Sub

Private Sub cboPasien_KeyPress(Index As Integer, KeyAscii As Integer)
  With Screen.ActiveControl
    Select Case KeyAscii
    Case vbKeyReturn
      KeyAscii = 0
      SendKeys "{TAB}"
    Case vbKeySpace
      KeyAscii = 0
      SendKeys "{F4}"
    End Select
  End With
End Sub

Private Sub cboPasien_Click(Index As Integer, Area As Integer)
  If Index = 0 Then
    If cboPasien(Index).Text = "<SEMUA>" Then
      cboPasien(1).Text = "<SEMUA>"
    Else
      If cboPasien(1).Text = "<SEMUA>" Or Len(Trim(cboPasien(1).Text)) = 0 Then cboPasien(1).Text = cboPasien(0).Text
    End If
  Else
    If cboPasien(Index).Text = "<SEMUA>" Then
      cboPasien(0).Text = "<SEMUA>"
    Else
      If cboPasien(0).Text = "<SEMUA>" Or Len(Trim(cboPasien(0).Text)) = 0 Then cboPasien(0).Text = cboPasien(1).Text
    End If
  End If
End Sub

Private Sub cboNoKunjungan_KeyPress(Index As Integer, KeyAscii As Integer)
  With Screen.ActiveControl
    Select Case KeyAscii
    Case vbKeyReturn
      KeyAscii = 0
      SendKeys "{TAB}"
    Case vbKeySpace
      KeyAscii = 0
      SendKeys "{F4}"
    End Select
  End With
End Sub

Private Sub cmdQuit_Click()
  Unload Me
End Sub

Private Sub cmdPrint_Click()
  Call lPrint
End Sub

Private Sub dtpTglKunjungan_Change(Index As Integer)
  If Index = 0 Then dtpTglKunjungan(1).Enabled = Not IsNull(dtpTglKunjungan(0).Value)
End Sub

Private Sub Form_Load()
  Call lInitObj
  Call lSetCombo
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 lSetCombo()
  '~ set combo
  cSQL = "SELECT '<SEMUA>' AS NoKunjungan UNION SELECT NoKunjungan FROM Kunjungan"
  goConn.SetCbo2 cboNoKunjungan(0), rsNoKunjungan, cSQL, "NoKunjungan"
  goConn.SetCbo2 cboNoKunjungan(1), rsNoKunjungan, cSQL, "NoKunjungan"

  cSQL = "SELECT '<SEMUA>' AS KdDokter UNION SELECT KdDokter FROM Dokter"
  goConn.SetCbo2 cboDokter(0), rsDokter, cSQL, "KdDokter"
  goConn.SetCbo2 cboDokter(1), rsDokter, cSQL, "KdDokter"

  cSQL = "SELECT '<SEMUA>' AS KdPasien UNION SELECT KdPasien FROM Pasien"
  goConn.SetCbo2 cboPasien(0), rsPasien, cSQL, "KdPasien"
  goConn.SetCbo2 cboPasien(1), rsPasien, cSQL, "KdPasien"
End Sub

Private Sub lRefresh()
  rsNoKunjungan.Requery
  rsDokter.Requery
  rsPasien.Requery
End Sub

Private Function lPrint()
  If Len(Trim(cboNoKunjungan(0).Text)) = 0 Then
    MsgBox "No Kunjungan tidak boleh kosong.", vbExclamation, "Data Tidak Lengkap"
    cboNoKunjungan(0).SetFocus
  ElseIf Len(Trim(cboNoKunjungan(1).Text)) = 0 Then
    MsgBox "No Kunjungan tidak boleh kosong.", vbExclamation, "Data Tidak Lengkap"
    cboNoKunjungan(1).SetFocus
  ElseIf Len(Trim(cboDokter(0).Text)) = 0 Then
    MsgBox "Dokter tidak boleh kosong.", vbExclamation, "Data Tidak Lengkap"
    cboDokter(0).SetFocus
  ElseIf Len(Trim(cboDokter(1).Text)) = 0 Then
    MsgBox "Dokter tidak boleh kosong.", vbExclamation, "Data Tidak Lengkap"
    cboDokter(1).SetFocus
  ElseIf Len(Trim(cboPasien(0).Text)) = 0 Then
    MsgBox "Pasien tidak boleh kosong.", vbExclamation, "Data Tidak Lengkap"
    cboPasien(0).SetFocus
  ElseIf Len(Trim(cboPasien(1).Text)) = 0 Then
    MsgBox "Pasien tidak boleh kosong.", vbExclamation, "Data Tidak Lengkap"
    cboPasien(1).SetFocus
  Else
    Screen.MousePointer = vbHourglass
    cmdPrint.Enabled = False
    Dim rpt As crKunjungan
    Set rpt = New crKunjungan
    With rpt
       cSQL = "SELECT *  FROM V_LapKunjungan WHERE " & _
              IIf(cboNoKunjungan(0).Text = "<SEMUA>", "", " (NoKunjungan Between '" & SafeChar(cboNoKunjungan(0).Text) & _
              "' AND '" & SafeChar(cboNoKunjungan(1).Text) & "')  AND ") & _
              IIf(cboDokter(0).Text = "<SEMUA>", "", " (KdDokter Between '" & SafeChar(cboDokter(0).Text) & _
              "' AND '" & SafeChar(cboDokter(1).Text) & "') AND ") & _
              IIf(cboPasien(0).Text = "<SEMUA>", "", " (KdPasien Between '" & SafeChar(cboPasien(0).Text) & _
              "' AND '" & SafeChar(cboPasien(1).Text) & "') AND ") & _
              IIf(IsNull(dtpTglKunjungan(0)), "", _
              " (TglKunjungan BETWEEN '" & Format(dtpTglKunjungan(0).Value, "mm/dd/yyyy") & "' AND '" & Format(dtpTglKunjungan(1).Value, "mm/dd/yyyy") & "') ")

      If Right(cSQL, 6) = "WHERE " Then cSQL = Mid(cSQL, 1, Len(cSQL) - 6)
      If Right(cSQL, 4) = "AND " Then cSQL = Mid(cSQL, 1, Len(cSQL) - 4)
      
      If goConn.OpenRSFO(rsSQL, cSQL) Then
        Call PrintReport("Preview Laporan Kunjungan", rpt, rsSQL)
      Else
        MsgBox "Tidak ada data untuk dicetak!", vbInformation, "Tidak ada data"
      End If
    End With
    Set rpt = Nothing
    cmdPrint.Enabled = True
    Screen.MousePointer = vbDefault
  End If
End Function

Private Sub lInitObj()
  Screen.MousePointer = vbHourglass
  goConn.ChangeLayout (Me)
  BackColor = MDI.BackColor
  Screen.MousePointer = vbDefault
  dtpTglKunjungan(0).Value = TglAwalBln(Date)
  dtpTglKunjungan(1).Value = TglAkhirBln(Date)
End Sub

Private Sub lUnload()
  Set rsDokter = Nothing
  Set rsPasien = Nothing
  Set rsNoKunjungan = Nothing
  Set rsSQL = Nothing
  Set rfKunjungan = Nothing
End Sub
