private void mnuWhereClause_Click(object sender, System.EventArgs e) { if (lstTables.SelectedItems.Count > 0) { ListViewItem item = lstTables.SelectedItems[0]; SQLSyncData.LookUpTableRow lookUpRow; DataRow[] rows = tableList.Database.Select(tableList.Database.NameColumn.ColumnName + " ='" + this.data.DatabaseName + "'"); if (rows.Length > 0) { DataRow[] lookUpRows = ((SQLSyncData.DatabaseRow)rows[0]).GetLookUpTableRows(); for (int i = 0; i < lookUpRows.Length; i++) { SQLSyncData.DatabaseRow dbRow = (SQLSyncData.DatabaseRow)rows[0]; if (((SQLSyncData.LookUpTableRow)lookUpRows[i]).Name.ToUpper() == item.Text.ToUpper()) { lookUpRow = (SQLSyncData.LookUpTableRow)lookUpRows[i]; WhereClauseForm frmWhere = new WhereClauseForm(this.data, item.Text, lookUpRow.WhereClause, lookUpRow.UseAsFullSelect); DialogResult result = frmWhere.ShowDialog(); if (result == DialogResult.OK) { lookUpRow.WhereClause = frmWhere.WhereClause; lookUpRow.UseAsFullSelect = frmWhere.UseAsFullSelect; lookUpRow.AcceptChanges(); this.SaveXmlTemplate(this.projectFileName); break; } } } } } }
private void RemoveDatabase(string databaseName) { DataRow[] deleteRows = this.tableList.Database.Select(this.tableList.Database.NameColumn.ColumnName + "='" + databaseName + "'"); if (deleteRows.Length > 0) { SQLSyncData.DatabaseRow dbRow = (SQLSyncData.DatabaseRow)deleteRows[0]; int childRowsCount = dbRow.GetLookUpTableRows().Length; if (childRowsCount > 0) { string entry = (childRowsCount > 1)? "entries":"entry"; string message = "The Database " + dbRow.Name + " has " + childRowsCount.ToString() + " table " + entry + ".\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.Database.RemoveDatabaseRow(dbRow); this.tableList.Database.AcceptChanges(); this.SaveXmlTemplate(this.projectFileName); this.LoadLookUpTableData(this.projectFileName); } }