private ArrayList cercaInUoFiglie(DocsPAWA.DocsPaWR.OrgUO uo) { //CALCOLARE I FIGLI DEL NODO DA SPOSTARE sysUoFrom ArrayList listaUo = null; Manager.OrganigrammaManager theManager = new Amministrazione.Manager.OrganigrammaManager(); listaUo = theManager.GetListaUoFiglie(uo); return(listaUo); }
private void btn_sposta_Click(object sender, System.EventArgs e) { DocsPAWA.DocsPaWR.OrgUO uoDaSpostare = new DocsPAWA.DocsPaWR.OrgUO(); uoDaSpostare.IDCorrGlobale = this.hd_idCorrGlobUODaSpostare.Value; uoDaSpostare.Codice = this.txt_codice.Text; uoDaSpostare.CodiceRubrica = this.txt_codice.Text; uoDaSpostare.Descrizione = this.txt_descrizione.Text; uoDaSpostare.IDAmministrazione = this.hd_idAmm.Value; uoDaSpostare.Livello = this.hd_livelloUO_DaSpostare.Value; DocsPAWA.DocsPaWR.OrgUO uoPadre = new DocsPAWA.DocsPaWR.OrgUO(); uoPadre.IDCorrGlobale = this.hd_idCorrGlobDest.Value; uoPadre.Codice = this.txt_ricCod.Text; uoPadre.CodiceRubrica = this.txt_ricCod.Text; uoPadre.Descrizione = this.txt_ricDesc.Text; uoPadre.IDAmministrazione = this.hd_idAmm.Value; Manager.OrganigrammaManager manager = new Amministrazione.Manager.OrganigrammaManager(); DocsPAWA.DocsPaWR.EsitoOperazione esito = new DocsPAWA.DocsPaWR.EsitoOperazione(); //Se la Uo si sta spostando in una dei suio figli si deve bloccare l'operazione //e avvisare l'utente ArrayList uoFiglie = cercaInUoFiglie(uoDaSpostare); /*verifico se la systemId della UoPadre * (intesa come il nodo sotto il quale si vuole spostare la Uo 'uoDaSpostare') * è presente tra i figli della 'uoDaSpostare', in tal caso blocchiamo tale operazione * Attualmente non è gestito il caso di sposare un NODO ('uoPadre') sotto a un suo FIGLIO*/ if (uoPadre.IDCorrGlobale != uoDaSpostare.IDCorrGlobale) { if (!uoFiglie.Contains(uoPadre.IDCorrGlobale)) { manager.SpostaUO(uoDaSpostare, uoPadre); esito = manager.getEsitoOperazione(); if (esito.Codice.Equals(0)) { this.executeJS("<SCRIPT>alert('Operazione di spostamento UO eseguita correttamente.'); window.returnValue = 'Y'; self.close();</SCRIPT>"); } else { this.executeJS("<SCRIPT>alert('Attenzione, " + esito.Descrizione.Replace("'", "\\'") + "');</SCRIPT>"); } } else { //caso in cui si tenta si spostare UN PADRE SOTTO A UN FIGLIO this.executeJS("<SCRIPT>alert('Attenzione: non è possibile spostare un nodo padre sotto a un nodo figlio.'); window.returnValue = 'Y'; self.close();</SCRIPT>"); } } else { //caso in cui si tenta si spostare un nodo sotto se stesso (senza questo controllo l'applicazione va in loop) this.executeJS("<SCRIPT>alert('Attenzione: si sta cercando di spostare una Uo sotto se stessa.'); window.returnValue = 'Y'; self.close();</SCRIPT>"); } }
/// <summary> /// Imposta la Root nella Treeview /// </summary> /// <param name="currentUO"></param> /// <returns></returns> private myTreeNode SetRootTreeview(DocsPAWA.DocsPaWR.OrgUO currentUO) { this.PulisceTuttaTreeView(); myTreeNode treenode = new myTreeNode(); treenode.ID = currentUO.IDCorrGlobale; treenode.Text = currentUO.Codice + " - " + currentUO.Descrizione; treeViewUO.Nodes.Add(treenode); treenode.setTipoNodo("U"); treenode.setRuoliUO(currentUO.Ruoli); treenode.setSottoUO(currentUO.SottoUo); treenode.setLivello(currentUO.Livello); return(treenode); }
/// <summary> /// Esegue l'espansione del nodo /// </summary> /// <param name="indice"></param> private void executeExpand(string indice) { DocsPaWR.OrgUO currentUO; myTreeNode TreeNodo = (myTreeNode)treeViewUO.GetNodeFromIndex(indice); TreeNodo.Expanded = true; // this.treeViewUO.SelectedNodeIndex = indice; if (TreeNodo.Nodes.Count > 0) { TreeNodo.Nodes.Clear(); } switch (TreeNodo.getTipoNodo()) { case "U": currentUO = new DocsPAWA.DocsPaWR.OrgUO(); currentUO.IDCorrGlobale = TreeNodo.ID; currentUO.IDAmministrazione = this.hd_idAmm.Value; currentUO.Ruoli = TreeNodo.getRuoliUO(); currentUO.SottoUo = TreeNodo.getSottoUO(); currentUO.Livello = TreeNodo.getLivello(); if (this.GetTipoNavigazione() > 1 && Convert.ToInt32(currentUO.Ruoli) > 0) { this.RuoliUO(currentUO, indice); } if (Convert.ToInt32(currentUO.SottoUo) > 0) { this.SottoUO(currentUO, indice); } break; } }
/// <summary> /// Visualizza i ruoli di una UO /// </summary> /// <param name="currentUO"></param> /// <param name="indice"></param> private void RuoliUO(DocsPAWA.DocsPaWR.OrgUO currentUO, string indice) { myTreeNode nodoRuoli; myTreeNode TreeNodo; TreeNodo = (myTreeNode)treeViewUO.GetNodeFromIndex(indice); Amministrazione.Manager.OrganigrammaManager manager = new Amministrazione.Manager.OrganigrammaManager(); manager.ListaRuoliUO(currentUO.IDCorrGlobale); if (manager.getListaRuoliUO() != null && manager.getListaRuoliUO().Count > 0) { TreeNodo.Expanded = true; foreach (DocsPAWA.DocsPaWR.OrgRuolo ruolo in manager.getListaRuoliUO()) { // filtro per nuova gestione RF if (this.visualizzaRuolo_filtroRF(ruolo.IDCorrGlobale)) { nodoRuoli = new myTreeNode(); nodoRuoli.ID = ruolo.IDCorrGlobale; nodoRuoli.Text = ruolo.CodiceRubrica + " - " + ruolo.Descrizione; nodoRuoli.ImageUrl = HttpFullPath + "/AdminTool/Images/ruolo.gif"; TreeNodo.Nodes.Add(nodoRuoli); nodoRuoli.setTipoNodo("R"); if (this.GetTipoNavigazione().Equals(3) && ruolo.Utenti.Length > 0) { this.UtentiRuolo(nodoRuoli, ruolo); } } } } }
/// <summary> /// Visualizza le sotto UO /// </summary> /// <param name="currentUO"></param> /// <param name="indice"></param> /// <returns></returns> private bool SottoUO(DocsPAWA.DocsPaWR.OrgUO currentUO, string indice) { bool retValue = true; myTreeNode TreeNodo; myTreeNode TreeNodoFiglio; if (indice != null) { TreeNodo = (myTreeNode)treeViewUO.GetNodeFromIndex(indice); } else { TreeNodo = (myTreeNode)treeViewUO.GetNodeFromIndex(treeViewUO.SelectedNodeIndex); } myTreeNode nodoUO; ArrayList lista = new ArrayList(); int livello = Convert.ToInt32(currentUO.Livello) + 1; Amministrazione.Manager.OrganigrammaManager manager = new Amministrazione.Manager.OrganigrammaManager(); manager.ListaUO(currentUO.IDCorrGlobale, Convert.ToString(livello), currentUO.IDAmministrazione); lista = manager.getListaUO(); if (lista != null && lista.Count > 0) { if (!this.isOrdinamentoAbilitato()) { lista.Sort(new UOSort()); } foreach (DocsPAWA.DocsPaWR.OrgUO sottoUO in lista) { nodoUO = new myTreeNode(); nodoUO.ID = sottoUO.IDCorrGlobale; nodoUO.Text = sottoUO.CodiceRubrica + " - " + sottoUO.Descrizione; nodoUO.ImageUrl = HttpFullPath + "/AdminTool/Images/uo.gif"; TreeNodo.Nodes.Add(nodoUO); nodoUO.setTipoNodo("U"); nodoUO.setRuoliUO(sottoUO.Ruoli); nodoUO.setSottoUO(sottoUO.SottoUo); nodoUO.setLivello(sottoUO.Livello); if ((this.GetTipoNavigazione() > 1 && Convert.ToInt32(sottoUO.Ruoli) > 0) || Convert.ToInt32(sottoUO.SottoUo) > 0) { TreeNodoFiglio = new myTreeNode(); TreeNodoFiglio.Text = "<font color='#ff0000'> loading...</font>"; nodoUO.Nodes.Add(TreeNodoFiglio); } } } else { retValue = false; } return(retValue); }