예제 #1
0
        private void retrieveSelection(FormPickControloAut frmPick, TextBox txtBox)
        {
            frmPick.caList.txtFiltroDesignacao.Clear();
            frmPick.caList.ReloadList();

            switch (frmPick.ShowDialog())
            {
            case DialogResult.OK:
                var li = frmPick.caList.SelectedItems.Cast <ListViewItem>().SingleOrDefault();
                if (li == null)
                {
                    return;
                }

                Debug.Assert(li.Tag is GISADataset.ControloAutDicionarioRow);

                var ca = ((GISADataset.ControloAutDicionarioRow)li.Tag).ControloAutRow;

                mTipologia  = GisaDataSetHelper.GetInstance().ControloAutDicionario.Cast <GISADataset.ControloAutDicionarioRow>().Single(r => r.IDControloAut == ca.ID && r.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada);
                txtBox.Text = mTipologia.DicionarioRow.Termo;

                break;

            case DialogResult.Cancel:
                break;
            }
        }
예제 #2
0
        private void ButtonTI_Click(object sender, EventArgs e)
        {
            FormPickControloAut frmPick = new FormPickControloAut();

            frmPick.Text = "Controlo de autoridade - Pesquisa por tipologia informacional";
            frmPick.caList.AllowedNoticiaAut(TipoNoticiaAut.TipologiaInformacional);
            retrieveSelection(frmPick, txtTipologia);
        }
예제 #3
0
        private void btnTecnicoDeObra_Click(object sender, EventArgs e)
        {
            FormPickControloAut frmPick = new FormPickControloAut();

            frmPick.Text = "Notícia de autoridade - Pesquisar registo de autoridade onomástico";
            frmPick.caList.AllowedNoticiaAut(TipoNoticiaAut.Onomastico);
            frmPick.caList.ReloadList();
            TheControloAutSelectionRetriever(frmPick, txtTecnicoDeObra);
        }
예제 #4
0
        private void btnLocalizacaoDeObra_Click(object sender, EventArgs e)
        {
            FormPickControloAut frmPick = new FormPickControloAut();

            frmPick.Text = "Notícia de autoridade - Pesquisar registo de autoridade geográfico";
            frmPick.caList.AllowedNoticiaAut(TipoNoticiaAut.ToponimicoGeografico);
            frmPick.caList.ReloadList();
            TheControloAutSelectionRetriever(frmPick, txtLocalizacao);
        }
        private void button_FormPickControloAut_Click(object sender, System.EventArgs e)
        {
            FormPickControloAut frmPick = new FormPickControloAut();

            frmPick.Text = "Notícia de autoridade - Pesquisar registo de autoridade geográfico";
            frmPick.caList.AllowedNoticiaAut(TipoNoticiaAut.ToponimicoGeografico);
            frmPick.caList.ReloadList();

            if (frmPick.caList.Items.Count > 0)
            {
                frmPick.caList.SelectItem(frmPick.caList.Items[0]);
            }

            switch (frmPick.ShowDialog())
            {
            case DialogResult.OK:
                if (frmPick.caList.SelectedItems.Count > 0)
                {
                    var selCadRow = (GISADataset.ControloAutDicionarioRow)frmPick.caList.SelectedItems[0].Tag;
                    if (selCadRow.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada)
                    {
                        this.cadRow = selCadRow;
                    }
                    else
                    {
                        GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                        try
                        {
                            ControloAutRule.Current.LoadDicionarioAndControloAutDicionario(GisaDataSetHelper.GetInstance(), selCadRow.IDControloAut, ho.Connection);
                        }
                        catch (Exception ex)
                        {
                            Trace.WriteLine(ex);
                            throw;
                        }
                        finally
                        {
                            ho.Dispose();
                        }
                        this.cadRow = selCadRow.ControloAutRow.GetControloAutDicionarioRows().Where(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).Single();
                    }
                    this.txtDesignacao.Text = this.cadRow.DicionarioRow.Termo;
                    updateButtons();
                }
                break;

            default:
                break;
            }
        }
예제 #6
0
        // Adicionar um tecnico de obra (registo de autoridade onomastico):
        private void btnAddTecnicoObra_Click(object sender, EventArgs e)
        {
            FormPickControloAut frmPick = new FormPickControloAut();

            frmPick.Text = "Notícia de autoridade - Pesquisar registo de autoridade onomástico";
            frmPick.caList.AllowedNoticiaAut(TipoNoticiaAut.Onomastico);
            frmPick.caList.ReloadList();

            GISADataset.ControloAutRow            caRow         = null;
            GISADataset.LicencaObraTecnicoObraRow tecnicoRow    = null;
            GISADataset.ControloAutDicionarioRow  dicionarioRow = null;

            if (frmPick.caList.Items.Count > 0)
            {
                frmPick.caList.SelectItem(frmPick.caList.Items[0]);
            }

            switch (frmPick.ShowDialog())
            {
            case DialogResult.OK:
                foreach (ListViewItem li in frmPick.caList.SelectedItems)
                {
                    dicionarioRow = (GISADataset.ControloAutDicionarioRow)li.Tag;
                    caRow         = dicionarioRow.ControloAutRow;
                    if (!existe_LicencaObraTecnicoObra(caRow))
                    {
                        tecnicoRow = GisaDataSetHelper.GetInstance().LicencaObraTecnicoObra.NewLicencaObraTecnicoObraRow();
                        tecnicoRow.LicencaObraRow = CurrentLicencaObra;
                        tecnicoRow.ControloAutRow = caRow;
                        tecnicoRow.isDeleted      = 0;
                        // Dados:
                        Add_RowTecnicoObra(tecnicoRow);
                        // GUI: adicionar `a lista:
                        Add_ViewTecnicoObra(dicionarioRow, tecnicoRow);
                    }
                }
                break;

            default:
                break;
            }
        }
예제 #7
0
        // Adicionar um tecnico de obra (registo de autoridade onomastico):
        private void btnAddTecnicoObra_Click(object sender, EventArgs e)
        {
            FormPickControloAut frmPick = new FormPickControloAut();

            frmPick.Text = "Notícia de autoridade - Pesquisar registo de autoridade onomástico";
            frmPick.caList.AllowedNoticiaAut(TipoNoticiaAut.Onomastico);
            frmPick.caList.ReloadList();

            GISADataset.ControloAutRow            caRow      = null;
            GISADataset.LicencaObraTecnicoObraRow tecnicoRow = null;
            GISADataset.ControloAutDicionarioRow  cadRow     = null;

            if (frmPick.caList.Items.Count > 0)
            {
                frmPick.caList.SelectItem(frmPick.caList.Items[0]);
            }

            switch (frmPick.ShowDialog())
            {
            case DialogResult.OK:
                foreach (ListViewItem li in frmPick.caList.SelectedItems)
                {
                    cadRow = (GISADataset.ControloAutDicionarioRow)li.Tag;
                    caRow  = cadRow.ControloAutRow;
                    if (!existe_LicencaObraTecnicoObra(caRow))
                    {
                        if (cadRow.IDTipoControloAutForma != (long)TipoControloAutForma.FormaAutorizada)
                        {
                            GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                            try
                            {
                                ControloAutRule.Current.LoadDicionarioAndControloAutDicionario(GisaDataSetHelper.GetInstance(), cadRow.IDControloAut, ho.Connection);
                            }
                            catch (Exception ex)
                            {
                                Trace.WriteLine(ex);
                                throw;
                            }
                            finally
                            {
                                ho.Dispose();
                            }
                            cadRow = caRow.GetControloAutDicionarioRows().Where(cad => cad.IDTipoControloAutForma == (long)TipoControloAutForma.FormaAutorizada).Single();
                        }

                        tecnicoRow = GisaDataSetHelper.GetInstance().LicencaObraTecnicoObra.NewLicencaObraTecnicoObraRow();
                        tecnicoRow.LicencaObraRow = CurrentLicencaObra;
                        tecnicoRow.ControloAutRow = caRow;
                        tecnicoRow.isDeleted      = 0;
                        // Dados:
                        Add_RowTecnicoObra(tecnicoRow);
                        // GUI: adicionar `a lista:
                        Add_ViewTecnicoObra(cadRow, tecnicoRow);
                    }
                }
                break;

            default:
                break;
            }
        }
        void suggestionPickerRA_BrowseEntidadeInterna(object sender, ref EntidadeInterna ei, TipoEntidadeExterna tee, out bool cancel, out TipoEstado estado)
        {
            estado = TipoEstado.Novo;
            cancel = false;
            var rai = (RegistoAutoridadeInterno)ei;
            var tna = TipoEntidade.GetTipoNoticiaAut(tee);
            FormPickControloAut frmPick = new FormPickControloAut();

            frmPick.Text = "Notícia de autoridade - Pesquisar registo de autoridade";
            frmPick.caList.AllowedNoticiaAut(tna);
            frmPick.caList.ReloadList();

            if (frmPick.caList.Items.Count > 0)
            {
                frmPick.caList.SelectItem(frmPick.caList.Items[0]);
            }

            switch (frmPick.ShowDialog())
            {
            case DialogResult.OK:
                var cadRow = (GISADataset.ControloAutDicionarioRow)frmPick.caList.SelectedItems[0].Tag;
                switch (tna)
                {
                case TipoNoticiaAut.EntidadeProdutora:
                    var produtor = new Model.EntidadesInternas.Produtor();
                    var nRowCA   = cadRow.ControloAutRow.GetNivelControloAutRows()[0].NivelRow;
                    produtor.Codigo = nRowCA.Codigo;
                    rai             = produtor;
                    estado          = Database.Database.IsProdutor(this.correspDocumento.EntidadeInterna.Id, nRowCA.ID) ? TipoEstado.SemAlteracoes : TipoEstado.Novo;
                    break;

                case TipoNoticiaAut.Onomastico:
                    rai = new Model.EntidadesInternas.Onomastico();
                    break;

                case TipoNoticiaAut.Ideografico:
                    rai = new Model.EntidadesInternas.Ideografico();
                    break;

                case TipoNoticiaAut.ToponimicoGeografico:
                    rai = new Model.EntidadesInternas.Geografico();
                    break;

                case TipoNoticiaAut.TipologiaInformacional:
                    rai = new Model.EntidadesInternas.Tipologia();
                    if (this.Documento.Id > 0)
                    {
                        var nRow = GisaDataSetHelper.GetInstance().Nivel.Cast <GISADataset.NivelRow>().Single(r => r.ID == this.Documento.Id);
                        if (GisaDataSetHelper.GetInstance().IndexFRDCA.Cast <GISADataset.IndexFRDCARow>().SingleOrDefault(r => r.IDControloAut == cadRow.IDControloAut && r.IDFRDBase == nRow.GetFRDBaseRows()[0].ID) != null)
                        {
                            estado = TipoEstado.SemAlteracoes;
                        }
                        else if (nRow.GetFRDBaseRows()[0].GetIndexFRDCARows().Select(r => r.ControloAutRow).Count(caRow => caRow.IDTipoNoticiaAut == (long)TipoNoticiaAut.TipologiaInformacional) > 0)
                        {
                            estado = TipoEstado.Editar;
                        }
                        else
                        {
                            estado = TipoEstado.Novo;
                        }
                    }
                    break;
                }
                rai.Titulo = cadRow.DicionarioRow.Termo;
                rai.Estado = TipoEstado.SemAlteracoes;
                rai.Id     = cadRow.IDControloAut;
                ei         = rai;
                break;

            case DialogResult.Cancel:
                cancel = true;
                break;
            }
        }
예제 #9
0
        private void btnAdd_Click(object sender, EventArgs e)
        {
            if (CurrentControloAut.RowState == DataRowState.Detached)
            {
                MessageBox.Show("A notícia de autoridade selecionada como contexto foi " + System.Environment.NewLine + "apagada por outro utilizador e por esse motivo não pode ser editada.", "Edição de Notícia de Autoridade", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            FormPickControloAut frmPick = new FormPickControloAut(CurrentControloAut);

            frmPick.Text = "Notícia de autoridade - Pesquisar entidades produtoras";
            frmPick.caList.AllowedNoticiaAut(TipoNoticiaAut.EntidadeProdutora);
            frmPick.caList.ReloadList();

            if (frmPick.caList.Items.Count > 0)
            {
                frmPick.caList.SelectItem(frmPick.caList.Items[0]);
            }

            GISADataset.ControloAutRow        caRow   = null;
            GISADataset.ControloAutRelRow     carRow  = null;
            GISADataset.TipoControloAutRelRow tcarRow = null;
            switch (frmPick.ShowDialog())
            {
            case DialogResult.OK:
                foreach (ListViewItem li in frmPick.caList.SelectedItems)
                {
                    caRow = ((GISADataset.ControloAutDicionarioRow)li.Tag).ControloAutRow;

                    // Proteger contra relações repetidas
                    string query = string.Format("({0} OR {1}) AND IDTipoRel = {2}", GetRelConstraint(caRow, CurrentControloAut), GetRelConstraint(CurrentControloAut, caRow), System.Enum.Format(typeof(TipoControloAutRel), TipoControloAutRel.Instituicao, "D"));

                    if ((GisaDataSetHelper.GetInstance().ControloAutRel.Select(query)).Length == 0)
                    {
                        tcarRow = (GISADataset.TipoControloAutRelRow)(GisaDataSetHelper.GetInstance().TipoControloAutRel.Select("ID=" + System.Enum.Format(typeof(TipoControloAutRel), TipoControloAutRel.Instituicao, "D"))[0]);
                        carRow  = GisaDataSetHelper.GetInstance().ControloAutRel.NewControloAutRelRow();
                        carRow.ControloAutRowByControloAutControloAutRel      = CurrentControloAut;
                        carRow.ControloAutRowByControloAutControloAutRelAlias = caRow;
                        carRow.TipoControloAutRelRow = tcarRow;
                        carRow["Descricao"]          = DBNull.Value;
                        carRow["InicioAno"]          = DBNull.Value;
                        carRow["InicioMes"]          = DBNull.Value;
                        carRow["InicioDia"]          = DBNull.Value;
                        carRow["FimAno"]             = DBNull.Value;
                        carRow["FimMes"]             = DBNull.Value;
                        carRow["FimDia"]             = DBNull.Value;

                        GisaDataSetHelper.GetInstance().ControloAutRel.AddControloAutRelRow(carRow);

                        PersistencyHelper.VerifyRelExistencePreConcArguments pcArgs = new PersistencyHelper.VerifyRelExistencePreConcArguments();
                        pcArgs.ID        = caRow.ID;
                        pcArgs.IDUpper   = CurrentControloAut.ID;
                        pcArgs.IDTipoRel = Convert.ToInt64(TipoControloAutRel.Instituicao);

                        PersistencyHelper.SaveResult successfulSave = PersistencyHelper.save(GetRelPanelCAControl, pcArgs);
                        PersistencyHelper.cleanDeletedData();

                        if (carRow.RowState == DataRowState.Detached)
                        {
                            MessageBox.Show("Não foi possível estabelecer a relação uma vez que a notícia de autoridade " + System.Environment.NewLine + "que pretende associar foi apagada por outro utilizador.", "Erro ao estabelecer relação", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                        else
                        {
                            AddIdentidadeInstituicao(carRow);

                            // registar inserção
                            ((frmMain)TopLevelControl).CurrentContext.RaiseRegisterModificationEvent(CurrentControloAut);

                            if (successfulSave == PersistencyHelper.SaveResult.successful)
                            {
                                UpdateCA(CurrentControloAut);
                                UpdateCA(caRow);
                            }
                        }
                    }
                    else
                    {
                        MessageBox.Show("A relação que pretende adicionar já existe.", "Erro ao estabelecer relação", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                    }
                }
                break;

            case DialogResult.Cancel:
                break;
            }
        }