Ejemplo n.º 1
0
        private void ImportExcel_Click(object sender, RoutedEventArgs e)
        {
            string[,] data = ExcelFileTools.UploadExcelData();
            if (data?.GetLength(1) >= ElementsModification.FindVisualChildren <GridViewColumnHeader>(this).Count() - 2)
            {
                for (int i = 0; i < data.GetLength(0); i++)
                {
                    int.TryParse(data[i, 1], out int complexity);

                    var subject = new SchoolSubject(data[i, 0], complexity);
                    SchoolSubjectDict.dictionaryList.Add(subject);
                    SubjectsList.Items.Add(subject);
                }
                (Owner as EditorWindow).HomePage.SubjectsIndicator.Fill = ColorPalette.GetPredefinedColor(PredefinedColors.Green);
            }
            else if (data?.GetLength(1) < ElementsModification.FindVisualChildren <GridViewColumnHeader>(this).Count() - 2)
            {
                MessageBox.Show("Wrong Columns Format");
            }
        }
        private void ImportExcel_Click(object sender, RoutedEventArgs e)
        {
            string[,] data = ExcelFileTools.UploadExcelData();
            // HACK: Change Length Checker
            if (data?.GetLength(1) > ElementsModification.FindVisualChildren <GridViewColumnHeader>(this).Count() - 2)
            {
                for (int i = 0; i < data.GetLength(0); i++)
                {
                    DateTime.TryParse(data[i, 1], out DateTime start);
                    DateTime.TryParse(data[i, 2], out DateTime end);

                    var period = new SchoolPeriod(data[i, 0], start, end);
                    StudyPeriodDict.dictionaryList.Add(period);
                    PeriodsList.Items.Add(period);
                }
            }
            else if (data?.GetLength(1) < ElementsModification.FindVisualChildren <GridViewColumnHeader>(this).Count() - 2)
            {
                MessageBox.Show("Wrong Columns Format");
            }
        }