Exemplo n.º 1
0
		private static string getCatCode(GISADataset.TipoNoticiaAutRow tnaRow)
		{
			if (tnaRow.ID == Convert.ToInt64(TipoNoticiaAut.Diploma))
			{
				return "DP";
			}
			else if (tnaRow.ID == Convert.ToInt64(TipoNoticiaAut.Modelo))
			{
				return "MD";
			}
			else
			{
				return "CA";
			}
		}
Exemplo n.º 2
0
		public void AllowedNoticiaAut(params TipoNoticiaAut[] NoticiaAutArray)
		{
			if (AllowedNoticiaAutLocked)
				return;

			string QueryFilter = string.Empty;

			foreach (TipoNoticiaAut tna in NoticiaAutArray)
			{
				if (QueryFilter.Length > 0)
					QueryFilter = QueryFilter + " OR ";

				QueryFilter = QueryFilter + "ID=" + System.Enum.Format(typeof(TipoNoticiaAut), tna, "D");
			}

			GISADataset.TipoNoticiaAutRow allNoticiaAut = null;
			allNoticiaAut = GisaDataSetHelper.GetInstance().TipoNoticiaAut. NewTipoNoticiaAutRow();
			allNoticiaAut.ID = -1;
			allNoticiaAut.Designacao = "<Todos>";

			DataRow[] DataRows = GisaDataSetHelper.GetInstance().TipoNoticiaAut.Select(QueryFilter);
			GISADataset.TipoNoticiaAutRow[] DataRowsEx = null;
			DataRowsEx = new GISADataset.TipoNoticiaAutRow[DataRows.Length + 1];
			DataRowsEx[0] = allNoticiaAut;
			Array.Copy(DataRows, 0, DataRowsEx, 1, DataRows.Length);

            cbNoticiaAut.BindingContext = new BindingContext();
			cbNoticiaAut.DataSource = DataRowsEx;
			cbNoticiaAut.DisplayMember = "Designacao";
            cbNoticiaAut.ValueMember = "ID";
			cbNoticiaAut.SelectedIndex = 0;
			Debug.WriteLine("Selected item: " + ((cbNoticiaAut.SelectedItem == null) ? "" : cbNoticiaAut.SelectedItem.ToString()).ToString());

			if (Array.IndexOf(NoticiaAutArray, TipoNoticiaAut.EntidadeProdutora) != -1)
			{
				if (colDatasExistencia.ListView == null)
                    this.lstVwPaginated.Columns.Add(colDatasExistencia);
			}
			else
			{
				if (colDatasExistencia.ListView != null)
                    this.lstVwPaginated.Columns.Remove(colDatasExistencia);
			}
		}
        void suggestionPickerRA_CreateEntidadeInterna(object sender, ref EntidadeInterna ei, TipoEntidadeExterna tee, out bool cancel, out TipoEstado estado)
        {
            cancel = false;
            estado = TipoEstado.Novo;
            FormCreateControloAut form = null;
            var rai = (RegistoAutoridadeInterno)ei;
            var tna = TipoEntidade.GetTipoNoticiaAut(tee);

            if (tna == TipoNoticiaAut.EntidadeProdutora)
            {
                form = new FormCreateEntidadeProdutora();
            }
            else
            {
                form = new FormCreateControloAut();
            }

            if (tna == TipoNoticiaAut.Onomastico)
            {
                form.SetOptionalControlsVisible(true);
                form.NIF = ei != null ? ((Model.EntidadesInternas.Onomastico)ei).Codigo : "";
            }

            GISADataset.TipoNoticiaAutRow allNoticiaAut = null;
            allNoticiaAut            = GisaDataSetHelper.GetInstance().TipoNoticiaAut.NewTipoNoticiaAutRow();
            allNoticiaAut.ID         = -1;
            allNoticiaAut.Designacao = "<Todos>";

            List <GISADataset.TipoNoticiaAutRow> rows = new List <GISADataset.TipoNoticiaAutRow>();

            rows.Add(allNoticiaAut);
            rows.AddRange(GisaDataSetHelper.GetInstance().TipoNoticiaAut.Cast <GISADataset.TipoNoticiaAutRow>().Where(r => r.ID == (long)tna));

            form.cbNoticiaAut.BeginUpdate();
            form.cbNoticiaAut.DataSource    = rows;
            form.cbNoticiaAut.DisplayMember = "Designacao";
            form.cbNoticiaAut.EndUpdate();
            if (form.cbNoticiaAut.Items.Count == 2)
            {
                form.cbNoticiaAut.SelectedIndex = 1;
                form.cbNoticiaAut.Enabled       = false;
            }
            form.LoadData(true);

            switch (form.ShowDialog())
            {
            case DialogResult.OK:
                var termo = form.ListTermos.ValidAuthorizedForm.Replace("'", "''");
                switch (tna)
                {
                case TipoNoticiaAut.EntidadeProdutora:
                    var produtor = new Model.EntidadesInternas.Produtor();
                    produtor.Codigo = ((FormCreateEntidadeProdutora)form).txtCodigo.Text;
                    rai             = produtor;
                    break;

                case TipoNoticiaAut.Onomastico:
                    rai = new Model.EntidadesInternas.Onomastico();
                    ((Model.EntidadesInternas.Onomastico)rai).Codigo = form.NIF;
                    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();
                    break;
                }
                rai.Titulo = termo;
                rai.Estado = TipoEstado.Novo;
                ei         = this.InternalEntitiesLst.AddInternalEntity(rai);
                break;

            case DialogResult.Cancel:
                cancel = true;
                break;
            }
        }
Exemplo n.º 4
0
		// Método que trata da atribuição de uma designação a um Diploma/Modelo durante uma criação ou edição
		private GISADataset.ControloAutDicionarioRow manageDesignacaoDiplomaModelo(GISADataset.ControloAutDicionarioRow cadRow, string termo, GISADataset.TipoNoticiaAutRow TipoNoticiaAutRow, GISADataset.ControloAutRow carow, GISADataset.TipoControloAutFormaRow tcafRowAutorizado)
		{

			// NOTA: é criada na mesma uma linha Dicionario; posteriormente no algoritmo que trata os
			//       conflitos de concorrência vai proceder à reutilização da linha existente na
			//       base de dados
			if (cadRow != null)
			{
				// se por algum motivo a transacção onde este método está inserido voltar a ser executada,
				// mfaPca.cadRow já não será nothing e por esse motivo deverá ser apagada a existente 
				// em memória seja qual for o seu rowstate
				GisaDataSetHelper.GetInstance().ControloAutDicionario.RemoveControloAutDicionarioRow(cadRow);
				GisaDataSetHelper.GetInstance().Dicionario.RemoveDicionarioRow(cadRow.DicionarioRow);
			}
			else if (GisaDataSetHelper.GetInstance().Dicionario.Select("Termo='" + termo.Replace("'", "''") + "' AND CatCode='" + getCatCode(carow.TipoNoticiaAutRow) + "'").Length > 0)
			{
				GISADataset.DicionarioRow dicionarioRow = (GISADataset.DicionarioRow)(GisaDataSetHelper.GetInstance().Dicionario.Select("Termo='" + termo.Replace("'", "''") + "' AND CatCode='" + getCatCode(carow.TipoNoticiaAutRow) + "'")[0]);
				GisaDataSetHelper.GetInstance().Dicionario.RemoveDicionarioRow(dicionarioRow);
			}
			GISADataset.DicionarioRow dRow = GisaDataSetHelper.GetInstance().Dicionario.AddDicionarioRow(termo, getCatCode(carow.TipoNoticiaAutRow), new byte[]{}, 0);
			return GisaDataSetHelper.GetInstance().ControloAutDicionario.AddControloAutDicionarioRow(carow, dRow, tcafRowAutorizado, new byte[]{}, 0);
		}
Exemplo n.º 5
0
		private void ToolBarButtonClickEvent(object sender, ToolBarButtonClickEventArgs e)
		{
			// obter o tipo de noticia em causa
			GISADataset.TipoNoticiaAutRow tnaRow = null;
			//tnaRow = DirectCast(GisaDataSetHelper.GetInstance().TipoNoticiaAut.Select("ID=" + DomainValuesHelper.stringifyEnumValue(TipoNoticiaAut.Diploma))(0), GISADataset.TipoNoticiaAutRow)
			tnaRow = (GISADataset.TipoNoticiaAutRow)caList.cbNoticiaAut.SelectedItem;
			if (tnaRow.ID == -1 && caList.cbNoticiaAut.Items.Count == 2)
			{
				tnaRow = (GISADataset.TipoNoticiaAutRow)(caList.cbNoticiaAut.Items[1]);
			}

			Trace.Assert(tnaRow != null);
			Trace.Assert(! (tnaRow.ID == -1));

			if (e.Button == ToolBarButtonNew)
			{
				FormCreateDiplomaModelo form = new FormCreateDiplomaModelo();
				if (tnaRow.ID == Convert.ToInt64(TipoNoticiaAut.Diploma))
				{
					form.Text = "Criar diploma";
				}
				else if (tnaRow.ID == Convert.ToInt64(TipoNoticiaAut.Modelo))
				{
					form.Text = "Criar modelo";
				}
				switch (form.ShowDialog())
				{
					case System.Windows.Forms.DialogResult.OK:

						//adicionar o novo controlo de autoridade ao modelo de dados e à interface
						GISADataset.ControloAutRow caRow = null;
						caRow = GisaDataSetHelper.GetInstance().ControloAut.NewControloAutRow();
						caRow.Autorizado = false;
						caRow.Completo = false;
						caRow.IDTipoNoticiaAut = tnaRow.ID;
						caRow.NotaExplicativa = "";
						caRow["IDIso639p2"] = DBNull.Value;
						caRow["IDIso15924"] = DBNull.Value;
						caRow.ChaveColectividade = "";
						caRow.ChaveRegisto = "";
						caRow.RegrasConvencoes = "";
						caRow.Observacoes = "";
						caRow.DescContextoGeral = "";
						caRow.DescEnquadramentoLegal = "";
						caRow.DescEstatutoLegal = "";
						caRow.DescEstruturaInterna = "";
						caRow.DescOcupacoesActividades = "";
						caRow.DescHistoria = "";
						caRow.DescOutraInformacaoRelevante = "";
						caRow.DescZonaGeografica = "";

						try
						{
							GisaDataSetHelper.GetInstance().ControloAut.AddControloAutRow(caRow);
							PersistencyHelper.ManageFormasAutorizadasPreConcArguments args = new PersistencyHelper.ManageFormasAutorizadasPreConcArguments();
							args.termo = form.Designacao.Trim().Replace("'", "''");
							args.caRowID = caRow.ID;

							PersistencyHelper.save(setNewTermo, args);
							PersistencyHelper.cleanDeletedData();

							caList.cbNoticiaAut.SelectedItem = tnaRow;
							caList.ReloadList();

							if (args.message.Length > 0)
							{
								MessageBox.Show(args.message, form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
							}

							if (args.cadRow != null)
                                caList.SelectItem(args.cadRow);
						}
						catch (Exception ex)
						{
							Trace.WriteLine(ex);
							throw;
						}

						break;
					case System.Windows.Forms.DialogResult.Cancel:

					break;
					default:

					break;
				}
			}
			else if (e.Button == ToolBarButtonEdit)
			{
				GISADataset.ControloAutDicionarioRow cad = null;
				GISADataset.DicionarioRow d = null;
				cad = (GISADataset.ControloAutDicionarioRow)(caList.SelectedItems[0].Tag);
				Debug.Assert(cad.IDTipoControloAutForma == Convert.ToInt64(TipoControloAutForma.FormaAutorizada));
				d = cad.DicionarioRow;

				FormCreateDiplomaModelo form = new FormCreateDiplomaModelo();
				if (tnaRow.ID == Convert.ToInt64(TipoNoticiaAut.Diploma))
				{
					form.Text = "Editar diploma";
				}
				else if (tnaRow.ID == Convert.ToInt64(TipoNoticiaAut.Modelo))
				{
					form.Text = "Editar modelo";
				}
				form.Designacao = d.Termo;
				switch (form.ShowDialog())
				{
					case System.Windows.Forms.DialogResult.OK:
						try
						{
							PersistencyHelper.ManageFormasAutorizadasPreConcArguments args = new PersistencyHelper.ManageFormasAutorizadasPreConcArguments();
							args.termo = form.Designacao.Trim().Replace("'", "''");
							args.caRowID = cad.ControloAutRow.ID;

							PersistencyHelper.save(setNewTermo, args);
							PersistencyHelper.cleanDeletedData();

							caList.ReloadList();

							if (args.message.Length > 0)
								MessageBox.Show(args.message, form.Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);

							if (args.cadRow != null)
                                caList.SelectItem(args.cadRow);
						}
						catch (Exception ex)
						{
							Trace.WriteLine(ex);
							throw;
						}
						break;
					case System.Windows.Forms.DialogResult.Cancel:

					break;
					default:

					break;
				}
			}
			else if (e.Button == ToolBarButtonDelete)
				DeleteControloAut(caList, "Eliminar diplomas/modelos", "Os items serão removidos apesar das associações existentes. Pretende continuar?", "Deseja apagar os elementos selecionados?");
			else if (e.Button == ToolBarButtonFilter)
                caList.FilterVisible = ToolBarButtonFilter.Pushed;
			else
				Debug.Assert(false, "Unexpected button clicked in ToolBar.");
		}