private void loadDataToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); ofd.Filter = "CSV|*.csv"; if (ofd.ShowDialog() == DialogResult.OK) { DataTable csvDT = GetDataTabletFromCSVFile(ofd.FileName); int expectedColumnCount = GlobalConfig.Connection.GetCustomQuestionCount(eventId) + 3; if (csvDT.Columns.Count < expectedColumnCount) { MessageBox.Show($"You don't have enough responses I can only find {csvDT.Columns.Count} columns of data, but i am expecting { expectedColumnCount }"); return; } if (csvDT.Columns.Count > expectedColumnCount) { MessageBox.Show("You don't have too many responses, maybe you have blank columns to right of data"); return; } DataTable ResponsesListDT = csvDT.Clone(); //check csvDT rows if (ResponseLogic.CheckCSVData(csvDT, ref ResponsesListDT, eventId) == false) { //If there are any errors with the data it will exit outbefore trying to load any data //Error message is show by CheckCSVData return; } DialogResult dr = MessageBox.Show("This will replace the responses for all clients on the spreadsheet \nThis will NOT affect responses for anyone not on the spreadsheet", "Press Yes to Continue", MessageBoxButtons.YesNo, MessageBoxIcon.Question); if (dr == DialogResult.Yes) { //Now that all the data has been checked //Loop through the DataTable and load the data ResponseLogic.LoadBasicReposnses(ResponsesListDT); ResponseLogic.LoadCustomResponses(ResponsesListDT); callingForm.RefreshAllInvitesListView(); MessageBox.Show("Data processed", "Load Complete", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { MessageBox.Show("No data processed", "Load aborted", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
private void invitesDataGridView_CellValueChanged(object sender, DataGridViewCellEventArgs e) { InviteLogic.invitesDataGridView_CellValueChanged(sender, e); callingForm.RefreshAllInvitesListView(); }