232 lines
6.2 KiB
C#
232 lines
6.2 KiB
C#
using GPW_data;
|
|
using SteamWare;
|
|
using System;
|
|
using System.Web.UI;
|
|
using System.Web.UI.WebControls;
|
|
|
|
namespace GPW.WebUserControls
|
|
{
|
|
public partial class mod_attivitaIns : System.Web.UI.UserControl
|
|
{
|
|
/// <summary>
|
|
/// pagina di return a fine editing
|
|
/// </summary>
|
|
protected string returnPage
|
|
{
|
|
get
|
|
{
|
|
string answ = memLayer.ML.confReadString("baseUrl");
|
|
try
|
|
{
|
|
answ = memLayer.ML.StringSessionObj("returnPage");
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("returnPage", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// RA selezionata
|
|
/// </summary>
|
|
protected int idxRASel
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("idxRASel");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("idxRASel", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// data selezionata
|
|
/// </summary>
|
|
protected DateTime dataRif
|
|
{
|
|
get
|
|
{
|
|
DateTime answ = DateTime.Now;
|
|
try
|
|
{
|
|
answ = Convert.ToDateTime(memLayer.ML.objSessionObj("dataRif"));
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("dataRif", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// progetto selezionato
|
|
/// </summary>
|
|
protected int idxProjSel
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("idxProjSel");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("idxProjSel", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// fase selezionata
|
|
/// </summary>
|
|
protected int idxFaseSel
|
|
{
|
|
get
|
|
{
|
|
return memLayer.ML.IntSessionObj("idxFaseSel");
|
|
}
|
|
set
|
|
{
|
|
memLayer.ML.setSessionVal("idxFaseSel", value);
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// al primo load ricarico i dati correnti (se ci sono)
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
DropDownList ddlFase_int;
|
|
if (!Page.IsPostBack)
|
|
{
|
|
// verifico se ci sia una richiesta di editing...
|
|
if (idxRASel > 0)
|
|
{
|
|
frViewRA.ChangeMode(FormViewMode.Edit);
|
|
// pre-seleziono idx progetto x ods fase...
|
|
idxFaseSel = DataProxy.DP.taRA.getByKey(idxRASel)[0].idxFase;
|
|
idxProjSel = idxPrjByFase(idxFaseSel);
|
|
// imposto valori selezionati
|
|
DropDownList ddlProj_int = (DropDownList)frViewRA.FindControl("ddlProgetto");
|
|
ddlProj_int.SelectedValue = idxProjSel.ToString();
|
|
ddlFase_int = (DropDownList)frViewRA.FindControl("ddlFase");
|
|
ddlFase_int.SelectedValue = idxFaseSel.ToString();
|
|
}
|
|
else // è insert nuova!!!
|
|
{
|
|
frViewRA.ChangeMode(FormViewMode.Insert);
|
|
mod_dateTime dtInizio = (mod_dateTime)frViewRA.FindControl("dtInizio");
|
|
mod_dateTime dtFine = (mod_dateTime)frViewRA.FindControl("dtFine");
|
|
dtInizio.valoreDateTime = dataRif.AddHours(DateTime.Now.Hour).AddMinutes(DateTime.Now.Minute);
|
|
dtFine.valoreDateTime = dtInizio.valoreDateTime.AddMinutes(memLayer.ML.confReadInt("defRegAttMin"));
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// calcola idxProgetto da idxFase
|
|
/// </summary>
|
|
/// <param name="idxFase"></param>
|
|
/// <returns></returns>
|
|
public int idxPrjByFase(object idxFase)
|
|
{
|
|
int answ = 0;
|
|
try
|
|
{
|
|
answ = DataProxy.DP.taAF.getByIdx(Convert.ToInt32(idxFase))[0].idxProgetto;
|
|
}
|
|
catch
|
|
{ }
|
|
return answ;
|
|
}
|
|
/// <summary>
|
|
/// aggiorno ods fasi...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlProgetto_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
// salvo in session idxProjSel!
|
|
DropDownList ddlProj_int = (DropDownList)sender;
|
|
idxProjSel = Convert.ToInt32(ddlProj_int.SelectedValue);
|
|
// ricarico dati fasi
|
|
odsFase.DataBind();
|
|
}
|
|
/// <summary>
|
|
/// evento richiesta update
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void odsRA_Updating(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
// recupero valore fase selezionato...
|
|
DropDownList ddlFase_int = (DropDownList)frViewRA.FindControl("ddlFase");
|
|
e.InputParameters["idxFase"] = ddlFase_int.SelectedValue;
|
|
e.InputParameters["idxDipendente"] = DataProxy.idxDipendente;
|
|
}
|
|
|
|
protected void frViewRA_ItemCommand(object sender, FormViewCommandEventArgs e)
|
|
{
|
|
// se è cancel ritorno ad altra pagina!
|
|
if (e.CommandName == "Cancel")
|
|
{
|
|
Response.Redirect(returnPage);
|
|
}
|
|
}
|
|
|
|
protected void odsRA_Inserting(object sender, ObjectDataSourceMethodEventArgs e)
|
|
{
|
|
// recupero valori non direttamente linkati...
|
|
DropDownList ddlFase_int = (DropDownList)frViewRA.FindControl("ddlFase");
|
|
e.InputParameters["idxFase"] = ddlFase_int.SelectedValue;
|
|
e.InputParameters["idxDipendente"] = DataProxy.idxDipendente;
|
|
}
|
|
|
|
protected void odsRA_Inserted(object sender, ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
Response.Redirect(returnPage);
|
|
}
|
|
|
|
protected void odsRA_Updated(object sender, ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
Response.Redirect(returnPage);
|
|
}
|
|
|
|
protected void odsRA_Deleted(object sender, ObjectDataSourceStatusEventArgs e)
|
|
{
|
|
Response.Redirect(returnPage);
|
|
}
|
|
/// <summary>
|
|
/// sistemo eventuali "headers"
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void ddlFase_DataBound(object sender, EventArgs e)
|
|
{
|
|
// cerco eventuali controlli tipo "ancestor" e li disattivo!
|
|
DropDownList ddlFase_int = (DropDownList)sender;
|
|
ListItem li = new ListItem();
|
|
while (li != null)
|
|
{
|
|
li = ddlFase_int.Items.FindByValue("0");
|
|
try
|
|
{
|
|
li.Attributes.Add("style", "color:gray;");
|
|
li.Attributes.Add("disabled", "true");
|
|
li.Value = "-1";
|
|
li.Text = string.Format("[ {0} ]", li.Text);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
try
|
|
{
|
|
ddlFase_int.SelectedIndex = 1;
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
}
|
|
} |