Check Box to call function that switches language

1

I'm having a question on a .aspx screen that generates a report in grid and I need to make it when checking in a checkbox and clicking the Generate button the report is generated in English.

To generate this report I have a report class that contains a function GerarRelatorioSg , in this function I already do a language treatment. If the user language is native English, all I need in English is through If Idioma = 2 then

Function Full Code

Function GerarRelatorioSg(ByVal dtini As String, ByVal dtfim As String, ByVal TipoData As Integer, ByVal cdConcessionario As Integer, ByVal cdLaudo As String, ByVal Idioma As Integer, ByVal perfil As Integer) As DataTable

        Dim sSql As System.Text.StringBuilder
        Dim dt As DataTable

        Dim dbgar As New DBProvider
        Dim dberp As New DBProvider

        Try

            dbgar.Abrir(DBProvider.enConnectionType.GARANTIA)

            If TipoData = 3 Then

                sSql = New System.Text.StringBuilder
                sSql.Append(" update garantia a set ")
                sSql.Append(" a.dt_entrada = (select min(x.dt_laudo) from garantia x where nu_sg = a.nu_sg and x.cd_laudo=3) ")
                sSql.Append(" where ")
                sSql.Append(" a.dt_exclusao is null and ")
                sSql.Append(" a.dt_entrada is null ")
                dbgar.ExecuteNonQuery(sSql.ToString)

                sSql = New System.Text.StringBuilder
                sSql.Append(" update garantia a set ")
                sSql.Append(" a.dt_entrada = (select min(x.dt_laudo) from garantia x where nu_sg = a.nu_sg and x.cd_laudo in (7,11,13,14)) ")
                sSql.Append(" where ")
                sSql.Append(" a.dt_exclusao is null and ")
                sSql.Append(" a.dt_entrada is null ")
                dbgar.ExecuteNonQuery(sSql.ToString)

            End If

            sSql = New System.Text.StringBuilder
            sSql.Append(" SELECT ")
            sSql.Append("           g.nu_oc, ")
            sSql.Append("           g.nu_ordem_servico, ")
            sSql.Append("           g.cd_tipo_garantia, ")
            sSql.Append("           g.nu_nd, ")
            sSql.Append("           g.nu_chassi, ")
            sSql.Append("           g.nu_quilometros, ")
            sSql.Append("           to_char((select min(dt_inclusao) from garantia where nu_sg = g.nu_sg), 'yyyy/mm/dd') as dt_inclusao, ")
            sSql.Append("           g.vl_pecas, ")
            sSql.Append("           g.vl_maodeobra, ")
            sSql.Append("           g.vl_servico, ")
            sSql.Append("           g.vl_total, ")
            If Idioma = 2 Then
                sSql.Append("           w.nm_perfil1_idioma2 as nm_perfil1,")
            Else
                sSql.Append("           w.nm_perfil1,")
            End If
            sSql.Append("           to_char(g.dt_laudo,'yyyy/mm/dd') as dt_laudof, ")
            sSql.Append("           c.sg_concessionario, ")
            sSql.Append("           cr.cd_regiao, ")
            sSql.Append("           gp.cd_peca, ")

            If Idioma = 2 Then
                sSql.Append("           p.ds_peca_idioma2 as nm_peca, ")
            Else
                sSql.Append("           p.ds_peca_idioma1 as nm_peca, ")
            End If


            sSql.Append("           g.ds_reclamacao,")
            sSql.Append("           g.ds_diagnostico,")
            sSql.Append("           g.ds_reparo,")
            sSql.Append("           to_char(g.dt_falha,'yyyy/mm/dd') as dt_falha,")
            sSql.Append("           to_char(g.dt_reclamacao,'yyyy/mm/dd') as dt_reclamacao,")
            sSql.Append("           null as dt_compensa, ")
            sSql.Append("           v.ds_modelo, ")
            sSql.Append("           v.cd_modelo_garantia, ")

            If Idioma = 2 Then
                sSql.Append("           (select distinct upper(vl_dominio||'-'||ds_dominio_idioma2) as cd_problema from dominio where id_tipo_dominio = 41 and dt_exclusao is null and vl_dominio = g.cd_falha) as cd_problema, ")
                sSql.Append("           (select distinct upper(vl_dominio||'-'||ds_dominio_idioma2) as cd_problema from dominio where id_tipo_dominio = 42 and dt_exclusao is null and vl_dominio = g.cd_consequencia) cd_defeito, ")
            Else
                sSql.Append("           (select distinct upper(vl_dominio||'-'||ds_dominio_idioma1) as cd_problema from dominio where id_tipo_dominio = 41 and dt_exclusao is null and vl_dominio = g.cd_falha) as cd_problema, ")
                sSql.Append("           (select distinct upper(vl_dominio||'-'||ds_dominio_idioma1) as cd_problema from dominio where id_tipo_dominio = 42 and dt_exclusao is null and vl_dominio = g.cd_consequencia) cd_defeito, ")
            End If

            sSql.Append("           to_char(g.dt_aprovacao, 'yyyy/mm/dd') as dt_aprovacao, ")
            sSql.Append("           (select distinct ds_nome from usuario where dt_exclusao is null and id_usuario=g.cd_usuario_inc and id_perfil=1) as nm_analista ")
            sSql.Append(" FROM  ")
            sSql.Append("           garantia g, garantia_pc gp, workflow w, concessionario c, veiculo v, peca p, concessionario_regiao cr ")
            sSql.Append(" WHERE ")
            sSql.Append("           c.dt_exclusao is null ")
            sSql.Append("           and g.dt_exclusao is null ")
            sSql.Append("           and gp.dt_exclusao is null ")
            sSql.Append("           and cr.dt_exclusao is null ")
            sSql.Append("           and g.nu_chassi = v.nu_chassi ")
            sSql.Append("           and g.cd_concessionario = c.id_concessionario ")
            sSql.Append("           and g.cd_concessionario = cr.cd_concessionario ")
            sSql.Append("           and g.cd_laudo = w.cd_laudo ")
            sSql.Append("           and g.nu_ordem_servico = gp.nu_ordem_servico")
            sSql.Append("           and g.nu_seq_ordem_servico = gp.nu_seq_ordem_servico")
            sSql.Append("           and g.cd_concessionario = gp.cd_concessionario")
            sSql.Append("           and gp.cd_peca = p.cd_peca ")
            sSql.Append("           and gp.cd_tipo = 1")
            sSql.Append("           and w.id_processo = 4 ")

            If cdConcessionario > 0 Then
                sSql.Append("       and g.cd_concessionario = " & cdConcessionario)
            End If

            If cdLaudo.Length > 0 Then
                sSql.Append("       and g.cd_laudo in (" & cdLaudo & ")")
            End If

            If dtini.Trim.Length > 0 AndAlso dtfim.Trim.Length > 0 Then
                If TipoData = 1 Then
                    sSql.Append("       and g.dt_reclamacao between ")
                ElseIf TipoData = 2 Then
                    sSql.Append("       and g.dt_laudo between ")
                ElseIf TipoData = 3 Then
                    sSql.Append("       and (select min(dt_inclusao) from garantia where nu_sg = g.nu_sg) between ")
                End If
                sSql.Append("       to_date('" & dtini & " 00:00:00','yyyy/mm/dd hh24:mi:ss') ")
                sSql.Append("       and to_date('" & dtfim & " 23:59:59','yyyy/mm/dd hh24:mi:ss')")
            End If

            sSql.Append("           order by g.dt_laudo ")

            dt = dbgar.CreateDataTable(sSql.ToString)

        Catch ex As Exception
            Throw New Exception(ex.Message, ex)

        Finally

            dbgar.FecharConexao()
            dberp.FecharConexao()

        End Try
        Return dt

    End Function

If the user has a native Portuguese profile and wants to generate the English Report, check box

To check box work I'll do the following

if chkIngles.checked = true then


end if

I do not know what to put in this last If

How do I call this language from the class GenerateReportSg and leave it as default 2 if chkIngles.checked = true?

    
asked by anonymous 02.05.2014 / 20:47

1 answer

0

People have been able to solve this problem.

I'm calling Idioma = 2 that way

If chkIngles.Checked = True Then
                dt = oRel.GerarRelatorioSg(Me.txtdtinicio.Text, Me.txtdtfim.Text, tpdata, idconcessionario, laudo, 2, CInt(Session("idperfil")))
            Else
                dt = oRel.GerarRelatorioSg(Me.txtdtinicio.Text, Me.txtdtfim.Text, tpdata, idconcessionario, laudo, Session("idioma"), CInt(Session("idperfil")))
            End If

Where is Session("idioma") in else , is replaced by 2 if Checked = true

    
05.05.2014 / 17:08