234 lines
9.0 KiB
C#
234 lines
9.0 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
using System.Data;
|
|
using System.IO;
|
|
using Consulenza.Web.ConsulenzaUnicaWS;
|
|
using Consulenza.Web.ConsulenzaImmobiliareWS;
|
|
|
|
namespace Consulenza.Web
|
|
{
|
|
public partial class MonitoraggioImmobiliare : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Report del patrimonio immobiliare
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnCreaReportImmobiliare_Click(object sender, EventArgs e)
|
|
{
|
|
var ci = new ConsulenzaImmobiliareWS.WSImmobiliare();
|
|
|
|
//Per test lettura template da db
|
|
ConsulenzaImmobiliareWS.Template template = null;
|
|
template = new ConsulenzaImmobiliareWS.Template { IdModello = -1, Nome = "Car_MonImm2" };
|
|
var chiaveClientePb = Convert.ToInt32(txtChiaveClientePb.Text.Trim());
|
|
|
|
var listaIdImmobileCatasto = new List<string>();
|
|
var listaIdSezione = new List<Int32>();
|
|
string immobili = "";
|
|
if (tx_immobili.Text != "")
|
|
{
|
|
immobili = tx_immobili.Text.Remove(tx_immobili.Text.Length - 1);
|
|
foreach (var item in immobili.Split(';'))
|
|
{
|
|
listaIdImmobileCatasto.Add(item);
|
|
};
|
|
}
|
|
|
|
foreach (var item in txtSchede.Text.Split(';'))
|
|
{
|
|
//solo per test
|
|
//if (Convert.ToInt32(item) == 223)
|
|
// listaIdSezione.Add(85000);
|
|
//else
|
|
listaIdSezione.Add(Convert.ToInt32(item));
|
|
};
|
|
|
|
|
|
|
|
byte[] myPdf = null;
|
|
myPdf = ci.CreaReport_MonitoraggioImmobiliareCUTest(chiaveClientePb, listaIdImmobileCatasto.ToArray(), listaIdSezione.ToArray());
|
|
|
|
// Chiamata con Template
|
|
// myPdf = ci.CreaReport_MonitoraggioImmobiliareCU(chiaveClientePb, listaIdImmobileCatasto.ToArray(), template);
|
|
|
|
if (myPdf != null)
|
|
{
|
|
Session["pdf"] = myPdf;
|
|
Response.Redirect("Report.aspx", false);
|
|
|
|
// Aggiunta ES 27/07/2017 per Test Salvataggio PDF
|
|
//string XlsTimeStamp = "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".pdf";
|
|
//string XlsFileCreate = "~/Docs/Report";
|
|
//string XlsFileName = Server.MapPath(XlsFileCreate + XlsTimeStamp);
|
|
|
|
//File.WriteAllBytes(XlsFileName, myPdf);
|
|
}
|
|
else
|
|
ScriptManager.RegisterClientScriptBlock(Page, typeof(Page), "ClientScript", "alert('Deve essere selezionata almeno una voce')", true);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// Popola la txtSchede con le selezioni fatte sulla lista delle sezioni
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSelezionaSchede_Click(object sender, EventArgs e)
|
|
{
|
|
var selected = chklstSezioni.Items.Cast<ListItem>().Where(li => li.Selected).ToList().Select(o => o.Value);
|
|
txtSchede.Text = string.Join(";", selected);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Popola la txtIdImmobile con le chiaviImmobile del chiaveclientepb selezionato
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void lkb_ChiaviImmobili_Click(object sender, EventArgs e)
|
|
{
|
|
int chiave = txtChiaveClientePb.Text != string.Empty ? int.Parse(txtChiaveClientePb.Text) : 0;
|
|
recuperaImmobili(chiave);
|
|
tx_immobili.Text = "";
|
|
lb_norecord.Visible = false;
|
|
}
|
|
private void recuperaImmobili(int chiave)
|
|
{
|
|
|
|
//try
|
|
//{
|
|
// DataTable dt = new DataTable();
|
|
// if (ck_unica.Checked)
|
|
// {
|
|
// dt = DataAccess.ExecuteDataTableSqlStatement(
|
|
// DBProvider.SqlServerConsulenzaUnica
|
|
// , string.Format(@"SELECT DISTINCT pt.idImmobileCatasto AS idImmobileCatasto
|
|
// FROM ConsulenzaUnica..PatrimonioTerzi pt
|
|
// inner join ConsulenzaUnica..DettImmobiliare dett
|
|
// on pt.chiaveProdottoTerzi=dett.chiaveProdottoTerzi
|
|
// inner join ConsulenzaUnica..PatrimonioImmobiliareStaging pis
|
|
// on pis.chiaveClientePB=pt.chiaveClientePB AND pis.idImmobileCatasto=pt.idImmobileCatasto
|
|
// left join ConsulenzaUnica..dcomune dc
|
|
// on dc.codcomune=dett.codcomune
|
|
// where dtfinevalidita > getdate()
|
|
// and pt.idImmobileCatasto is not null
|
|
// and dett.codTipologia in ('A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A11')
|
|
// AND pt.chiaveClientePB = {0}", chiave)
|
|
// , null);
|
|
// }
|
|
// else
|
|
// {
|
|
// dt = DataAccess.ExecuteDataTableSqlStatement(
|
|
// DBProvider.SqlServerConsulenzaEvoluta
|
|
// , string.Format(@"SELECT DISTINCT pt.idImmobileCatasto AS idImmobileCatasto
|
|
// FROM ConsulenzaEvoluta..PatrimonioTerzi pt
|
|
// inner join ConsulenzaEvoluta..DettImmobiliare dett
|
|
// on pt.chiaveProdottoTerzi=dett.chiaveProdottoTerzi
|
|
// inner join ConsulenzaEvoluta..PatrimonioImmobiliareStaging pis
|
|
// on pis.chiaveClientePB=pt.chiaveClientePB AND pis.idImmobileCatasto=pt.idImmobileCatasto
|
|
// left join ConsulenzaEvoluta..dcomune dc
|
|
// on dc.codcomune=dett.codcomune
|
|
// where dtfinevalidita > getdate()
|
|
// and pt.idImmobileCatasto is not null
|
|
// and dett.codTipologia in ('A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A11')
|
|
// AND pt.chiaveClientePB = {0}", chiave)
|
|
// , null);
|
|
// }
|
|
// delenco.Visible = true;
|
|
// if (dt.Rows.Count > 0)
|
|
// {
|
|
|
|
// rp_link.Visible = true;
|
|
// rp_link.DataSource = dt;
|
|
// rp_link.DataBind();
|
|
// }
|
|
// else
|
|
// {
|
|
// lb_norecord.Visible = true;
|
|
// }
|
|
|
|
|
|
//}
|
|
//catch (Exception ex)
|
|
//{
|
|
// throw new Exception(ex.Message);
|
|
//}
|
|
}
|
|
|
|
protected void lkb_close_Click(object sender, EventArgs e)
|
|
{
|
|
delenco.Visible = false;
|
|
tx_immobili.Text = "";
|
|
|
|
}
|
|
protected void rp_link_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
|
|
{
|
|
|
|
DataRowView rec = (DataRowView)e.Item.DataItem;
|
|
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
|
|
{
|
|
LinkButton lk = (LinkButton)e.Item.FindControl("lk_immobile");
|
|
lk.CommandName = "immobile";
|
|
lk.Text = rec["idImmobileCatasto"].ToString();
|
|
lk.CommandArgument = rec["idImmobileCatasto"].ToString();
|
|
}
|
|
}
|
|
|
|
protected void rp_link_ItemCommand(object source, RepeaterCommandEventArgs e)
|
|
{
|
|
|
|
string comm = e.CommandArgument.ToString();
|
|
tx_immobili.Text += comm + ";";
|
|
}
|
|
|
|
protected void btnTest_Click(object sender, EventArgs e)
|
|
{
|
|
var ci = new ConsulenzaImmobiliareWS.WSImmobiliare();
|
|
|
|
ConsulenzaImmobiliareWS.Template template = null;
|
|
|
|
|
|
var chiaveClientePb = Convert.ToInt32(txtChiaveClientePb.Text.Trim());
|
|
|
|
var listaIdImmobileCatasto = new List<string>();
|
|
|
|
string immobili = "";
|
|
if (tx_immobili.Text != "")
|
|
{
|
|
immobili = tx_immobili.Text.Remove(tx_immobili.Text.Length - 1);
|
|
foreach (var item in immobili.Split(';'))
|
|
{
|
|
listaIdImmobileCatasto.Add(item);
|
|
};
|
|
}
|
|
|
|
|
|
|
|
|
|
template = new ConsulenzaImmobiliareWS.Template { IdModello = -1, Nome = "Car_MonImm" };
|
|
|
|
var imagePDF = ci.CreaReport_MonitoraggioImmobiliareCU(chiaveClientePb, listaIdImmobileCatasto.ToArray(), template);
|
|
|
|
if (imagePDF == null) return;
|
|
|
|
Session["pdf"] = imagePDF;
|
|
Response.Redirect("Report.aspx", false);
|
|
|
|
}
|
|
|
|
protected void chklstSezioni_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|