191 lines
7.7 KiB
C#
191 lines
7.7 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;
|
|
|
|
namespace Consulenza.Web
|
|
{
|
|
public partial class NucleoImmobiliare : System.Web.UI.Page
|
|
{
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
|
|
|
|
}
|
|
protected void Button3_Click(object sender, EventArgs e)
|
|
{
|
|
var ci = new ConsulenzaImmobiliareWS.WSImmobiliare();
|
|
|
|
var chiaveNucleo = Convert.ToInt64(txtChiaveNucleo.Text.Trim());
|
|
|
|
var listaIdSezione = new List<Int32>();
|
|
|
|
var listaIdImmobileCatasto = new List<string>();
|
|
var listaChiaveClientePB = new List<long>();
|
|
//metto sempre il ; dopo idimmobile e chiaveclientepb anche se è una, quindi la tolgo se text non è vuoto.
|
|
string chiavi = "";
|
|
if (tx_chiaveclientepb.Text != "")
|
|
{
|
|
chiavi = tx_chiaveclientepb.Text.Remove(tx_chiaveclientepb.Text.Length - 1);
|
|
foreach (var item in chiavi.Split(';'))
|
|
{
|
|
listaChiaveClientePB.Add(Convert.ToInt64(item));
|
|
};
|
|
}
|
|
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(';'))
|
|
{
|
|
listaIdSezione.Add(Convert.ToInt32(item));
|
|
};
|
|
byte[] myPdf = null;
|
|
myPdf = ck_unica.Checked ? ci.CreaReport_NucleiImmobiliareCU(chiaveNucleo, listaIdImmobileCatasto.ToArray(), listaChiaveClientePB.ToArray(), listaIdSezione.ToArray()):
|
|
ci.CreaReport_NucleiImmobiliare(chiaveNucleo, listaIdImmobileCatasto.ToArray(), listaChiaveClientePB.ToArray(), listaIdSezione.ToArray());
|
|
if (myPdf != null)
|
|
{
|
|
Session["pdf"] = myPdf;
|
|
Response.Redirect("Report.aspx", false);
|
|
}
|
|
//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 Button4_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 Button5_Click(object sender, EventArgs e)
|
|
{
|
|
long chiave = txtChiaveNucleo.Text != string.Empty ? Convert.ToInt64(txtChiaveNucleo.Text) : 0;
|
|
recuperaClientiNucleo(chiave);
|
|
tx_immobili.Text =tx_chiaveclientepb.Text = "";
|
|
lb_norecord.Visible = false;
|
|
}
|
|
|
|
private void recuperaClientiNucleo(long chiave)
|
|
{
|
|
|
|
try
|
|
{
|
|
DataTable dt = new DataTable();
|
|
DataTable dt1 = new DataTable();
|
|
var parametri = new List<Parametro>
|
|
{
|
|
new Parametro
|
|
{
|
|
Direction = ParameterDirection.Input,
|
|
DbType = DbType.Int64,
|
|
ParameterName = "ChiaveNucleo",
|
|
Value = chiave
|
|
}
|
|
};
|
|
|
|
dt = DataAccess.ExecuteDataTableSqlStatement(
|
|
DBProvider.SqlServerConsulenzaUnica
|
|
, string.Format(@"SELECT *--distinct pt.idImmobileCatasto AS idImmobileCatasto
|
|
FROM ConsulenzaUnica..ClientiNucleo cn
|
|
inner join ConsulenzaUnica..PosizioniTerziNucleo po
|
|
on cn.chiaveNucleo = po.chiaveNucleo
|
|
inner join ConsulenzaUnica..PatrimonioTerzi pt
|
|
on po.chiaveProdottoTerzi=pt.chiaveProdottoTerzi
|
|
inner join ConsulenzaUnica..DettImmobiliare dett
|
|
on pt.chiaveProdottoTerzi=dett.chiaveProdottoTerzi
|
|
where
|
|
cn.dtFineValidita>GETDATE()
|
|
and pt.dtfinevalidita > getdate()
|
|
and po.dtfinevalidita > getdate()
|
|
and dett.tipoImmobile='F'
|
|
and pt.idImmobileCatasto is not null
|
|
and dett.codTipologia in ('A1', 'A2', 'A3', 'A4', 'A5', 'A6', 'A7', 'A8', 'A11')
|
|
and cn.chiavenucleo={0}", chiave),
|
|
null);
|
|
//dt.Load(dato);
|
|
delenco.Visible = true;
|
|
if (dt.Rows.Count > 0)
|
|
{
|
|
|
|
rp_link.Visible = true;
|
|
rp_link.DataSource = dt;
|
|
rp_link.DataBind();
|
|
}
|
|
else
|
|
{
|
|
lb_norecord.Visible = true;
|
|
}
|
|
|
|
//foreach (DataRow row in dt.Rows)
|
|
//{
|
|
// lblElencoImmobili.Text += "<br>" + row["idImmobileCatasto"].ToString() + "<br>" + Convert.ToInt64(row["chiaveClientePB"].ToString());
|
|
|
|
//}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw new Exception(ex.Message);
|
|
}
|
|
}
|
|
|
|
protected void lkb_close_Click(object sender, EventArgs e)
|
|
{
|
|
delenco.Visible = false;
|
|
tx_chiaveclientepb.Text = tx_immobili.Text = "";
|
|
//lkb_close.Visible = lblImmobiliCatasto.Visible = false;
|
|
|
|
}
|
|
|
|
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");
|
|
Label lb = (Label)e.Item.FindControl("lk_cliente");
|
|
lk.CommandName = "immobile";
|
|
lk.Text = rec["idImmobileCatasto"].ToString();
|
|
lb.Text = rec["chiaveClientePB"].ToString();
|
|
lk.CommandArgument = rec["idImmobileCatasto"].ToString() + "|" + rec["chiaveClientePB"].ToString();
|
|
}
|
|
}
|
|
|
|
protected void rp_link_ItemCommand(object source, RepeaterCommandEventArgs e)
|
|
{
|
|
|
|
int lenght = e.CommandArgument.ToString().IndexOf("|");
|
|
|
|
string comm = e.CommandArgument.ToString();
|
|
string imm = comm.Substring(0, lenght);
|
|
string chiavecliente = e.CommandArgument.ToString().Substring(lenght + 1);
|
|
tx_immobili.Text += imm + ";";
|
|
|
|
tx_chiaveclientepb.Text += chiavecliente + ";";
|
|
|
|
}
|
|
}
|
|
} |