-
Notifications
You must be signed in to change notification settings - Fork 0
/
ArchivioNotizie.aspx.cs
169 lines (154 loc) · 4.92 KB
/
ArchivioNotizie.aspx.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
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 pa_taverne
{
public partial class ArchivioNotizie : Pagebasic
{
int indicepagina = 0;
public static string filtro;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (!IsPostBack)
{
filtro = string.Empty;
indicepagina = 0;
PopolaElenco(filtro);
ComboTipi();
ComboAnni();
}
}
catch (Exception Ex)
{
lblErr.Text = Ex.Message;
}
}
public void ComboTipi()
{
DataTable dtTipi = new DataTable();
try
{
dtTipi = objQry.TipiIniziativeConNullo();
cmbTipo.DataSource = dtTipi;
cmbTipo.DataValueField = "ID_TIPO";
cmbTipo.DataTextField = "DS_TIPO";
cmbTipo.DataBind();
}
catch (Exception Ex)
{
throw Ex;
}
}
public void ComboAnni()
{
DataTable dtAnni = new DataTable();
try
{
dtAnni = objQry.AnniNews();
cmbAnno.DataSource = dtAnni;
cmbAnno.DataValueField = "ANNO_EVN";
cmbAnno.DataTextField = "ANNO_EVN";
cmbAnno.DataBind();
cmbAnno.Items[0].Text = "";
}
catch (Exception Ex)
{
throw Ex;
}
}
public void PopolaElenco(string Filtro)
{
DataTable dtNews = new DataTable();
DataView dvNews;
try
{
dtNews = objQry.TotNotizie();
dvNews = new DataView(dtNews);
if (Filtro != string.Empty)
{
dvNews.RowFilter = Filtro;
}
dgNews.DataSource = dvNews;
dgNews.PageIndex = indicepagina;
dgNews.DataBind();
}
catch (Exception Ex)
{
throw Ex;
}
}
protected void dgNews_RowDataBound(object sender, GridViewRowEventArgs e)
{
try
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.Cells[3].Text = objUti.PrimeParole(e.Row.Cells[3].Text, 5);
e.Row.Cells[4].Text = "<a style=\"cursor:pointer;\" onclick=\"javascript:location.href='DettaglioNotizia.aspx?notizia=" + e.Row.Cells[0].Text + "'\">Leggi</a>";
}
if (e.Row.RowType != DataControlRowType.Pager)
{
e.Row.Cells[0].Visible = false;
}
}
catch (Exception Ex)
{
lblErr.Text = Ex.Message;
}
}
protected void dgNews_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
indicepagina = e.NewPageIndex;
PopolaElenco(filtro);
}
protected void btnFiltra_Click(object sender, ImageClickEventArgs e)
{
string descfiltro = "<b>FILTRO ATTIVO: </b><br /><br />";
if (cmbAnno.SelectedIndex > 0)
{
filtro = "ANNO_EVN=" + cmbAnno.SelectedValue;
descfiltro = descfiltro + "ANNO INIZIATIVA: " + cmbAnno.SelectedItem.Text;
if (cmbTipo.SelectedIndex > 0)
{
filtro = filtro + " AND ID_TIPO=" + cmbTipo.SelectedValue;
descfiltro = descfiltro + "<br/ ><br/ >TIPO INIZIATIVA: " + cmbTipo.SelectedItem.Text;
}
}
else
{
if (cmbTipo.SelectedIndex > 0)
{
filtro = "ID_TIPO=" + cmbTipo.SelectedValue;
descfiltro = descfiltro + "TIPO INIZIATIVA: " + cmbTipo.SelectedItem.Text;
}
else
{
filtro = string.Empty;
}
}
if (filtro != string.Empty)
{
lblFiltro.Visible = true;
lblFiltro.Text = descfiltro;
btnEliFiltro.Visible = true;
pnlFiltri.Visible = false;
PopolaElenco(filtro);
}
}
protected void btnEliFiltro_Click(object sender, ImageClickEventArgs e)
{
filtro = string.Empty;
lblFiltro.Visible = false;
lblFiltro.Text = string.Empty;
btnEliFiltro.Visible = false;
pnlFiltri.Visible = true;
PopolaElenco(filtro);
}
}
}