Files
WebSCR/WebSCR/WebUserControls/mod_gestIntSquadre.ascx.cs
T
2015-09-29 18:16:08 +02:00

171 lines
4.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 SteamWare;
using WebSCR_data;
namespace WebSCR.WebUserControls
{
public partial class mod_gestIntSquadre : System.Web.UI.UserControl
{
public event EventHandler eh_update;
/// <summary>
/// solleva evento selezione data
/// </summary>
protected void reportEvent()
{
// evento!
if (eh_update != null)
{
eh_update(this, new EventArgs());
}
}
/// <summary>
/// load pagina
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
fixVisibility();
}
protected int IdxImpegno
{
get
{
int answ = 0;
try
{
answ = memLayer.ML.QSI("IdxImpegno");
}
catch
{ }
return answ;
}
}
protected double latitude
{
get
{
double answ = 0;
try
{
answ = Convert.ToDouble(hLat.Value.Replace(".", ","));
}
catch
{ }
return answ;
}
}
protected double longitude
{
get
{
double answ = 0;
try
{
answ = Convert.ToDouble(hLon.Value.Replace(".", ","));
}
catch
{ }
return answ;
}
}
/// <summary>
/// sistemo visibilità buttons
/// </summary>
private void fixVisibility()
{
// verifico se impegno è iniziato o meno e di conseguenza mostro inizio/fine
if (IdxImpegno > 0)
{
DS_Applicazione.ImpegniRow riga = DtProxy.man.taImp.getByKey(IdxImpegno)[0];
bool iniziato = false;
bool finito = false;
try
{
if (riga.InizioInt != null)
{
iniziato = true;
}
}
catch
{ }
try
{
if (riga.FineInt != null)
{
finito = true;
}
}
catch
{ }
lbInizioInt.Visible = !iniziato;
lbFineInt.Visible = iniziato && !finito;
if (divNote.Visible)
{
lbNoteInt.Text = "Chiudi Note Intervento";
}
else
{
lbNoteInt.Text = "Note Intervento";
}
}
}
//protected void btnLoad_Click(object sender, EventArgs e)
//{
// lblCoord.Text = string.Format("Lat: {0}, Lon: {1}", hLat.Value, hLon.Value);
//}
protected void lbInizioInt_Click(object sender, EventArgs e)
{
DtProxy.man.taImp.recStartInt(IdxImpegno, DateTime.Now, latitude, longitude);
fixVisibility();
reportEvent();
}
protected void lbFineInt_Click(object sender, EventArgs e)
{
DtProxy.man.taImp.recFineInt(IdxImpegno, DateTime.Now, latitude, longitude);
fixVisibility();
reportEvent();
}
protected void lbNoteInt_Click(object sender, EventArgs e)
{
divNote.Visible = !divNote.Visible;
fixVisibility();
string note = "";
bool aperto = false;
try
{
DS_Applicazione.ImpegniRow riga = DtProxy.man.taImp.getByKey(IdxImpegno)[0];
note = riga.NoteInt;
aperto = riga.IntAperto;
}
catch
{ }
txtNote.Text = note;
chkIntAperto.Checked = aperto;
reportEvent();
}
/// <summary>
/// Aggiungo nota...
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void lbAddNote_Click(object sender, EventArgs e)
{
DtProxy.man.taImp.updNoteInt(IdxImpegno, txtNote.Text.Trim(), chkIntAperto.Checked);
divNote.Visible = false;
fixVisibility();
reportEvent();
}
}
}