Files
GMW/GMW/ExportExcel_SAO.aspx.cs
T

122 lines
3.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SteamWare;
using GMW_data;
namespace GMW
{
public partial class ExportExcel_SAO : System.Web.UI.Page
{
/// <summary>
/// fix x export excel
/// </summary>
/// <param name="control"></param>
public override void VerifyRenderingInServerForm(Control control)
{
// Confirms that an HtmlForm control is rendered for the specified ASP.NET server control at run time.
}
/// <summary>
/// evento dati associati a controllo
/// </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>
/// wrapper traduzione
/// </summary>
/// <param name="lemma"></param>
/// <returns></returns>
public string traduci(object lemma)
{
return user_std.UtSn.Traduci(lemma.ToString());
}
private void doExport()
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=Export Storico Azioni Operatore.xls");
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();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
grView.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
#region area protected
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
aggiornamento();
doExport();
}
}
#endregion
public void aggiornamento()
{
grView.AllowPaging = false;
checkFixOds();
odsSAO.DataBind();
grView.DataBind();
}
/// <summary>
/// sistemo filtraggio con valori selezionati
/// </summary>
private void checkFixOds()
{
//ods.FilterExpression = "( (CodImpianto LIKE '%{0}%') OR (nomeImpianto LIKE '%{0}%') OR (codMacchina LIKE '%{0}%') OR (nomeMacchina LIKE '%{0}%') OR (descrizione LIKE '%{0}%') OR (descrPriorita LIKE '%{0}%') OR (descrTipo LIKE '%{0}%') )";
//if (memLayer.ML.isInSessionObject("idxTipo_filt"))
//{
// ods.FilterExpression += " AND (idxTipo = {1})";
//}
//if (memLayer.ML.isInSessionObject("idxMacchina_filt"))
//{
// ods.FilterExpression += " AND (idxMacchina = {2})";
//}
}
/// <summary>
/// converte CodSoggetto in cognome/nome
/// </summary>
/// <param name="codOperatore"></param>
/// <returns></returns>
public string getOperatoreByCod(object CodSoggetto)
{
return utils.obj.getOperatoreByCod(CodSoggetto.ToString());
}
}
}