コード例 #1
0
		// Neste caso adiciona apenas um 
		protected override ArrayList GetPossibleSubItems(GISADataset.NivelRow nRow)
		{
			ArrayList subItems = new ArrayList();
			TipoNivelRelacionado.PossibleSubNivel subItem = new TipoNivelRelacionado.PossibleSubNivel();
			subItem.SubIDTipoNivelRelacionado = TipoNivelRelacionadoRow.ID;
			subItem.Designacao = TipoNivelRelacionadoRow.Designacao;
			subItems.Add(subItem);
			return subItems;
		}
コード例 #2
0
        private void btnEdit_Click(object sender, EventArgs e)
        {
            DataRow relRow = null;

            relRow = (DataRow)(lstVwRelacoes.SelectedItems[0].Tag);

            // verificar se tanto a entidade produtora seleccionada como contexto como a relação seleccionada
            // para edição não foram apagadas concorrentemente por outro utilizador
            if (CurrentControloAut.RowState == DataRowState.Detached)
            {
                MessageBox.Show("Não é possível editar qualquer relação da entidade produtora " + System.Environment.NewLine + "selecionada uma vez que foi apagada por outro utilizador.", "Edição de Relações", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                lstVwRelacoes.SelectedItems.Clear();
                lstVwRelacoes.Items.Clear();
                return;
            }
            else if (relRow.RowState == DataRowState.Detached)
            {
                MessageBox.Show("Não é possível editar a relação selecionada uma " + System.Environment.NewLine + "vez que foi apagada por outro utilizador.", "Edição de Relações", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                ListViewItem lvItem = lstVwRelacoes.SelectedItems[0];
                lstVwRelacoes.SelectedItems.Clear();
                lstVwRelacoes.Items.Remove(lvItem);
                return;
            }

            GISADataset.ControloAutRow        caRow  = null;
            GISADataset.ControloAutRelRow     carRow = null;
            GISADataset.RelacaoHierarquicaRow rhRow  = null;

            FormControloAutRel frm = null;

            if (relRow is GISADataset.ControloAutRelRow)
            {
                frm = new FormControloAutRel(CurrentControloAut, ((frmMain)TopLevelControl).MasterPanel);

                carRow = (GISADataset.ControloAutRelRow)relRow;
                if (carRow.ControloAutRowByControloAutControloAutRel == CurrentControloAut)
                {
                    caRow = carRow.ControloAutRowByControloAutControloAutRelAlias;
                }
                else if (carRow.ControloAutRowByControloAutControloAutRelAlias == CurrentControloAut)
                {
                    caRow = carRow.ControloAutRowByControloAutControloAutRel;
                    // nas edições, ao visualizar uma relação pelo outro extremo é necessário alterar a designação da relação apresentada
                    frm.relacaoCA.cbTipoControloAutRel.DisplayMember = "Designacao";
                }
            }
            else if (relRow is GISADataset.RelacaoHierarquicaRow)
            {
                rhRow = (GISADataset.RelacaoHierarquicaRow)relRow;
                caRow = rhRow.NivelRowByNivelRelacaoHierarquica.GetNivelControloAutRows()[0].ControloAutRow;
                // Se estivermos a ver o extremo errado da relação hierarquica trocamos para o outro extremo
                if (CurrentControloAut == caRow)
                {
                    caRow = rhRow.NivelRowByNivelRelacaoHierarquicaUpper.GetNivelControloAutRows()[0].ControloAutRow;

                    frm = new FormControloAutRel(caRow, ((frmMain)TopLevelControl).MasterPanel);
                    // nas edições, ao visualizar uma relação pelo outro extremo é necessário alterar a designação da relação apresentada
                    frm.relacaoCA.cbTipoControloAutRel.DisplayMember = "Designacao";
                }
                else
                {
                    frm = new FormControloAutRel(CurrentControloAut, ((frmMain)TopLevelControl).MasterPanel);
                }
            }

            GISADataset.ControloAutDicionarioRow cadRow = null;
            string termo = null;

            cadRow = ControloAutHelper.getFormaAutorizada(caRow);
            termo  = cadRow.DicionarioRow.Termo;

            frm.ContextRel = relRow;
            frm.caList.AllowedNoticiaAut(TipoNoticiaAut.EntidadeProdutora);
            frm.caList.SelectedItems.Clear();
            frm.caList.txtFiltroDesignacao.Text = termo.Trim();
            frm.caList.ReloadList();
            frm.caList.SelectItem(cadRow);

            frm.caList.txtFiltroDesignacao.Clear();
            // popular datas
            frm.relacaoCA.dtRelacaoInicio.ValueYear  = GisaDataSetHelper.GetDBNullableText(relRow, "InicioAno");
            frm.relacaoCA.dtRelacaoInicio.ValueMonth = GisaDataSetHelper.GetDBNullableText(relRow, "InicioMes");
            frm.relacaoCA.dtRelacaoInicio.ValueDay   = GisaDataSetHelper.GetDBNullableText(relRow, "InicioDia");
            frm.relacaoCA.dtRelacaoFim.ValueYear     = GisaDataSetHelper.GetDBNullableText(relRow, "FimAno");
            frm.relacaoCA.dtRelacaoFim.ValueMonth    = GisaDataSetHelper.GetDBNullableText(relRow, "FimMes");
            frm.relacaoCA.dtRelacaoFim.ValueDay      = GisaDataSetHelper.GetDBNullableText(relRow, "FimDia");
            frm.relacaoCA.txtDescricao.Text          = GisaDataSetHelper.GetDBNullableText(relRow, "Descricao");

            // Encontrar e selecionar o TipoControloAutRel correcto
            if (relRow is GISADataset.ControloAutRelRow)
            {
                foreach (object drView in frm.relacaoCA.cbTipoControloAutRel.Items)
                {
                    if (((GISADataset.TipoControloAutRelRow)drView).ID == carRow.TipoControloAutRelRow.ID)
                    {
                        frm.relacaoCA.cbTipoControloAutRel.SelectedItem = drView;
                    }
                }
            }
            else if (relRow is GISADataset.RelacaoHierarquicaRow)
            {
                foreach (object drView in frm.relacaoCA.cbTipoControloAutRel.Items)
                {
                    if (((GISADataset.TipoControloAutRelRow)drView).ID == Convert.ToInt64(TipoControloAutRel.Hierarquica))
                    {
                        frm.relacaoCA.cbTipoControloAutRel.SelectedItem = drView;
                        break;
                    }
                }

                bool foundTipoNivel = false;
                foreach (TipoNivelRelacionado.PossibleSubNivel subNivel in frm.relacaoCA.cbTipoNivel.Items)
                {
                    if (subNivel.SubIDTipoNivelRelacionado == rhRow.IDTipoNivelRelacionado)
                    {
                        frm.relacaoCA.cbTipoNivel.SelectedItem = subNivel;
                        foundTipoNivel = true;
                        break;
                    }
                }

                // O tipo de nivel já definido pode nao ser encontrado entre os possiveis
                // se o tipo de nivel do pai tiver entretanto também ele mudado. Nesse caso
                // adicionamos mais esse tipo de nivel de forma a ser mantida a selecção
                // anteriormente existente.
                if (!foundTipoNivel)
                {
                    ArrayList data = null;
                    data = (ArrayList)frm.relacaoCA.cbTipoNivel.DataSource;
                    TipoNivelRelacionado.PossibleSubNivel subTipoNivel = null;
                    string inicioAno = string.Empty;
                    string inicioMes = string.Empty;
                    string inicioDia = string.Empty;
                    string fimAno    = string.Empty;
                    string fimMes    = string.Empty;
                    string fimDia    = string.Empty;

                    if (!rhRow.IsInicioAnoNull())
                    {
                        inicioAno = rhRow.InicioAno;
                    }
                    if (!rhRow.IsInicioMesNull())
                    {
                        inicioMes = rhRow.InicioMes;
                    }
                    if (!rhRow.IsInicioDiaNull())
                    {
                        inicioDia = rhRow.InicioDia;
                    }

                    if (!rhRow.IsFimAnoNull())
                    {
                        fimAno = rhRow.FimAno;
                    }
                    if (!rhRow.IsFimMesNull())
                    {
                        fimMes = rhRow.FimMes;
                    }
                    if (!rhRow.IsFimDiaNull())
                    {
                        fimDia = rhRow.FimDia;
                    }

                    subTipoNivel = new TipoNivelRelacionado.PossibleSubNivel(rhRow.IDTipoNivelRelacionado, rhRow.TipoNivelRelacionadoRow.Designacao, inicioAno, inicioMes, inicioDia, fimAno, fimMes, fimDia, true);
                    int idx = data.Add(subTipoNivel);

                    frm.relacaoCA.cbTipoNivel.ImageIndexes.Add(SharedResourcesOld.CurrentSharedResources.NivelImageBase(System.Convert.ToInt32(subTipoNivel.SubIDTipoNivelRelacionado)));
                    frm.relacaoCA.cbTipoNivel.DataSource    = null;
                    frm.relacaoCA.cbTipoNivel.DataSource    = data;
                    frm.relacaoCA.cbTipoNivel.DisplayMember = "DesignacaoComposta";
                    frm.relacaoCA.cbTipoNivel.SelectedItem  = subTipoNivel;
                }
            }
            RetrieveSelection(frm, relRow);
        }
コード例 #3
0
ファイル: PanelCARelacoes.cs プロジェクト: aureliopires/gisa
		private void btnEdit_Click(object sender, EventArgs e)
		{

			DataRow relRow = null;
			relRow = (DataRow)(lstVwRelacoes.SelectedItems[0].Tag);

			// verificar se tanto a entidade produtora seleccionada como contexto como a relação seleccionada
			// para edição não foram apagadas concorrentemente por outro utilizador
			if (CurrentControloAut.RowState == DataRowState.Detached)
			{
				MessageBox.Show("Não é possível editar qualquer relação da entidade produtora " + System.Environment.NewLine + "selecionada uma vez que foi apagada por outro utilizador.", "Edição de Relações", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				lstVwRelacoes.SelectedItems.Clear();
				lstVwRelacoes.Items.Clear();
				return;
			}
			else if (relRow.RowState == DataRowState.Detached)
			{
				MessageBox.Show("Não é possível editar a relação selecionada uma " + System.Environment.NewLine + "vez que foi apagada por outro utilizador.", "Edição de Relações", MessageBoxButtons.OK, MessageBoxIcon.Warning);
				ListViewItem lvItem = lstVwRelacoes.SelectedItems[0];
				lstVwRelacoes.SelectedItems.Clear();
				lstVwRelacoes.Items.Remove(lvItem);
				return;
			}

			GISADataset.ControloAutRow caRow = null;
			GISADataset.ControloAutRelRow carRow = null;
			GISADataset.RelacaoHierarquicaRow rhRow = null;

			FormControloAutRel frm = null;

			if (relRow is GISADataset.ControloAutRelRow)
			{
                frm = new FormControloAutRel(CurrentControloAut, ((frmMain)TopLevelControl).MasterPanel);

				carRow = (GISADataset.ControloAutRelRow)relRow;
				if (carRow.ControloAutRowByControloAutControloAutRel == CurrentControloAut)
					caRow = carRow.ControloAutRowByControloAutControloAutRelAlias;
				else if (carRow.ControloAutRowByControloAutControloAutRelAlias == CurrentControloAut)
				{
					caRow = carRow.ControloAutRowByControloAutControloAutRel;
					// nas edições, ao visualizar uma relação pelo outro extremo é necessário alterar a designação da relação apresentada
					frm.relacaoCA.cbTipoControloAutRel.DisplayMember = "Designacao";
				}
			}
			else if (relRow is GISADataset.RelacaoHierarquicaRow)
			{
				rhRow = (GISADataset.RelacaoHierarquicaRow)relRow;
				caRow = rhRow.NivelRowByNivelRelacaoHierarquica.GetNivelControloAutRows()[0].ControloAutRow;
				// Se estivermos a ver o extremo errado da relação hierarquica trocamos para o outro extremo
				if (CurrentControloAut == caRow)
				{
					caRow = rhRow.NivelRowByNivelRelacaoHierarquicaUpper.GetNivelControloAutRows()[0].ControloAutRow;

                    frm = new FormControloAutRel(caRow, ((frmMain)TopLevelControl).MasterPanel);
					// nas edições, ao visualizar uma relação pelo outro extremo é necessário alterar a designação da relação apresentada
					frm.relacaoCA.cbTipoControloAutRel.DisplayMember = "Designacao";
				}
				else
                    frm = new FormControloAutRel(CurrentControloAut, ((frmMain)TopLevelControl).MasterPanel);
			}

			GISADataset.ControloAutDicionarioRow cadRow = null;
			string termo = null;
			cadRow = ControloAutHelper.getFormaAutorizada(caRow);
			termo = cadRow.DicionarioRow.Termo;

			frm.ContextRel = relRow;
			frm.caList.AllowedNoticiaAut(TipoNoticiaAut.EntidadeProdutora);
			frm.caList.SelectedItems.Clear();
			frm.caList.txtFiltroDesignacao.Text = termo.Trim();
			frm.caList.ReloadList();
            frm.caList.SelectItem(cadRow);

			frm.caList.txtFiltroDesignacao.Clear();
			// popular datas
			frm.relacaoCA.dtRelacaoInicio.ValueYear = GisaDataSetHelper.GetDBNullableText(relRow, "InicioAno");
			frm.relacaoCA.dtRelacaoInicio.ValueMonth = GisaDataSetHelper.GetDBNullableText(relRow, "InicioMes");
			frm.relacaoCA.dtRelacaoInicio.ValueDay = GisaDataSetHelper.GetDBNullableText(relRow, "InicioDia");
			frm.relacaoCA.dtRelacaoFim.ValueYear = GisaDataSetHelper.GetDBNullableText(relRow, "FimAno");
			frm.relacaoCA.dtRelacaoFim.ValueMonth = GisaDataSetHelper.GetDBNullableText(relRow, "FimMes");
			frm.relacaoCA.dtRelacaoFim.ValueDay = GisaDataSetHelper.GetDBNullableText(relRow, "FimDia");
			frm.relacaoCA.txtDescricao.Text = GisaDataSetHelper.GetDBNullableText(relRow, "Descricao");

			// Encontrar e selecionar o TipoControloAutRel correcto
			if (relRow is GISADataset.ControloAutRelRow)
			{
				foreach (object drView in frm.relacaoCA.cbTipoControloAutRel.Items)
					if (((GISADataset.TipoControloAutRelRow)drView).ID == carRow.TipoControloAutRelRow.ID)
						frm.relacaoCA.cbTipoControloAutRel.SelectedItem = drView;
			}
			else if (relRow is GISADataset.RelacaoHierarquicaRow)
			{
				foreach (object drView in frm.relacaoCA.cbTipoControloAutRel.Items)
				{
					if (((GISADataset.TipoControloAutRelRow)drView).ID == Convert.ToInt64(TipoControloAutRel.Hierarquica))
					{
						frm.relacaoCA.cbTipoControloAutRel.SelectedItem = drView;
						break;
					}
				}

				bool foundTipoNivel = false;
				foreach (TipoNivelRelacionado.PossibleSubNivel subNivel in frm.relacaoCA.cbTipoNivel.Items)
				{
					if (subNivel.SubIDTipoNivelRelacionado == rhRow.IDTipoNivelRelacionado)
					{
						frm.relacaoCA.cbTipoNivel.SelectedItem = subNivel;
						foundTipoNivel = true;
						break;
					}
				}

				// O tipo de nivel já definido pode nao ser encontrado entre os possiveis 
				// se o tipo de nivel do pai tiver entretanto também ele mudado. Nesse caso 
				// adicionamos mais esse tipo de nivel de forma a ser mantida a selecção 
				// anteriormente existente.
				if (! foundTipoNivel)
				{
					ArrayList data = null;
					data = (ArrayList)frm.relacaoCA.cbTipoNivel.DataSource;
					TipoNivelRelacionado.PossibleSubNivel subTipoNivel = null;
					string inicioAno = string.Empty;
					string inicioMes = string.Empty;
					string inicioDia = string.Empty;
					string fimAno = string.Empty;
					string fimMes = string.Empty;
					string fimDia = string.Empty;

					if (! rhRow.IsInicioAnoNull())
						inicioAno = rhRow.InicioAno;
					if (! rhRow.IsInicioMesNull())
						inicioMes = rhRow.InicioMes;
					if (! rhRow.IsInicioDiaNull())
						inicioDia = rhRow.InicioDia;

					if (! rhRow.IsFimAnoNull())
						fimAno = rhRow.FimAno;
					if (! rhRow.IsFimMesNull())
						fimMes = rhRow.FimMes;
                    if (! rhRow.IsFimDiaNull())
						fimDia = rhRow.FimDia;

					subTipoNivel = new TipoNivelRelacionado.PossibleSubNivel(rhRow.IDTipoNivelRelacionado, rhRow.TipoNivelRelacionadoRow.Designacao, inicioAno, inicioMes, inicioDia, fimAno, fimMes, fimDia, true);
					int idx = data.Add(subTipoNivel);

					frm.relacaoCA.cbTipoNivel.ImageIndexes.Add(SharedResourcesOld.CurrentSharedResources.NivelImageBase(System.Convert.ToInt32(subTipoNivel.SubIDTipoNivelRelacionado)));
					frm.relacaoCA.cbTipoNivel.DataSource = null;
					frm.relacaoCA.cbTipoNivel.DataSource = data;
					frm.relacaoCA.cbTipoNivel.DisplayMember = "DesignacaoComposta";
					frm.relacaoCA.cbTipoNivel.SelectedItem = subTipoNivel;
				}
			}
			RetrieveSelection(frm, relRow);
		}