Fix gestione FileUpload in Allegati
This commit is contained in:
@@ -1,9 +1,22 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/JQMob.Master" AutoEventWireup="true" CodeBehind="Allegati.aspx.cs" Inherits="ScheMe.Allegati" %>
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/Bootstrap.Master" AutoEventWireup="true" CodeBehind="Allegati.aspx.cs" Inherits="ScheMe.Allegati" %>
|
||||
|
||||
<%@ Register Src="WebUserControls/mod_fileUpload.ascx" TagName="mod_fileUpload" TagPrefix="uc1" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
|
||||
<uc1:mod_fileUpload ID="mod_fileUpload1" runat="server" />
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="NoAjaxContent" runat="server">
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-heading">
|
||||
<div class="row" style="margin-bottom: 0.5em;">
|
||||
<div class="col-xs-12">
|
||||
<b>Allegati Paziente</b>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="panel-body">
|
||||
<uc1:mod_fileUpload ID="mod_fileUpload1" runat="server" />
|
||||
</div>
|
||||
</div>
|
||||
</asp:Content>
|
||||
|
||||
@@ -42,10 +42,10 @@ namespace ScheMe
|
||||
"~/Scripts/jSteamware.js"));
|
||||
bundles.Add(new ScriptBundle("~/bundles/bootSwitch").Include(
|
||||
"~/Scripts/bootstrap-switch.min.js"));
|
||||
|
||||
|
||||
bundles.Add(new ScriptBundle("~/bundles/jquerymobile").Include(
|
||||
"~/Scripts/jquery.mobile-{version}.js"));
|
||||
|
||||
|
||||
//bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
|
||||
// "~/Scripts/jquery.unobtrusive*",
|
||||
// "~/Scripts/jquery.validate*"));
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
<%: Scripts.Render("~/bundles/jquery") %>
|
||||
<%: Scripts.Render("~/bundles/jqueryui") %>
|
||||
<%: Scripts.Render("~/bundles/bootSwitch") %>
|
||||
<%--<%: Scripts.Render("~/bundles/bootstrap-file-input") %>--%>
|
||||
</asp:PlaceHolder>
|
||||
|
||||
<webopt:BundleReference ID="BundleReference2" runat="server" Path="~/Content/bootstrap/css" />
|
||||
@@ -61,9 +62,11 @@
|
||||
</asp:ContentPlaceHolder>
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
<asp:ContentPlaceHolder ID="NoAjaxContent" runat="server">
|
||||
</asp:ContentPlaceHolder>
|
||||
<asp:UpdatePanel ID="uppFooter" runat="server">
|
||||
<ContentTemplate>
|
||||
<uc1:mod_bottom runat="server" ID="mod_bottom" />
|
||||
<uc1:mod_bottom runat="server" ID="mod_bottom" />
|
||||
</ContentTemplate>
|
||||
</asp:UpdatePanel>
|
||||
</div>
|
||||
|
||||
Generated
+9
@@ -84,6 +84,15 @@ namespace ScheMe {
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ContentPlaceHolder MainContent;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo NoAjaxContent.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ContentPlaceHolder NoAjaxContent;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo uppFooter.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<%@ Page Title="" Language="C#" MasterPageFile="~/Bootstrap.Master" AutoEventWireup="true" CodeBehind="Prova.aspx.cs" Inherits="ScheMe.Prova" %>
|
||||
|
||||
<%@ Register Src="~/WebUserControls/mod_fileUpload.ascx" TagPrefix="uc1" TagName="mod_fileUpload" %>
|
||||
|
||||
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
|
||||
</asp:Content>
|
||||
<asp:Content ID="Content3" ContentPlaceHolderID="NoAjaxContent" runat="server">
|
||||
<uc1:mod_fileUpload runat="server" ID="mod_fileUpload" />
|
||||
</asp:Content>
|
||||
|
||||
Generated
+17
-10
@@ -1,17 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// <generato automaticamente>
|
||||
// Codice generato da uno strumento.
|
||||
//
|
||||
// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se
|
||||
// il codice viene rigenerato.
|
||||
// </auto-generated>
|
||||
// il codice viene rigenerato.
|
||||
// </generato automaticamente>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ScheMe
|
||||
{
|
||||
|
||||
|
||||
public partial class Prova
|
||||
{
|
||||
}
|
||||
namespace ScheMe {
|
||||
|
||||
|
||||
public partial class Prova {
|
||||
|
||||
/// <summary>
|
||||
/// Controllo mod_fileUpload.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::ScheMe.WebUserControls.mod_fileUpload mod_fileUpload;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,80 +1,85 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_fileUpload.ascx.cs" Inherits="ScheMe.WebUserControls.mod_fileUpload" %>
|
||||
<div id="divNewEdit" runat="server">
|
||||
<asp:Button ID="btnAdd" runat="server" Text="Nuovo Allegato" OnClick="btnAdd_Click" />
|
||||
<asp:Button ID="btnCancel" runat="server" Text="Annulla" OnClick="btnCancel_Click" />
|
||||
</div>
|
||||
|
||||
<div id="divFileUpl" runat="server">
|
||||
<div style="width: 75%; float: left; padding: 4px;">
|
||||
<asp:FileUpload ID="FileUpload1" runat="server" />
|
||||
</div>
|
||||
<div style="width: 23%; float: right; padding: 4px;">
|
||||
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="Upload" />
|
||||
</div>
|
||||
<div id="divFileUpl" runat="server" class="row">
|
||||
<div class="col-xs-12 col-sm-3 col-md-2">
|
||||
<asp:Button ID="btnCancel" runat="server" Text="Annulla" OnClick="btnCancel_Click" CssClass="btn btn-warning form-control" />
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-8">
|
||||
<asp:FileUpload ID="FileUpload1" runat="server" CssClass="form-control" />
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-3 col-md-2">
|
||||
<asp:Button ID="btnUpload" runat="server" Text="Upload" OnClick="Upload" CssClass="btn btn-success form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<div id="divNewEdit" runat="server" class="row">
|
||||
<div class="col-xs-12 col-sm-3 col-md-2">
|
||||
<asp:Button ID="btnAdd" runat="server" Text="Nuovo Allegato" OnClick="btnAdd_Click" CssClass="btn btn-info form-control" />
|
||||
</div>
|
||||
</div>
|
||||
<hr />
|
||||
<asp:GridView ID="grView" runat="server" Width="100%" AutoGenerateColumns="False" DataSourceID="odsFile" DataKeyNames="idxFile" OnSelectedIndexChanged="grView_SelectedIndexChanged">
|
||||
<EditRowStyle BackColor="#CF6124" />
|
||||
<FooterStyle BackColor="#FF7C50" Font-Bold="True" ForeColor="White" />
|
||||
<HeaderStyle BackColor="#FF7C50" Font-Bold="True" ForeColor="White" />
|
||||
<PagerStyle BackColor="#CF6124" ForeColor="White" HorizontalAlign="Center" />
|
||||
<RowStyle BackColor="#FBF3EF" HorizontalAlign="Left" />
|
||||
<SelectedRowStyle BackColor="#F1CCC1" Font-Bold="True" ForeColor="#333333" />
|
||||
<SortedAscendingCellStyle BackColor="#F5F7FB" />
|
||||
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
|
||||
<SortedDescendingCellStyle BackColor="#E9EBEF" />
|
||||
<SortedDescendingHeaderStyle BackColor="#4870BE" />
|
||||
<AlternatingRowStyle BackColor="White" />
|
||||
<Columns>
|
||||
<asp:TemplateField HeaderText="Documento">
|
||||
<EditItemTemplate>
|
||||
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FileName") %>'></asp:TextBox>
|
||||
</EditItemTemplate>
|
||||
<ItemTemplate>
|
||||
<asp:LinkButton ID="lnkDownload" runat="server" OnClick="DownloadFile"
|
||||
CommandArgument='<%# Eval("idxFile") %>'>
|
||||
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FileName") %>'></asp:Label>
|
||||
</asp:LinkButton>
|
||||
</ItemTemplate>
|
||||
<ItemStyle HorizontalAlign="Left" />
|
||||
</asp:TemplateField>
|
||||
<asp:BoundField DataField="DataMod" HeaderText="modificato" ItemStyle-HorizontalAlign="left">
|
||||
<ItemStyle HorizontalAlign="Left"></ItemStyle>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="Size" HeaderText="Size" DataFormatString="{0:N0} kb" ItemStyle-HorizontalAlign="Right">
|
||||
<ItemStyle HorizontalAlign="Left"></ItemStyle>
|
||||
</asp:BoundField>
|
||||
<asp:TemplateField ItemStyle-HorizontalAlign="right">
|
||||
<ItemTemplate>
|
||||
<div id="Div1" runat="server" visible='<%# isWriteEnabled %>'>
|
||||
<asp:LinkButton ID="lnkSelect" runat="server" CausesValidation="False" CommandName="Select" Text="Select" CssClass="ui-btn ui-shadow ui-corner-all ui-icon-edit ui-btn-icon-notext ui-btn-inline" ToolTip="Modifica" />
|
||||
<asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" CssClass="ui-btn ui-shadow ui-corner-all ui-icon-delete ui-btn-icon-notext ui-btn-inline" ToolTip="Elimina" OnClientClick="return confirm('Sei sicuro di voler eliminare il file?')" />
|
||||
</div>
|
||||
</ItemTemplate>
|
||||
<ItemStyle HorizontalAlign="Center"></ItemStyle>
|
||||
</asp:TemplateField>
|
||||
</Columns>
|
||||
<EditRowStyle CssClass="editRowStyle spacedRow" />
|
||||
<FooterStyle CssClass="footerRowStyle" />
|
||||
<HeaderStyle CssClass="headerRowStyle" />
|
||||
<PagerStyle CssClass="active GridPager" />
|
||||
<RowStyle CssClass="rowStyle spacedRow" />
|
||||
<SelectedRowStyle CssClass="selectedRowStyle spacedRow" />
|
||||
<AlternatingRowStyle CssClass="alternatingRowStyle spacedRow" />
|
||||
<SortedAscendingCellStyle CssClass="stortAscCellStyle" />
|
||||
<SortedAscendingHeaderStyle CssClass="stortAscHeadStyle" />
|
||||
<SortedDescendingCellStyle CssClass="stortDescCellStyle" />
|
||||
<SortedDescendingHeaderStyle CssClass="stortDescHeadStyle" />
|
||||
<Columns>
|
||||
<asp:TemplateField HeaderText="Documento">
|
||||
<EditItemTemplate>
|
||||
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FileName") %>'></asp:TextBox>
|
||||
</EditItemTemplate>
|
||||
<ItemTemplate>
|
||||
<asp:LinkButton ID="lnkDownload" runat="server" OnClick="DownloadFile"
|
||||
CommandArgument='<%# Eval("idxFile") %>'>
|
||||
<asp:Label ID="Label1" runat="server" Text='<%# Bind("FileName") %>'></asp:Label>
|
||||
</asp:LinkButton>
|
||||
</ItemTemplate>
|
||||
<ItemStyle HorizontalAlign="Left" />
|
||||
</asp:TemplateField>
|
||||
<asp:BoundField DataField="DataMod" HeaderText="modificato" ItemStyle-HorizontalAlign="left">
|
||||
<ItemStyle HorizontalAlign="Left"></ItemStyle>
|
||||
</asp:BoundField>
|
||||
<asp:BoundField DataField="Size" HeaderText="Size" DataFormatString="{0:N0} kb" ItemStyle-HorizontalAlign="Right">
|
||||
<ItemStyle HorizontalAlign="Left"></ItemStyle>
|
||||
</asp:BoundField>
|
||||
<asp:TemplateField ItemStyle-HorizontalAlign="right">
|
||||
<ItemTemplate>
|
||||
<div id="Div1" runat="server" visible='<%# isWriteEnabled %>'>
|
||||
<asp:LinkButton ID="lnkSelect" runat="server" CausesValidation="False" CommandName="Select" Text="Select" CssClass="btn btn-default btn-circle" ToolTip="Modifica"><i class="fa fa-edit fa-lg" aria-hidden="true"></i></asp:LinkButton>
|
||||
<asp:LinkButton ID="lnkDelete" runat="server" CausesValidation="False" CommandName="Delete" Text="Delete" CssClass="btn btn-default btn-circle" ToolTip="Elimina" OnClientClick="return confirm('Sei sicuro di voler eliminare il file?')" ><i class="fa fa-trash-o fa-lg" aria-hidden="true"></i></asp:LinkButton>
|
||||
</div>
|
||||
</ItemTemplate>
|
||||
<ItemStyle HorizontalAlign="Center"></ItemStyle>
|
||||
</asp:TemplateField>
|
||||
</Columns>
|
||||
</asp:GridView>
|
||||
|
||||
<asp:ObjectDataSource ID="odsFile" runat="server" DeleteMethod="DeleteQuery" InsertMethod="InsertQuery" OldValuesParameterFormatString="original_{0}" SelectMethod="getByPaziente" TypeName="ScheMe_Data.DS_UtilityTableAdapters.tblFilesTableAdapter" UpdateMethod="UpdateQuery">
|
||||
<SelectParameters>
|
||||
<asp:SessionParameter Name="IdxPaziente" SessionField="IdxPaziente" Type="Int32" DefaultValue="0" />
|
||||
</SelectParameters>
|
||||
<DeleteParameters>
|
||||
<asp:Parameter Name="Original_idxFile" Type="Int32" />
|
||||
</DeleteParameters>
|
||||
<InsertParameters>
|
||||
<asp:Parameter Name="Gruppo" Type="String" />
|
||||
<asp:SessionParameter Name="IdxPaziente" SessionField="IdxPaziente" Type="Int32" DefaultValue="0" />
|
||||
<asp:Parameter Name="FileName" Type="String" />
|
||||
<asp:Parameter Name="ContentType" Type="String" />
|
||||
<asp:Parameter Name="Data" Type="Object" />
|
||||
</InsertParameters>
|
||||
<UpdateParameters>
|
||||
<asp:Parameter Name="Gruppo" Type="String" />
|
||||
<asp:SessionParameter Name="IdxPaziente" SessionField="IdxPaziente" Type="Int32" DefaultValue="0" />
|
||||
<asp:Parameter Name="FileName" Type="String" />
|
||||
<asp:Parameter Name="ContentType" Type="String" />
|
||||
<asp:Parameter Name="Data" Type="Object" />
|
||||
<asp:Parameter Name="Original_idxFile" Type="Int32" />
|
||||
</UpdateParameters>
|
||||
<SelectParameters>
|
||||
<asp:SessionParameter Name="IdxPaziente" SessionField="IdxPaziente" Type="Int32" DefaultValue="0" />
|
||||
</SelectParameters>
|
||||
<DeleteParameters>
|
||||
<asp:Parameter Name="Original_idxFile" Type="Int32" />
|
||||
</DeleteParameters>
|
||||
<InsertParameters>
|
||||
<asp:Parameter Name="Gruppo" Type="String" />
|
||||
<asp:SessionParameter Name="IdxPaziente" SessionField="IdxPaziente" Type="Int32" DefaultValue="0" />
|
||||
<asp:Parameter Name="FileName" Type="String" />
|
||||
<asp:Parameter Name="ContentType" Type="String" />
|
||||
<asp:Parameter Name="Data" Type="Object" />
|
||||
</InsertParameters>
|
||||
<UpdateParameters>
|
||||
<asp:Parameter Name="Gruppo" Type="String" />
|
||||
<asp:SessionParameter Name="IdxPaziente" SessionField="IdxPaziente" Type="Int32" DefaultValue="0" />
|
||||
<asp:Parameter Name="FileName" Type="String" />
|
||||
<asp:Parameter Name="ContentType" Type="String" />
|
||||
<asp:Parameter Name="Data" Type="Object" />
|
||||
<asp:Parameter Name="Original_idxFile" Type="Int32" />
|
||||
</UpdateParameters>
|
||||
</asp:ObjectDataSource>
|
||||
|
||||
@@ -14,99 +14,102 @@ using SteamWare;
|
||||
|
||||
namespace ScheMe.WebUserControls
|
||||
{
|
||||
public partial class mod_fileUpload : SteamWare.UserControl
|
||||
public partial class mod_fileUpload : SteamWare.UserControl
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
{
|
||||
fisVisFU(false);
|
||||
grView.DataBind();
|
||||
}
|
||||
divNewEdit.Visible = isWriteEnabled;
|
||||
}
|
||||
protected void Upload(object sender, EventArgs e)
|
||||
{
|
||||
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
|
||||
string contentType = FileUpload1.PostedFile.ContentType;
|
||||
string gruppo = memLayer.ML.StringSessionObj("Gruppo");
|
||||
int idxPaziente = memLayer.ML.IntSessionObj("IdxPaziente");
|
||||
using (Stream fs = FileUpload1.PostedFile.InputStream)
|
||||
{
|
||||
using (BinaryReader br = new BinaryReader(fs))
|
||||
{
|
||||
byte[] bytes = br.ReadBytes((Int32)fs.Length);
|
||||
// controllo se sia caricamento o update...
|
||||
if (grView.SelectedIndex != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
int orig_idxFile = Convert.ToInt32(grView.SelectedValue);
|
||||
DtProxy.man.taFile.UpdateQuery(gruppo, idxPaziente, filename, contentType, bytes, orig_idxFile);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
DtProxy.man.taFile.InsertQuery(gruppo, idxPaziente, filename, contentType, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
Response.Redirect(Request.Url.AbsoluteUri);
|
||||
}
|
||||
|
||||
protected void DownloadFile(object sender, EventArgs e)
|
||||
{
|
||||
int idxFile = int.Parse((sender as LinkButton).CommandArgument);
|
||||
byte[] bytes;
|
||||
string fileName, contentType;
|
||||
ScheMe_Data.DS_Utility.tblFilesRow fileRow = DtProxy.man.taFile.getByKey(idxFile)[0];
|
||||
bytes = fileRow.Data;
|
||||
contentType = fileRow.ContentType;
|
||||
fileName = fileRow.FileName;
|
||||
Response.Clear();
|
||||
Response.Buffer = true;
|
||||
Response.Charset = "";
|
||||
Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
||||
Response.ContentType = contentType;
|
||||
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||
Response.BinaryWrite(bytes);
|
||||
Response.Flush();
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// mostro controllo x edit...
|
||||
fisVisFU(true);
|
||||
btnUpload.Text = "Aggiorna File";
|
||||
}
|
||||
|
||||
protected void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
fisVisFU(true);
|
||||
btnUpload.Text = "Carica Nuovo";
|
||||
}
|
||||
/// <summary>
|
||||
/// fix visibilità controllo file upload
|
||||
/// </summary>
|
||||
/// <param name="showAdd">mostra controlli add=true oppure nasconde = false</param>
|
||||
private void fisVisFU(bool showAdd)
|
||||
{
|
||||
divFileUpl.Visible = showAdd;
|
||||
btnAdd.Visible = !showAdd;
|
||||
btnCancel.Visible = showAdd;
|
||||
if (grView.SelectedIndex != -1 && !showAdd)
|
||||
{
|
||||
grView.SelectedIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
fisVisFU(false);
|
||||
}
|
||||
|
||||
if (!IsPostBack)
|
||||
{
|
||||
fisVisFU(false);
|
||||
grView.DataBind();
|
||||
}
|
||||
divNewEdit.Visible = isWriteEnabled || true;
|
||||
}
|
||||
protected void Upload(object sender, EventArgs e)
|
||||
{
|
||||
if (FileUpload1.PostedFile != null)
|
||||
{
|
||||
string filename = Path.GetFileName(FileUpload1.PostedFile.FileName);
|
||||
string contentType = FileUpload1.PostedFile.ContentType;
|
||||
string gruppo = memLayer.ML.StringSessionObj("Gruppo");
|
||||
int idxPaziente = memLayer.ML.IntSessionObj("IdxPaziente");
|
||||
using (Stream fs = FileUpload1.PostedFile.InputStream)
|
||||
{
|
||||
using (BinaryReader br = new BinaryReader(fs))
|
||||
{
|
||||
byte[] bytes = br.ReadBytes((Int32)fs.Length);
|
||||
// controllo se sia caricamento o update...
|
||||
if (grView.SelectedIndex != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
int orig_idxFile = Convert.ToInt32(grView.SelectedValue);
|
||||
DtProxy.man.taFile.UpdateQuery(gruppo, idxPaziente, filename, contentType, bytes, orig_idxFile);
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
}
|
||||
else
|
||||
{
|
||||
DtProxy.man.taFile.InsertQuery(gruppo, idxPaziente, filename, contentType, bytes);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Response.Redirect(Request.Url.AbsoluteUri);
|
||||
}
|
||||
|
||||
protected void DownloadFile(object sender, EventArgs e)
|
||||
{
|
||||
int idxFile = int.Parse((sender as LinkButton).CommandArgument);
|
||||
byte[] bytes;
|
||||
string fileName, contentType;
|
||||
ScheMe_Data.DS_Utility.tblFilesRow fileRow = DtProxy.man.taFile.getByKey(idxFile)[0];
|
||||
bytes = fileRow.Data;
|
||||
contentType = fileRow.ContentType;
|
||||
fileName = fileRow.FileName;
|
||||
Response.Clear();
|
||||
Response.Buffer = true;
|
||||
Response.Charset = "";
|
||||
Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
||||
Response.ContentType = contentType;
|
||||
Response.AppendHeader("Content-Disposition", "attachment; filename=" + fileName);
|
||||
Response.BinaryWrite(bytes);
|
||||
Response.Flush();
|
||||
Response.End();
|
||||
}
|
||||
|
||||
protected void grView_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// mostro controllo x edit...
|
||||
fisVisFU(true);
|
||||
btnUpload.Text = "Aggiorna File";
|
||||
}
|
||||
|
||||
protected void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
fisVisFU(true);
|
||||
btnUpload.Text = "Carica Nuovo";
|
||||
}
|
||||
/// <summary>
|
||||
/// fix visibilità controllo file upload
|
||||
/// </summary>
|
||||
/// <param name="showAdd">mostra controlli add=true oppure nasconde = false</param>
|
||||
private void fisVisFU(bool showAdd)
|
||||
{
|
||||
divFileUpl.Visible = showAdd;
|
||||
btnAdd.Visible = !showAdd;
|
||||
btnCancel.Visible = showAdd;
|
||||
if (grView.SelectedIndex != -1 && !showAdd)
|
||||
{
|
||||
grView.SelectedIndex = -1;
|
||||
}
|
||||
}
|
||||
|
||||
protected void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
fisVisFU(false);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+47
-47
@@ -1,10 +1,10 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// <generato automaticamente>
|
||||
// Codice generato da uno strumento.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
// Le modifiche a questo file possono causare un comportamento non corretto e verranno perse se
|
||||
// il codice viene rigenerato.
|
||||
// </generato automaticamente>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace ScheMe.WebUserControls {
|
||||
@@ -13,74 +13,74 @@ namespace ScheMe.WebUserControls {
|
||||
public partial class mod_fileUpload {
|
||||
|
||||
/// <summary>
|
||||
/// divNewEdit control.
|
||||
/// Controllo divFileUpl.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl divNewEdit;
|
||||
|
||||
/// <summary>
|
||||
/// btnAdd control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnAdd;
|
||||
|
||||
/// <summary>
|
||||
/// btnCancel control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnCancel;
|
||||
|
||||
/// <summary>
|
||||
/// divFileUpl control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl divFileUpl;
|
||||
|
||||
/// <summary>
|
||||
/// FileUpload1 control.
|
||||
/// Controllo btnCancel.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnCancel;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo FileUpload1.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.FileUpload FileUpload1;
|
||||
|
||||
/// <summary>
|
||||
/// btnUpload control.
|
||||
/// Controllo btnUpload.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnUpload;
|
||||
|
||||
/// <summary>
|
||||
/// grView control.
|
||||
/// Controllo divNewEdit.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.HtmlControls.HtmlGenericControl divNewEdit;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo btnAdd.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnAdd;
|
||||
|
||||
/// <summary>
|
||||
/// Controllo grView.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.GridView grView;
|
||||
|
||||
/// <summary>
|
||||
/// odsFile control.
|
||||
/// Controllo odsFile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// Campo generato automaticamente.
|
||||
/// Per la modifica, spostare la dichiarazione di campo dal file di progettazione al file code-behind.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.ObjectDataSource odsFile;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user