gaerecil 17 novembre 2008 alle 19:01
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.IO" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Grid As GridView
Dim index As Integer
' Apro il file specificando il percorso (in questo esempio
' utiliziamo Server.MapPath)
Dim miofile As String = Server.MapPath("connectstring.txt")
' Istanzio un nuovo oggetto StreamReader
' Utilizzo il metodo OpenText per aprire il file
Dim objStreamReader As StreamReader
objStreamReader = File.OpenText(miofile)
' Leggo il contenuto del file sino alla fine (ReadToEnd)
Dim contenuto As String = objStreamReader.ReadToEnd()
' Passo al web control (label) il contenuto del file perchè
' venga stampato a video
Dim txtb As TextBox
Dim txtb2 As TextBox
Dim miofile2 As String = Server.MapPath("PathPDF.txt")
' Istanzio un nuovo oggetto StreamReader
' Utilizzo il metodo OpenText per aprire il file
Dim objStreamReader2 As StreamReader
objStreamReader2 = File.OpenText(miofile2)
' Leggo il contenuto del file sino alla fine (ReadToEnd)
Dim contenuto2 As String = objStreamReader2.ReadToEnd()
txtb = Page.FindControl("TextBoxConn")
txtb.Text = contenuto
txtb2 = Page.FindControl("TextBoxPath")
txtb2.Text = contenuto2
' Chiudo l'oggetto StreamReader
objStreamReader.Close()
objStreamReader2.Close()
SqlConnEventi.ConnectionString() = contenuto
If Not (Page.PreviousPage Is Nothing) Then
If Not (Page.IsCrossPagePostBack) Then
Grid = PreviousPage.FindControl("gridview1")
index = Grid.SelectedIndex
' Display the primary key value of the selected row.
'Response.Write(row.DataKeys(index).Value)
SqlConnEventi.SelectCommand = "SELECT [Codice_Paziente_WEB], [Nome_Evento], [Identificativo_Referto_PDF], [Data_Ora_refertazione_D], [Data_Richiesta_Evento_D], [Nome_Struttura_Effettuante], RIGHT(REPLACE(Identificativo_Referto_PDF, '\', '/'), LEN(Identificativo_Referto_PDF) - (CHARINDEX('PATHPDF', Identificativo_Referto_PDF) - 1)) as referto FROM [EVENTI] WHERE ([Codice_Paziente_WEB] = @ID)"
SqlConnEventi.SelectParameters.Add("ID", Int(Grid.DataKeys(index).Value))
GridView2.DataSourceID = SqlConnEventi.ID
LABELPAZIENTI.Text = LABELPAZIENTI.Text + " " + Grid.SelectedRow.Cells(2).Text + " " + Grid.SelectedRow.Cells(3).Text
GridView2.DataBind()
End If
End If
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs)
End Sub
Protected Sub GridView2_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
Dim index, index2 As Integer
Dim nomefile As String
Dim newstring As String
index = GridView2.SelectedIndex
If index >= 0 Then
nomefile = GridView2.DataKeys(index).Value
nomefile.Replace("\", "/")
If nomefile.Length > 0 Then
index2 = nomefile.LastIndexOf("REFPDF")
If index2 > 0 Then
TextBox1.Text = System.Convert.ToString(index2)
newstring = nomefile.Substring(index2)
TextBox2.Text = TextBoxPath.Text + "\" + newstring
If nomefile.Length = 0 Then
TextBox3.Text = "0-REFERTO NON DISPONIBILE"
TextBox3.Visible = True
Else
' If File.Exists(nomefile) Then
'Button2.PostBackUrl = nomefile
If File.Exists(TextBox2.Text) Then
Button2.PostBackUrl = TextBox2.Text
Else
TextBox3.Text = "1-REFERTO NON DISPONIBILE"
TextBox3.Visible = True
End If
End If
Else
TextBox3.Text = "2-REFERTO NON DISPONIBILE"
TextBox3.Visible = True
End If
Else
TextBox3.Text = "3-REFERTO NON DISPONIBILE"
TextBox3.Visible = True
End If
Else
TextBox3.Text = "4-REFERTO NON DISPONIBILE"
TextBox3.Visible = True
End If
End Sub
Protected Sub GridView2_SelectedIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewSelectEventArgs)
TextBox3.Text = ""
TextBox3.Visible = False
Button2.PostBackUrl = ""
End Sub
Protected Sub GridView2_PageIndexChanging(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewPageEventArgs)
TextBox1.Text = "changing"
End Sub
Protected Sub GridView2_PageIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
TextBox1.Text = "changed"
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Pagina senza titolo</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView2" runat="server" CellPadding="4" ForeColor="#333333" GridLines="None"
Style="z-index: 100; left: 0px; position: absolute; top: 83px; border-right: silver thin solid; border-top: silver thin solid; border-left: silver thin solid; border-bottom: silver thin solid; overflow: scroll;" DataSourceID="SqlDataSource9" AutoGenerateColumns="False" AllowPaging="True" PageSize="13" DataKeyNames="Identificativo_Referto_PDF" OnSelectedIndexChanged="GridView2_SelectedIndexChanged" OnSelectedIndexChanging="GridView2_SelectedIndexChanging" AllowSorting="True" Width="1000px" Font-Names="Verdana" Font-Size="9pt" BackColor="#507CD1" TabIndex="1" OnPageIndexChanging="GridView2_PageIndexChanging" OnPageIndexChanged="GridView2_PageIndexChanged">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" BorderStyle="Ridge" BorderWidth="20px" Font-Names="Verdana" Font-Size="8pt" Wrap="False" VerticalAlign="Middle" Width="400px" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" Wrap="False" BorderStyle="Solid" BorderWidth="2px" />
<SelectedRowStyle BackColor="#FFFFC0" Font-Bold="True" ForeColor="#333333" BorderStyle="Solid" BorderWidth="2px" Wrap="False" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" Font-Names="Arial" Font-Size="10pt" Wrap="False" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" BorderStyle="Solid" BorderWidth="2px" />
<Columns>
<asp:CommandField HeaderText="Seleziona" ShowSelectButton="True" >
<ItemStyle Font-Names="Verdana" Font-Size="8pt" />
</asp:CommandField>
<asp:BoundField DataField="Codice_Paziente_WEB" HeaderText="Codice_Paziente_WEB"
SortExpression="Codice_Paziente_WEB" Visible="False" />
<asp:BoundField DataField="Nome_Evento" HeaderText="Evento" SortExpression="Evento" >
<ControlStyle BackColor="#FFFFC0" Width="400px" />
<ItemStyle Width="600px" Wrap="False" Font-Names="Verdana" Font-Size="8pt" HorizontalAlign="Center" />
<HeaderStyle Width="400px" />
</asp:BoundField>
<asp:BoundField DataField="Data_Ora_refertazione_D" HeaderText="Data Ora Referto"
SortExpression="Data Ora Referto" >
<ItemStyle Width="400px" Wrap="False" Font-Names="Verdana" Font-Size="8pt" HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Data_Richiesta_Evento_D" HeaderText="Richiesto Il"
SortExpression="Data_Richiesta_Evento_D" DataFormatString="{0:d}" >
<ItemStyle Width="300px" Wrap="False" Font-Names="Verdana" Font-Size="8pt" HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Nome_Struttura_Effettuante" HeaderText="Effettuato presso"
SortExpression="Nome_Struttura_Effettuante" >
<ControlStyle Width="500px" />
<FooterStyle Width="500px" />
<HeaderStyle Width="500px" />
<ItemStyle Width="500px" Font-Names="Verdana" Font-Size="8pt" HorizontalAlign="Center" />
</asp:BoundField>
<asp:BoundField DataField="Nome_Evento" HeaderText="Identificativo_Referto_PDF" SortExpression="Identificativo_Referto_PDF"
Visible="False" />
<asp:HyperLinkField DataNavigateUrlFields="referto" DataTextField="Nome_Evento" HeaderText="referto" Target="_blank" >
<ControlStyle Width="200px" />
<ItemStyle Width="200px" Wrap="False" Font-Names="Verdana" Font-Size="8pt" HorizontalAlign="Center" />
</asp:HyperLinkField>
</Columns>
</asp:GridView>
<asp:TextBox ID="TextBoxConn" runat="server" Style="z-index: 101; left: 0px; position: absolute;
top: 0px" Width="336px"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server" Style="z-index: 102; left: 376px; position: absolute;
top: 0px" Width="240px"></asp:TextBox>
<asp:SqlDataSource ID="SqlConnEventi" runat="server"
SelectCommand="SELECT [Codice_Paziente_WEB], [Nome_Evento], [Data_Ora_refertazione_D], [Data_Ora_refertazione], [Data_Richiesta_Evento_D], [Nome_Struttura_Effettuante], [Identificativo_Referto_PDF] FROM [EVENTI] WHERE ([Codice_Paziente_WEB] = @ID)">
</asp:SqlDataSource>
<asp:TextBox ID="TextBoxPath" runat="server" Style="z-index: 109; left: 440px; position: absolute;
top: 32px"></asp:TextBox>
<asp:TextBox ID="TextBox1" runat="server" Style="z-index: 104; left: 192px; position: absolute;
top: 32px" Width="232px"></asp:TextBox>
<asp:Label ID="LABELPAZIENTI" runat="server" BackColor="Yellow" Font-Bold="True" Font-Names="Verdana"
Font-Size="13pt" Style="z-index: 105; left: 0px; position: absolute; top: 60px;
text-align: center" Text="EVENTI DEL PAZIENTE :" Width="1000px"></asp:Label>
<asp:Button ID="Button1" runat="server" Font-Bold="True" Font-Names="Verdana" Font-Size="9pt"
Height="40px" PostBackUrl="~/Pazienti.aspx" Style="z-index: 106; left: 496px;
position: absolute; top: 432px" Text="ALTRO PAZIENTE" Width="128px" TabIndex="4" BackColor="#C0C000" />
<asp:Button ID="Button2" runat="server" Height="40px" Style="z-index: 107; left: 16px;
position: absolute; top: 432px" Text="VISUALIZZA REFERTO" Width="160px" OnClick="Button2_Click" Font-Bold="True" TabIndex="2" BackColor="#C0C000" />
<asp:TextBox ID="TextBox3" runat="server" Style="z-index: 108; left: 184px; position: absolute;
top: 440px" Enabled="False" TabIndex="3" Visible="False" Width="300px" BackColor="Yellow"></asp:TextBox>
</div>
</form>
</body>
</html>