Exemplo n.º 1
0
        private void btnImport_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                var ofd = new OpenFileDialog();
                ofd.DefaultExt  = ".csv";
                ofd.Multiselect = false;
                ofd.Filter      = "CSV files|*.csv|All Files|*.*";
                if (ofd.ShowDialog() != true)
                {
                    return;
                }
                var results = _gradebook.ImportStudents(ofd.FileName);
                if (results.Count() == 0)
                {
                    MessageBox.Show("No changes");
                    return;
                }

                string message;
                if (results.Count() > 30)
                {
                    message = "More than " + results.Count() + " rows changed";
                }
                else
                {
                    message = string.Join(Environment.NewLine, results.ToArray());
                }

                var result = MessageBox.Show(message + Environment.NewLine + "Save results and close?", "Import Complete", MessageBoxButton.YesNo);
                if (result == MessageBoxResult.Yes)
                {
                    _gradebook.Save();
                    Close();
                }
                else
                {
                    Close();
                }
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
        }
Exemplo n.º 2
0
 private void btnSave_Click(object sender, EventArgs e)
 {
     gradebookVM.Save();
 }