Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

santind2

[Resolvido] Requisição com ajax

Recommended Posts

Boa tarde,

 

Eu tenho uns combos que acada escolha ele popula o de baixo, porém preciso agora implementar para o usuário ter a opção de escolher "todos".

Cheguei em uma forma que não sei mais como resolver.

Preciso pegar todos os vendedores de todas as lojas (filial ou matriz) quando o combo filial estiver em todos.

 

Segue o código.

<%

Response.CharSet = "UTF-8"

'Objeto connection
Set cnn = Server.CreateObject("ADODB.Connection")
cnn.ConnectionString = "File Name="& Server.MapPath("../conexao.udl") &";"
cnn.Open

'Objeto RecordSet
Set rec                 = Server.CreateObject("ADODB.RecordSet")
Set rec_SubEstipulante  = Server.CreateObject("ADODB.RecordSet")
Set rec_filial          = Server.CreateObject("ADODB.RecordSet")
Set rec_vendedor        = Server.CreateObject("ADODB.RecordSet")
'Variáveis
Dim campo, id, id_ven

'Nivel de Acesso
    Nivel = Request("mais_garantia")("intIdNivelAcesso")

'Recebimento do campo a carregar
campo  = Cstr(Request("campo"))

'Recebimento do Id para filtro
id = Request("id")
id_vendedor = Request("id_vendedor")
id_filial =  Request("id_filial")
id_sub = Request("id_sub")
id_loja = Request("id_loja")

campo_loja = Request("campo_loja")
campo_filial = Request("campo_filial")
campo_subEstipulante = Request("campo_subEstipulante")
campo_vendedor = Request("campo_vendedor")


'Para carregamento do campo Estipulante
if campo_loja = "loja" then
   dim estipulante
   Response.Write "<option value=''>Selecione</option>"
   if Nivel = 7 or Nivel = 8 then
       Response.Write "<option value='0'>Todos</option>"
   end if
   'Consulta o modelo do estipulante
       sql = " select b.id_estipulante, a.razaosocial, b.nm_fantasia from garantia_modelo_estipulante as a "
       sql = sql & " inner join garantia_estipulante as b on b.id_modeloEstipulante = a.id_modeloestipulante "
       if id_loja <> "0" then
       sql = sql & " where b.id_modelodistribuicao = "&id_loja
       end if
rec.open sql, cnn
 		    If (Not rec.EOF) Then
			Do While (Not rec.EOF)
					Response.Write "<option value='"&rec(0)&"'>"&rec(1)&"</option>"
					rec.movenext
			Loop
	    End If
   'Set rec = Nothing
end if

'Para carregamento do campo Sub-Estipulante
if campo_subEstipulante = "SubEstipulante" then
   Response.Write "<option value=''>Selecione</option>"
   'Consulta o modelo do estipulante
       sql = " select b.id_estipulante, a.id_modelosubestipulante, a.razaoSocial from dbo.garantia_modelo_subestipulante as a "
       sql = sql & " inner join dbo.garantia_estipulante as b on a.id_modelodistribuicao = b.id_modeloDistribuicao "
       sql = sql & " and a.id_modelosubestipulante = b.id_modeloSubEstipulante "
       sql = sql & " where b.id_estipulante = "&id_sub
rec_SubEstipulante.open sql, cnn
 		    If (Not rec_SubEstipulante.EOF) Then
			Do While (Not rec_SubEstipulante.EOF)
					Response.Write "<option value='"&rec_SubEstipulante(0)&"'>"&rec_SubEstipulante(2)&"</option>"
					rec.movenext
			Loop
	    End If
   Set rec_SubEstipulante = Nothing
end if

'Para carregamento do campo filial
if campo_filial = "filial" then
   Response.Write "<option value='0'>Selecione</option>"
   if Nivel = 7 or Nivel = 8 then
       Response.Write "<option value='0'>Todos</option>"
   end if
   'Consulta o modelo do estipulante
     sql = " select id_pdv, ds_pdv, id_estipulante from dbo.garantia_pdv "
     'sql = sql & " inner join dbo.garantia_estipulante as b on a.id_estipulante = b.id_estipulante "
     if id_filial <> "0" then
     	sql = sql & " where id_estipulante = "&id_filial	
     'else
      ' sql = sql & "where id_pdv != 1"
     end if
rec_filial.open sql, cnn
 		  If (Not rec_filial.EOF) Then
			Do While (Not rec_filial.EOF)
					Response.Write "<option value='"&rec_filial(0)&"'>"&rec_filial("ds_pdv")&"</option>"
					rec_filial.movenext
			Loop
	   End If
   Set rec_filial = Nothing
end if

'Para carregamento do campo vendedor
if campo_vendedor = "vendedor" then
   Response.Write "<option value=''>Selecione</option>"
   if Nivel = 7 or Nivel = 8 then
       Response.Write "<option value='0'>Todos</option>"
   end if
   'Consulta o modelo do estipulante
     sql = " select id_usuario, nm_usuario "
     sql = sql & " from garantia_usuario "
     'Todas as filiais foram selecionadas
     if id_vendedor = "0" then
       'if rec(0) <> "5" then
        '   sql = sql & " where id_pdv = " &id&" and id_nivel = 1 "
       'else
           sql = sql & " where id_estipulante = 248 and id_nivel = 1  "
       'end if
     else
       'sql = sql & " where id_estipulante = 248 and id_nivel = 1 "'&estipulante
       sql = sql & " where id_nivel = 1 "'&estipulante
     end if
rec_vendedor.open sql, cnn
 		  If (Not rec_vendedor.EOF) Then
			Do While (Not rec_vendedor.EOF)
					Response.Write "<option value='"&rec_vendedor(0)&"'>"&id_sub&"</option>"
					rec_vendedor.movenext
			Loop
	   End If
   Set rec_vendedor = Nothing
end if
%>

 

Valeu!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.