84d98a7795
- start
261 lines
8.7 KiB
C#
261 lines
8.7 KiB
C#
using GPW_data;
|
|
using System;
|
|
|
|
namespace GPW_Admin
|
|
{
|
|
public enum tipoSpostamento
|
|
{
|
|
/// <summary>
|
|
/// nessuno spsotamento consentito
|
|
/// </summary>
|
|
none,
|
|
|
|
/// <summary>
|
|
/// spostamento fase ancestor tra progetti
|
|
/// </summary>
|
|
chgProj,
|
|
|
|
/// <summary>
|
|
/// spostamento sottofase in altra fase ancestor
|
|
/// </summary>
|
|
chgAncest,
|
|
|
|
/// <summary>
|
|
/// sposta i record assegnati ad una fase (micro o macro) ad un altra fase (micro o macro)
|
|
/// </summary>
|
|
moveRA
|
|
}
|
|
|
|
public partial class spostaFasi : BasePage
|
|
{
|
|
#region Private Methods
|
|
|
|
private void fasiFrom_eh_faseSel(object sender, EventArgs e)
|
|
{
|
|
fixBtnFunc();
|
|
}
|
|
|
|
private void fasiFrom_eh_resetSelezione(object sender, EventArgs e)
|
|
{
|
|
fixBtnFunc();
|
|
}
|
|
|
|
private void fasiTo_eh_faseSel(object sender, EventArgs e)
|
|
{
|
|
fixBtnFunc();
|
|
}
|
|
|
|
private void fasiTo_eh_resetSelezione(object sender, EventArgs e)
|
|
{
|
|
fixBtnFunc();
|
|
}
|
|
|
|
private void Mod_pageSize_eh_nuovaSize(object sender, EventArgs e)
|
|
{
|
|
fasiFrom.doUpdate();
|
|
fasiTo.doUpdate();
|
|
}
|
|
|
|
#endregion Private Methods
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// clona la macrofase (e le sottofasi) dal primo progetto al secondo
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnClona_Click(object sender, EventArgs e)
|
|
{
|
|
switch (moveEnabled(fasiFrom.idxFase, fasiTo.idxFase))
|
|
{
|
|
case tipoSpostamento.none:
|
|
// non faccio nulla
|
|
break;
|
|
|
|
case tipoSpostamento.chgProj:
|
|
// sposto fase ANCESTOR selezionata nel progetto di destinazione
|
|
if (fasiTo.idxProgetto > 0 && fasiFrom.idxFase > 0)
|
|
{
|
|
DataProxy.DP.taAF.clonaFaseAnc(fasiTo.idxProgetto, fasiFrom.idxFase);
|
|
}
|
|
break;
|
|
|
|
case tipoSpostamento.chgAncest:
|
|
// sposto sottofase in una differente fase ancestor
|
|
if (fasiTo.idxProgetto > 0 && fasiFrom.idxFase > 0)
|
|
{
|
|
DataProxy.DP.taAF.clonaFase(fasiTo.idxFase, fasiFrom.idxFase);
|
|
}
|
|
break;
|
|
|
|
case tipoSpostamento.moveRA:
|
|
break;
|
|
|
|
default:
|
|
// non faccio nulla
|
|
break;
|
|
}
|
|
fasiFrom.resetSelezione();
|
|
fasiTo.resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// effettua spostamento fasi seconda dei casi...
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void btnSposta_Click(object sender, EventArgs e)
|
|
{
|
|
switch (moveEnabled(fasiFrom.idxFase, fasiTo.idxFase))
|
|
{
|
|
case tipoSpostamento.none:
|
|
// non faccio nulla
|
|
break;
|
|
|
|
case tipoSpostamento.chgProj:
|
|
// sposto fase ANCESTOR selezionata nel progetto di destinazione
|
|
if (fasiTo.idxProgetto > 0 && fasiFrom.idxFase > 0)
|
|
{
|
|
DataProxy.DP.taAF.updateProgetto(fasiTo.idxProgetto, fasiFrom.idxFase);
|
|
}
|
|
break;
|
|
|
|
case tipoSpostamento.chgAncest:
|
|
// sposto sottofase in una differente fase ancestor
|
|
if (fasiTo.idxProgetto > 0 && fasiFrom.idxFase > 0)
|
|
{
|
|
DataProxy.DP.taAF.updateFaseAncest(fasiTo.idxFase, fasiFrom.idxFase);
|
|
}
|
|
break;
|
|
|
|
case tipoSpostamento.moveRA:
|
|
break;
|
|
|
|
default:
|
|
// non faccio nulla
|
|
break;
|
|
}
|
|
fasiFrom.resetSelezione();
|
|
fasiTo.resetSelezione();
|
|
}
|
|
|
|
/// <summary>
|
|
/// sistema abilitazione del button spostamenti
|
|
/// </summary>
|
|
protected void fixBtnFunc()
|
|
{
|
|
/* **************************************************
|
|
* controllo selezione fasi:
|
|
* - se seleziona 1 fase "top" a sx e nessuna a dx ok
|
|
* - se seleziona 1 fase "child" a sx ed 1 fase ""top" a dx ok
|
|
* **************************************************/
|
|
bool enableBtnSposta = false;
|
|
bool enableBtnClona = false;
|
|
string testoBtn = traduci("noAction");
|
|
string testoBtnClona = traduci("noAction");
|
|
string cssBtn = "btn btn-lg btn-secondary w-100";
|
|
string cssBtnClona = "btn btn-lg btn-secondary w-100";
|
|
switch (moveEnabled(fasiFrom.idxFase, fasiTo.idxFase))
|
|
{
|
|
case tipoSpostamento.chgProj:
|
|
enableBtnSposta = true;
|
|
enableBtnClona = true;
|
|
testoBtn = traduci("chgProj");
|
|
testoBtnClona = traduci("clonaFase");
|
|
cssBtn = "btn btn-lg btn-primary w-100";
|
|
cssBtnClona = "btn btn-lg btn-success w-100";
|
|
break;
|
|
|
|
case tipoSpostamento.chgAncest:
|
|
enableBtnSposta = true;
|
|
enableBtnClona = true;
|
|
testoBtn = traduci("chgAncest");
|
|
testoBtnClona = traduci("clonaSottoFase");
|
|
cssBtn = "btn btn-lg btn-secondary w-100";
|
|
cssBtnClona = "btn btn-lg btn-success w-100";
|
|
break;
|
|
|
|
case tipoSpostamento.moveRA:
|
|
//enableBtnSposta = true;
|
|
//testoBtn = traduci("moveRA");
|
|
//cssBtn = "btnBlu ui-corner-all shadowBox btnEditBig";
|
|
break;
|
|
|
|
default:
|
|
break;
|
|
}
|
|
// fix sposta
|
|
btnSposta.Enabled = enableBtnSposta;
|
|
btnSposta.Text = testoBtn;
|
|
btnSposta.CssClass = cssBtn;
|
|
// fix clona
|
|
btnClona.Enabled = enableBtnClona;
|
|
btnClona.Text = testoBtnClona;
|
|
btnClona.CssClass = cssBtnClona;
|
|
}
|
|
|
|
/// <summary>
|
|
/// fornisce il tipo di spostamento concesso secondo valori selezionati
|
|
/// </summary>
|
|
/// <param name="idxFaseFrom"></param>
|
|
/// <param name="idxFaseTo"></param>
|
|
/// <returns></returns>
|
|
protected tipoSpostamento moveEnabled(int idxFaseFrom, int idxFaseTo)
|
|
{
|
|
tipoSpostamento answ = tipoSpostamento.none;
|
|
bool faseSxTop = false;
|
|
bool faseDxTop = false;
|
|
// se non ho nulla selezioanto a sx non faccio nulla...
|
|
if (idxFaseFrom > 0)
|
|
{
|
|
// carico info su tipo fase sx/dx...
|
|
try
|
|
{
|
|
faseSxTop = (DataProxy.DP.taAF.getByIdx(idxFaseFrom)[0].idxFaseAncest == 0);
|
|
}
|
|
catch
|
|
{ }
|
|
if (fasiTo.idxFase > 0)
|
|
{
|
|
try
|
|
{
|
|
faseDxTop = (DataProxy.DP.taAF.getByIdx(idxFaseTo)[0].idxFaseAncest == 0);
|
|
}
|
|
catch
|
|
{ }
|
|
}
|
|
if (faseSxTop && fasiTo.idxFase == 0)
|
|
{
|
|
answ = tipoSpostamento.chgProj;
|
|
}
|
|
else if (!faseSxTop && faseDxTop)
|
|
{
|
|
answ = tipoSpostamento.chgAncest;
|
|
}
|
|
else if (fasiTo.idxFase > 0)
|
|
{
|
|
answ = tipoSpostamento.moveRA;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
|
|
/// <summary>
|
|
/// caricamento pagina
|
|
/// </summary>
|
|
/// <param name="sender"></param>
|
|
/// <param name="e"></param>
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
fasiFrom.eh_faseSel += new EventHandler(fasiFrom_eh_faseSel);
|
|
fasiFrom.eh_doReset += new EventHandler(fasiFrom_eh_resetSelezione);
|
|
fasiTo.eh_faseSel += new EventHandler(fasiTo_eh_faseSel);
|
|
fasiTo.eh_doReset += new EventHandler(fasiTo_eh_resetSelezione);
|
|
fixBtnFunc();
|
|
mod_pageSize.eh_nuovaSize += Mod_pageSize_eh_nuovaSize;
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
}
|
|
} |