Exemplo n.º 1
0
        private void RetrieveSelection(FormControloAutRel frm, DataRow relRow)
        {
            try
            {
                if (relRow != null)                 // edição
                {
                    frm.SetEditMode();
                }

                frm.ShowDialog();

                GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                try
                {
                    LoadData(CurrentControloAut, ho.Connection);
                    ModelToView();
                }
                finally
                {
                    ho.Dispose();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex);
                throw ex;
            }
        }
Exemplo n.º 2
0
		protected override void AcceptContents(object Value)
		{
			this.ControloAutRow = (GISADataset.ControloAutRow)Value;

			if (FRDBaseRow != null)
			{
				NotPresentInIndexResults indexPresence = NotPresentInIndex(ControloAutRow);
				switch (indexPresence)
				{
					case NotPresentInIndexResults.NotPresentInIndex:
					{
                        TempIndexFRDCA = NewRow(ControloAutRow);
                                                
						GISADataset.ControloAutDicionarioRow[] cadRows = null;
						cadRows = (GISADataset.ControloAutDicionarioRow[])(GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0} AND IDTipoControloAutForma = {1:d}", ControloAutRow.ID, TipoControloAutForma.FormaAutorizada)));
						if (cadRows.Length == 0)
						{
							GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
							try
							{
								DBAbstractDataLayer.DataAccessRules.ControloAutRule.Current.LoadFormaAutorizada(ControloAutRow.ID, GisaDataSetHelper.GetInstance(), ho.Connection);
							}
							finally
							{
								ho.Dispose();
							}
							cadRows = (GISADataset.ControloAutDicionarioRow[])(GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0} AND IDTipoControloAutForma = {1:d}", ControloAutRow.ID, TipoControloAutForma.FormaAutorizada)));
						}
						if (cadRows.Length > 0)
						{
							DisplayFormaAutorizada(cadRows[0]);
						}
						break;
					}
					case NotPresentInIndexResults.PresentInIndex:
					{
						MessageBox.Show("Não é possível a existência de items repetidos.", "Adição", MessageBoxButtons.OK, MessageBoxIcon.Warning);
						break;
					}
					case NotPresentInIndexResults.PresentInIndexDeleted:
					{
						GISADataset.ControloAutDicionarioRow[] cadRows = null;
						TempIndexFRDCA = GetRow();
						cadRows = (GISADataset.ControloAutDicionarioRow[])(GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0} AND IDTipoControloAutForma = {1:d}", ControloAutRow.ID, TipoControloAutForma.FormaAutorizada)));
						if (cadRows.Length == 0)
						{
							GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
							try
							{
								DBAbstractDataLayer.DataAccessRules.ControloAutRule.Current.LoadFormaAutorizada(ControloAutRow.ID, GisaDataSetHelper.GetInstance(), ho.Connection);
							}
							finally
							{
								ho.Dispose();
							}
							cadRows = (GISADataset.ControloAutDicionarioRow[])(GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0} AND IDTipoControloAutForma = {1:d}", ControloAutRow.ID, TipoControloAutForma.FormaAutorizada)));
						}
						if (cadRows.Length > 0)
						{
							DisplayFormaAutorizada(cadRows[0]);
						}
						break;
					}
				}
			}
			else if (this.ControloAutRow != null)
			{
				// TODO: FIXME legibilidade
				// Determinar se Value já se encontra em ControloAutRel
				try
				{
					// make sure we do not relate an item to itself
					if (ControloAutRow.ID == this.ControloAutRow.ID)
					{
						return;
					}

					// If the dropped item was not already added to the selected
					// item (or vice versa)
					if (GisaDataSetHelper.GetInstance().ControloAutRel.Select(GetRelConstraint(ControloAutRow, this.ControloAutRow) + " OR " + GetRelConstraint(this.ControloAutRow, ControloAutRow)).Length == 0)
					{

						// adicionar nova relação
                        FormControloAutRel frm = new FormControloAutRel(ControloAutRow, parent);

						switch (frm.ShowDialog())
						{
							case DialogResult.OK:
								TempIndexFRDCA = GisaDataSetHelper.GetInstance().ControloAutRel.NewControloAutRelRow();
                                GISADataset.ControloAutRelRow tempWith1 = (GISADataset.ControloAutRelRow)TempIndexFRDCA;
								tempWith1.IDControloAut = this.ControloAutRow.ID;
								tempWith1.IDControloAutAlias = ControloAutRow.ID;
								tempWith1["IDTipoRel"] = ((GISADataset.TipoControloAutRelRow)(((DataRowView)frm.relacaoCA.cbTipoControloAutRel.SelectedItem).Row)).ID;
								tempWith1.Descricao = frm.relacaoCA.txtDescricao.Text;
								GisaDataSetHelper.GetInstance().ControloAutRel.AddControloAutRelRow((GISADataset.ControloAutRelRow)TempIndexFRDCA);
								break;
							case DialogResult.Cancel:
								return;
						}

						GisaDataSetHelper. VisitControloAutDicionario(ControloAutRow, DisplayFormaAutorizada);
					}
				}
				catch (Exception ex)
				{
					Trace.WriteLine(ex);
				}
			}
		}
Exemplo n.º 3
0
        protected override void AcceptContents(object Value)
        {
            this.ControloAutRow = (GISADataset.ControloAutRow)Value;

            if (FRDBaseRow != null)
            {
                NotPresentInIndexResults indexPresence = NotPresentInIndex(ControloAutRow);
                switch (indexPresence)
                {
                case NotPresentInIndexResults.NotPresentInIndex:
                {
                    TempIndexFRDCA = NewRow(ControloAutRow);

                    GISADataset.ControloAutDicionarioRow[] cadRows = null;
                    cadRows = (GISADataset.ControloAutDicionarioRow[])(GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0} AND IDTipoControloAutForma = {1:d}", ControloAutRow.ID, TipoControloAutForma.FormaAutorizada)));
                    if (cadRows.Length == 0)
                    {
                        GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                        try
                        {
                            DBAbstractDataLayer.DataAccessRules.ControloAutRule.Current.LoadFormaAutorizada(ControloAutRow.ID, GisaDataSetHelper.GetInstance(), ho.Connection);
                        }
                        finally
                        {
                            ho.Dispose();
                        }
                        cadRows = (GISADataset.ControloAutDicionarioRow[])(GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0} AND IDTipoControloAutForma = {1:d}", ControloAutRow.ID, TipoControloAutForma.FormaAutorizada)));
                    }
                    if (cadRows.Length > 0)
                    {
                        DisplayFormaAutorizada(cadRows[0]);
                    }
                    break;
                }

                case NotPresentInIndexResults.PresentInIndex:
                {
                    MessageBox.Show("Não é possível a existência de items repetidos.", "Adição", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    break;
                }

                case NotPresentInIndexResults.PresentInIndexDeleted:
                {
                    GISADataset.ControloAutDicionarioRow[] cadRows = null;
                    TempIndexFRDCA = GetRow();
                    cadRows        = (GISADataset.ControloAutDicionarioRow[])(GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0} AND IDTipoControloAutForma = {1:d}", ControloAutRow.ID, TipoControloAutForma.FormaAutorizada)));
                    if (cadRows.Length == 0)
                    {
                        GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
                        try
                        {
                            DBAbstractDataLayer.DataAccessRules.ControloAutRule.Current.LoadFormaAutorizada(ControloAutRow.ID, GisaDataSetHelper.GetInstance(), ho.Connection);
                        }
                        finally
                        {
                            ho.Dispose();
                        }
                        cadRows = (GISADataset.ControloAutDicionarioRow[])(GisaDataSetHelper.GetInstance().ControloAutDicionario.Select(string.Format("IDControloAut={0} AND IDTipoControloAutForma = {1:d}", ControloAutRow.ID, TipoControloAutForma.FormaAutorizada)));
                    }
                    if (cadRows.Length > 0)
                    {
                        DisplayFormaAutorizada(cadRows[0]);
                    }
                    break;
                }
                }
            }
            else if (this.ControloAutRow != null)
            {
                // TODO: FIXME legibilidade
                // Determinar se Value já se encontra em ControloAutRel
                try
                {
                    // make sure we do not relate an item to itself
                    if (ControloAutRow.ID == this.ControloAutRow.ID)
                    {
                        return;
                    }

                    // If the dropped item was not already added to the selected
                    // item (or vice versa)
                    if (GisaDataSetHelper.GetInstance().ControloAutRel.Select(GetRelConstraint(ControloAutRow, this.ControloAutRow) + " OR " + GetRelConstraint(this.ControloAutRow, ControloAutRow)).Length == 0)
                    {
                        // adicionar nova relação
                        FormControloAutRel frm = new FormControloAutRel(ControloAutRow, parent);

                        switch (frm.ShowDialog())
                        {
                        case DialogResult.OK:
                            TempIndexFRDCA = GisaDataSetHelper.GetInstance().ControloAutRel.NewControloAutRelRow();
                            GISADataset.ControloAutRelRow tempWith1 = (GISADataset.ControloAutRelRow)TempIndexFRDCA;
                            tempWith1.IDControloAut      = this.ControloAutRow.ID;
                            tempWith1.IDControloAutAlias = ControloAutRow.ID;
                            tempWith1["IDTipoRel"]       = ((GISADataset.TipoControloAutRelRow)(((DataRowView)frm.relacaoCA.cbTipoControloAutRel.SelectedItem).Row)).ID;
                            tempWith1.Descricao          = frm.relacaoCA.txtDescricao.Text;
                            GisaDataSetHelper.GetInstance().ControloAutRel.AddControloAutRelRow((GISADataset.ControloAutRelRow)TempIndexFRDCA);
                            break;

                        case DialogResult.Cancel:
                            return;
                        }

                        GisaDataSetHelper.VisitControloAutDicionario(ControloAutRow, DisplayFormaAutorizada);
                    }
                }
                catch (Exception ex)
                {
                    Trace.WriteLine(ex);
                }
            }
        }
Exemplo n.º 4
0
		private void RetrieveSelection(FormControloAutRel frm, DataRow relRow)
		{
			try
			{
				if (relRow != null) // edição
					frm.SetEditMode();

                frm.ShowDialog();

				GisaDataSetHelper.HoldOpen ho = new GisaDataSetHelper.HoldOpen(GisaDataSetHelper.GetConnection());
				try
				{
					LoadData(CurrentControloAut, ho.Connection);
					ModelToView();
				}
				finally
				{
					ho.Dispose();
				}
			}
			catch (Exception ex)
			{
				Trace.WriteLine(ex);
				throw ex;
			}
		}