1
I’m having a doubt on a screen .aspx
that generates a grid report and need to do that when checking a checkbox and clicking the button Beget the report is generated in English.
To generate this report I have a class reports that contains a function GerarRelatorioSg
, in this function I already do a language treatment. If the user’s language is native English, all I need in English is through a If Idioma = 2 then
Full code of Function
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 Report in English, the check box is selected
To make the check box work I do the following
if chkIngles.checked = true then
end if
I don’t know what to put on that last If
How do I call this Language of the Gerarrelatoriosg class and leave it as default 2 if chkIngles.checked = true ?
Hi, Igor, Welcome to [en.so]. I tried to give a descriptive title to your question, but I think your question is not very clear... How so, "among the
()
"? Do you refer to function parameters? You are free to [Edit] the question and add more details.– brasofilo
Hello brasofilo, thank you very much. What I intend to do is a way to call the Language for that if making the checked = true language 2, so I don’t need to change anything in the class. But I don’t know how to do it.
– Igor
Actually, I don’t know the language, but I suspect you need to show more code (the full or almost function in case). Check out the guide How to create a Minimum, Complete and Verifiable example
– brasofilo
I will edit to improve the understanding.
– Igor