diff --git a/PROJ-ETS/PROJ-ETS/WebUserControls/mod_weekPlan.ascx.cs b/PROJ-ETS/PROJ-ETS/WebUserControls/mod_weekPlan.ascx.cs
index 5addb1f..88d9e6c 100644
--- a/PROJ-ETS/PROJ-ETS/WebUserControls/mod_weekPlan.ascx.cs
+++ b/PROJ-ETS/PROJ-ETS/WebUserControls/mod_weekPlan.ascx.cs
@@ -9,898 +9,898 @@ using NLog;
namespace PROJ_ETS.WebUserControls
{
- public partial class mod_weekPlan : System.Web.UI.UserControl
+ public partial class mod_weekPlan : System.Web.UI.UserControl
+ {
+ ///
+ /// evento nuovi valori caricati
+ ///
+ public event EventHandler eh_newVal;
+ protected Logger lg = LogManager.GetCurrentClassLogger();
+ protected int numDip = 0;
+ protected int numComm = 0;
+ protected int IdxDipSel
{
- ///
- /// evento nuovi valori caricati
- ///
- public event EventHandler eh_newVal;
- protected Logger lg = LogManager.GetCurrentClassLogger();
- protected int numDip = 0;
- protected int numComm = 0;
- protected int IdxDipSel
+ get
+ {
+ int answ = 0;
+ try
{
- get
- {
- int answ = 0;
- try
- {
- answ = utils.obj.IntSessionObj("IdxDipSel");
- }
- catch
- { }
- return answ;
- }
- set
- {
- utils.obj.setSessionVal("IdxDipSel", value);
- }
+ answ = utils.obj.IntSessionObj("IdxDipSel");
}
- protected int IdxFaseSel
+ catch
+ { }
+ return answ;
+ }
+ set
+ {
+ utils.obj.setSessionVal("IdxDipSel", value);
+ }
+ }
+ protected int IdxFaseSel
+ {
+ get
+ {
+ int answ = 0;
+ try
{
- get
- {
- int answ = 0;
- try
- {
- answ = utils.obj.IntSessionObj("IdxFaseSel");
- }
- catch
- { }
- return answ;
- }
- set
- {
- utils.obj.setSessionVal("IdxFaseSel", value);
- }
+ answ = utils.obj.IntSessionObj("IdxFaseSel");
}
- protected ETS_Data.Type.BazaarRes[,] TabellaRisorse;
- protected int[] oreTotDip;
- protected int[] oreTotComm;
- protected int oreTot;
- protected string[] schemaOreDip;
- protected Ds_ProjEts.DipendentiDataTable tabDip = new Ds_ProjEts.DipendentiDataTable();
- protected Ds_ProjEts.Dip2ATRDataTable tabD2ATR = new Ds_ProjEts.Dip2ATRDataTable();
- protected Ds_ProjEts.BazaarRisorseDataTable tabBaz = new Ds_ProjEts.BazaarRisorseDataTable();
- protected Ds_ProjEts.BazaarRisorseDataTable tabBazSingle = new Ds_ProjEts.BazaarRisorseDataTable();
- protected DS_utilsProjEts.v_selCommesseDataTable tabComm = new DS_utilsProjEts.v_selCommesseDataTable();
- protected DS_utilsProjEts.v_selCommesseDataTable tabCommShort = new DS_utilsProjEts.v_selCommesseDataTable();
- protected Ds_ProjEts.BazaarRisorseRow rigaBaz;
- protected Ds_ProjEts.DipendentiRow rigaDip;
- protected DS_utilsProjEts.v_selCommesseRow rigaComm;
- protected DS_utilsProjEts.v_selCommesseRow rigaCommShort;
- ///
- /// istante corrente
- ///
- protected DateTime adesso
+ catch
+ { }
+ return answ;
+ }
+ set
+ {
+ utils.obj.setSessionVal("IdxFaseSel", value);
+ }
+ }
+ protected ETS_Data.Type.BazaarRes[,] TabellaRisorse;
+ protected int[] oreTotDip;
+ protected int[] oreTotComm;
+ protected int oreTot;
+ protected string[] schemaOreDip;
+ protected Ds_ProjEts.DipendentiDataTable tabDip = new Ds_ProjEts.DipendentiDataTable();
+ protected Ds_ProjEts.Dip2ATRDataTable tabD2ATR = new Ds_ProjEts.Dip2ATRDataTable();
+ protected Ds_ProjEts.BazaarRisorseDataTable tabBaz = new Ds_ProjEts.BazaarRisorseDataTable();
+ protected Ds_ProjEts.BazaarRisorseDataTable tabBazSingle = new Ds_ProjEts.BazaarRisorseDataTable();
+ protected DS_utilsProjEts.v_selCommesseDataTable tabComm = new DS_utilsProjEts.v_selCommesseDataTable();
+ protected DS_utilsProjEts.v_selCommesseDataTable tabCommShort = new DS_utilsProjEts.v_selCommesseDataTable();
+ protected Ds_ProjEts.BazaarRisorseRow rigaBaz;
+ protected Ds_ProjEts.DipendentiRow rigaDip;
+ protected DS_utilsProjEts.v_selCommesseRow rigaComm;
+ protected DS_utilsProjEts.v_selCommesseRow rigaCommShort;
+ ///
+ /// istante corrente
+ ///
+ protected DateTime adesso
+ {
+ set
+ {
+ utils.obj.setSessionVal("timeBazaar", value);
+ }
+ get
+ {
+ DateTime answ = DateTime.Now;
+ try
{
- set
- {
- utils.obj.setSessionVal("timeBazaar", value);
- }
- get
- {
- DateTime answ = DateTime.Now;
- try
- {
- answ = (DateTime)utils.obj.objSessionObj("timeBazaar");
- }
- catch
- { }
- return answ;
- }
+ answ = (DateTime)utils.obj.objSessionObj("timeBazaar");
}
- ///
- /// caricamento pagina
- ///
- ///
- ///
- protected void Page_Load(object sender, EventArgs e)
- {
- if (!Page.IsPostBack)
- {
- showPnlAddNewComm(false);
- lblOut.Text = "";
- }
- // carico tabelle: elenco dipendenti (raggruppato x tipo) ed elenco dip in bazaar...
- tabDip = DataProxy_ProjEts.DP.taDip.GetData();
- tabD2ATR = DataProxy_ProjEts.DP.taD2ATR.getBazOrd();
- // faccio update!
- doUpdate();
- mod_navigaWeek1.eh_newWeekSelected += mod_navigaWeek1_eh_newWeekSelected;
- }
- ///
- /// selezioanta nuova sett --> faccio udpate!!!
- ///
- ///
- ///
- void mod_navigaWeek1_eh_newWeekSelected(object sender, EventArgs e)
- {
- doUpdate();
- }
- ///
- /// esegue update controllo
- ///
- public void doUpdate()
- {
- setBtnStatus();
- caricaDatiBlocco();
- disegnaTabella();
- }
- ///
- /// sistema i vari buttons come visibilità ed abilitazione a seconda dello stato della settimana, del cudEnabled, dei diritti utente...
- ///
- private void setBtnStatus()
- {
- // aggiunta commesse e clona seguono stessa regola di visibilità e abilitazione...
- btnAddNew.Enabled = cudEnabled;
- btnCloneWeek.Enabled = cudEnabled;
- btnAddNew.Visible = isWritable() && (utils.obj.isPowerUser || utils.obj.isPM);
- btnCloneWeek.Visible = isWritable() && utils.obj.isPowerUser;
- fixBtnAddNewComm();
- if (!cudEnabled)
- {
- btnAddNew.CssClass = "btnDisabled";
- btnAddNew.ToolTip = "Modifica non consentita";
- btnCloneWeek.CssClass = "btnDisabled";
- btnCloneWeek.ToolTip = "Modifica non consentita";
- }
- else
- {
- btnAddNew.CssClass = "btnNew";
- btnAddNew.ToolTip = "Mostra pannello Aggiungi Commesse";
- btnCloneWeek.CssClass = "btnNew";
- btnCloneWeek.ToolTip = "Copia le Commesse dalla settimana precedente";
- }
- // rilascio / congelamento ore in GPW ha sua regola (NON lo mostra direttamente se "scaduto")
- btnReleaseWeek.Visible = isWritable() && utils.obj.isPowerUser && cudEnabled;
- // a seconda che sia stata rilasciata o meno la settimana mostro sblocco o rilascio settimana...
- if (isReleased)
- {
- btnReleaseWeek.Text = "Sblocca WeekPlan rilasciato";
- btnReleaseWeek.CssClass = "btnPinnedDis";
- btnReleaseWeek.ToolTip = "Elimina schema orario rilasciato in GPW e sblocca settimana";
- }
- else
- {
- btnReleaseWeek.Text = "Rilascia WeekPlan";
- btnReleaseWeek.CssClass = "btnPinned";
- btnReleaseWeek.ToolTip = "Rilascia il piano settimanale copiando in GPW lo schema delle ore a progetto indicate per la settimana";
- }
+ catch
+ { }
+ return answ;
+ }
+ }
+ ///
+ /// caricamento pagina
+ ///
+ ///
+ ///
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!Page.IsPostBack)
+ {
+ showPnlAddNewComm(false);
+ lblOut.Text = "";
+ }
+ // carico tabelle: elenco dipendenti (raggruppato x tipo) ed elenco dip in bazaar...
+ tabDip = DataProxy_ProjEts.DP.taDip.GetData();
+ tabD2ATR = DataProxy_ProjEts.DP.taD2ATR.getBazOrd();
+ // faccio update!
+ doUpdate();
+ mod_navigaWeek1.eh_newWeekSelected += mod_navigaWeek1_eh_newWeekSelected;
+ }
+ ///
+ /// selezioanta nuova sett --> faccio udpate!!!
+ ///
+ ///
+ ///
+ void mod_navigaWeek1_eh_newWeekSelected(object sender, EventArgs e)
+ {
+ doUpdate();
+ }
+ ///
+ /// esegue update controllo
+ ///
+ public void doUpdate()
+ {
+ setBtnStatus();
+ caricaDatiBlocco();
+ disegnaTabella();
+ }
+ ///
+ /// sistema i vari buttons come visibilità ed abilitazione a seconda dello stato della settimana, del cudEnabled, dei diritti utente...
+ ///
+ private void setBtnStatus()
+ {
+ // aggiunta commesse e clona seguono stessa regola di visibilità e abilitazione...
+ btnAddNew.Enabled = cudEnabled;
+ btnCloneWeek.Enabled = cudEnabled;
+ btnAddNew.Visible = isWritable() && (utils.obj.isPowerUser || utils.obj.isPM);
+ btnCloneWeek.Visible = isWritable() && utils.obj.isPowerUser;
+ fixBtnAddNewComm();
+ if (!cudEnabled)
+ {
+ btnAddNew.CssClass = "btnDisabled";
+ btnAddNew.ToolTip = "Modifica non consentita";
+ btnCloneWeek.CssClass = "btnDisabled";
+ btnCloneWeek.ToolTip = "Modifica non consentita";
+ }
+ else
+ {
+ btnAddNew.CssClass = "btnNew";
+ btnAddNew.ToolTip = "Mostra pannello Aggiungi Commesse";
+ btnCloneWeek.CssClass = "btnNew";
+ btnCloneWeek.ToolTip = "Copia le Commesse dalla settimana precedente";
+ }
+ // rilascio / congelamento ore in GPW ha sua regola (NON lo mostra direttamente se "scaduto")
+ btnReleaseWeek.Visible = isWritable() && utils.obj.isPowerUser && cudEnabled;
+ // a seconda che sia stata rilasciata o meno la settimana mostro sblocco o rilascio settimana...
+ if (isReleased)
+ {
+ btnReleaseWeek.Text = "Sblocca WeekPlan rilasciato";
+ btnReleaseWeek.CssClass = "btnPinnedDis";
+ btnReleaseWeek.ToolTip = "Elimina schema orario rilasciato in GPW e sblocca settimana";
+ }
+ else
+ {
+ btnReleaseWeek.Text = "Rilascia WeekPlan";
+ btnReleaseWeek.CssClass = "btnPinned";
+ btnReleaseWeek.ToolTip = "Rilascia il piano settimanale copiando in GPW lo schema delle ore a progetto indicate per la settimana";
+ }
- }
- ///
- /// anno selezionato (wrapper)
- ///
- protected int anno
+ }
+ ///
+ /// anno selezionato (wrapper)
+ ///
+ protected int anno
+ {
+ get
+ {
+ return mod_navigaWeek1.anno;
+ }
+ }
+ ///
+ /// settimana selezionato (wrapper)
+ ///
+ protected int settimana
+ {
+ get
+ {
+ return mod_navigaWeek1.settimana;
+ }
+ }
+ ///
+ /// definisce se create/update/delete siano abilitati
+ ///
+ protected bool cudEnabled
+ {
+ get
+ {
+ // controllo le condizioni: in primis se in web config è abilitato edit passato è ok...
+ bool answ = utils.obj.confReadBool("bazCudPastEnabled");
+ // se non globalmente permesso controllo se sia anno/sett successiva a quella corrente
+ if (!answ)
{
- get
- {
- return mod_navigaWeek1.anno;
- }
- }
- ///
- /// settimana selezionato (wrapper)
- ///
- protected int settimana
- {
- get
- {
- return mod_navigaWeek1.settimana;
- }
- }
- ///
- /// definisce se create/update/delete siano abilitati
- ///
- protected bool cudEnabled
- {
- get
- {
- // controllo le condizioni: in primis se in web config è abilitato edit passato è ok...
- bool answ = utils.obj.confReadBool("bazCudPastEnabled");
- // se non globalmente permesso controllo se sia anno/sett successiva a quella corrente
- if (!answ)
- {
- DateTime ora = DateTime.Now;
- if ((anno > ora.Year) || ((anno == ora.Year) && (settimana > datario.WeekOfYearISO8601(ora))))
- {
- answ = true;
- }
- }
- return answ;
- }
+ DateTime ora = DateTime.Now;
+ if ((anno > ora.Year) || ((anno == ora.Year) && (settimana > datario.WeekOfYearISO8601(ora))))
+ {
+ answ = true;
+ }
}
+ return answ;
+ }
+ }
- ///
- /// carica i dati del blocco in un oggetto BlockMap (compreso attive/inattive)
- ///
- private void caricaDatiBlocco()
+ ///
+ /// carica i dati del blocco in un oggetto BlockMap (compreso attive/inattive)
+ ///
+ private void caricaDatiBlocco()
+ {
+ unlockRes();
+ int totCelle = 0;
+ int idxDip = 0;
+ // recupero il numero di TUTTE le celle
+ string css = "";
+ string tooltip = "";
+ try
+ {
+ // carico TUTTE le celle del bazaar...
+ tabBaz = DataProxy_ProjEts.DP.taBaz.getByAnnoSett(anno, settimana);
+ tabComm = DataProxy_ProjEts.DP.taSelCom.GetData(); // leggo tutte commesse...
+ tabCommShort = DataProxy_ProjEts.DP.taSelCom.getCommShort(); // leggo tutte commesse formato short (nickname...)
+ // calcolo il primo dip
+ idxDip = tabBaz[0].idxDipendente;
+ // calcolo num celle totali
+ totCelle = tabBaz.Rows.Count;
+ tabBazSingle = DataProxy_ProjEts.DP.taBaz.getByAnnoSettDip(anno, settimana, idxDip);
+ // calcolo numero commesse!
+ numComm = tabBazSingle.Rows.Count;
+ numDip = tabD2ATR.Rows.Count;
+ //numDip = totCelle / numComm;
+ }
+ catch
+ {
+ numDip = 0;
+ numComm = 0;
+ }
+ if (numDip > 0 && numComm > 0)
+ {
+ // inizializzo i miei array...
+ TabellaRisorse = new ETS_Data.Type.BazaarRes[numDip, numComm];
+ oreTotDip = new int[numDip];
+ oreTotComm = new int[numComm];
+ schemaOreDip = new string[numDip];
+ oreTot = 0;
+ for (int ii = 0; ii < numDip; ii++)
{
- unlockRes();
- int totCelle = 0;
- int idxDip = 0;
- // recupero il numero di TUTTE le celle
- string css = "";
- string tooltip = "";
- try
- {
- // carico TUTTE le celle del bazaar...
- tabBaz = DataProxy_ProjEts.DP.taBaz.getByAnnoSett(anno, settimana);
- tabComm = DataProxy_ProjEts.DP.taSelCom.GetData(); // leggo tutte commesse...
- tabCommShort = DataProxy_ProjEts.DP.taSelCom.getCommShort(); // leggo tutte commesse formato short (nickname...)
- // calcolo il primo dip
- idxDip = tabBaz[0].idxDipendente;
- // calcolo num celle totali
- totCelle = tabBaz.Rows.Count;
- tabBazSingle = DataProxy_ProjEts.DP.taBaz.getByAnnoSettDip(anno, settimana, idxDip);
- // calcolo numero commesse!
- numComm = tabBazSingle.Rows.Count;
- numDip = tabD2ATR.Rows.Count;
- //numDip = totCelle / numComm;
- }
- catch
- {
- numDip = 0;
- numComm = 0;
- }
- if (numDip > 0 && numComm > 0)
- {
- // inizializzo i miei array...
- TabellaRisorse = new ETS_Data.Type.BazaarRes[numDip, numComm];
- oreTotDip = new int[numDip];
- oreTotComm = new int[numComm];
- schemaOreDip = new string[numDip];
- oreTot = 0;
- for (int ii = 0; ii < numDip; ii++)
- {
- schemaOreDip[ii] = "00000";
- }
- // carico i dati nell'array: di default tutto VUOTO, con posizione attiva...
- for (int pos_y = 0; pos_y < numComm; pos_y++)
- {
- for (int pos_x = 0; pos_x < numDip; pos_x++)
- {
- // carico valori x la singola cella
- rigaBaz = (Ds_ProjEts.BazaarRisorseRow)tabBaz.Select(string.Format("idxDipendente={0} AND idxFase={1}", tabD2ATR[pos_x].idxDipendente, tabBazSingle[pos_y].idxFase))[0];
- rigaDip = (Ds_ProjEts.DipendentiRow)tabDip.Select(string.Format("idxDipendente={0}", tabD2ATR[pos_x].idxDipendente))[0];
- rigaComm = (DS_utilsProjEts.v_selCommesseRow)tabComm.Select(string.Format("value = {0}", tabBazSingle[pos_y].idxFase))[0];
- rigaCommShort = (DS_utilsProjEts.v_selCommesseRow)tabCommShort.Select(string.Format("value = {0}", tabBazSingle[pos_y].idxFase))[0];
- if (rigaBaz.OreTot == 0)
- {
- css = "cTab cEmp";
- }
- else if (rigaBaz.OreTot < utils.obj.confReadInt("soglia1"))
- {
- css = "cTab cS01";
- }
- else if (rigaBaz.OreTot < utils.obj.confReadInt("soglia2"))
- {
- css = "cTab cS02";
- }
- else if (rigaBaz.OreTot < utils.obj.confReadInt("soglia3"))
- {
- css = "cTab cS03";
- }
- else if (rigaBaz.OreTot < utils.obj.confReadInt("soglia4"))
- {
- css = "cTab cS04";
- }
- else
- {
- css = "cTab cOvr";
- }
- tooltip = string.Format("{2} / {0} {1}", rigaDip.Nome, rigaDip.Cognome, rigaCommShort.label.Substring(0, 9));
- TabellaRisorse[pos_x, pos_y] = new ETS_Data.Type.BazaarRes(rigaBaz.SchemaWeek, tooltip, css, rigaBaz.idxDipendente, string.Format("{0} {1}", rigaDip.Nome, rigaDip.Cognome), rigaDip.SIGLA, rigaBaz.idxFase, rigaBaz.SchemaWeek, rigaBaz.OreTot);
- // aggiorno totali righe/colonne (comemsse/dip)
- oreTotDip[pos_x] += rigaBaz.OreTot;
- schemaOreDip[pos_x] = oreWeek.addOre(schemaOreDip[pos_x].ToString(), rigaBaz.SchemaWeek, 8);
- oreTotComm[pos_y] += rigaBaz.OreTot;
- oreTot += rigaBaz.OreTot;
- }
- }
- }
+ schemaOreDip[ii] = "00000";
}
- ///
- /// sblocca le risorse scadute (= lock da oltre tempo max)
- ///
- private void unlockRes()
+ // carico i dati nell'array: di default tutto VUOTO, con posizione attiva...
+ for (int pos_y = 0; pos_y < numComm; pos_y++)
{
- int minBlockEditRes = utils.obj.confReadInt("minBlockEditRes");
- if (minBlockEditRes > 0)
- {
- DataProxy_ProjEts.DP.taTLB.unlockExpired(minBlockEditRes);
- }
- }
-
- ///
- /// disegna la riga di intestazione/chiusura x dipendenti
- ///
- /// true = mostra totale ore / false = mostra sigla dip + nome/cognome tooltip
- private void setupRigaDip(bool showOre)
- {
- TableRow riga = new TableRow();
- TableCell cell;
- // cella vuota iniziale
- cell = new TableCell();
- riga.Cells.Add(cell);
- // variabili accessorie x dip
- Ds_ProjEts.DipendentiRow rigaDip;
- // preparo celle!
- for (int pos_x = 0; pos_x < numDip; pos_x++)
- {
- cell = new TableCell();
- cell.CssClass = "cBia cCent";
- // se è ultima riga...
- if (showOre && numDip > 0 && numComm > 0)
- {
- cell.Text = string.Format("{0:0#} h{1}", oreTotDip[pos_x], schemaOreDip[pos_x]);
- if (userIsLocked(tabD2ATR[pos_x].idxDipendente))
- {
- cell.ToolTip = string.Format("LOCK: {0} in modifica", lockedBy(tabD2ATR[pos_x].idxDipendente));
- }
- else
- {
- //cell.ToolTip = "";
- cell.ToolTip = schemaOreDip[pos_x];
- }
- // SE sono 40h coloro di verde!!!
- if (oreTotDip[pos_x] == 40)
- {
- cell.CssClass = "cBia cCent lblGreen";
- }
- // SE sono oltre 40h coloro di rosso!!!
- else if ((oreTotDip[pos_x] > 40) || (schemaOreDip[pos_x].IndexOf("X") > 0))
- {
- cell.CssClass = "cBia cCent lblErrore";
- }
- }
- else
- {
- rigaDip = (Ds_ProjEts.DipendentiRow)tabDip.Select(string.Format("idxDipendente={0}", tabD2ATR[pos_x].idxDipendente))[0];
- cell.Text = rigaDip.codHw;
- //cell.Text = rigaDip.SIGLA;
- //cell.Text = rigaDip.Nome.Substring(0, 1) + rigaDip.Cognome.Substring(0, 1) + rigaDip.Cognome.Substring(1, 2).ToLower();
- cell.ToolTip = string.Format("{0} {1}", rigaDip.Nome, rigaDip.Cognome);
- }
- riga.Cells.Add(cell);
- }
- // cella vuota finale
- if (showOre && numDip > 0 && numComm > 0)
- {
- cell = new TableCell();
- cell.CssClass = "cBia lblBlu";
- cell.Text = string.Format("{0:0##} h", oreTot);
- cell.ToolTip = "Ore TOTALI";
- riga.Cells.Add(cell);
- }
- else
- {
- cell = new TableCell();
- riga.Cells.Add(cell);
- }
- // aggiungo riga!
- tblBlocco.Rows.Add(riga);
- }
- ///
- /// controlla abilitazione edit x celle e cancellazione, ovvero
- /// - cudEnabled (controllo periodo scaduto e permette sett future)
- /// - isWritable (utente con permessi RW = S)
- /// - utente PowerUser/ProjectManager oppure settimana non rilasciata (x utente CapoComm)
- ///
- protected bool editEnabled
- {
- get
- {
- return cudEnabled && isWritable() && (utils.obj.isPowerUser || utils.obj.isPM || !isReleased);
- }
- }
- ///
- /// crea una cella per il numero dei livelli
- ///
- ///
- ///
- /// indica se mostrare le ore totali di resoconto al posto del nome commessa
- ///
- private TableCell setupCellaComm(int pos_y, TableRow riga, bool showOre)
- {
- // variabili accessorie x dip
- DS_utilsProjEts.v_selCommesseRow rigaComm;
- //cella!
- TableCell cell;
- cell = new TableCell();
- cell.CssClass = "cRBia";
+ for (int pos_x = 0; pos_x < numDip; pos_x++)
+ {
+ // carico valori x la singola cella
+ rigaBaz = (Ds_ProjEts.BazaarRisorseRow)tabBaz.Select(string.Format("idxDipendente={0} AND idxFase={1}", tabD2ATR[pos_x].idxDipendente, tabBazSingle[pos_y].idxFase))[0];
+ rigaDip = (Ds_ProjEts.DipendentiRow)tabDip.Select(string.Format("idxDipendente={0}", tabD2ATR[pos_x].idxDipendente))[0];
rigaComm = (DS_utilsProjEts.v_selCommesseRow)tabComm.Select(string.Format("value = {0}", tabBazSingle[pos_y].idxFase))[0];
rigaCommShort = (DS_utilsProjEts.v_selCommesseRow)tabCommShort.Select(string.Format("value = {0}", tabBazSingle[pos_y].idxFase))[0];
- if (showOre)
+ if (rigaBaz.OreTot == 0)
{
- // controllo edit è abilitato
- if (editEnabled && (utils.obj.isPowerUser || utils.obj.isPM || utils.obj.isCurrentCC(tabBazSingle[pos_y].idxFase)))
- {
- // aggiungo button x fare elemento cliccabile
- LinkButton lnkbDel = new LinkButton();
- lnkbDel.Click += new EventHandler(lnkbDel_Click);
- lnkbDel.CommandArgument = rigaComm.value.ToString();
- lnkbDel.Text = string.Format("{0:0##} h [elimina]", oreTotComm[pos_y]);
- lnkbDel.ToolTip = string.Format("Click per eliminare commessa {0}", rigaComm.label.Substring(0, 9));
- lnkbDel.OnClientClick = "return confirm('Confermi eliminazione record?')";
- lnkbDel.Enabled = cudEnabled;
- cell.Controls.Add(lnkbDel);
- }
- else
- {
- cell.Text = string.Format("{0:0##} h", oreTotComm[pos_y]);
- cell.ToolTip = string.Format("Commessa {0} (non modificabile)", rigaComm.label.Substring(0, 9));
- }
+ css = "cTab cEmp";
+ }
+ else if (rigaBaz.OreTot < utils.obj.confReadInt("soglia1"))
+ {
+ css = "cTab cS01";
+ }
+ else if (rigaBaz.OreTot < utils.obj.confReadInt("soglia2"))
+ {
+ css = "cTab cS02";
+ }
+ else if (rigaBaz.OreTot < utils.obj.confReadInt("soglia3"))
+ {
+ css = "cTab cS03";
+ }
+ else if (rigaBaz.OreTot < utils.obj.confReadInt("soglia4"))
+ {
+ css = "cTab cS04";
}
else
{
- // inserisco URL x rimando a dettaglio commessa via jumper...
- if (utils.obj.confReadBool("showLinkDettComm"))
- {
- // aggiungo link x fare elemento cliccabile
- HyperLink hlJump = new HyperLink();
- hlJump.NavigateUrl = string.Format("~/jumper?tipoJump=DettComm&idxFase={0}", rigaComm.value);
- hlJump.Target = "_blank";
- hlJump.Text = rigaCommShort.label;
- hlJump.ToolTip = rigaComm.label;
- cell.Controls.Add(hlJump);
- }
- else
- {
- cell.Text = rigaCommShort.label;
- //cell.Text = utils.shrinkString(rigaComm.label, utils.obj.confReadInt("char2showComm"), 8);
- cell.ToolTip = rigaComm.label;
- }
- }
- riga.Cells.Add(cell);
- return cell;
- }
- ///
- /// intercetta richiesta di eliminazione dell'intera riga della commessa...
- ///
- ///
- ///
- void lnkbDel_Click(object sender, EventArgs e)
- {
- // procedo SOLO se cud enabled
- if (cudEnabled)
- {
- LinkButton lnk = (LinkButton)sender;
- // calcolo i parametri passati
- int idxFase = 0;
- try
- {
- idxFase = Convert.ToInt32(lnk.CommandArgument.ToString());
- DataProxy_ProjEts.DP.taBaz.deleteByIdxFase(anno, settimana, idxFase);
- }
- catch
- { }
- Response.Redirect("Bazaar");
- }
- }
- ///
- /// intercetta richiesta di jump verso dettaglio commessa...
- ///
- ///
- ///
- void lnkbJump_Click(object sender, EventArgs e)
- {
- LinkButton lnk = (LinkButton)sender;
- // calcolo i parametri passati
- int idxFase = 0;
- try
- {
- idxFase = Convert.ToInt32(lnk.CommandArgument.ToString());
- }
- catch
- { }
- Response.Redirect(string.Format("jumper?tipoJump=DettComm&idxFase={0}", idxFase));
- }
- ///
- /// intercetta richiesta di zoom e zoomma sull'Udc in esame...
- ///
- ///
- ///
- void lnkb_Click(object sender, EventArgs e)
- {
- LinkButton lnk = (LinkButton)sender;
- // calcolo i parametri passati
- string[] valori = lnk.CommandArgument.ToString().Split('#');
- // salvo valori
- IdxDipSel = Convert.ToInt32(valori[0]);
- IdxFaseSel = Convert.ToInt32(valori[1]);
- // blocco dip!
- DataProxy_ProjEts.DP.taTLB.lockDip(IdxDipSel, user_std.UtSn.NomeCognome);
- // continuo
- rigaBaz = (Ds_ProjEts.BazaarRisorseRow)tabBaz.Select(string.Format("idxDipendente={0} AND idxFase={1}", IdxDipSel, IdxFaseSel))[0];
- rigaDip = (Ds_ProjEts.DipendentiRow)tabDip.Select(string.Format("idxDipendente={0}", IdxDipSel))[0];
- rigaComm = (DS_utilsProjEts.v_selCommesseRow)tabComm.Select(string.Format("value = {0}", IdxFaseSel))[0];
- lblOut.Text = string.Format("Edit corrente: {0} {1} / {2} - valore originale {3}", rigaDip.Nome, rigaDip.Cognome, rigaComm.label.Substring(0, 9), rigaBaz.SchemaWeek);
- doUpdate();
- }
- ///
- /// esegue il vero plotting della tabella
- ///
- private void disegnaTabella()
- {
- bool tabPresente = tblBlocco.Rows.Count > 0;
- if (tabPresente)
- {
- tblBlocco.Rows.Clear();
- }
- // metto prima riga con indicazione valori NUMERICI delle colonne
- setupRigaDip(false);
- // ciclo nel mio array e creo di conseguenza le celle di tabella
- for (int pos_y = numComm - 1; pos_y >= 0; pos_y--)
- {
- TableRow riga = new TableRow();
- TableCell cell;
- // cella con numero livello
- cell = setupCellaComm(pos_y, riga, false);
- for (int pos_x = 0; pos_x < numDip; pos_x++)
- {
- cell = new TableCell();
- cell.CssClass = TabellaRisorse[pos_x, pos_y].Css;
- // controllo edit è abilitato
- if (editEnabled && (utils.obj.isPowerUser || utils.obj.isPM || utils.obj.isCurrentCC(TabellaRisorse[pos_x, pos_y].IdxFase)))
- {
- // aggiungo button x fare elemento cliccabile
- LinkButton lnkb = new LinkButton();
- lnkb.ToolTip = TabellaRisorse[pos_x, pos_y].ToolTip;
- lnkb.Text = TabellaRisorse[pos_x, pos_y].Label;
- // controllo che user NON sia locked...
- if (!userIsLocked(TabellaRisorse[pos_x, pos_y].IdxDipendente) || lockedByMe(TabellaRisorse[pos_x, pos_y].IdxDipendente))
- {
- lnkb.CssClass = "openDiag"; // server x far si che apra il dialog modale...
- lnkb.Click += new EventHandler(lnkb_Click);
- lnkb.CommandArgument = string.Format("{0}#{1}", TabellaRisorse[pos_x, pos_y].IdxDipendente, TabellaRisorse[pos_x, pos_y].IdxFase);
- lnkb.Enabled = cudEnabled && isWritable();
- }
- else
- {
- lnkb.Enabled = lockedByMe(TabellaRisorse[pos_x, pos_y].IdxDipendente);
- //lnkb.Enabled = false;
- }
- cell.Controls.Add(lnkb);
- }
- else
- {
- cell.ToolTip = TabellaRisorse[pos_x, pos_y].ToolTip;
- cell.Text = TabellaRisorse[pos_x, pos_y].Label;
- }
- // controllo se la cella è selezionata, nel caso BOLD!
- //if (TabellaRisorse[pos_x, pos_y].IdxDipendente == IdxDipSel && TabellaRisorse[pos_x, pos_y].IdxFase == IdxFaseSel)
- if (TabellaRisorse[pos_x, pos_y].IdxFase == IdxFaseSel)
- {
-
- if (TabellaRisorse[pos_x, pos_y].IdxDipendente == IdxDipSel)
- {
- cell.CssClass = "selCel";
- }
- // se è la commessa della riga selezionata la segno...
- else
- {
- cell.CssClass = "myLockLight";
- }
- }
- // altrimenti controllo se la COLONNA di un dip bloccato, nel caso SEGNALO e blocco....
- else if (userIsLocked(TabellaRisorse[pos_x, pos_y].IdxDipendente))
- {
- if (lockedByMe(TabellaRisorse[pos_x, pos_y].IdxDipendente))
- {
- cell.CssClass = "myLock";
- }
- else
- {
- cell.CssClass = "lockCol";
- }
- }
-
- // carico in cella di tabella il linkButton
- riga.Cells.Add(cell);
- }
- cell = setupCellaComm(pos_y, riga, true);
- tblBlocco.Rows.Add(riga);
- }
- // metto ultima riga con indicazione valori NUMERICI del totale ore x dipendente
- setupRigaDip(true);
- }
- ///
- /// verifica se utente sia locked
- ///
- ///
- ///
- protected bool userIsLocked(int IdxDipendente)
- {
- return DataProxy_ProjEts.DP.taTLB.getByDip(IdxDipendente).Rows.Count > 0;
- }
- ///
- /// verifica se sia io a tenere in lock...
- ///
- ///
- ///
- protected bool lockedByMe(int IdxDipendente)
- {
- bool answ = false;
- try
- {
- // controllo: SE sono io che ho bloccato allora NON vale blocco x ME...
- answ = DataProxy_ProjEts.DP.taTLB.getByDip(IdxDipendente)[0].LockedBy == user_std.UtSn.NomeCognome;
- }
- catch
- { }
- return answ;
- }
- ///
- /// restituisce nome di chi ha lock su risorsa (dipendente)...
- ///
- ///
- ///
- protected string lockedBy(int IdxDipendente)
- {
- string answ = "ND";
- try
- {
- answ = DataProxy_ProjEts.DP.taTLB.getByDip(IdxDipendente)[0].LockedBy;
- }
- catch
- { }
- return answ;
- }
-
- ///
- /// gestione visualizzaizone pannello elenco commesse da inserire
- ///
- ///
- ///
- protected void btnAddNew_Click(object sender, EventArgs e)
- {
- showPnlAddNewComm(!pnlAddNew.Visible);
- }
- ///
- /// gestione visualizzaizone pannello elenco commesse da inserire
- ///
- ///
- ///
- protected void btnCloneWeek_Click(object sender, EventArgs e)
- {
- // clono dalal week precedente (con valori a zero...), se valori ci sono NON li sovrascrivo...
- DataProxy_ProjEts.DP.taBaz.clonePrevWeek(anno, settimana);
- Response.Redirect("Bazaar");
- }
- ///
- /// rilascia la settimana congelandola ed inserendo in GPW le ore a commessa previste
- ///
- ///
- ///
- protected void btnReleaseWeek_Click(object sender, EventArgs e)
- {
- // controllo se la settimana è rilasciata o meno e di conseguenza opero...
- if (isReleased)
- {
- // sblocco
- DataProxy_ProjEts.DP.taBaz.resetCopyGPW(anno, settimana, user_std.UtSn.userNameAD);
- }
- else
- {
- // rilascio al settimana salvando ore in GPW e congelandola x modifiche di utenti NON PowerUser
- DataProxy_ProjEts.DP.taBaz.copy2GPW(anno, settimana, user_std.UtSn.userNameAD);
- }
- Response.Redirect("Bazaar");
- }
- ///
- /// controllo visibilità pannello
- ///
- ///
- private void showPnlAddNewComm(bool showPnlNew)
- {
- lblOut.Text = "";
- pnlAddNew.Visible = showPnlNew;
- fixBtnAddNewComm();
- }
- ///
- /// sistema visualizzazione button x mostrare/nascondere
- ///
- private void fixBtnAddNewComm()
- {
- if (pnlAddNew.Visible)
- {
- btnAddNew.Text = "Chiudi Aggiungi Commesse";
- btnAddNew.ToolTip = "Nascondi pannello Aggiungi Commesse";
- btnAddNew.ToolTip = "Modifica non consentita";
- btnAddNew.CssClass = "";
- }
- else
- {
- btnAddNew.Text = "Aggiungi Commesse";
- btnAddNew.ToolTip = "Mostra pannello Aggiungi Commesse";
- btnAddNew.CssClass = "btnNew";
- }
- }
-
- ///
- /// trimma una stringa per il num max di caratteri richiesti
- ///
- ///
- ///
- public string trimChar(object stringaIn, object maxChar)
- {
- return utils.trimChar(stringaIn, maxChar);
- }
-
- ///
- /// seleziona/deseleziona le righe indicate...
- ///
- ///
- ///
- protected void btnSelAll_Click(object sender, EventArgs e)
- {
- // seleziono tutti i valori visibili nel datagrid
- CheckBox chkbox = ((CheckBox)sender);
- bool isChecked = chkbox.Checked;
- if (!isChecked)
- {
- chkbox.ToolTip = "Seleziona tutti";
- }
- else
- {
- chkbox.ToolTip = "Deseleziona tutti";
- }
- foreach (GridViewRow riga in grViewCommesse.Rows)
- {
- ((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked;
- }
- }
- ///
- /// aggiunge commesse selezionata x tutti gli utenti codificati x bazaar
- ///
- ///
- ///
- protected void btnAddSelected_Click(object sender, EventArgs e)
- {
- // procedo SOLO se cud enabled
- if (cudEnabled)
- {
- // prende valori selezionati e crea x tutti gli utenti record BazaarRisorse
- int value = 0;
- int year = mod_navigaWeek1.anno;
- int week = mod_navigaWeek1.settimana;
- // sposto i files selezionati secondo i dati in sessione
- foreach (GridViewRow riga in grViewCommesse.Rows)
- {
- if (((CheckBox)riga.FindControl("chkSelect")).Checked)
- {
- // devo salvare file con le info relative...
- value = Convert.ToInt32(((Label)riga.FindControl("lblValue")).Text);
- DataProxy_ProjEts.DP.taBaz.creaBulkByIdxFase(anno, settimana, value);
- }
- }
- // aggiorno gridView...
- grViewCommesse.DataBind();
- // segnalo che ci sono nuovi dati!
- if (eh_newVal != null)
- {
- eh_newVal(this, new EventArgs());
- }
- doUpdate();
- }
- }
-
- ///
- /// restituisce stringa allocazione digitata, trimamta a 5 char (eventualmente) i primi 5...
- ///
- protected string allocazione
- {
- get
- {
- string answ = txtAllocazione.Text.Trim();
- if (answ.Length > 5)
- {
- // trimmo!
- answ = answ.Substring(0, 5);
- }
- return answ;
- }
- }
-
- protected void btnSalva_Click(object sender, EventArgs e)
- {
- // procedo SOLO se cud enabled
- if (cudEnabled)
- {
- int allocazione = 0;
- try
- {
- allocazione = Convert.ToInt32(txtAllocazione.Text.Trim());
- DataProxy_ProjEts.DP.taBaz.updateQuery(anno, settimana, IdxDipSel, IdxFaseSel, allocazione);
- // sblocco dip!
- DataProxy_ProjEts.DP.taTLB.unlockDip(IdxDipSel);
- }
- catch
- { }
- lblOut.Text = "";
- IdxDipSel = 0;
- IdxFaseSel = 0;
- Response.Redirect("Bazaar");
- }
- }
-
- protected void btnCancel_Click(object sender, EventArgs e)
- {
- // sblocco dip!
- DataProxy_ProjEts.DP.taTLB.unlockDip(IdxDipSel);
- // resetto
- lblOut.Text = "";
- IdxDipSel = 0;
- IdxFaseSel = 0;
- Response.Redirect("Bazaar");
- }
-
- protected void txtAllocazione_TextChanged(object sender, EventArgs e)
- {
- try
- {
- btnSalva.Focus();
- showPnlAddNewComm(!pnlAddNew.Visible);
- rigaBaz = (Ds_ProjEts.BazaarRisorseRow)tabBaz.Select(string.Format("idxDipendente={0} AND idxFase={1}", IdxDipSel, IdxFaseSel))[0];
- rigaDip = (Ds_ProjEts.DipendentiRow)tabDip.Select(string.Format("idxDipendente={0}", IdxDipSel))[0];
- rigaComm = (DS_utilsProjEts.v_selCommesseRow)tabComm.Select(string.Format("value = {0}", IdxFaseSel))[0];
- lblOut.Text = string.Format("Edit corrente: {0} {1} / {2} - valore originale {3}", rigaDip.Nome, rigaDip.Cognome, rigaComm.label.Substring(0, 9), rigaBaz.SchemaWeek);
- }
- catch (Exception exc)
- {
- lg.ErrorException("Eccezione in recupero nuovo valore impegno orario: {0}", exc);
- }
- }
-
-
- ///
- /// pagina corrente (URL finale)
- ///
- public string _paginaCorrente { get; set; }
- ///
- /// salva in variabile pagina il nome della pagina corrente
- ///
- protected void PagCorrente()
- {
- Uri MyUrl = Request.Url;
- string delimStr = "/";
- char[] delimiter = delimStr.ToCharArray();
- string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter);
- int n = finalUrl.Length;
- _paginaCorrente = finalUrl[n - 1].ToString();
- }
- ///
- /// risponde alla domanda se l'utente abbia permesso tipo writable (S) nel permessi2funzione
- ///
- ///
- public bool isWritable()
- {
- bool answ = false;
- if (_paginaCorrente == null)
- {
- PagCorrente();
- }
- answ = user_std.UtSn.isPageWriteEnabled(_paginaCorrente);
- return answ;
- }
- ///
- /// indica se la settimana sia già stata rilasciata (c'è record in tab ReleasedWeek e quindi è stato esportato su GPW)
- ///
- public bool isReleased
- {
- get
- {
- bool answ = false;
- try
- {
- answ = DataProxy_ProjEts.DP.taReW.getByAnnoWeek(anno, settimana).Rows.Count > 0;
- }
- catch
- { }
- return answ;
+ css = "cTab cOvr";
}
+ tooltip = string.Format("{2} / {0} {1}", rigaDip.Nome, rigaDip.Cognome, rigaCommShort.label.Substring(0, 9));
+ TabellaRisorse[pos_x, pos_y] = new ETS_Data.Type.BazaarRes(rigaBaz.SchemaWeek, tooltip, css, rigaBaz.idxDipendente, string.Format("{0} {1}", rigaDip.Nome, rigaDip.Cognome), rigaDip.SIGLA, rigaBaz.idxFase, rigaBaz.SchemaWeek, rigaBaz.OreTot);
+ // aggiorno totali righe/colonne (comemsse/dip)
+ oreTotDip[pos_x] += rigaBaz.OreTot;
+ schemaOreDip[pos_x] = oreWeek.addOre(schemaOreDip[pos_x].ToString(), rigaBaz.SchemaWeek, 8);
+ oreTotComm[pos_y] += rigaBaz.OreTot;
+ oreTot += rigaBaz.OreTot;
+ }
}
+ }
}
+ ///
+ /// sblocca le risorse scadute (= lock da oltre tempo max)
+ ///
+ private void unlockRes()
+ {
+ int minBlockEditRes = utils.obj.confReadInt("minBlockEditRes");
+ if (minBlockEditRes > 0)
+ {
+ DataProxy_ProjEts.DP.taTLB.unlockExpired(minBlockEditRes);
+ }
+ }
+
+ ///
+ /// disegna la riga di intestazione/chiusura x dipendenti
+ ///
+ /// true = mostra totale ore / false = mostra sigla dip + nome/cognome tooltip
+ private void setupRigaDip(bool showOre)
+ {
+ TableRow riga = new TableRow();
+ TableCell cell;
+ // cella vuota iniziale
+ cell = new TableCell();
+ riga.Cells.Add(cell);
+ // variabili accessorie x dip
+ Ds_ProjEts.DipendentiRow rigaDip;
+ // preparo celle!
+ for (int pos_x = 0; pos_x < numDip; pos_x++)
+ {
+ cell = new TableCell();
+ cell.CssClass = "cBia cCent";
+ // se è ultima riga...
+ if (showOre && numDip > 0 && numComm > 0)
+ {
+ cell.Text = string.Format("{0:0#} h{1}", oreTotDip[pos_x], schemaOreDip[pos_x]);
+ if (userIsLocked(tabD2ATR[pos_x].idxDipendente))
+ {
+ cell.ToolTip = string.Format("LOCK: {0} in modifica", lockedBy(tabD2ATR[pos_x].idxDipendente));
+ }
+ else
+ {
+ //cell.ToolTip = "";
+ cell.ToolTip = schemaOreDip[pos_x];
+ }
+ // SE sono 40h coloro di verde!!!
+ if (oreTotDip[pos_x] == 40)
+ {
+ cell.CssClass = "cBia cCent lblGreen";
+ }
+ // SE sono oltre 40h coloro di rosso!!!
+ else if ((oreTotDip[pos_x] > 40) || (schemaOreDip[pos_x].IndexOf("X") > 0))
+ {
+ cell.CssClass = "cBia cCent lblErrore";
+ }
+ }
+ else
+ {
+ rigaDip = (Ds_ProjEts.DipendentiRow)tabDip.Select(string.Format("idxDipendente={0}", tabD2ATR[pos_x].idxDipendente))[0];
+ cell.Text = rigaDip.codHw;
+ //cell.Text = rigaDip.SIGLA;
+ //cell.Text = rigaDip.Nome.Substring(0, 1) + rigaDip.Cognome.Substring(0, 1) + rigaDip.Cognome.Substring(1, 2).ToLower();
+ cell.ToolTip = string.Format("{0} {1}", rigaDip.Nome, rigaDip.Cognome);
+ }
+ riga.Cells.Add(cell);
+ }
+ // cella vuota finale
+ if (showOre && numDip > 0 && numComm > 0)
+ {
+ cell = new TableCell();
+ cell.CssClass = "cBia lblBlu";
+ cell.Text = string.Format("{0:0##} h", oreTot);
+ cell.ToolTip = "Ore TOTALI";
+ riga.Cells.Add(cell);
+ }
+ else
+ {
+ cell = new TableCell();
+ riga.Cells.Add(cell);
+ }
+ // aggiungo riga!
+ tblBlocco.Rows.Add(riga);
+ }
+ ///
+ /// controlla abilitazione edit x celle e cancellazione, ovvero
+ /// - cudEnabled (controllo periodo scaduto e permette sett future)
+ /// - isWritable (utente con permessi RW = S)
+ /// - utente PowerUser/ProjectManager oppure settimana non rilasciata (x utente CapoComm)
+ ///
+ protected bool editEnabled
+ {
+ get
+ {
+ return cudEnabled && isWritable() && (utils.obj.isPowerUser || utils.obj.isPM || !isReleased);
+ }
+ }
+ ///
+ /// crea una cella per il numero dei livelli
+ ///
+ ///
+ ///
+ /// indica se mostrare le ore totali di resoconto al posto del nome commessa
+ ///
+ private TableCell setupCellaComm(int pos_y, TableRow riga, bool showOre)
+ {
+ // variabili accessorie x dip
+ DS_utilsProjEts.v_selCommesseRow rigaComm;
+ //cella!
+ TableCell cell;
+ cell = new TableCell();
+ cell.CssClass = "cRBia";
+ rigaComm = (DS_utilsProjEts.v_selCommesseRow)tabComm.Select(string.Format("value = {0}", tabBazSingle[pos_y].idxFase))[0];
+ rigaCommShort = (DS_utilsProjEts.v_selCommesseRow)tabCommShort.Select(string.Format("value = {0}", tabBazSingle[pos_y].idxFase))[0];
+ if (showOre)
+ {
+ // controllo edit è abilitato
+ if (editEnabled && (utils.obj.isPowerUser || utils.obj.isPM || utils.obj.isCurrentCC(tabBazSingle[pos_y].idxFase)))
+ {
+ // aggiungo button x fare elemento cliccabile
+ LinkButton lnkbDel = new LinkButton();
+ lnkbDel.Click += new EventHandler(lnkbDel_Click);
+ lnkbDel.CommandArgument = rigaComm.value.ToString();
+ lnkbDel.Text = string.Format("{0:0##} h [elimina]", oreTotComm[pos_y]);
+ lnkbDel.ToolTip = string.Format("Click per eliminare commessa {0}", rigaComm.label.Substring(0, 9));
+ lnkbDel.OnClientClick = "return confirm('Confermi eliminazione record?')";
+ lnkbDel.Enabled = cudEnabled;
+ cell.Controls.Add(lnkbDel);
+ }
+ else
+ {
+ cell.Text = string.Format("{0:0##} h", oreTotComm[pos_y]);
+ cell.ToolTip = string.Format("Commessa {0} (non modificabile)", rigaComm.label.Substring(0, 9));
+ }
+ }
+ else
+ {
+ // inserisco URL x rimando a dettaglio commessa via jumper...
+ if (utils.obj.confReadBool("showLinkDettComm"))
+ {
+ // aggiungo link x fare elemento cliccabile
+ HyperLink hlJump = new HyperLink();
+ hlJump.NavigateUrl = string.Format("~/jumper?tipoJump=DettComm&idxFase={0}", rigaComm.value);
+ hlJump.Target = "_blank";
+ hlJump.Text = rigaCommShort.label;
+ hlJump.ToolTip = rigaComm.label;
+ cell.Controls.Add(hlJump);
+ }
+ else
+ {
+ cell.Text = rigaCommShort.label;
+ //cell.Text = utils.shrinkString(rigaComm.label, utils.obj.confReadInt("char2showComm"), 8);
+ cell.ToolTip = rigaComm.label;
+ }
+ }
+ riga.Cells.Add(cell);
+ return cell;
+ }
+ ///
+ /// intercetta richiesta di eliminazione dell'intera riga della commessa...
+ ///
+ ///
+ ///
+ void lnkbDel_Click(object sender, EventArgs e)
+ {
+ // procedo SOLO se cud enabled
+ if (cudEnabled)
+ {
+ LinkButton lnk = (LinkButton)sender;
+ // calcolo i parametri passati
+ int idxFase = 0;
+ try
+ {
+ idxFase = Convert.ToInt32(lnk.CommandArgument.ToString());
+ DataProxy_ProjEts.DP.taBaz.deleteByIdxFase(anno, settimana, idxFase);
+ }
+ catch
+ { }
+ Response.Redirect("Bazaar");
+ }
+ }
+ ///
+ /// intercetta richiesta di jump verso dettaglio commessa...
+ ///
+ ///
+ ///
+ void lnkbJump_Click(object sender, EventArgs e)
+ {
+ LinkButton lnk = (LinkButton)sender;
+ // calcolo i parametri passati
+ int idxFase = 0;
+ try
+ {
+ idxFase = Convert.ToInt32(lnk.CommandArgument.ToString());
+ }
+ catch
+ { }
+ Response.Redirect(string.Format("jumper?tipoJump=DettComm&idxFase={0}", idxFase));
+ }
+ ///
+ /// intercetta richiesta di zoom e zoomma sull'Udc in esame...
+ ///
+ ///
+ ///
+ void lnkb_Click(object sender, EventArgs e)
+ {
+ LinkButton lnk = (LinkButton)sender;
+ // calcolo i parametri passati
+ string[] valori = lnk.CommandArgument.ToString().Split('#');
+ // salvo valori
+ IdxDipSel = Convert.ToInt32(valori[0]);
+ IdxFaseSel = Convert.ToInt32(valori[1]);
+ // blocco dip!
+ DataProxy_ProjEts.DP.taTLB.lockDip(IdxDipSel, user_std.UtSn.NomeCognome);
+ // continuo
+ rigaBaz = (Ds_ProjEts.BazaarRisorseRow)tabBaz.Select(string.Format("idxDipendente={0} AND idxFase={1}", IdxDipSel, IdxFaseSel))[0];
+ rigaDip = (Ds_ProjEts.DipendentiRow)tabDip.Select(string.Format("idxDipendente={0}", IdxDipSel))[0];
+ rigaComm = (DS_utilsProjEts.v_selCommesseRow)tabComm.Select(string.Format("value = {0}", IdxFaseSel))[0];
+ lblOut.Text = string.Format("Edit corrente: {0} {1} / {2} - valore originale {3}", rigaDip.Nome, rigaDip.Cognome, rigaComm.label.Substring(0, 9), rigaBaz.SchemaWeek);
+ doUpdate();
+ }
+ ///
+ /// esegue il vero plotting della tabella
+ ///
+ private void disegnaTabella()
+ {
+ bool tabPresente = tblBlocco.Rows.Count > 0;
+ if (tabPresente)
+ {
+ tblBlocco.Rows.Clear();
+ }
+ // metto prima riga con indicazione valori NUMERICI delle colonne
+ setupRigaDip(false);
+ // ciclo nel mio array e creo di conseguenza le celle di tabella
+ for (int pos_y = numComm - 1; pos_y >= 0; pos_y--)
+ {
+ TableRow riga = new TableRow();
+ TableCell cell;
+ // cella con numero livello
+ cell = setupCellaComm(pos_y, riga, false);
+ for (int pos_x = 0; pos_x < numDip; pos_x++)
+ {
+ cell = new TableCell();
+ cell.CssClass = TabellaRisorse[pos_x, pos_y].Css;
+ // controllo edit è abilitato
+ if (editEnabled && (utils.obj.isPowerUser || utils.obj.isPM || utils.obj.isCurrentCC(TabellaRisorse[pos_x, pos_y].IdxFase)))
+ {
+ // aggiungo button x fare elemento cliccabile
+ LinkButton lnkb = new LinkButton();
+ lnkb.ToolTip = TabellaRisorse[pos_x, pos_y].ToolTip;
+ lnkb.Text = TabellaRisorse[pos_x, pos_y].Label;
+ // controllo che user NON sia locked...
+ if (!userIsLocked(TabellaRisorse[pos_x, pos_y].IdxDipendente) || lockedByMe(TabellaRisorse[pos_x, pos_y].IdxDipendente))
+ {
+ lnkb.CssClass = "openDiag"; // server x far si che apra il dialog modale...
+ lnkb.Click += new EventHandler(lnkb_Click);
+ lnkb.CommandArgument = string.Format("{0}#{1}", TabellaRisorse[pos_x, pos_y].IdxDipendente, TabellaRisorse[pos_x, pos_y].IdxFase);
+ lnkb.Enabled = cudEnabled && isWritable();
+ }
+ else
+ {
+ lnkb.Enabled = lockedByMe(TabellaRisorse[pos_x, pos_y].IdxDipendente);
+ //lnkb.Enabled = false;
+ }
+ cell.Controls.Add(lnkb);
+ }
+ else
+ {
+ cell.ToolTip = TabellaRisorse[pos_x, pos_y].ToolTip;
+ cell.Text = TabellaRisorse[pos_x, pos_y].Label;
+ }
+ // controllo se la cella è selezionata, nel caso BOLD!
+ //if (TabellaRisorse[pos_x, pos_y].IdxDipendente == IdxDipSel && TabellaRisorse[pos_x, pos_y].IdxFase == IdxFaseSel)
+ if (TabellaRisorse[pos_x, pos_y].IdxFase == IdxFaseSel)
+ {
+
+ if (TabellaRisorse[pos_x, pos_y].IdxDipendente == IdxDipSel)
+ {
+ cell.CssClass = "selCel";
+ }
+ // se è la commessa della riga selezionata la segno...
+ else
+ {
+ cell.CssClass = "myLockLight";
+ }
+ }
+ // altrimenti controllo se la COLONNA di un dip bloccato, nel caso SEGNALO e blocco....
+ else if (userIsLocked(TabellaRisorse[pos_x, pos_y].IdxDipendente))
+ {
+ if (lockedByMe(TabellaRisorse[pos_x, pos_y].IdxDipendente))
+ {
+ cell.CssClass = "myLock";
+ }
+ else
+ {
+ cell.CssClass = "lockCol";
+ }
+ }
+
+ // carico in cella di tabella il linkButton
+ riga.Cells.Add(cell);
+ }
+ cell = setupCellaComm(pos_y, riga, true);
+ tblBlocco.Rows.Add(riga);
+ }
+ // metto ultima riga con indicazione valori NUMERICI del totale ore x dipendente
+ setupRigaDip(true);
+ }
+ ///
+ /// verifica se utente sia locked
+ ///
+ ///
+ ///
+ protected bool userIsLocked(int IdxDipendente)
+ {
+ return DataProxy_ProjEts.DP.taTLB.getByDip(IdxDipendente).Rows.Count > 0;
+ }
+ ///
+ /// verifica se sia io a tenere in lock...
+ ///
+ ///
+ ///
+ protected bool lockedByMe(int IdxDipendente)
+ {
+ bool answ = false;
+ try
+ {
+ // controllo: SE sono io che ho bloccato allora NON vale blocco x ME...
+ answ = DataProxy_ProjEts.DP.taTLB.getByDip(IdxDipendente)[0].LockedBy == user_std.UtSn.NomeCognome;
+ }
+ catch
+ { }
+ return answ;
+ }
+ ///
+ /// restituisce nome di chi ha lock su risorsa (dipendente)...
+ ///
+ ///
+ ///
+ protected string lockedBy(int IdxDipendente)
+ {
+ string answ = "ND";
+ try
+ {
+ answ = DataProxy_ProjEts.DP.taTLB.getByDip(IdxDipendente)[0].LockedBy;
+ }
+ catch
+ { }
+ return answ;
+ }
+
+ ///
+ /// gestione visualizzaizone pannello elenco commesse da inserire
+ ///
+ ///
+ ///
+ protected void btnAddNew_Click(object sender, EventArgs e)
+ {
+ showPnlAddNewComm(!pnlAddNew.Visible);
+ }
+ ///
+ /// gestione visualizzaizone pannello elenco commesse da inserire
+ ///
+ ///
+ ///
+ protected void btnCloneWeek_Click(object sender, EventArgs e)
+ {
+ // clono dalal week precedente (con valori a zero...), se valori ci sono NON li sovrascrivo...
+ DataProxy_ProjEts.DP.taBaz.clonePrevWeek(anno, settimana);
+ Response.Redirect("Bazaar");
+ }
+ ///
+ /// rilascia la settimana congelandola ed inserendo in GPW le ore a commessa previste
+ ///
+ ///
+ ///
+ protected void btnReleaseWeek_Click(object sender, EventArgs e)
+ {
+ // controllo se la settimana è rilasciata o meno e di conseguenza opero...
+ if (isReleased)
+ {
+ // sblocco
+ DataProxy_ProjEts.DP.taBaz.resetCopyGPW(anno, settimana, user_std.UtSn.userNameAD);
+ }
+ else
+ {
+ // rilascio al settimana salvando ore in GPW e congelandola x modifiche di utenti NON PowerUser
+ DataProxy_ProjEts.DP.taBaz.copy2GPW(anno, settimana, user_std.UtSn.userNameAD);
+ }
+ Response.Redirect("Bazaar");
+ }
+ ///
+ /// controllo visibilità pannello
+ ///
+ ///
+ private void showPnlAddNewComm(bool showPnlNew)
+ {
+ lblOut.Text = "";
+ pnlAddNew.Visible = showPnlNew;
+ fixBtnAddNewComm();
+ }
+ ///
+ /// sistema visualizzazione button x mostrare/nascondere
+ ///
+ private void fixBtnAddNewComm()
+ {
+ if (pnlAddNew.Visible)
+ {
+ btnAddNew.Text = "Chiudi Aggiungi Commesse";
+ btnAddNew.ToolTip = "Nascondi pannello Aggiungi Commesse";
+ btnAddNew.ToolTip = "Modifica non consentita";
+ btnAddNew.CssClass = "";
+ }
+ else
+ {
+ btnAddNew.Text = "Aggiungi Commesse";
+ btnAddNew.ToolTip = "Mostra pannello Aggiungi Commesse";
+ btnAddNew.CssClass = "btnNew";
+ }
+ }
+
+ ///
+ /// trimma una stringa per il num max di caratteri richiesti
+ ///
+ ///
+ ///
+ public string trimChar(object stringaIn, object maxChar)
+ {
+ return utils.trimChar(stringaIn, maxChar);
+ }
+
+ ///
+ /// seleziona/deseleziona le righe indicate...
+ ///
+ ///
+ ///
+ protected void btnSelAll_Click(object sender, EventArgs e)
+ {
+ // seleziono tutti i valori visibili nel datagrid
+ CheckBox chkbox = ((CheckBox)sender);
+ bool isChecked = chkbox.Checked;
+ if (!isChecked)
+ {
+ chkbox.ToolTip = "Seleziona tutti";
+ }
+ else
+ {
+ chkbox.ToolTip = "Deseleziona tutti";
+ }
+ foreach (GridViewRow riga in grViewCommesse.Rows)
+ {
+ ((CheckBox)riga.FindControl("chkSelect")).Checked = isChecked;
+ }
+ }
+ ///
+ /// aggiunge commesse selezionata x tutti gli utenti codificati x bazaar
+ ///
+ ///
+ ///
+ protected void btnAddSelected_Click(object sender, EventArgs e)
+ {
+ // procedo SOLO se cud enabled
+ if (cudEnabled)
+ {
+ // prende valori selezionati e crea x tutti gli utenti record BazaarRisorse
+ int value = 0;
+ int year = mod_navigaWeek1.anno;
+ int week = mod_navigaWeek1.settimana;
+ // sposto i files selezionati secondo i dati in sessione
+ foreach (GridViewRow riga in grViewCommesse.Rows)
+ {
+ if (((CheckBox)riga.FindControl("chkSelect")).Checked)
+ {
+ // devo salvare file con le info relative...
+ value = Convert.ToInt32(((Label)riga.FindControl("lblValue")).Text);
+ DataProxy_ProjEts.DP.taBaz.creaBulkByIdxFase(anno, settimana, value);
+ }
+ }
+ // aggiorno gridView...
+ grViewCommesse.DataBind();
+ // segnalo che ci sono nuovi dati!
+ if (eh_newVal != null)
+ {
+ eh_newVal(this, new EventArgs());
+ }
+ doUpdate();
+ }
+ }
+
+ ///
+ /// restituisce stringa allocazione digitata, trimamta a 5 char (eventualmente) i primi 5...
+ ///
+ protected string allocazione
+ {
+ get
+ {
+ string answ = txtAllocazione.Text.Trim();
+ if (answ.Length > 5)
+ {
+ // trimmo!
+ answ = answ.Substring(0, 5);
+ }
+ return answ;
+ }
+ }
+
+ protected void btnSalva_Click(object sender, EventArgs e)
+ {
+ // procedo SOLO se cud enabled
+ if (cudEnabled)
+ {
+ int allocazione = 0;
+ try
+ {
+ allocazione = Convert.ToInt32(txtAllocazione.Text.Trim());
+ DataProxy_ProjEts.DP.taBaz.updateQuery(anno, settimana, IdxDipSel, IdxFaseSel, allocazione);
+ // sblocco dip!
+ DataProxy_ProjEts.DP.taTLB.unlockDip(IdxDipSel);
+ }
+ catch
+ { }
+ lblOut.Text = "";
+ IdxDipSel = 0;
+ IdxFaseSel = 0;
+ Response.Redirect("Bazaar");
+ }
+ }
+
+ protected void btnCancel_Click(object sender, EventArgs e)
+ {
+ // sblocco dip!
+ DataProxy_ProjEts.DP.taTLB.unlockDip(IdxDipSel);
+ // resetto
+ lblOut.Text = "";
+ IdxDipSel = 0;
+ IdxFaseSel = 0;
+ Response.Redirect("Bazaar");
+ }
+
+ protected void txtAllocazione_TextChanged(object sender, EventArgs e)
+ {
+ try
+ {
+ btnSalva.Focus();
+ showPnlAddNewComm(!pnlAddNew.Visible);
+ rigaBaz = (Ds_ProjEts.BazaarRisorseRow)tabBaz.Select(string.Format("idxDipendente={0} AND idxFase={1}", IdxDipSel, IdxFaseSel))[0];
+ rigaDip = (Ds_ProjEts.DipendentiRow)tabDip.Select(string.Format("idxDipendente={0}", IdxDipSel))[0];
+ rigaComm = (DS_utilsProjEts.v_selCommesseRow)tabComm.Select(string.Format("value = {0}", IdxFaseSel))[0];
+ lblOut.Text = string.Format("Edit corrente: {0} {1} / {2} - valore originale {3}", rigaDip.Nome, rigaDip.Cognome, rigaComm.label.Substring(0, 9), rigaBaz.SchemaWeek);
+ }
+ catch (Exception exc)
+ {
+ lg.ErrorException("Eccezione in recupero nuovo valore impegno orario: {0}", exc);
+ }
+ }
+
+
+ ///
+ /// pagina corrente (URL finale)
+ ///
+ public string _paginaCorrente { get; set; }
+ ///
+ /// salva in variabile pagina il nome della pagina corrente
+ ///
+ protected void PagCorrente()
+ {
+ Uri MyUrl = Request.Url;
+ string delimStr = "/";
+ char[] delimiter = delimStr.ToCharArray();
+ string[] finalUrl = MyUrl.LocalPath.ToString().Split(delimiter);
+ int n = finalUrl.Length;
+ _paginaCorrente = finalUrl[n - 1].ToString();
+ }
+ ///
+ /// risponde alla domanda se l'utente abbia permesso tipo writable (S) nel permessi2funzione
+ ///
+ ///
+ public bool isWritable()
+ {
+ bool answ = false;
+ if (_paginaCorrente == null)
+ {
+ PagCorrente();
+ }
+ answ = user_std.UtSn.isPageWriteEnabled(_paginaCorrente);
+ return answ;
+ }
+ ///
+ /// indica se la settimana sia già stata rilasciata (c'è record in tab ReleasedWeek e quindi è stato esportato su GPW)
+ ///
+ public bool isReleased
+ {
+ get
+ {
+ bool answ = false;
+ try
+ {
+ answ = DataProxy_ProjEts.DP.taReW.getByAnnoWeek(anno, settimana).Rows.Count > 0;
+ }
+ catch
+ { }
+ return answ;
+ }
+ }
+ }
}
\ No newline at end of file