Esempio n. 1
0
 private bool CreateDocumentoInterno(ref EntidadeInterna ei, long tnr)
 {
     bool cancel = false;
     FormAddNivel form = new FormAddNivel();
     form.IDTipoNivelRelacionado = tnr;
     if (ei != null)
     {
         form.txtDesignacao.Text = ei != null ? ((DocumentoGisa)ei).Titulo : "";
         if (tnr == TipoNivelRelacionado.SD)
             form.txtCodigo.Text = ei != null ? ((DocumentoGisa)ei).Codigo : "";
     }
     switch (form.ShowDialog())
     {
         case DialogResult.OK:
             var documento = new DocumentoGisa();
             documento.Tipo = tnr == (long)TipoNivelRelacionado.SD ? TipoEntidadeInterna.DocumentoSimples : TipoEntidadeInterna.DocumentoComposto;
             if (tnr == (long)TipoNivelRelacionado.SD)
                 documento.CopyProperties(this.correspDocumento);
             documento.Titulo = form.txtDesignacao.Text;
             documento.Codigo = form.txtCodigo.Text;
             ei = this.InternalEntitiesLst.AddInternalEntity(documento);
             break;
         case DialogResult.Cancel:
             cancel = true;
             break;
     }
     return cancel;
 }
Esempio n. 2
0
 private void CreateED()
 {
     // as ED usam o mesmo form que os níveis documentais
     FormAddNivel frm = new FormAddNivel();
     GISADataset.TipoNivelRelacionadoRow tnrRow = null;
     tnrRow = TipoNivelRelacionado.GetTipoNivelRelacionadoFromRelacaoHierarquica(null);
     frm.IDTipoNivelRelacionado = tnrRow.ID; // necessário para validação do código parcial
     handleNewNivel(frm, null, tnrRow);
     UpdateToolBarButtons();
 }
Esempio n. 3
0
		private void EditNivel(FormAddNivel frm, GISADataset.NivelRow NivelRow)
		{
            GISADataset.TipoNivelRelacionadoRow tnrRow;
            if (NivelRow.IDTipoNivel == TipoNivel.LOGICO && GisaDataSetHelper.GetInstance().RelacaoHierarquica.Select("ID="+NivelRow.ID.ToString()).Length == 0)
                tnrRow = GisaDataSetHelper.GetInstance().TipoNivelRelacionado.Cast<GISADataset.TipoNivelRelacionadoRow>().Single(r => r.ID == TipoNivelRelacionado.ED);
            else
                tnrRow = GisaDataSetHelper.GetInstance().RelacaoHierarquica.Cast<GISADataset.RelacaoHierarquicaRow>().First(r => r.ID == NivelRow.ID && r.RowState != DataRowState.Deleted).TipoNivelRelacionadoRow;

			string WindowTitle = string.Format("Editar {0}", tnrRow.Designacao);
			// Don't allow to edit a Nivel without a Controlo 
			// Autoridade using a form with Controlo Autoridade.
			// frm will only be of type FormNivelEstrutural if the
			// related administration option is set to "demand a ControloAutoridade"
			if (frm is FormNivelEstrutural && ! (NivelRow.CatCode.Trim().Equals("CA")))
			{
				MessageBox.Show("O nível selecionado não foi definido com " + "base numa entidade produtora." + System.Environment.NewLine + "Assim, para que este nível seja editável é necessário " + "que a aplicação esteja " + System.Environment.NewLine + "configurada para lidar com níveis não controlados.", WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
				return;
			}
			else if (! (frm is FormNivelEstrutural) && ! (NivelRow.CatCode.Trim().Equals("NVL")))
			{
				MessageBox.Show("O nível selecionado foi definido com " + "base numa entidade produtora." + System.Environment.NewLine + "Assim, para que este nível seja editável é necessário " + "que a aplicação esteja " + System.Environment.NewLine + "configurada para lidar com níveis controlados.", WindowTitle, MessageBoxButtons.OK, MessageBoxIcon.Information);
				return;
			}

			frm.Text = WindowTitle;
			frm.txtCodigo.Text = NivelRow.Codigo;
			frm.txtDesignacao.Text = Nivel.GetDesignacao(NivelRow);
			// se se tratar de uma série ou subsérie o código será sempre automático
			if (tnrRow.ID == TipoNivelRelacionado.SR || tnrRow.ID == TipoNivelRelacionado.SSR)
				frm.txtCodigo.Enabled = false;

			frm.LoadData();

			if (NivelRow.TipoNivelRow.ID != TipoNivel.LOGICO)
			{
				// populate controls with data so that it can be edited

				if (frm is FormNivelEstrutural)
				{
                    FormNivelEstrutural tempWith1 = (FormNivelEstrutural)frm;
					if (NivelRow.CatCode.Trim().Equals("CA"))
					{
						tempWith1.caList.txtFiltroDesignacao.Text = tempWith1.txtDesignacao.Text;
                        tempWith1.caList.ReloadList();
						tempWith1.chkControloAut = true;
					}
					else if (NivelRow.CatCode.Trim().Equals("NVL"))
						tempWith1.chkControloAut = false;
				}
			}

			// show form and receive user feedback
			switch (frm.ShowDialog())
			{
				case DialogResult.OK:
				Trace.WriteLine("A editar nível...");
					GISADataset.NivelDesignadoRow ndRow = null;
					
					// Um Nivel documental deve ter obrigatoriamente um NivelDesignado.
                    Debug.Assert(NivelRow.GetNivelDesignadoRows().Length > 0);
					ndRow = NivelRow.GetNivelDesignadoRows()[0];
                    
                    NivelRow.Codigo = frm.txtCodigo.Text;
                    ndRow.Designacao = frm.txtDesignacao.Text;

                    // registar a edição do item selecionado
                    if (NivelRow.IDTipoNivel != TipoNivel.LOGICO)
                        CurrentContext.RaiseRegisterModificationEvent(NivelRow.GetFRDBaseRows()[0]);

					PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments pcArgs = new PersistencyHelper.EnsureUniqueCodigoNivelPreConcArguments();
					pcArgs.nRowID = NivelRow.ID;
					pcArgs.ndRowID = ndRow.ID;
					// Se se tratar de uma entidade detentora não passar os Ids de uma relação
					// hierárquica para um nível superior pois não existe nenhum.
					if (NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica().Length > 0)
					{
						pcArgs.rhRowID = NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].ID;
						pcArgs.rhRowIDUpper = NivelRow.GetRelacaoHierarquicaRowsByNivelRelacaoHierarquica()[0].IDUpper;
					}
					pcArgs.testOnlyWithinNivel = true;

                    PersistencyHelper.SaveResult successfulSave = PersistencyHelper.save(DelegatesHelper.ensureUniqueCodigo, pcArgs);
					if (! pcArgs.successful)
						MessageBox.Show(pcArgs.message, "Criação de unidade de descrição", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    else if (successfulSave == PersistencyHelper.SaveResult.successful)
                    {
                        GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                        try
                        {
                            List<string> IDNiveis = new List<string>();
                            IDNiveis.Add(NivelRow.ID.ToString());
                            GISA.Search.Updater.updateNivelDocumental(IDNiveis);
                        }
                        catch (Exception ex)
                        {
                            Trace.WriteLine(ex.ToString());
                            throw;
                        }
                        finally
                        {
                            ho.Dispose();
                        }
                    }

                    PersistencyHelper.cleanDeletedData(PersistencyHelper.determinaNuvem("RelacaoHierarquica"));

					// Actualizar a interface com os novos valores. Se editarmos a 
					// raiz (estrutural) da vista documental é necessário actualizar 
					// automaticamente também a vista estrutural.

					if (! (NivelRow.RowState == DataRowState.Detached))
					{
                        if (this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Estrutural)
							this.nivelNavigator1.UpdateSelectedNodeName(Nivel.GetDesignacao(NivelRow));
						else
                            this.nivelNavigator1.UpdateSelectedListItemName(Nivel.GetDesignacao(NivelRow));
					}

					// Forçar a gravação do documento
					CurrentContext.SetNivelEstrututalDocumental(null);
					CurrentContext.SetNivelEstrututalDocumental(NivelRow);
					break;
			}
		}
Esempio n. 4
0
        private void EditNivelAction()
        {
            GISADataset.NivelRow nRow = null;
            if (this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Estrutural)
            {
                if (this.nivelNavigator1.EPFilterMode)
                    nRow = this.nivelNavigator1.SelectedNivel;
                else
                    nRow = ((GISATreeNode)this.nivelNavigator1.SelectedNode).NivelRow;
            }
            else
                nRow = this.nivelNavigator1.SelectedNivel;

            if (nRow.TipoNivelRow.ID == TipoNivel.ESTRUTURAL || nRow.TipoNivelRow.ID == TipoNivel.OUTRO)
            {
                var trace_msg = string.Format("Trying to edit UI of type {0}...",  nRow.TipoNivelRow.ID.ToString());
                Trace.WriteLine(trace_msg);
                Trace.WriteLine("The nivel row ID is: " + nRow.ID.ToString());
                Debug.Assert(false, trace_msg);
            }

            // Criar o tipo de form correcto conforme o tipo de nível em edição
            FormAddNivel frm = null;
            if (nRow.TipoNivelRow.ID == TipoNivel.LOGICO)
            {
                // Nível é uma Entidade detentora ou um grupo de arquivos
                frm = new FormAddNivel();
                frm.IDTipoNivelRelacionado = nRow.TipoNivelRow.ID;
            }
            else if (nRow.TipoNivelRow.ID == TipoNivel.ESTRUTURAL)
            {
                //// Nível estrutural
                //if (GisaDataSetHelper.UsingNiveisOrganicos())
                //    frm = new FormNivelEstrutural();
                //else
                //    frm = new FormAddNivel();

                //frm.IDTipoNivelRelacionado = nRow.TipoNivelRow.ID;
            }
            else if (nRow.TipoNivelRow.ID == TipoNivel.DOCUMENTAL)
            {
                // Nível documental
                frm = new FormAddNivel();
                frm.IDTipoNivelRelacionado = nRow.TipoNivelRow.ID;
            }
            else if (nRow.TipoNivelRow.ID == TipoNivel.OUTRO)
            {
                // Nível é uma unidade física
            }

            EditNivel(frm, nRow);
        }
Esempio n. 5
0
        private void ToolBarButtonCreateMenuItemClick(object sender, EventArgs e)
		{
            ((frmMain)TopLevelControl).EnterWaitMode();

			GISADataset.TipoNivelRelacionadoRow tnrRow = ((TipoNivelMenuItem)sender).Row;

			FormAddNivel frm = null;
			GISADataset.NivelRow nivelRow = null;
			if (tnrRow.TipoNivelRow.ID == TipoNivel.LOGICO)
			{
				frm = new FormAddNivel();
                nivelRow = ((GISATreeNode)this.nivelNavigator1.SelectedNode).NivelRow;
			}
			else if (tnrRow.TipoNivelRow.ID == TipoNivel.DOCUMENTAL)
			{
				// Nível documental
				frm = new FormNivelDocumental();
                nivelRow = (GISADataset.NivelRow)(GisaDataSetHelper.GetInstance().Nivel.Select(string.Format("ID={0}", this.nivelNavigator1.ContextBreadCrumbsPathID.ToString()))[0]);
                ((FormNivelDocumental)frm).NivelRow = nivelRow;
			}
			else
			{
				// Nível estrutural
				if (GisaDataSetHelper.UsingNiveisOrganicos())
				{
					frm = new FormNivelEstrutural();
					((FormNivelEstrutural)frm).caList.txtFiltroDesignacao.Clear();
					((FormNivelEstrutural)frm).caList.ReloadList();
				}
				else
					frm = new FormNivelDocumental();

                nivelRow = ((GISATreeNode)this.nivelNavigator1.SelectedNode).NivelRow;
			}
            long click = DateTime.Now.Ticks;
			frm.IDTipoNivelRelacionado = tnrRow.ID; // necessário para validação do código parcial
			bool successfulSave = handleNewNivel(frm, nivelRow, tnrRow);
            Debug.WriteLine("<<NewNivel>> " + new TimeSpan(DateTime.Now.Ticks - click).ToString());

            ((frmMain)TopLevelControl).LeaveWaitMode();

			// O UpdateToolBarButtons não é executado quando é adicionado um novo nível documental pois 
			// esta operação já é feita durante a inserção do nó (caso essa inserção não aconteça por 
			// motivos de conflito de concorrência o método pode ser executado de forma a impedir o 
			// acesso de opções ao utilizador que poderiam levar a um crash da aplicação). Executar o 
			// UpdateToolBarButtons neste ponto para a situação acima mencionada vai alterar 
			// erradamente o estado dos botões
            if ((this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Estrutural && successfulSave) || (this.nivelNavigator1.PanelToggleState == NivelNavigator.ToggleState.Documental && !successfulSave))
			{
                if (this.nivelNavigator1.SelectedItems.Count > 0)
                    UpdateToolBarButtons(this.nivelNavigator1.SelectedItems[0]);
				else
					UpdateToolBarButtons();
			}
		}