示例#1
0
        public Collection <Error> IsPossibleSetDataContext(LogicalLibrary.Component source, LogicalLibrary.Component target)
        {
            Collection <Error>  errors              = new Collection <Error>();
            Widget              sourceWidget        = source as Widget;
            FormMenuItem        formMenuItem        = source as FormMenuItem;
            EnterSingleDataForm enterSingleDataForm = source as EnterSingleDataForm;

            if (formMenuItem != null)
            {
                sourceWidget = activeWidget;
            }
            if (sourceWidget.OutputDataContext == null && (formMenuItem == null) && (enterSingleDataForm == null))
            {
                errors.Add(new Error("", "", LogicalLibrary.Properties.Resources.NoOutputContext));
            }


            if (sourceWidget.OutputDataContext != null && target.InputDataContext != null)
            {
                if (!(target is DataSource))
                {
                    if (sourceWidget.OutputDataContext.Name != target.InputDataContext.Name)
                    {
                        errors.Add(new Error("", "", LogicalLibrary.Properties.Resources.DifferentContext));
                    }
                }
            }
            return(errors);
        }
示例#2
0
 public override bool Equals(object obj)
 {
     if (obj != null)
     {
         FormMenuItem formMenuItem = (FormMenuItem)obj;
         if (String.CompareOrdinal(this.text, formMenuItem.text) == 0)
         {
             return(true);
         }
     }
     return(false);
 }
示例#3
0
        /// <summary>
        /// Valida la conexión y retorna una colección de errores indicados.
        /// </summary>
        /// <returns></returns>
        public Collection <Error> CheckConnection()
        {
            Collection <Error> connectionErrors = new Collection <Error>();

            // No es posible conectar "Enter Single Data Form" o "Show Data Form" con un   "List Form"
            if (connectionWidgetTarget is ListForm)
            {
                if (connectionWidgetFrom is EnterSingleDataForm || connectionWidgetFrom is ShowDataForm)
                {
                    connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.PreviousFormToListForm));
                }
            }

            // No es posible conectar "Data Source" u otro "Show Data Form" con un "Show Data Form"
            if (connectionWidgetTarget is ShowDataForm)
            {
                if (connectionWidgetFrom is DataSource || connectionWidgetFrom is ShowDataForm)
                {
                    connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.PreviousFormToShowForm));
                }
            }

            if (connectionWidgetTarget is DataSource)
            {
                if ((connectionWidgetTarget as DataSource).OutputDataContext == null || (connectionWidgetTarget as DataSource).RelatedTable.IsStorage)
                {
                    // Solo puede conectar un "Input Form" con un "Data Storage".
                    if (!(connectionWidgetFrom is EnterSingleDataForm))
                    {
                        connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.PreviousFormToDataStorage));
                    }
                }
                else
                {
                    // Un origen de datos no puede ser un formulario objetivo
                    connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.DataSourceCantBeTarget));
                }
            }

            if (connectionWidgetTarget is EnterSingleDataForm)
            {
                if (connectionWidgetFrom is DataSource)
                {
                    // No es posible conectar un "Data Source" con un "Enter Single Data Form"
                    connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.NoDataSourceToInputForm));
                }
            }

            if (connectionWidgetFrom != null && connectionWidgetTarget != null)
            {
                if (connectionWidgetFrom == connectionWidgetTarget)
                {
                    // Seleccione dos formularios diferentes para hacer una conexión
                    connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.SameFormForConnection));
                }
            }

            if (connectionWidgetFrom is EnterSingleDataForm)
            {
                if (connectionWidgetTarget is DataSource)
                {
                    bool hasStorage = CheckInputFormToStorageConnection(connectionWidgetFrom as EnterSingleDataForm);
                    if (hasStorage)
                    {
                        // El formulario de ingreso de datos ya posee asignado un almacenamiento
                        connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.InputFormHasStorage));
                    }
                }
                else
                {
                    bool hasOtherForm = CheckInputFormToOtherFormConnection(connectionWidgetFrom as EnterSingleDataForm);
                    if (hasOtherForm)
                    {
                        // El formulario de ingreso de datos ya posee un formulario objetivo
                        connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.InputFormHasOtherForm));
                    }
                }
            }

            if (ConnectionPointFrom != null && ConnectionPointTarget != null)
            {
                if (ConnectionPointFrom.ConnectionPointType == ConnectionPointTarget.ConnectionPointType)
                {
                    // Seleccione dos tipos de ConnectionsPoint diferentes para hacer una conexión.
                    connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.SameConnectionPointType));
                }

                FormMenuItem componentFrom = ConnectionPointFrom.Parent as FormMenuItem;

                if (componentFrom != null)
                {
                    if (((FormMenuItem)componentFrom).Parent == ConnectionPointTarget.Parent)
                    {
                        // Seleccione dos formularios diferentes para hacer una conexión.
                        connectionErrors.Add(new Error("", "", LogicalLibrary.Properties.Resources.SameFormForConnection));
                    }
                }
            }

            return(connectionErrors);
        }