<%@ Page language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Sub GridViewCommandEventHandler(ByVal sender As Object, ByVal e As GridViewCommandEventArgs)
If (e.CommandName = "Detalle") Then
Response.Redirect("Calando4.aspx?rpe=" + e.CommandArgument.ToString())
End If
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>GridView Select Example</title>
</head>
<body>
<form id="form1" runat="server">
<h3>Trabajadores jubilables mayores de 55 años con más de 25 años trabajando</h3>
<asp:gridview id="CustomersGridView"
datasourceid="CustomersSource"
autogeneratecolumns="False"
autogenerateselectbutton="True"
allowpaging="True"
OnRowCommand="GridViewCommandEventHandler"
runat="server" DataKeyNames="rpe" BackColor="LightGoldenrodYellow"
BorderColor="Tan" BorderWidth="1px" CellPadding="2" ForeColor="Black"
GridLines="None">
<AlternatingRowStyle BackColor="PaleGoldenrod" />
<Columns>
<asp:TemplateField HeaderText="Detalle" ItemStyle-Width="70px" HeaderStyle-Width="70px">
<ItemTemplate>
<asp:LinkButton ID="Lnk_Redireccionar" Text="Incidencias" Style="background-color: Transparent; margin-top: -3px;"
CommandName="Detalle" runat="server" CommandArgument='<%#Eval("rpe") %>'>
</asp:LinkButton>
</ItemTemplate>
<HeaderStyle Width="70px" />
<ItemStyle HorizontalAlign="Center" />
</asp:TemplateField>
<asp:BoundField DataField="rpe"
HeaderText="RPE del Empleado"
InsertVisible="False" ReadOnly="True"
SortExpression="b_contra.fe_repro" />
<asp:BoundField DataField="nombre"
HeaderText="Nombre del Empleado"
SortExpression="c_zonas.nombre" />
<asp:BoundField DataField="fechanat"
HeaderText="Fecha de Nacimiento"
SortExpression="fe_inic" />
<asp:BoundField DataField="fechaant"
HeaderText="Fecha de Antigüedad Reconocida"
SortExpression="fe_inic" />
<asp:BoundField DataField="fe"
HeaderText="Fecha Probable de Jubilación"
SortExpression="fe_inic" />
<asp:BoundField DataField="anyjub"
HeaderText="Años Transcurridos Desde la jubilación"
SortExpression="fe_inic" />
<asp:BoundField DataField="fepos"
HeaderText="Fecha Probable Para Jubilación"
SortExpression="fe_inic" />
</Columns>
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True" />
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
HorizontalAlign="Center" />
<selectedrowstyle backcolor="DarkSlateBlue"
forecolor="GhostWhite"/>
<SortedAscendingCellStyle BackColor="#FAFAE7" />
<SortedAscendingHeaderStyle BackColor="#DAC09E" />
<SortedDescendingCellStyle BackColor="#E1DB9C" />
<SortedDescendingHeaderStyle BackColor="#C2A47B" />
</asp:gridview>
<br/>
<asp:label id="Label1"
forecolor="Red"
runat="server"/>
<asp:sqldatasource id="CustomersSource"
selectcommand="SELECT MAX(b_contra.fe_repro), MAX(c_zonas.nombre) AS nombrezona, MAX(c_puesto.puesto) AS puesto, MAX(c_a_resp.dscarea) AS area, b_traba1.rpe, MAX(b_traba1.nombre) AS nombre, convert(varchar,b_traba1.fe_antre,103) as fechaant, convert(varchar,b_traba1.fe_ingre,103) AS fechaingre, convert(varchar,b_traba3.fe_natra,103) AS fechanat, CONVERT (INT,(DATEDIFF (dd, b_traba3.fe_natra, GETDATE()) - DATEDIFF (yy, b_traba3.fe_natra, GETDATE()) / 4.25) / 365) AS Edad, MAX(b_traba1.sexotrab) AS sexo, MAX(c_ubica.ubicapza) AS ubicacion, MAX(b_traba1.cl_nides) AS nides, MAX(b_traba1.if_nire2) AS nire, convert(varchar,fe,103) AS fe, CASE WHEN fe<convert(varchar,GETDATE(),103) THEN convert(varchar,GETDATE(),103) ELSE null END AS fepos, CONVERT (INT,(DATEDIFF (dd, GETDATE(), fe) - DATEDIFF (yy, GETDATE(), fe) / 4.25) / 365) AS anyjub FROM (SELECT fe_antre, CASE WHEN b_traba1.sexotrab='M' THEN DATEADD(yy, 30, convert(varchar,b_traba1.fe_antre,103)) ELSE DATEADD(yy, 25, convert(varchar,b_traba1.fe_antre,103)) END AS fe FROM b_traba1) AS t1, b_traba1, b_traba3, c_zonas, c_a_resp, c_ubica, c_puesto, b_contra WHERE (DATEDIFF(yy, b_traba1.fe_antre, GETDATE()) > 25) AND (DATEDIFF(yy, b_traba3.fe_natra, GETDATE()) > 55) AND b_traba1.cl_sitla IS NULL AND c_zonas.descr=b_traba1.cl_zona AND c_a_resp.area=b_traba1.area AND b_traba1.rpe=b_traba3.rpe AND b_traba1.rpe=b_contra.rpe AND c_puesto.cl_puest=b_contra.cl_puest AND b_traba1.fe_antre=t1.fe_antre AND b_traba1.cl_ubica=c_ubica.cl_ubica GROUP BY b_traba1.rpe, b_traba1.fe_antre, b_traba1.fe_ingre, b_traba3.fe_natra, fe"
connectionstring="server=myhost;database=mydb;User ID=myuser;Password=mypass;Trusted_Connection=no"
runat="server"/>
<ASP:DataGrid id="MyDataGrid" runat="server"
Width="700px"
BackColor="LightGoldenrodYellow"
BorderColor="Tan"
CellPadding=2
Font-Name="Verdana"
Font-Size="8pt"
HeaderStyle-BackColor="#aaaadd"
EnableViewState="False" BorderWidth="1px" Font-Names="Verdana"
ForeColor="Black" GridLines="None"
>
<AlternatingItemStyle BackColor="PaleGoldenrod" />
<FooterStyle BackColor="Tan" />
<HeaderStyle BackColor="Tan" Font-Bold="True"></HeaderStyle>
<PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
HorizontalAlign="Center" />
<SelectedItemStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />
</asp:DataGrid>
</form>
</body>
</html>