Inserita prima release modulo x selezione periodo date
inserito e messo in bundle jscript x datepicker
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Utility JS Steamware
|
||||
*
|
||||
* Steamware 2014+
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
// Gestione oggetti datepicker (globale)
|
||||
function fixDatePicker()
|
||||
{
|
||||
$.datepicker.setDefaults($.datepicker.regional["it"]);
|
||||
$(".datepicker").datepicker({
|
||||
//showOtherMonths: true,
|
||||
//selectOtherMonths: true,
|
||||
showButtonPanel: true,
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
dateFormat: "dd/mm/yy"
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
// richiamo quando il DOM della pagina è ok...
|
||||
$(function () {
|
||||
fixDatePicker();
|
||||
});
|
||||
|
||||
// oggetto da legare all'update parziale ajax x sistemare script vari
|
||||
var prm = Sys.WebForms.PageRequestManager.getInstance();
|
||||
prm.add_endRequest(function () {
|
||||
// re-bind post eventi here
|
||||
fixDatePicker();
|
||||
});
|
||||
@@ -0,0 +1,109 @@
|
||||
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="mod_selPeriodo.ascx.cs" Inherits="C2P.WebUserControls.mod_selPeriodo" %>
|
||||
|
||||
<%--<script>
|
||||
$(function () {
|
||||
$.datepicker.setDefaults($.datepicker.regional["it"]);
|
||||
$(".datepicker").datepicker({
|
||||
//showOtherMonths: true,
|
||||
//selectOtherMonths: true,
|
||||
showButtonPanel: true,
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
dateFormat: "dd/mm/yy"
|
||||
});
|
||||
});
|
||||
|
||||
// oggetto da legare all'update parziale ajax x sistemare btns & co
|
||||
var prm = Sys.WebForms.PageRequestManager.getInstance();
|
||||
prm.add_endRequest(function () {
|
||||
// re-bind your jQuery events here
|
||||
$(function () {
|
||||
$.datepicker.setDefaults($.datepicker.regional["it"]);
|
||||
$(".datepicker").datepicker({
|
||||
//showOtherMonths: true,
|
||||
//selectOtherMonths: true,
|
||||
showButtonPanel: true,
|
||||
changeMonth: true,
|
||||
changeYear: true,
|
||||
dateFormat: "dd/mm/yy"
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>--%>
|
||||
<div style="font-size:8pt;">
|
||||
<asp:Label ID="lblPeriodo" runat="server"></asp:Label>
|
||||
|
||||
<asp:TextBox ID="txtInizio" TabIndex="1" runat="server" Width="6em" MaxLength="10" AutoPostBack="True" OnTextChanged="txtInizio_TextChanged" CssClass="datepicker" />
|
||||
<asp:DropDownList ID="ddlOraInizio" TabIndex="2" runat="server" AutoPostBack="True" OnTextChanged="txtInizio_TextChanged" CssClass="btn btn-default btn-sm">
|
||||
<asp:ListItem>00</asp:ListItem>
|
||||
<asp:ListItem>01</asp:ListItem>
|
||||
<asp:ListItem>02</asp:ListItem>
|
||||
<asp:ListItem>03</asp:ListItem>
|
||||
<asp:ListItem>04</asp:ListItem>
|
||||
<asp:ListItem>05</asp:ListItem>
|
||||
<asp:ListItem>06</asp:ListItem>
|
||||
<asp:ListItem>07</asp:ListItem>
|
||||
<asp:ListItem>08</asp:ListItem>
|
||||
<asp:ListItem>09</asp:ListItem>
|
||||
<asp:ListItem>10</asp:ListItem>
|
||||
<asp:ListItem>11</asp:ListItem>
|
||||
<asp:ListItem>12</asp:ListItem>
|
||||
<asp:ListItem>13</asp:ListItem>
|
||||
<asp:ListItem>14</asp:ListItem>
|
||||
<asp:ListItem>15</asp:ListItem>
|
||||
<asp:ListItem>16</asp:ListItem>
|
||||
<asp:ListItem>17</asp:ListItem>
|
||||
<asp:ListItem>18</asp:ListItem>
|
||||
<asp:ListItem>19</asp:ListItem>
|
||||
<asp:ListItem>20</asp:ListItem>
|
||||
<asp:ListItem>21</asp:ListItem>
|
||||
<asp:ListItem>22</asp:ListItem>
|
||||
<asp:ListItem>23</asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
|
||||
→
|
||||
<asp:TextBox ID="txtFine" TabIndex="3" runat="server" Width="6em" MaxLength="10" AutoPostBack="True" OnTextChanged="txtFine_TextChanged" CssClass="datepicker" />
|
||||
<asp:DropDownList ID="ddlOraFine" TabIndex="2" runat="server" AutoPostBack="True" OnTextChanged="txtFine_TextChanged" CssClass="btn btn-default btn-sm">
|
||||
<asp:ListItem>00</asp:ListItem>
|
||||
<asp:ListItem>01</asp:ListItem>
|
||||
<asp:ListItem>02</asp:ListItem>
|
||||
<asp:ListItem>03</asp:ListItem>
|
||||
<asp:ListItem>04</asp:ListItem>
|
||||
<asp:ListItem>05</asp:ListItem>
|
||||
<asp:ListItem>06</asp:ListItem>
|
||||
<asp:ListItem>07</asp:ListItem>
|
||||
<asp:ListItem>08</asp:ListItem>
|
||||
<asp:ListItem>09</asp:ListItem>
|
||||
<asp:ListItem>10</asp:ListItem>
|
||||
<asp:ListItem>11</asp:ListItem>
|
||||
<asp:ListItem>12</asp:ListItem>
|
||||
<asp:ListItem>13</asp:ListItem>
|
||||
<asp:ListItem>14</asp:ListItem>
|
||||
<asp:ListItem>15</asp:ListItem>
|
||||
<asp:ListItem>16</asp:ListItem>
|
||||
<asp:ListItem>17</asp:ListItem>
|
||||
<asp:ListItem>18</asp:ListItem>
|
||||
<asp:ListItem>19</asp:ListItem>
|
||||
<asp:ListItem>20</asp:ListItem>
|
||||
<asp:ListItem>21</asp:ListItem>
|
||||
<asp:ListItem>22</asp:ListItem>
|
||||
<asp:ListItem>23</asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
|
||||
<asp:DropDownList ID="ddlSelPeriodo" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlSelPeriodo_SelectedIndexChanged" CssClass="btn btn-default btn-sm">
|
||||
<asp:ListItem>selezione</asp:ListItem>
|
||||
<asp:ListItem>oggi</asp:ListItem>
|
||||
<asp:ListItem>ieri</asp:ListItem>
|
||||
<asp:ListItem>questa settimana</asp:ListItem>
|
||||
<asp:ListItem Selected="True">ultimi 7gg</asp:ListItem>
|
||||
<asp:ListItem>questo mese</asp:ListItem>
|
||||
<asp:ListItem>ultimi 30gg</asp:ListItem>
|
||||
<asp:ListItem>1 anno</asp:ListItem>
|
||||
</asp:DropDownList>
|
||||
|
||||
<asp:Button ID="btnUpdate" CssClass="btn btn-default btn-sm" runat="server" Text="update" Visible="false" OnClick="btnUpdate_Click" />
|
||||
|
||||
<asp:Label ID="lblDurataMin" runat="server" Visible="false"></asp:Label>
|
||||
|
||||
<asp:TextBox ID="txtDurataMin" TabIndex="3" runat="server" Width="30px" MaxLength="3" AutoPostBack="True" OnTextChanged="txtInizio_TextChanged" Visible="false"></asp:TextBox>
|
||||
</div>
|
||||
@@ -0,0 +1,313 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using SteamWare;
|
||||
|
||||
|
||||
namespace C2P.WebUserControls
|
||||
{
|
||||
public partial class mod_selPeriodo : System.Web.UI.UserControl
|
||||
{
|
||||
#region area protected
|
||||
|
||||
protected intervalloDate _intervallo;
|
||||
|
||||
/// <summary>
|
||||
/// avvio componente
|
||||
/// </summary>
|
||||
/// <param name="e"></param>
|
||||
protected override void OnInit(EventArgs e)
|
||||
{
|
||||
base.OnInit(e);
|
||||
setIntervallo();
|
||||
setDurataMin();
|
||||
}
|
||||
/// <summary>
|
||||
/// definisce se sia da mostrare il selettore delle ore nel controllo
|
||||
/// </summary>
|
||||
protected bool mostraSelOra
|
||||
{
|
||||
get
|
||||
{
|
||||
bool answ = false;
|
||||
if (memLayer.ML.isInSessionObject("mostraSelOra"))
|
||||
{
|
||||
answ = memLayer.ML.BoolSessionObj("mostraSelOra");
|
||||
}
|
||||
else
|
||||
{
|
||||
// leggo da sessione e salvo...
|
||||
try
|
||||
{
|
||||
answ = memLayer.ML.confReadBool("mostraSelOra");
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
memLayer.ML.setSessionVal("mostraSelOra", answ);
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// gestione del selettore rapido dell'intervallo temporale...
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void ddlSelPeriodo_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
// verifico cosa sia cambiato ed imposto date...
|
||||
datario _datario = new datario();
|
||||
switch (ddlSelPeriodo.SelectedValue)
|
||||
{
|
||||
case "oggi":
|
||||
_intervallo = _datario.giornata(DateTime.Now);
|
||||
break;
|
||||
case "ieri":
|
||||
_intervallo = _datario.giornata(DateTime.Now.AddDays(-1));
|
||||
break;
|
||||
case "ultimi 7gg":
|
||||
_intervallo = _datario.ultimiGiorni(DateTime.Now, 7);
|
||||
break;
|
||||
case "questa settimana":
|
||||
_intervallo = _datario.questaSett(DateTime.Now);
|
||||
break;
|
||||
case "ultimi 30gg":
|
||||
_intervallo = _datario.ultimiGiorni(DateTime.Now, 30);
|
||||
break;
|
||||
case "questo mese":
|
||||
_intervallo = _datario.questoMese(DateTime.Now);
|
||||
break;
|
||||
case "1 anno":
|
||||
_intervallo = _datario.ultimiGiorni(DateTime.Now, 366);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if ((intervalloAnalisi.inizio != _intervallo.inizio) || (intervalloAnalisi.fine != _intervallo.fine))
|
||||
{
|
||||
verificaCoerenzaDate();
|
||||
aggiornaDateMostrate(false);
|
||||
// mostro btn update
|
||||
btnUpdate.Visible = true;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// effettua update delle date mostrate da intervallo analisi (ed eventualmente riporta update...)
|
||||
/// </summary>
|
||||
/// <param name="doReportUpdate"></param>
|
||||
private void aggiornaDateMostrate(bool doReportUpdate)
|
||||
{
|
||||
scriviDate();
|
||||
if (doReportUpdate)
|
||||
{
|
||||
reportUpdate();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// scrive nuove date in controllo
|
||||
/// </summary>
|
||||
private void scriviDate()
|
||||
{
|
||||
// se intervallo non è valorizzato leggo da sessione...
|
||||
if (!_intervallo.isValid)
|
||||
{
|
||||
_intervallo = intervalloAnalisi;
|
||||
}
|
||||
txtInizio.Text = _intervallo.inizio.ToShortDateString();
|
||||
ddlOraInizio.SelectedValue = _intervallo.inizio.Hour.ToString("00");
|
||||
txtFine.Text = _intervallo.fine.ToShortDateString();
|
||||
ddlOraFine.SelectedValue = _intervallo.fine.Hour.ToString("00");
|
||||
if (mostraSelOra)
|
||||
{
|
||||
ddlOraInizio.Visible = true;
|
||||
ddlOraFine.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
ddlOraInizio.Visible = false;
|
||||
ddlOraFine.Visible = false;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// imposta intervallo da sessione o di default
|
||||
/// </summary>
|
||||
private void setIntervallo()
|
||||
{
|
||||
intervalloDate _intervallo;
|
||||
try
|
||||
{
|
||||
_intervallo = (intervalloDate)Session["_intervallo"];
|
||||
}
|
||||
catch
|
||||
{
|
||||
_intervallo = new intervalloDate();
|
||||
_intervallo.inizio = DateTime.Now.AddDays(memLayer.ML.confReadInt("defDayFrom"));
|
||||
_intervallo.fine = DateTime.Now.AddDays(1);
|
||||
Session["_intervallo"] = _intervallo;
|
||||
Session["_inizio"] = _intervallo.inizio;
|
||||
Session["_fine"] = _intervallo.fine;
|
||||
}
|
||||
scriviDate();
|
||||
}
|
||||
/// <summary>
|
||||
/// imposta durata minima
|
||||
/// </summary>
|
||||
private void setDurataMin()
|
||||
{
|
||||
int _durataMin;
|
||||
try
|
||||
{
|
||||
_durataMin = (int)Session["_durataMin"];
|
||||
}
|
||||
catch
|
||||
{
|
||||
_durataMin = 0;
|
||||
Session["_durataMin"] = _durataMin;
|
||||
}
|
||||
txtDurataMin.Text = _durataMin.ToString();
|
||||
}
|
||||
/// <summary>
|
||||
/// caricamento pagina
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
lblPeriodo.Text = "Periodo di riferimento: ";
|
||||
txtInizio.ToolTip = "inizio periodo di riferimento per i dati mostrati";
|
||||
txtFine.ToolTip = "fine periodo di riferimento per i dati mostrati";
|
||||
lblDurataMin.Text = "Visualizza eventi con durata superiore a";
|
||||
}
|
||||
|
||||
|
||||
private void aggiornaPeriodo()
|
||||
{
|
||||
_intervallo = new intervalloDate();
|
||||
// calcolo tempi arrotondati
|
||||
int oraInizio = Convert.ToInt32(ddlOraInizio.SelectedValue);
|
||||
int oraFine = Convert.ToInt32(ddlOraFine.SelectedValue);
|
||||
_intervallo.inizio = Convert.ToDateTime(txtInizio.Text).AddHours(oraInizio);
|
||||
_intervallo.fine = Convert.ToDateTime(txtFine.Text).AddHours(oraFine);
|
||||
verificaCoerenzaDate();
|
||||
int _durataMin;
|
||||
_durataMin = Convert.ToInt32(txtDurataMin.Text);
|
||||
Session["_durataMin"] = _durataMin;
|
||||
reportUpdate();
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// verifica che le date dell'intervallo siano coerenti (inizio < fine)
|
||||
/// </summary>
|
||||
private void verificaCoerenzaDate()
|
||||
{
|
||||
// controllo date siano coerenti (fine > inizio)...
|
||||
if (_intervallo.inizio >= _intervallo.fine)
|
||||
{
|
||||
// controllo non siano date successive ad oggi...
|
||||
if (_intervallo.fine > DateTime.Now)
|
||||
{
|
||||
_intervallo.fine = DateTime.Now;
|
||||
}
|
||||
_intervallo.inizio = _intervallo.fine.AddDays(-1);
|
||||
}
|
||||
//intervalloAnalisi = _intervallo;
|
||||
aggiornaDateMostrate(false);
|
||||
}
|
||||
/// <summary>
|
||||
/// evento cambio testo data inizio
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void txtInizio_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// imposto il selettore a discesa...
|
||||
setPeriodoFree();
|
||||
// mostro btn update
|
||||
btnUpdate.Visible = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// evento cambio testo data fine
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void txtFine_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
// imposto il selettore a discesa...
|
||||
setPeriodoFree();
|
||||
// mostro btn update
|
||||
btnUpdate.Visible = true;
|
||||
}
|
||||
/// <summary>
|
||||
/// in questo caso faccio udpate periodo mostrato
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
protected void btnUpdate_Click(object sender, EventArgs e)
|
||||
{
|
||||
aggiornaPeriodo();
|
||||
// nascondo btn update
|
||||
btnUpdate.Visible = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// riporta aggiornamento a controller
|
||||
/// </summary>
|
||||
protected void reportUpdate()
|
||||
{
|
||||
intervalloAnalisi = _intervallo;
|
||||
// alzo l'evento d update/inserimento e ricarico cache...
|
||||
if (eh_doUpdate != null)
|
||||
{
|
||||
eh_doUpdate(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region area public
|
||||
|
||||
public intervalloDate intervalloAnalisi
|
||||
{
|
||||
get
|
||||
{
|
||||
return (intervalloDate)Session["_intervallo"];
|
||||
}
|
||||
set
|
||||
{
|
||||
intervalloDate interv = value;
|
||||
Session["_intervallo"] = interv;
|
||||
Session["_inizio"] = interv.inizio;
|
||||
Session["_fine"] = interv.fine;
|
||||
_intervallo = interv;
|
||||
aggiornaDateMostrate(false);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// effettua update
|
||||
/// </summary>
|
||||
/// <param name="doReportUpdate"></param>
|
||||
public void doUpdate(bool doReportUpdate)
|
||||
{
|
||||
aggiornaDateMostrate(doReportUpdate);
|
||||
}
|
||||
/// <summary>
|
||||
/// imposta periodo libero di selezione
|
||||
/// </summary>
|
||||
public void setPeriodoFree()
|
||||
{
|
||||
ddlSelPeriodo.SelectedIndex = 0;
|
||||
}
|
||||
|
||||
#region gestione eventi
|
||||
|
||||
public event EventHandler eh_doUpdate;
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace C2P.WebUserControls {
|
||||
|
||||
|
||||
public partial class mod_selPeriodo {
|
||||
|
||||
/// <summary>
|
||||
/// lblPeriodo control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblPeriodo;
|
||||
|
||||
/// <summary>
|
||||
/// txtInizio control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox txtInizio;
|
||||
|
||||
/// <summary>
|
||||
/// ddlOraInizio control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList ddlOraInizio;
|
||||
|
||||
/// <summary>
|
||||
/// txtFine control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox txtFine;
|
||||
|
||||
/// <summary>
|
||||
/// ddlOraFine control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList ddlOraFine;
|
||||
|
||||
/// <summary>
|
||||
/// ddlSelPeriodo control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.DropDownList ddlSelPeriodo;
|
||||
|
||||
/// <summary>
|
||||
/// btnUpdate control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Button btnUpdate;
|
||||
|
||||
/// <summary>
|
||||
/// lblDurataMin control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.Label lblDurataMin;
|
||||
|
||||
/// <summary>
|
||||
/// txtDurataMin control.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Auto-generated field.
|
||||
/// To modify move field declaration from designer file to code-behind file.
|
||||
/// </remarks>
|
||||
protected global::System.Web.UI.WebControls.TextBox txtDurataMin;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user