private void buttonImport_Click(object sender, EventArgs e) { var itm = (from EDCommander c in EDCommander.GetList() where c.Name.Equals(comboBoxCommander.Text) select c).ToList(); if (itm == null || itm.Count == 0) { ExtendedControls.MessageBoxTheme.Show("Code failure - cannot find selected commander", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } long cmdrID = itm[0].Nr; if (string.IsNullOrEmpty(importFile) || !File.Exists(importFile)) { ExtendedControls.MessageBoxTheme.Show("An import file must be specified.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string delim = radioButtonTab.Checked ? "\t" : textBoxDelimiter.Text; if (string.IsNullOrEmpty(delim)) { ExtendedControls.MessageBoxTheme.Show("A delimiter must be defined.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int?datecol = string.IsNullOrEmpty(textBoxArrivalDate.Text) ? null : (int?)int.Parse(textBoxArrivalDate.Text); int?timecol = string.IsNullOrEmpty(textBoxArrivalTime.Text) ? null : (int?)int.Parse(textBoxArrivalTime.Text); int?namecol = string.IsNullOrEmpty(textBoxSysName.Text) ? null : (int?)int.Parse(textBoxSysName.Text); int?notecol = string.IsNullOrEmpty(textBoxSysNotes.Text) ? null : (int?)int.Parse(textBoxSysNotes.Text); if (!namecol.HasValue) { ExtendedControls.MessageBoxTheme.Show("System Name column must be defined.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!datecol.HasValue && !notecol.HasValue) { ExtendedControls.MessageBoxTheme.Show("At least one of arrival date and system note columns must be defined.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ImportHistory ih = new ImportHistory(importFile, delim, datecol, timecol, namecol, notecol, checkBoxImpHeader.Checked, cmdrID); string result; if (ih.Import(out result)) { ExtendedControls.MessageBoxTheme.Show("Import successful.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.None); _discoveryForm.RefreshHistoryAsync(); } else { ExtendedControls.MessageBoxTheme.Show("Import failed: " + result, "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Error); } ih = null; }
private void buttonImport_Click(object sender, EventArgs e) { long cmdrID = long.Parse(comboBoxCommander.SelectedValue.ToString()); if (string.IsNullOrEmpty(importFile) || !File.Exists(importFile)) { EDDiscovery.Forms.MessageBoxTheme.Show("An import file must be specified.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } string delim = radioButtonTab.Checked ? "\t" : textBoxDelimiter.Text; if (string.IsNullOrEmpty(delim)) { EDDiscovery.Forms.MessageBoxTheme.Show("A delimiter must be defined.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int?datecol = string.IsNullOrEmpty(textBoxArrivalDate.Text) ? null : (int?)int.Parse(textBoxArrivalDate.Text); int?timecol = string.IsNullOrEmpty(textBoxArrivalTime.Text) ? null : (int?)int.Parse(textBoxArrivalTime.Text); int?namecol = string.IsNullOrEmpty(textBoxSysName.Text) ? null : (int?)int.Parse(textBoxSysName.Text); int?notecol = string.IsNullOrEmpty(textBoxSysNotes.Text) ? null : (int?)int.Parse(textBoxSysNotes.Text); if (!namecol.HasValue) { EDDiscovery.Forms.MessageBoxTheme.Show("System Name column must be defined.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (!datecol.HasValue && !notecol.HasValue) { EDDiscovery.Forms.MessageBoxTheme.Show("At least one of arrival date and system note columns must be defined.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } ImportHistory ih = new ImportHistory(importFile, delim, datecol, timecol, namecol, notecol, checkBoxImpHeader.Checked, cmdrID); _discoveryForm.ShowInfoPanel("Importing, please wait...", true, Color.Gold); string result; if (ih.Import(out result)) { EDDiscovery.Forms.MessageBoxTheme.Show("Import successful.", "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.None); _discoveryForm.RefreshHistoryAsync(); } else { EDDiscovery.Forms.MessageBoxTheme.Show("Import failed: " + result, "EDD Import", MessageBoxButtons.OK, MessageBoxIcon.Error); } _discoveryForm.ShowInfoPanel("", false); ih = null; }