private void ReadXmlFileAndBindToDataGrid() { string dataFilePath = AppConfig.dataFilePath; // // read data file // IDataService dataService = new MongoDBDataService(); _characters = dataService.ReadAll() as List <Character>; // // bind list to DataGridView control // var bindingList = new BindingList <Character>(_characters); var source = new BindingSource(bindingList, null); dataGridView_Characters.DataSource = source; // // configure DataGridView control // this.dataGridView_Characters.Columns["Id"].Visible = true; this.dataGridView_Characters.Columns["ImageFileName"].Visible = false; this.dataGridView_Characters.Columns["Description"].Visible = false; }
/// <summary> /// Connect to the database, retrieve a list of Characters, and bind the list to the data grid /// </summary> private void ReadMongoDBAndBindToDataGrid() { // // read data file // IDataService dataService = new MongoDBDataService(); // // insert data into the table, only needed when the table is empty // //dataService.WriteAll(GenerateListOfCharacters()); _characters = dataService.ReadAll().ToList <Character>(); // // bind list to DataGridView control // var bindingList = new BindingList <Character>(_characters); var source = new BindingSource(bindingList, null); dataGridView_Characters.DataSource = source; // // configure DataGridView control // this.dataGridView_Characters.Columns["Id"].Visible = false; this.dataGridView_Characters.Columns["ImageFileName"].Visible = false; this.dataGridView_Characters.Columns["Description"].Visible = false; }
private void btn_exit_Click(object sender, EventArgs e) { try { IDataService MongoDBDataService = new MongoDBDataService(); MongoDBDataService.WriteAll(_characters); } catch (Exception) { throw; } this.Close(); }
static void Main(string[] args) { IDataService dataService = new MongoDBDataService(); // // Required to test the MongoDB data service // refresh MongoDB collection // dataService.WriteAll(GenerateListOfPeople()); CharacterBLL characterBLL = new CharacterBLL(dataService); Presenter presenter = new Presenter(characterBLL); }
private void btn_exit_Click(object sender, EventArgs e) { try { // // make sure the grid is replicated to the data source // IDataService dataService = new MongoDBDataService(); dataService.WriteAll(_characters); } catch (Exception) { throw; } this.Close(); }
/// <summary> /// Connect to the database, retrieve a list of Characters, and bind the list to the data grid /// </summary> private void ReadMongoDBAndBindToDataGrid() { // // read data file // IDataService dataService = new MongoDBDataService(); // // insert data into the table, only needed when the table is empty // //dataService.WriteAll(GenerateListOfCharacters()); _characters = dataService.ReadAll().ToList <Character>(); // // bind list to DataGridView control // var bindingList = new BindingList <Character>(_characters); dataGridView_Characters.ItemsSource = bindingList; HideGridColumns(); }