private void Form1_FormClosing(object sender, FormClosingEventArgs e) { // saving data this.HistoryFields.DefaultView.RowFilter = ""; RepositoryData o = new RepositoryData(); o.HistoricFields = (from DataRow oRow in this.HistoryFields.Rows select Convert.ToString(oRow["Value"])).ToArray(); o.DataAccessFields = (from DataRow oRow in this.DataAccessFields.Rows select Convert.ToString(oRow["Value"])).ToArray(); o.Fields = (from DataRow oRow in this.Fields.Rows select Convert.ToString(oRow["Value"])).ToArray(); o.FilterFields = (from DataRow oRow in this.FilterFields.Rows select Convert.ToString(oRow["Value"])).ToArray(); o.InfoFields = (from DataRow oRow in this.InfoFields.Rows select Convert.ToString(oRow["Value"])).ToArray(); o.NewDataFields = (from DataRow oRow in this.NewDataFields.Rows select Convert.ToString(oRow["Value"])).ToArray(); o.RepositoryMethods = (from DataRow oRow in this.RepositoryMethods.Rows select Convert.ToString(oRow["Value"])).ToArray(); o.UniqueItem = this.chkUniqueItem.Checked; o.CreateTests = this.chkCreateTests.Checked; o.FillData = this.chkFillData.Checked; o.RepositoryName = this.txtRepositoryName.Text; IFormatter formater = new BinaryFormatter(); Stream stream = new FileStream(StoreFile(), FileMode.Create, FileAccess.Write); formater.Serialize(stream, o); stream.Close(); }
public Form1() { InitializeComponent(); var dtFields = new DataTable(); dtFields.Columns.Add("Value", typeof(string)); this.gridDataInfo.DataSource = dtFields.Clone(); this.gridHistory.DataSource = dtFields.Clone(); this.gridDataFilter.DataSource = dtFields.Clone(); this.gridFields.DataSource = dtFields.Clone(); this.gridDac.DataSource = dtFields.Clone(); this.gridNew.DataSource = dtFields.Clone(); this.gridRepository.DataSource = dtFields.Clone(); DataGridView[] grids = { gridDataInfo, gridHistory, gridDataFilter, gridFields, gridDac, gridNew, gridRepository }; foreach (DataGridView grid in grids) { grid.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill; grid.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.DisplayedCells; } // Loading Data try { IFormatter formater = new BinaryFormatter(); Stream stream = new FileStream(StoreFile(), FileMode.Open, FileAccess.Read); RepositoryData o = (RepositoryData)formater.Deserialize(stream); stream.Close(); // this.chkUniqueItem.Checked = o.UniqueItem; this.chkCreateTests.Checked = o.CreateTests; this.chkFillData.Checked = o.FillData; this.txtRepositoryName.Text = o.RepositoryName; // foreach (string field in o.HistoricFields) { this.HistoryFields.Rows.Add(field); } foreach (string field in o.InfoFields) { this.InfoFields.Rows.Add(field); } foreach (string field in o.FilterFields) { this.FilterFields.Rows.Add(field); } foreach (string field in o.Fields) { this.Fields.Rows.Add(field); } foreach (string field in o.DataAccessFields) { this.DataAccessFields.Rows.Add(field); } foreach (string field in o.NewDataFields) { this.NewDataFields.Rows.Add(field); } foreach (string field in o.RepositoryMethods) { this.RepositoryMethods.Rows.Add(field); } } catch { } }