private void SaveAsMenuItem_Click(object sender, EventArgs e) { if (this.DataSource == null) { return; } SaveFileDialog sf = new SaveFileDialog(); sf.InitialDirectory = this.LastDirectory; sf.DefaultExt = ".csv"; sf.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"; sf.ShowDialog(); if (sf.FileName == "") { return; } this.LastDirectory = Path.GetDirectoryName(sf.FileName); IODataTable iodt = new IODataTable(); iodt.SaveDataTabletoCSV(sf.FileName, (DataTable)this.DataSource); }
private void SaveLocally() { if (this.DataSource == null) { return; } int changes = editedCells.Count; DialogResult mb = MessageBox.Show("Changes to " + changes.ToString() + " cell(s) have been registered for this data file. " + Environment.NewLine + "Would you like to save changes to: " + Environment.NewLine + this.FileName, "Save changes?", MessageBoxButtons.YesNoCancel); if (mb != DialogResult.Yes) { return; } IODataTable iodt = new IODataTable(); iodt.SaveDataTabletoCSV(this.FileName, (DataTable)this.DataSource); }
private void OpenMenuItem_Click(object sender, EventArgs e) { OpenFileDialog of = new OpenFileDialog(); of.InitialDirectory = this.LastDirectory; of.DefaultExt = ".csv"; of.Filter = "CSV files (*.csv)|*.csv|All files (*.*)|*.*"; of.ShowDialog(); if (of.FileName == "") { return; } this.LastDirectory = Path.GetDirectoryName(of.FileName); this.FileName = of.FileName; SetModeSavesLocal(); IODataTable iodt = new IODataTable(); DataTable dt = iodt.LoadCSVtoDataTable(of.FileName); this.SetDataSource(dt); }