예제 #1
0
        private void RemoveTable(string tableName)
        {
            DataRow[] deleteRows = this.tableList.LookUpTable.Select(this.tableList.LookUpTable.NameColumn.ColumnName + "='" + tableName + "'");
            if (deleteRows.Length > 0)
            {
                SQLSyncData.LookUpTableRow tblRow = (SQLSyncData.LookUpTableRow)deleteRows[0];
                if (tblRow.WhereClause.Length > 0)
                {
                    string       message = "The table " + tblRow.Name + " has a WHERE clause.\r\nAre you sure you want to remove it?";
                    DialogResult result  = MessageBox.Show(message, "Confirm Removal", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                    if (result == DialogResult.No)
                    {
                        return;
                    }
                }

                this.tableList.LookUpTable.RemoveLookUpTableRow(tblRow);
                this.tableList.LookUpTable.AcceptChanges();
                this.SaveXmlTemplate(this.projectFileName);
                this.LoadLookUpTableData(this.projectFileName);
            }
        }
예제 #2
0
        private void PopulateTableList(string databaseName)
        {
            this.lstTables.Items.Clear();
            this.data.DatabaseName = databaseName;
            PopulateHelper helper = new PopulateHelper(this.data, null);

            DataRow[] dbRows = this.tableList.Database.Select(tableList.Database.NameColumn.ColumnName + " = '" + this.data.DatabaseName + "'");

            if (dbRows.Length > 0)
            {
                SQLSyncData.LookUpTableRow[] lookUpRows = ((SQLSyncData.DatabaseRow)dbRows[0]).GetLookUpTableRows();
                //Add the rows to a table so we can sort by Name

                SQLSyncData.LookUpTableDataTable lookTable = new SQLSync.SQLSyncData.LookUpTableDataTable();
                for (int i = 0; i < lookUpRows.Length; i++)
                {
                    lookTable.ImportRow(lookUpRows[i]);
                }

                DataView view = lookTable.DefaultView;
                view.Sort = tableList.LookUpTable.NameColumn.ColumnName + " ASC";
                for (int i = 0; i < view.Count; i++)
                {
                    SQLSyncData.LookUpTableRow row = (SQLSyncData.LookUpTableRow)view[i].Row;
                    ListViewItem item = new ListViewItem(row.Name);
                    if (helper.DbContainsTable(row.Name) == false)
                    {
                        item.ForeColor = Color.LightGray;
                    }
                    if (row.WhereClause.Length > 0)
                    {
                        item.BackColor = Color.LightBlue;
                    }
                    lstTables.Items.Add(item);
                }
            }
        }