Attribute VB_Name = "ModMain"
Option Explicit

Public Type typeDBLogin
  ServerName As String
  DBName As String
  UserName  As String
  Pass As String
  Authentic As Boolean
End Type

Public gcDBLogin As typeDBLogin

Public Const KFORMAT As String = "###,###.#0"
Public Const kcDBName As String = "Hospital"
Public Const kcEncryptPass As String = "04091983"

Public goConn  As dllUtil.clsRs
Public goConnDB As dllUtil.clsSQLDmo

Private Sub Main()
If App.PrevInstance = True Then End
'LongCut
ShortCut
End Sub

Private Sub LongCut()
'  On Error Resume Next
  frmLogin.Show
End Sub

Private Sub ShortCut()
  Set goConn = New dllUtil.clsRs
  With gcDBLogin
    .Authentic = True
    .ServerName = "."
    .DBName = kcDBName
    Set goConnDB = New dllUtil.clsSQLDmo
    If goConnDB.ConnectToServer(.Authentic, .ServerName, .UserName, .Pass) Then
    End If
       
    goConn.OpenConn True, .ServerName, .DBName
    goConn.Conn.CursorLocation = adUseClient
  End With

MDI.Show
'frmAbout.Show
'frmBackRest.Show
'frmDokter.Show
'frmObat.Show
'frmPenyakit.Show
'frmPasien.Show
'frmKunjungan.Show
'rfKunjungan.Show
End Sub

Public Sub ShowChildForm(ByVal poForm)
  Screen.MousePointer = vbHourglass
  DoEvents
  With poForm
    .Show
    .ZOrder 0
  End With
  Screen.MousePointer = vbDefault
End Sub

Public Function DBPath() As String
  DBPath = ProgPath & "DBase"
End Function

Public Function ProgPath() As String
  ProgPath = App.Path & IIf(Len(App.Path) = 3, "", "\")
End Function

Public Function QueryPath() As String
  QueryPath = ProgPath & "DBase.SQL"
End Function

Public Function CloseForms(pbAllForms As Boolean, Optional pcFormNameNotClosed As String = "") As Boolean
  Screen.MousePointer = vbHourglass
  DoEvents
  Dim nI  As Integer
  For nI = Forms.Count - 1 To 0 Step -1
    If Not TypeOf Forms(nI) Is MDIForm And _
      IIf(pbAllForms, True, Not (Forms(nI).Name = pcFormNameNotClosed)) Then Unload Forms(nI)
  Next nI
  Screen.MousePointer = vbDefault
End Function

Public Sub ChangeLogin()
  Screen.MousePointer = vbHourglass
  DoEvents
  CloseForms True
  Unload MDI
  Screen.MousePointer = vbDefault
  frmLogin.Show
End Sub


