147 lines
4.0 KiB
C#
147 lines
4.0 KiB
C#
using SteamWare;
|
|
using System;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace GPW_Admin
|
|
{
|
|
public partial class ExportCommesse : BasePage
|
|
{
|
|
#region Protected Properties
|
|
|
|
/// <summary>
|
|
/// fine report
|
|
/// </summary>
|
|
protected DateTime fine
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToDateTime(memLayer.ML.objSessionObj("_fine"));
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// inizio report
|
|
/// </summary>
|
|
protected DateTime inizio
|
|
{
|
|
get
|
|
{
|
|
return Convert.ToDateTime(memLayer.ML.objSessionObj("_inizio"));
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// restituisce info se utente sia admin (vedi web.config x ruolo...)
|
|
/// </summary>
|
|
public bool userIsAdmin
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
try
|
|
{
|
|
string adminRole = memLayer.ML.confReadString("adminRole");
|
|
answ = user_std.UtSn.userHasRight(adminRole);
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Methods
|
|
|
|
/// <summary>
|
|
/// export html pagina
|
|
/// </summary>
|
|
private void doExport()
|
|
{
|
|
Response.Clear();
|
|
Response.AddHeader("content-disposition", string.Format("attachment; filename=ExportCommesse_{0:dd-MM-yyyy}_{1:dd-MM-yyyy}.xls", inizio, fine));
|
|
Response.Charset = "";
|
|
// If you want the option to open the Excel file without saving than
|
|
// comment out the line below
|
|
Response.Cache.SetCacheability(HttpCacheability.NoCache);
|
|
Response.ContentType = "application/vnd.xls";
|
|
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
|
|
using (
|
|
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite))
|
|
{
|
|
grView.RenderControl(htmlWrite);
|
|
}
|
|
Response.Write(stringWrite.ToString());
|
|
Response.End();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// traduce gli header delle colonne
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void grView_DataBound(object sender, EventArgs e)
|
|
{
|
|
if (grView.Rows.Count > 0)
|
|
{
|
|
LinkButton lb;
|
|
// aggiorno gli headers
|
|
foreach (TableCell cella in grView.HeaderRow.Cells)
|
|
{
|
|
try
|
|
{
|
|
lb = (LinkButton)cella.Controls[0];
|
|
lb.Text = traduci(lb.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!Page.IsPostBack)
|
|
{
|
|
aggiornamento();
|
|
doExport();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Public Methods
|
|
|
|
/// <summary>
|
|
/// update controlli
|
|
/// </summary>
|
|
public void aggiornamento()
|
|
{
|
|
grView.AllowPaging = false;
|
|
//gvEventi.PageSize = _numRighe;
|
|
ods.DataBind();
|
|
}
|
|
|
|
public override void VerifyRenderingInServerForm(Control control)
|
|
{
|
|
// Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
|
|
}
|
|
|
|
#endregion Public Methods
|
|
}
|
|
} |