private void lnkGenerateScripts_LinkClicked(object sender, System.Windows.Forms.LinkLabelLinkClickedEventArgs e) { this.Cursor = Cursors.WaitCursor; try { //Clear out any old controls tcTables.Controls.Clear(); //Get the list of selected tables ArrayList list = new ArrayList(); for (int i = 0; i < lstTables.Items.Count; i++) { if (lstTables.Items[i].Checked && lstTables.Items[i].ForeColor != Color.LightGray) { list.Add(lstTables.Items[i].Text); } } string[] tableList = new string[list.Count]; list.CopyTo(tableList); //Run the scripting PopulateHelper helper = new PopulateHelper(this.data, tableList); helper.SyncData = this.tableList; helper.ReplaceDateAndId = chkReplaceDateAndId.Checked; TableScriptData[] scriptedTables = helper.GeneratePopulateScripts(); //Add a tab page per generated script for (int i = 0; i < scriptedTables.Length; i++) { TabPage page = new TabPage(); page.Text = scriptedTables[i].TableName; PopulateScriptDisplay disp = new PopulateScriptDisplay(scriptedTables[i], false); disp.ScriptText = scriptedTables[i].InsertScript; disp.ScriptName = scriptedTables[i].TableName; disp.ScriptDataTable = scriptedTables[i].ValuesTable; disp.Size = page.Size; disp.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right; page.Controls.Add(disp); tcTables.Controls.Add(page); } this.Size = new System.Drawing.Size(this.Width + 1, this.Height); } finally { this.Cursor = Cursors.Default; } }
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); } } }