public void saveOutput(string fileName) { HeaderRecgonition hRec = new HeaderRecgonition(); bool headersFormatedCorrectly = true; foreach (DataGridViewCell dCell in dataViewer.Rows[0].Cells) { if (hRec.isHeaderInStandardFormat(dCell.Value.ToString()) != true) { headersFormatedCorrectly = false; } } if (headersFormatedCorrectly) { switch (comboFileExtension.Text) { case (".wtr"): saveWater(fileName); break; case (".wnd"): saveWind(fileName); break; case (".sal"): saveSalinity(fileName); break; case(".csv"): saveCSV(fileName); break; default: saveStandard(fileName); break; } } else { DialogResult result = MessageBox.Show("Some of your headers appear to be incorrectly formatted.\n\rDo you wish to save anyway?", "", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation); if (result == DialogResult.Yes) { switch (comboFileExtension.Text) { case (".wtr"): saveWater(fileName); break; case (".wnd"): saveWind(fileName); break; case (".sal"): saveSalinity(fileName); break; case (".csv"): saveCSV(fileName); break; default: saveStandard(fileName); break; } } } }
private void HeaderGuess() { List<string> unRecHeaders = new List<string>(); HeaderRecgonition Hrec = new HeaderRecgonition(); foreach (DataGridViewCell dCell in dataViewer.Rows[0].Cells) { if (Hrec.isHeaderInStandardFormat(dCell.Value.ToString()) == false) { string guess = Hrec.RoughGuess(dCell.Value.ToString()); if (guess != dCell.Value.ToString()) { if (guess != "") { DialogResult result = MessageBox.Show("Header '"+ dCell.Value.ToString()+"' was recognized as \"" + guess + "\"\n\rUse the recognized header?\n\r(If you click \"No\" the old header will be retained.", "Recognition made", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { InputTable.Rows[dCell.RowIndex][dCell.ColumnIndex] = guess; } } else { unRecHeaders.Add(dCell.ColumnIndex.ToString()); } } } } if (unRecHeaders.Count != 0) { string unRecWarning = ""; unRecWarning = "Some columns have unrecognized headers\n\r"; foreach (string colNum in unRecHeaders) { unRecWarning += colNum + " "; } MessageBox.Show(unRecWarning, "Invalid Column Headers", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } for (int i = 1; i < dataViewer.Columns.Count; i++) { setBoxesFromGLEONCoding(i, dataViewer.Rows[0].Cells[i].Value.ToString()); } }