Exemplo n.º 1
0
        private bool ColumnExists()
        {
            bool result = true;

            try
            {
                QDatabase      database = QInstance.Environments.GetDatabase(DatabaseName);
                QDBTableSchema schema   = ((QAlterViewCR)Parent).GetSchema(false);
                schema.Load(database, ViewName);
                if (schema.ContainsColumn(ColumnName))
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = string.Format("Add field {0} in view {1}", ColumnName, ViewName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                }
                else
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.AddColumn,
                        Description  = string.Format("Add field {0} in view {1}", ColumnName, ViewName),
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.AddColumn,
                    Description  = string.Format(ex.Message),
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
                result = false;
            }
            return(result);
        }
Exemplo n.º 2
0
        private bool CheckFieldInTable()
        {
            bool result = true;

            try
            {
                QDatabase      database = QInstance.Environments.GetDatabase(DatabaseName);
                QDBTableSchema schema   = ((QAlterTableCR)Parent).GetSchema(false);
                schema.Load(database, TableName);
                if (schema.ContainsColumn(ColumnName))
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.WellImplemented,
                        ActionType   = QCRActionType.NoActionNeeded,
                        Description  = this.Description,
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                }
                else
                {
                    QCRAction check = new QCRAction()
                    {
                        State        = QCRActionState.NeedsAction,
                        ActionType   = QCRActionType.AddColumn,
                        Description  = this.Description,
                        DatabaseName = this.DatabaseName
                    };
                    Actions.Add(check);
                }
            }
            catch (Exception ex)
            {
                QCRAction check = new QCRAction()
                {
                    State        = QCRActionState.NeedsAction,
                    ActionType   = QCRActionType.AddColumn,
                    Description  = ex.Message,
                    DatabaseName = this.DatabaseName
                };
                Actions.Add(check);
                result = false;
            }
            return(result);
        }