Imports System.Data
Imports System.Data.SqlClient
Public Class getCommonData


    '*******************************  Get Octroi Percentage for a particular Ship ID *****************************
    Protected Function getOctroi(ByVal intUID As String, ByVal intshipId As String, _
                                 ByVal strPara As String) As Int32
        Dim intOctPer As Int32
        'cmd = New SqlClient.SqlCommand("getOctroi", con)
        'cmd.CommandType = CommandType.StoredProcedure
        'cmd.Parameters.Add("@UID", intUID)
        'cmd.Parameters.Add("@AddID", intshipId)
        'cmd.Parameters.Add("@Para", strPara.Trim)
        'If con.State = ConnectionState.Open Then
        '    con.Close()
        'End If
        'con.Open()
        'dr = cmd.ExecuteReader(CommandBehavior.SingleRow)
        'If dr.Read = True Then
        '    If Not IsDBNull(dr.Item(strSE.Trim)) Then
        '        intOctPer = dr.Item(strSE.Trim)
        '    Else
        '        intOctPer = 0
        '    End If
        'Else
        '    intOctPer = 0
        'End If
        'dr.Close()
        'con.Close()
        Return intOctPer
    End Function


    '******************************  Get Tax Percentage for a particular Product ***************************
    Protected Function getTax(ByVal intUID As String, ByVal intProdID As String, _
                                 ByVal strCond As String, ByVal strSE As String) As Int32
        Dim intTaxPer As Int32
        cmd = New SqlClient.SqlCommand("getTax", con)
        cmd.CommandType = CommandType.StoredProcedure
        cmd.Parameters.Add("@UID", intUID)
        cmd.Parameters.Add("@ProdID", intProdID)
        cmd.Parameters.Add("@Cond", strCond.Trim)
        If con.State = ConnectionState.Open Then
            con.Close()
        End If
        con.Open()
        dr = cmd.ExecuteReader(CommandBehavior.SingleRow)
        If dr.Read = True Then
            If Not IsDBNull(dr.Item(strSE.Trim)) Then
                intTaxPer = dr.Item(strSE.Trim)
            Else
                intTaxPer = 0
            End If
        Else
            intTaxPer = 0
        End If
        dr.Close()
        con.Close()
        Return intTaxPer
    End Function

    '************************************ Get the Exemption **********************************************

    Public Function getexemp(ByVal ddl As DropDownList) As String
        If ddl.DataSource Is Nothing Then
            sql = "Select * from Exemp"
            cmd = New SqlClient.SqlCommand(sql, con)
            If con.State = ConnectionState.Open Then
                con.Close()
            End If
            ddl.Items.Add(New ListItem("No Exemption", "Rate"))
            con.Open()
            dr = cmd.ExecuteReader
            While dr.Read = True
                ddl.Items.Add(New ListItem(dr.Item("ExName"), dr.Item("Excode")))
            End While
            ddl.Visible = True
        End If
    End Function

    Protected Sub updateDataTable(ByVal da As SqlClient.SqlDataAdapter, ByVal dt As DataTable)
        Try
            cmdBuilder = New SqlClient.SqlCommandBuilder(da)
            da.InsertCommand = cmdBuilder.GetInsertCommand
            da.UpdateCommand = cmdBuilder.GetUpdateCommand
            da.DeleteCommand = cmdBuilder.GetDeleteCommand
            da.Update(dt)
        Catch ex As Exception
            ex.Message.ToString()
        End Try
    End Sub


End Class
