Beispiel #1
0
        public void changeTable(string tableName)
        {
            if (model != null)
            {
                if (Program.connectedMode)
                {
                    model.changeTable(tableName);

                    if (model.getForeignKeys().Count > 0)
                    {
                        this.extendedModel = new ExtendedDefaultTableModel(model.getConnection());
                        extendedModel.changeTable(tableName);
                    }

                    updateAll();
                }
                else
                {
                    DataTable        table   = null;
                    DataTable        schema  = null;
                    List <DataTable> tables  = view.getTables();
                    List <DataTable> schemas = view.getSchemas();

                    for (int i = 0; i < tables.Count; ++i)
                    {
                        if (tables[i].TableName == tableName)
                        {
                            table  = tables[i];
                            schema = schemas[i];
                        }
                    }


                    if (table != null && schema != null)
                    {
                        model.changeTableDisconnected(tableName, table, schema);
                    }
                    else
                    {
                        throw new ArgumentException("Wrong table name.");
                    }

                    if (model.getForeignKeys().Count > 0)
                    {
                        this.extendedModel = new ExtendedDefaultTableModel(model.getConnection());
                        extendedModel.changeTable(tableName);
                    }
                    updateView();
                }
            }
        }