Imports EDSL.Entities
Imports Microsoft.Practices.EnterpriseLibrary.Common
Imports Microsoft.Practices.EnterpriseLibrary.data
Imports System.Configuration
Imports System.Data.Common
Public Class dbMainFunctions
  Private Shared strMainConnString As String = "MainConnString"
  Public Function GetDropDownReference(byval intDDLType as integer) As List(Of entMainDropDown)
  Dim objDropdowns As new list(Of entMainDropDown)
  Dim db As Database = DatabaseFactory.CreateDatabase(strMainConnString)
  Try
    Using dbCommand As DbCommand = db.GetStoredProcCommand("MainGetDropDownReference")
    db.AddInParameter(dbCommand, "@DropDownType", DbType.Int16, intDDLType)
    Dim oRecordset As IDataReader = db.ExecuteReader(dbCommand)
    While oRecordset.Read()
      objDropdowns.Add(New entMainDropDown() with { _
        .DropDownID = Convert.ToInt32(oRecordset("DropDownID")), _
        .DropDownType = Convert.ToString(oRecordset("DropDownType")), _
        .DropDownValue = Convert.ToString(oRecordset("DropDownValue")), _
        .SecondaryValue = Convert.ToString(oRecordset("SecondaryValue")), _
        .TextDisplay = Convert.ToString(oRecordset("TextDisplay")), _
        .OrderBy = Convert.ToString(oRecordset("OrderBy")), _
        .Active = Convert.ToString(oRecordset("Active")) _
      })
    End While
    oRecordset.Close()
    End Using
  Catch ex As Exception
    Throw ex
  End Try
  Return objDropdowns   
  End Function
  Public Function GetDropDownReferenceUsertypes() As List(Of entMainDropDown)
    Dim objDropdowns As new list(Of entMainDropDown)
    Dim db As Database = DatabaseFactory.CreateDatabase(strMainConnString)
    Try
      Using dbCommand As DbCommand = db.GetStoredProcCommand("MainGetDropDownReferenceUserTypes")
        Dim oRecordset As IDataReader = db.ExecuteReader(dbCommand)
        While oRecordset.Read()
          objDropdowns.Add(New entMainDropDown() with { _
            .DropDownID = Convert.ToInt32(oRecordset("DropDownID")), _
            .DropDownType = Convert.ToString(oRecordset("DropDownType")), _
            .DropDownValue = Convert.ToString(oRecordset("DropDownValue")), _
            .TextDisplay = Convert.ToString(oRecordset("TextDisplay")), _
            .OrderBy = Convert.ToString(oRecordset("OrderBy")), _
            .Active = Convert.ToString(oRecordset("Active")) _
          })
        End While
        oRecordset.Close()
      End Using
    Catch ex As Exception
        Throw ex
    End Try
    Return objDropdowns   
  End Function
End Class
