Ver Mensaje Individual
  #4 (permalink)  
Antiguo 15/07/2011, 13:39
r0xdrig0
 
Fecha de Ingreso: diciembre-2007
Mensajes: 385
Antigüedad: 16 años, 4 meses
Puntos: 0
Respuesta: ¿como imprimir una variable q contiene una consulta sql por paantalla (con

hola Aquaventus gracias por mostrarte atento a mi consulta, el codigo es:

Pagina BuscarCliente.aspx

Código PHP:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="BuscarClienteNew.aspx.vb" Inherits="BuscarClienteNew" %>

<!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<
html xmlns="http://www.w3.org/1999/xhtml" >
<
head runat="server">
    <
title>Buscar Cliente</title>
    <
link href="css/style.css" rel="stylesheet" type="text/css"/>
<
script language="javascript" type="text/javascript">
// <!CDATA[

function pasarparametro(rutnombrecod) {
     
window.opener.document.getElementById('dato1').innerHTML nombre
     
window.opener.document.getElementById('hdnClienteCod').value=cod;
     
window.opener.document.getElementById('hdnClienteInfo').valuenombre;
     
window.opener.document.getElementById('imgQuitar').style.visibility 'visible';
     
window.close();
}

// ]]>
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div id="header">
<img src="css/img/logotipo.png" width="525" height="80" />
</div>
<div id="container">

    <h3>Buscar Clientes</h3>
<TABLE style="WIDTH: 100%">
  <TBODY>
  <TR>
    <TD style="WIDTH: 101%" align=middle>
      <TABLE width="54%" height="244" border=0 style="WIDTH: 50%">
        <TBODY>
        <TR>
          <TD 
            style="WIDTH: 35%; HEIGHT: 21px; TEXT-ALIGN: left">Nombre/Apellido</TD>
          <TD style="WIDTH: 50%; HEIGHT: 21px; TEXT-ALIGN: left">
              <asp:TextBox ID="txtNombre"  class="formulario" runat="server" Width="90%"></asp:TextBox></TD></TR>
        <TR>
          <TD style="WIDTH: 35%; TEXT-ALIGN: left">Razón Social</TD>
          <TD style="WIDTH: 50%; TEXT-ALIGN: left">
              <asp:TextBox ID="txtRznSoc"  class="formulario" runat="server" Width="90%"></asp:TextBox></TD></TR>
        <TR>
          <TD style="WIDTH: 35%; TEXT-ALIGN: left">Rut</TD>
          <TD style="WIDTH: 50%; TEXT-ALIGN: left">
              &nbsp;<asp:TextBox ID="txtRut"  class="formulario" runat="server" Width="30%"></asp:TextBox>(12345678-9)</TD></TR>
        <TR>
          <TD style="WIDTH: 35%; TEXT-ALIGN: left">Código Embonor</TD>
          <TD style="WIDTH: 50%; TEXT-ALIGN: left">
              &nbsp;<asp:TextBox ID="txtCodigo"  class="formulario" runat="server" Width="30%"></asp:TextBox></TD></TR>
        <TR>
          <TD style="WIDTH: 35%; TEXT-ALIGN: left">Código Comercio Net</TD>
          <TD style="WIDTH: 50%; TEXT-ALIGN: left">
              <asp:TextBox ID="txtCodComercio"  class="formulario" runat="server" Width="30%"></asp:TextBox></TD></TR>
        <TR>
          <TD></TD> <TD>
              <asp:Button ID="btnBuscar" class="buscar" runat="server" Text="Buscar" /></TD></TR></TBODY></TABLE></TD></TR>
  <TR>
    <TD style="WIDTH: 101%">
      <DIV>
          <asp:GridView ID="gvwTrazabilidad" runat="server" AllowPaging="True" AutoGenerateColumns="False"
              BackColor="White" BorderColor="#999999" BorderStyle="Solid" BorderWidth="1px"
              CellPadding="3" ForeColor="Black" GridLines="Vertical" PageSize="25" Width="100%">
              <FooterStyle BackColor="#CCCCCC" />
              <Columns>
                  <asp:TemplateField HeaderText="RUT">
                      <EditItemTemplate>
                          <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Rut") %>'></asp:TextBox>
                      </EditItemTemplate>
                      <ItemTemplate>
                          <asp:HyperLink ID="HyperLink1" runat="server" Text='<%# Bind("Rut") %>'></asp:HyperLink>
                      </ItemTemplate>
                      <ItemStyle Width="20%" />
                  </asp:TemplateField>
                  <asp:BoundField DataField="RznSoc" HeaderText="RZN SOC">
                      <ItemStyle Width="40%" />
                  </asp:BoundField>
                  <asp:BoundField DataField="CodComercio" HeaderText="CODIGO NET">
                      <ItemStyle Width="20%" />
                  </asp:BoundField>
                  <asp:BoundField DataField="CodCliente" HeaderText="COD EMBONOR">
                      <ItemStyle Width="20%" />
                  </asp:BoundField>
              </Columns>
              <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
              <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
              <HeaderStyle BackColor="Black" Font-Bold="True" ForeColor="White" />
              <AlternatingRowStyle BackColor="#CCCCCC" />
          </asp:GridView>
      </DIV></TD></TR></TBODY></TABLE>
      </div>
    </form>
</body>
</html> 
Pagina BuscarCliente.vb

Código PHP:
Imports System.Data
Imports System
.Data.OleDb

Partial 
Class BuscarClienteNew
    Inherits System
.Web.UI.Page

    
Private stringConn As String
    
Private NOMBRE_BD As String

    
Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgsHandles Me.Load
        stringConn 
ConfigurationSettings.AppSettings("conn")
        
NOMBRE_BD ConfigurationSettings.AppSettings("NombreDB")
    
End Sub

    
Protected Sub btnBuscar_Click(ByVal sender As ObjectByVal e As System.EventArgsHandles btnBuscar.Click

        Dim bolComercio 
As String "1"
        
Dim codComercio As String "-1"
        
If IsNumeric(txtCodComercio.TextThen
            bolComercio 
"0"
            
codComercio txtCodComercio.Text
        End 
If

        
Dim bolCliente As String "1"
        
Dim codCliente As String "-1"
        
If IsNumeric(txtCodigo.TextThen
            bolCliente 
"0"
            
codCliente txtCodigo.Text
        End 
If

        
Dim bolRut As String "1"
        
Dim rut As String "-1"
        
If txtRut.Text <> "" Then
            bolRut 
"0"
            
rut txtRut.Text
        End 
If

        
Dim bolRznSoc As String "1"
        
Dim RznSoc As String "qwerty"
        
If txtRznSoc.Text <> "" Then
            bolRznSoc 
"0"
            
RznSoc txtRznSoc.Text.ToUpper
        End 
If

        
Dim bolNombre As String "1"
        
Dim nombre As String "qwerty"
        
If txtNombre.Text <> "" Then
            bolNombre 
"0"
            
nombre txtNombre.Text.ToUpper
        End 
If



        
Dim sSelect As String "select DB2APP.trcabe.TCCLIE as CodCliente, DB2APP.trcabe.TCRUT || '-' || DB2APP.trcabe.TCDV as Rut, DB2APP.trcabe.TCOCOR CodComercio, DB2APP.trcabe.TCRAZ as RznSoc from DB2APP.trcabe "

        
sSelect += " where (DB2APP.trcabe.TCRUT || '-' || DB2APP.trcabe.TCDV = '" rut "' or 1=" bolRut " ) AND (TCCLIE = '" codCliente "' or 1=" bolCliente ") AND (TCOCOR = '" codComercio "' or 1=" bolComercio ") AND ((UPPER(TCRAZ) like '%" RznSoc "%' or 1=" bolRznSoc ") and (UPPER(TCRAZ) like '%" nombre "%' or 1=" bolNombre ")) "


        '        Dim s As String = Request.Cookies("plantas").Value

        sSelect += " AND " + getWherePlantas(Session("plantas"))
        '
sWhere " (DB2APP.trcabe.CPLAN = " codPlanta " or " codPlanta " = '-1') "


        
sSelect += " AND " getWhereSucursales(Session("sucursales"))

        
sSelect += " group by TCRUT, TCDV , TCOCOR, TCCLIE , TCRAZ order by TCRAZ asc"

        
Dim dt As DataTable ExecuteQuery(sSelect)
        
Session("dtClientes") = dt
        gvwTrazabilidad
.DataSource Session("dtClientes")
        
gvwTrazabilidad.DataBind()

        
MsgBox("El resultado es " sSelect)


    
End Sub

    
Private Function getWherePlantas(ByVal plantas As String()) As String
        Dim sQuery 
As String
        sQuery 
" ("
        
If plantas IsNot Nothing Then
            
For As Int16 0 To plantas.Length 1
                Dim codPlanta 
As String plantas(i)
                
sQuery += " DB2APP.trcabe.CPLAN = '" codPlanta "' OR"
            
Next
        End 
If
        
sQuery += " 0=1) "
        
Return sQuery
    End 
Function
    Private Function 
getWhereSucursales(ByVal sucus As String()) As String
        Dim sQuery 
As String
        sQuery 
" ("
        
If sucus IsNot Nothing Then

            
For As Int16 0 To sucus.Length 1
                Dim codSucu 
As String sucus(i)
                
sQuery += " DB2APP.trcabe.CSUCU = '" codSucu "' OR"
            
Next

        End 
If
        
sQuery += " 0=1) "
        
Return sQuery
    End 
Function

    Private Function 
ExecuteQuery(ByVal query As String) As DataTable
        Dim conn 
As OleDbConnection = New OleDbConnection(stringConn)
        
conn.Open()
        
Dim cmd As New OleDbCommand(queryconn)
        
Dim da As New OleDbDataAdapter(cmd)
        
Dim dt As New Data.DataTable
        da
.Fill(dt)

        
conn.Close()

        Return 
dt
    End 
Function

    Protected 
Sub gvwClientes_PageIndexChanging(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewPageEventArgsHandles gvwTrazabilidad.PageIndexChanging
        gvwTrazabilidad
.PageIndex e.NewPageIndex
        gvwTrazabilidad
.DataSource Session("dtClientes")
        
gvwTrazabilidad.DataBind()
    
End Sub



    
Protected Sub gvwClientes_RowDataBound(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewRowEventArgsHandles gvwTrazabilidad.RowDataBound
        
If e.Row.RowIndex > -1 Then
            CType
(e.Row.FindControl("HyperLink1"), HyperLink).NavigateUrl "javascript:pasarparametro('" CType(e.Row.FindControl("HyperLink1"), HyperLink).Text "', '" e.Row.Cells(1).Text "', '" e.Row.Cells(3).Text "');"
        
End If

    
End Sub


    
Protected Sub gvwTrazabilidad_SelectedIndexChanged(ByVal sender As ObjectByVal e As System.EventArgsHandles gvwTrazabilidad.SelectedIndexChanged

    End Sub
End 
Class