private void customSignReport(FormQueryBuilder tableFilters) { bool selectResults = false; string query = tableFilters.getQuery(); if (tableFilters.checkBoxSelectResults.Checked && query != "SELECT * FROM sign") { selectResults = true; } query += " GROUP BY TAMSID ORDER BY TAMSID ASC, support_id ASC;"; DataTable results = Database.GetDataByQuery(Project.conn, query); if (results.Rows.Count == 0) { MessageBox.Show("No signs matching the given description were found."); return; } DataTable outputTable = signReports.addSignColumns(); FormOutput report = new FormOutput(Project, null, "Sign Inventory"); FeatureLayer selectionLayer = (FeatureLayer)moduleSigns.Layer; selectionLayer.ClearSelection(); foreach (DataRow row in results.Rows) { if (selectResults) { String tamsidcolumn = Project.settings.GetValue("sign_f_TAMSID"); selectionLayer.SelectByAttribute(tamsidcolumn + " = " + row["support_id"], ModifySelectionMode.Append); } DataRow nr = outputTable.NewRow(); string note = row["notes"].ToString().Split(new[] { '\r', '\n' }).FirstOrDefault(); //retrive most recent note int oldNoteLength = note.Length; int maxLength = 17; if (!string.IsNullOrEmpty(note)) { note = note.Substring(0, Math.Min(oldNoteLength, maxLength)); if (note.Length == maxLength) { note += "..."; } } signReports.addSignRows(nr, row); outputTable.Rows.Add(nr); } report.dataGridViewReport.DataSource = outputTable; report.Text = "Custom Sign Report"; report.Show(); if (selectResults) { moduleSigns.selectionChanged(); } }
private void searchByID() { if (uxMap.Layers.Count == 0) { MessageBox.Show("A SHP file is required to do this action."); return; } string input = toolStripTextBoxSearch.Text; if (String.IsNullOrEmpty(input)) { return; } //remove spaces before entry int j = 0; while (input[j] == ' ') { j++; } input = input.Remove(0, j); for (int i = 0; i < input.Length; i++) { if (input[i] == ',') { //remove spaces after comma j = 1; while (input[i + j] == ' ') { j++; } input = input.Remove(i + 1, j - 1); //remove spaces before comma j = 1; while (input[i - j] == ' ') { j++; } input = input.Remove(i - j + 1, j - 1); } } string[] ids = input.Split(',').ToArray(); FeatureLayer selectionLayer = (FeatureLayer)uxMap.Layers.SelectedLayer; string layerName = ""; if (Project.currentModuleName == "Roads") { layerName = "road"; } else if (Project.currentModuleName == "Signs") { layerName = "sign"; } else { layerName = "other"; } foreach (FeatureLayer layer in uxMap.Layers) { layer.UnSelectAll(); if (layer.Name.ToString() == layerName) { selectionLayer = layer; } } String tamsidcolumn = Project.settings.GetValue(selectionLayer.Name + "_f_TAMSID"); string searchBy = toolStripComboBoxFind.Text; if (searchBy == "ID") { foreach (string id in ids) { int x; if (!Int32.TryParse(id, out x)) { MessageBox.Show("'" + id + "' is not a valid input.\nPlease Enter a Number", "", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); continue; } selectionLayer.SelectByAttribute(tamsidcolumn + " = " + id, ModifySelectionMode.Append); } } if (searchBy == "Street") { foreach (string name in ids) { DataTable searchName = Database.GetDataByQuery(Project.conn, "SELECT DISTINCT TAMSID FROM road WHERE name LIKE '%" + name + "%';"); foreach (DataRow row in searchName.Rows) { selectionLayer.SelectByAttribute(tamsidcolumn + " = " + row["TAMSID"], ModifySelectionMode.Append); } } } if (selectionLayer.Selection.Count == 0) { MessageBox.Show(searchBy + " Not Found", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); return; } if (layerName == "road") { road.selectionChanged(); } if (layerName == "sign") { sign.selectionChanged(); } if (layerName == "other") { other.selectionChanged(); } }