Imports System.Data.SqlClient

Public Class CargarElementosDAO





    Public Function ListaEstado()
        Dim objCon As New Conexion
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim da = New SqlDataAdapter("SP_ListaEstadoInversion", cn)
        da.Fill(ds)
        dt = ds.Tables(0)
        For Each row As DataRow In dt.Rows
            diccionario.Add(row(0).ToString, row(1).ToString)
        Next
        cn.Close()
        Return diccionario
    End Function


    Public Function ListaCasasCorredoras()
        Dim objCon As New Conexion
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim da = New SqlDataAdapter("SP_ListaCasasCorredoras", cn)
        da.Fill(ds)
        dt = ds.Tables(0)
        For Each row As DataRow In dt.Rows
            diccionario.Add(row(0).ToString, row(1).ToString)
        Next
        cn.Close()
        Return diccionario
    End Function





    Public Function ListaTipoRenta()
        Dim objCon As New Conexion
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim da = New SqlDataAdapter("SP_ListaTipoRenta", cn)
        da.Fill(ds)
        dt = ds.Tables(0)
        For Each row As DataRow In dt.Rows
            diccionario.Add(row(0).ToString, row(1).ToString)
        Next
        cn.Close()
        Return diccionario
    End Function





    Public Function ListaTipoTasa()
        Dim objCon As New Conexion
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim da = New SqlDataAdapter("SP_ListaTipoTasa", cn)
        da.Fill(ds)
        dt = ds.Tables(0)
        For Each row As DataRow In dt.Rows
            diccionario.Add(row(0).ToString, row(1).ToString)
        Next
        cn.Close()
        Return diccionario
    End Function



    Public Function ListaPeriodos()
        Dim objCon As New Conexion
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim da = New SqlDataAdapter("SP_ListaPeriodos", cn)
        da.Fill(ds)
        dt = ds.Tables(0)
        For Each row As DataRow In dt.Rows
            diccionario.Add(row(0).ToString, row(1).ToString)
        Next
        cn.Close()
        Return diccionario
    End Function





    Public Function ListaPlazosFactor()
        Dim objCon As New Conexion
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim da = New SqlDataAdapter("SP_ListaPlazosFactor", cn)
        da.Fill(ds)
        dt = ds.Tables(0)

        For Each row As DataRow In dt.Rows
            diccionario.Add(row(0).ToString, row(1).ToString)
        Next

        cn.Close()
        Return diccionario
    End Function

    Public Function ListaTiposMercado()
        Dim objCon As New Conexion
        Dim ds As New DataSet
        Dim dt As DataTable
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim da = New SqlDataAdapter("SP_ListaTiposMercado", cn)
        da.Fill(ds)
        dt = ds.Tables(0)



        For Each row As DataRow In dt.Rows
            diccionario.Add(row(0).ToString, row(1).ToString)

        Next
        cn.Close()
        Return diccionario
    End Function
    Public Function CodEmpr()
        Dim objCon As New Conexion

        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim sql = "SELECT * FROM [dbo].[EMPR]  "

        If Not cn.State = ConnectionState.Open Then

            cn.Open()
        End If
        Dim cmd As New SqlCommand(sql, cn)
        Dim dr As SqlDataReader

        dr = cmd.ExecuteReader
        If (diccionario.Count = 0) Then
            While dr.Read
                diccionario.Add(dr("CodEmpr"), dr("Descrip").ToString)


            End While
        End If

        cn.Close()
        Return diccionario
    End Function

    Public Function CodIF()
        Dim objCon As New Conexion
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim sql = "SELECT * FROM [dbo].[INFI]  "


        Dim cmd As New SqlCommand(sql, cn)
        Dim dr As SqlDataReader
        dr = cmd.ExecuteReader

        Return dr
    End Function
    Public Function CodEmis()
        Dim objCon As New Conexion
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim sql = "SELECT * FROM [dbo].[EMIS]  "


        Dim cmd As New SqlCommand(sql, cn)
        Dim dr As SqlDataReader
        dr = cmd.ExecuteReader
        If (diccionario.Count = 0) Then
            While dr.Read
                diccionario.Add(dr("CodEmis"), dr("Descrip").ToString)


            End While
        End If
        cn.Close()
        Return diccionario
    End Function
    Public Function CodECalRi()
        Dim objCon As New Conexion
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim sql = "SELECT * FROM [dbo].[ECALRI]"


        Dim cmd As New SqlCommand(sql, cn)
        Dim dr As SqlDataReader
        dr = cmd.ExecuteReader
        While dr.Read
            diccionario.Add(dr("CodECalRi").ToString, dr("Descrip").ToString)


        End While
        cn.Close()
        cn.Close()
        Return diccionario
    End Function
    Public Function CodPais()
        Dim objCon As New Conexion
        Dim diccionario As New Dictionary(Of String, String)
        Dim cn As SqlConnection = objCon.Conectar
        If cn.State = ConnectionState.Closed Then
            cn.Open()
        End If
        Dim sql = "SELECT * FROM [dbo].[PAIS]  "


        Dim cmd As New SqlCommand(sql, cn)
        Dim dr As SqlDataReader
        dr = cmd.ExecuteReader
        While dr.Read
            diccionario.Add(dr("CodPais"), dr("Descrip").ToString)


        End While
        cn.Close()
        Return diccionario
    End Function


End Class
