<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    CodeBehind="frmBusqueda.aspx.cs" Inherits="bajaWare.Interfaces.frmBusqueda" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="AjaxToolkit" %>
<%@ Register Src="../UserControl/Cliente/wucPersonaCredito.ascx" TagName="wucPersonaCredito"
    TagPrefix="uc1" %>
<%@ Register Src="../UserControl/Cliente/wucPersonaPromocion.ascx" TagName="wucPersonaPromocion"
    TagPrefix="uc2" %>
<%@ Register Src="../UserControl/Mensaje.ascx" TagName="Mensaje" TagPrefix="uc3" %>
<%@ Register Src="../UserControl/Comun/wucListaInterfaces.ascx" TagName="wucListaInterfaces"
    TagPrefix="uc4" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <script src="../JavaScript/funGen.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript">
        function clickButton(e, buttonid, txtControl) {
            var evt = e ? e : window.event;
            //  var bt = document.getElement(buttonid);
            var bt = document.getElementById(buttonid);

            if (bt) {

                if (evt.keyCode == 13) {

                    var txt = document.getElementById(txtControl);
                    txt.focus();
                    bt.click();
                    return false;

                }
            }

        }

        function ChangeValidation(sender, e) {

            var CurrentTab = $get('<%=Tabs.ClientID%>');
            var btnGuarda = document.getElementById('btnGuardaPersona');
            var tx = sender.get_activeTab().get_headerText();

            if (tx == 'Promocion') {
                newValGroup = "vsg_PersonaProm";
            } else
                newValGroup = "vsg_PersonaCred";

            btnGuarda.onclick = function () {
                WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("btnGuarda", "", true, newValGroup, "", false, false));
            }
        }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolderContenido" runat="server">
    <uc3:Mensaje ID="wucMensajeSist" runat="server" />
    <asp:HiddenField ID="Version" Value="20130701" runat="server" />
    <asp:Panel ID="Panel1" runat="server" BackColor="Transparent" Width="100%" Style="text-align: center;">
        <asp:UpdatePanel ID="UPD_MotBusPersonas" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <table runat="server" id="tblBusPersonas" width="600px" visible="false">
                    <tr>
                        <td class="Titulo" colspan="4">
                            PERSONAS
                        </td>
                    </tr>
                    <tr>
                        <td class="th">
                            ID Cliente:
                        </td>
                        <td>
                            <asp:TextBox ID="txtIDCliente" SkinID="TextBox_Numero" ClientIDMode="Static" runat="server"
                                onkeypress="return clickButton(event,'btnBuscaCliente','txtIDCliente')" />
                        </td>
                        <td class="th" style="visibility: hidden;">
                            Estatus:
                        </td>
                        <td style="visibility: hidden;">
                            <asp:DropDownList runat="server" ID="ddlEstatusCliente">
                                <asp:ListItem Text="[Seleccionar...]" Value="" Selected="True" />
                                <asp:ListItem Text="Pendientes" Value="0" />
                                <asp:ListItem Text="Completo" Value="1" />
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td class="th">
                            Nombre:
                        </td>
                        <td>
                            <asp:TextBox ID="txtNombrePersona" ClientIDMode="Static" runat="server" Text="" onkeypress="return clickButton(event,'btnBuscaCliente','txtNombrePersona')" />
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="4">
                            <asp:Button runat="server" ID="btnBuscaCliente" Text="Buscar" OnClick="btnBuscarClientes_OnClick"
                                ClientIDMode="Static" CssClass="Boton" CausesValidation="false" />
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" align="center">
                            <asp:Panel ID="pnlClientes" runat="server" Width="100%" Height="500px" ScrollBars="Auto">
                                <asp:GridView ID="grvClientes" runat="server" AllowSorting="false" Width="95%" AutoGenerateColumns="false"
                                    DataKeyNames="" EmptyDataText="No se encontraron datos" PageSize="10" AllowPaging="True"
                                    OnRowDataBound="grvPersonas_RowDataBound" OnPageIndexChanging="grvPersonas_OnPageIndexChanging"
                                    OnRowCommand="grvPersonas_OnRowCommand" ShowHeader="true" ShowHeaderWhenEmpty="true"
                                    CssClass="tablestyle">
                                    <AlternatingRowStyle CssClass="alternatingrowstyle" />
                                    <HeaderStyle CssClass="headerstyle" />
                                    <RowStyle CssClass="rowstyle" />
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <%# Convert.ToInt32(DataBinder.Eval(Container, "DataItemIndex")) + 1 %>.</ItemTemplate>
                                            <ItemStyle Font-Size="X-Small" HorizontalAlign="Center" Width="15px" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="intPersonaID" HeaderText="ID" />
                                        <asp:BoundField DataField="strNombre" HeaderText="Nombre del Cliente" />
                                        <asp:BoundField DataField="strApPaterno" HeaderText="Ap Paterno" />
                                        <asp:BoundField DataField="strApMaterno" HeaderText="Ap Materno" />
                                        <asp:BoundField DataField="strRazonSocial" HeaderText="Razon Social" />
                                        <asp:BoundField DataField="strRFC" HeaderText="RFC" />
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:ImageButton ID="btnGo" runat="server" ImageUrl="../Images/flechDer.jpg" Style="border: none;"
                                                    Height="15px" ToolTip="ir a datos" CommandArgument='<%# Eval("intPersonaID") %>'
                                                    CausesValidation="false" CommandName="go" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <PagerTemplate>
                                        <asp:Label ID="Label1" runat="server" Text="Muestra Filas:" />
                                        <asp:DropDownList ID="grvClientes_ddlPageSize" runat="server" AutoPostBack="true"
                                            OnSelectedIndexChanged="grvClientes_SelectedIndexChanged">
                                            <asp:ListItem Value="5" />
                                            <asp:ListItem Value="10" />
                                            <asp:ListItem Value="15" />
                                            <asp:ListItem Value="20" />
                                            <asp:ListItem Value="25" />
                                        </asp:DropDownList>
                                        &nbsp; Pagina
                                        <asp:TextBox ID="grvClientes_txtGoToPage" runat="server" AutoPostBack="true" OnTextChanged="grvClientes_GoToPage_TextChanged"
                                            Width="40" />
                                        de
                                        <asp:Label ID="grvClientes_lblTotalNumberOfPages" runat="server" />
                                        &nbsp;
                                        <asp:Button ID="grvClientes_Button1" runat="server" CommandName="Page" ToolTip="Página Anterior"
                                            CommandArgument="Prev" CssClass="previous" />
                                        <asp:Button ID="grvClientes_Button2" runat="server" CommandName="Page" ToolTip="Página Siguiente"
                                            CommandArgument="Next" CssClass="next" />
                                    </PagerTemplate>
                                </asp:GridView>
                            </asp:Panel>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" align="center">
                            <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UPD_Reg">
                                <ContentTemplate>
                                    <asp:Button runat="server" ID="btnPRegresa" Text="Regresar" OnClientClick="window.location.href('frmBusqueda.aspx');"
                                        CssClass="Boton" CausesValidation="false" />
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
        <asp:UpdatePanel ID="UPD_MotBusCredito" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <table runat="server" id="tblBusCredito" visible="false">
                    <tr>
                        <td class="Titulo" colspan="4">
                            CREDITOS
                        </td>
                    </tr>
                    <tr>
                        <td class="th">
                            ID credito
                        </td>
                        <td align="left">
                            <asp:TextBox ID="txtIDProyecto" runat="server" Text="" SkinID="TextBox_Numero" />
                        </td>
                        <td class="th">
                            Nombre
                        </td>
                        <td align="left">
                            <asp:TextBox ID="txtNombreAcred" runat="server" Text="" />
                        </td>
                    </tr>
                    <tr>
                        <td class="th">
                            Desarrollo
                        </td>
                        <td align="left">
                            <asp:TextBox ID="txtNombreProyecto" runat="server" Text="" />
                        </td>
                        <td class="th" style="visibility: hidden;">
                            Estatus:
                        </td>
                        <td align="left" style="visibility: hidden;">
                            <asp:DropDownList runat="server" ID="ddlEstatusProy">
                                <asp:ListItem Text="[Seleccionar...]" Value="" Selected="True" />
                                <asp:ListItem Text="Pendientes" Value="0" />
                                <asp:ListItem Text="Completo" Value="1" />
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="4">
                            <asp:Button runat="server" ID="btnBuscaCred" Text="Buscar" OnClick="btnBuscaCred_OnClick"
                                ClientIDMode="Static" CssClass="Boton" CausesValidation="false" />
                        </td>
                    </tr>
                    <tr>
                        <td align="center" colspan="4">
                            <asp:Panel ID="pnlGridCreditos" runat="server" Height="500px" Width="100%" ScrollBars="Auto">
                                <asp:GridView ID="grvCreditos" runat="server" AllowSorting="false" Width="95%" AutoGenerateColumns="false"
                                    DataKeyNames="" EmptyDataText="No se Encontraron Datos" PageSize="10" AllowPaging="True"
                                    OnRowDataBound="grvCreditos_RowDataBound" OnPageIndexChanging="grvCreditos_RowDataBound"
                                    OnRowCommand="grvCreditos_OnRowCommand" ShowHeader="true" ShowHeaderWhenEmpty="true"
                                    CssClass="tablestyle">
                                    <AlternatingRowStyle CssClass="alternatingrowstyle" />
                                    <HeaderStyle CssClass="headerstyle" />
                                    <RowStyle CssClass="rowstyle" />
                                    <Columns>
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <%# Convert.ToInt32(DataBinder.Eval(Container, "DataItemIndex")) + 1 %>.</ItemTemplate>
                                            <ItemStyle Font-Size="X-Small" HorizontalAlign="Center" Width="15px" />
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="iOperacionId" HeaderText="Operacion" />
                                        <asp:BoundField DataField="vhcNombre" HeaderText="Nombre" />
                                        <asp:BoundField DataField="vchDesarrollo" HeaderText="Desarrollo" />
                                        <asp:TemplateField>
                                            <ItemTemplate>
                                                <asp:ImageButton ID="btnGo" runat="server" ImageUrl="../Images/flechDer.jpg" Style="border: none;"
                                                    Height="15px" ToolTip="ir a datos" CommandArgument='<%# Eval("iOperacionId") %>'
                                                    CausesValidation="false" CommandName="go" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                    </Columns>
                                    <PagerTemplate>
                                        <asp:Label ID="Label1" runat="server" Text="Muestra Filas:" />
                                        <asp:DropDownList ID="grvCreditos_ddlPageSize" runat="server" AutoPostBack="true"
                                            OnSelectedIndexChanged="grvCreditos_SelectedIndexChanged">
                                            <asp:ListItem Value="5" />
                                            <asp:ListItem Value="10" />
                                            <asp:ListItem Value="15" />
                                            <asp:ListItem Value="20" />
                                            <asp:ListItem Value="25" />
                                        </asp:DropDownList>
                                        &nbsp; Pagina
                                        <asp:TextBox ID="grvCreditos_txtGoToPage" runat="server" AutoPostBack="true" OnTextChanged="grvCreditos_GoToPage_TextChanged"
                                            Width="40" />
                                        de
                                        <asp:Label ID="grvCreditos_lblTotalNumberOfPages" runat="server" />
                                        &nbsp;
                                        <asp:Button ID="grvCreditos_Button1" runat="server" CommandName="Page" ToolTip="Página Anterior"
                                            CommandArgument="Prev" CssClass="previous" />
                                        <asp:Button ID="grvCreditos_Button2" runat="server" CommandName="Page" ToolTip="Página Siguiente"
                                            CommandArgument="Next" CssClass="next" />
                                    </PagerTemplate>
                                </asp:GridView>
                            </asp:Panel>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="4" align="center">
                            <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UpdatePanel2">
                                <ContentTemplate>
                                    <asp:Button runat="server" ID="btnCRegresa" Text="Regresar" OnClientClick="window.location.href('frmBusqueda.aspx');"
                                        CssClass="Boton" CausesValidation="false" />
                                </ContentTemplate>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <asp:Button ID="btnShowPopup_Seleccion" runat="server" Style="display: none;" />
    <AjaxToolkit:ModalPopupExtender ID="mdlSeleccion" runat="server" TargetControlID="btnShowPopup_Seleccion"
        PopupControlID="pnlPopup_Seleccion" BackgroundCssClass="modalBackground" PopupDragHandleControlID="pnlPopup_Seleccion">
    </AjaxToolkit:ModalPopupExtender>
    <asp:Panel ID="pnlPopup_Seleccion" runat="server" Width="480px" HorizontalAlign="Center"
        Style="display: none;">
        <asp:UpdatePanel ID="UPD_Seleccion" runat="server">
            <ContentTemplate>
                <asp:Panel ID="pnlCambioLoggin" runat="server" BackColor="White" Width="100%">
                    <table border="3" cellpadding="2" cellspacing="2" style="border-color: #CCD7E4;">
                        <tr>
                            <td class="Titulo" colspan="2">
                                <center>
                                    SELECCION
                                </center>
                            </td>
                        </tr>
                        <tr>
                            <td class="th" align="center" colspan="2">
                                Datos
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:ImageButton runat="server" ID="btnClientes" ImageUrl="../Images/clientes.png"
                                    ClientIDMode="Static" Style="border: none;" ToolTip="Clientes" OnClick="btnClientes_OnClick"
                                    Width="70px" Height="70px" />
                            </td>
                            <td align="left">
                                <asp:ImageButton runat="server" ID="btnCreditos" ToolTip="Creditos" ImageUrl="../Images/HipEmpresa.jpg"
                                    OnClick="btnCreditos_OnClick" Width="70px" Height="70px" Style="border: none;"
                                    ClientIDMode="Static" />
                            </td>
                        </tr>
                        <tr style="display: none;">
                            <td class="th" align="center" colspan="2">
                                Interfaces
                            </td>
                        </tr>
                        <tr>
                            <td align="right">
                                <asp:ImageButton runat="server" ID="btnInterfaces" ImageUrl="../Images/processAccept.png"
                                    Style="border: none;" ToolTip="Generacion Interfaces" OnClick="btnGenera_OnClick"
                                    ClientIDMode="Static" Width="70px" Height="70px" />
                            </td>
                            <td align="left">
                                <asp:ImageButton runat="server" ID="btnBitacora" ToolTip="Bitacora de Interfaces"
                                    ClientIDMode="Static" ImageUrl="../Images/bitacora.png" OnClientClick="window.location.href('frmBitacoraInterface.aspx');"
                                    Width="70px" Height="70px" Style="border: none;" />
                            </td>
                        </tr>
                        <tr>
                            <td class="th" align="center" colspan="2">
                                Monitoreo de Datos
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                <asp:ImageButton runat="server" ID="imgBtnMonitoreo" ImageUrl="../Images/monitor.jpg"
                                    ClientIDMode="Static" Style="border: none;" ToolTip="Monitoreo de datos" Width="120px"
                                    OnClientClick="window.location.href('../Monitoreo/frmMonitoreo.aspx');" Height="70px" />
                            </td>
                        </tr>
                        <tr>
                            <td align="center" colspan="2"><br />
                                <asp:Label ID="lblVersion" runat="server" Text="" CssClass="PerfilPeriodo"></asp:Label>
                            </td>
                        </tr>
                    </table>
                    <table>
                        <tr>
                            <td align="center">
                                <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
                                    <ContentTemplate>
                                        <asp:Button ID="Button1" runat="server" Text="Cancelar" ToolTip="Cierra el modal para la cancelación de la seleccion."
                                            CssClass="Boton" OnClick="btnCancelSeleccion_OnClick" OnClientClick="javascript:window.close();"
                                            CausesValidation="false" />
                                    </ContentTemplate>
                                </asp:UpdatePanel>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </ContentTemplate>
        </asp:UpdatePanel>
    </asp:Panel>
    <asp:Button ID="btnPersona" runat="server" Style="display: none;" />
    <AjaxToolkit:ModalPopupExtender ID="mdlDatosPersna" runat="server" TargetControlID="btnPersona"
        PopupControlID="pnlPopup_Persona" BackgroundCssClass="modalBackground" CancelControlID="btnCierraPersona">
    </AjaxToolkit:ModalPopupExtender>
    <asp:Panel ID="pnlPopup_Persona" runat="server" Width="80%" HorizontalAlign="Center"
        Style="display: none;">
        <asp:Panel ID="pnlPopup_Pers" runat="server" BackColor="White" Width="100%">
            <table>
                <tr>
                    <td class="Titulo" colspan="2">
                        <center>
                            Datos Persona
                        </center>
                    </td>
                </tr>
                <tr>
                    <td align="center">
                        Datos que no Aplican:
                        <asp:Label runat="server" BackColor="Orange" Width="100px"></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td>
                        <table>
                            <tr>
                                <td>
                                    <AjaxToolkit:TabContainer runat="server" ID="Tabs" BackColor="Transparent" ActiveTabIndex="0"
                                        OnClientActiveTabChanged="ChangeValidation">
                                        <AjaxToolkit:TabPanel runat="Server" ID="tabPromocion" HeaderText="Promocion" Height="100px"
                                            BackColor="Transparent">
                                            <ContentTemplate>
                                                <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UPD_DatosPromocion">
                                                    <ContentTemplate>
                                                        <uc2:wucPersonaPromocion ID="wucPersonaPromo" runat="server" />
                                                    </ContentTemplate>
                                                </asp:UpdatePanel>
                                            </ContentTemplate>
                                        </AjaxToolkit:TabPanel>
                                        <AjaxToolkit:TabPanel runat="Server" ID="tabCredito" HeaderText="Credito" Height="100px"
                                            BackColor="Transparent">
                                            <ContentTemplate>
                                                <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UPD_DatosCredito">
                                                    <ContentTemplate>
                                                        <uc1:wucPersonaCredito ID="wucPersonaCred" runat="server" />
                                                    </ContentTemplate>
                                                </asp:UpdatePanel>
                                            </ContentTemplate>
                                        </AjaxToolkit:TabPanel>
                                    </AjaxToolkit:TabContainer>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <asp:Button ID="btnCierraPersona" runat="server" Text="Cancelar" ToolTip="Cierra la ventana."
                            CssClass="Boton" CausesValidation="false" />
                        <asp:UpdatePanel runat="server" UpdateMode="Conditional" ID="UPD_pnlPersona" RenderMode="Inline">
                            <ContentTemplate>
                                <asp:Button ID="btnGuardaPersona" runat="server" Text="Guardar" ToolTip="Guarda datos de la persona."
                                    CssClass="Boton" ClientIDMode="Static" OnClick="btnGuardaPersona_Onclick" ValidationGroup="vsg_Persona" />
                            </ContentTemplate>
                        </asp:UpdatePanel>
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </asp:Panel>
    <asp:Button ID="btnLista" runat="server" Style="display: none;" />
    <AjaxToolkit:ModalPopupExtender ID="mdlListaInterface" runat="server" TargetControlID="btnLista"
        PopupControlID="pnlPopup_Interface" BackgroundCssClass="modalBackground" CancelControlID="btnCancelInterface">
    </AjaxToolkit:ModalPopupExtender>
    <asp:Panel ID="pnlPopup_Interface" runat="server" Width="40%" HorizontalAlign="Center"
        Style="display: none;">
        <asp:Panel ID="Panel3" runat="server" BackColor="White" Width="100%">
            <table width="100%">
                <tr>
                    <td class="Titulo" colspan="2">
                        <center>
                            Lista Interfaces
                        </center>
                    </td>
                </tr>
                <tr>
                    <td>
                        <uc4:wucListaInterfaces ID="wucListaInterfaces" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <asp:Button ID="btnCancelInterface" runat="server" Text="Cancelar" ToolTip="Cierra la ventana."
                            CssClass="Boton" CausesValidation="false" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
    </asp:Panel>
    <script language="javascript" type="text/javascript">
        document.getElementById('<%= lblVersion.ClientID %>').innerHTML = 'Versión: ' + document.getElementById('<%= Version.ClientID %>').value;
    </script>
</asp:Content>
