Ejemplo n.º 1
0
        private void PreviousFileNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (!CheckContainsValidFileNameAndPath(CurrentFileNameTextBox.Text))
            {
                StatusTextBlock.Text = "The previous input is not a valid file path with filename.";
            }
            else
            {
                CSVParser parser = new CSVParser(PreviousFileNameTextBox.Text);
                if (parser.CheckCanParse(out string result))
                {
                    previousDataset = parser.ParseIntoFileDataset(FileDatasetType.PreviousMonth);
                    SetCurrentDatasetPreviousAverages();
                    StatusTextBlock.Text = $"File successfully read.";
                    PopulateDataGrid();
                    DateCalendar.SelectedDateChanged += DateCalendar_SelectedDateChanged;
                    ExportToExcelButton.IsEnabled     = true;
                }
                else
                {
                    StatusTextBlock.Text = "File can't be read.";

                    if (!string.IsNullOrEmpty(result))
                    {
                        StatusTextBlock.Text += $" Error:{Environment.NewLine}{result}";
                    }
                }
            }
            if (previousDataset != null)
            {
                StatusTextBlock.Text += $"{Environment.NewLine}Last month dataset: {previousDataset}";
            }
        }
Ejemplo n.º 2
0
        private void CurrentFileNameTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (!CheckContainsValidFileNameAndPath(CurrentFileNameTextBox.Text))
            {
                StatusTextBlock.Text = "The current input is not a valid file path with filename.";
            }
            else
            {
                CSVParser parser = new CSVParser(CurrentFileNameTextBox.Text);
                string    result;
                if (parser.CheckCanParse(out result))
                {
                    //if have set the start date and end date
                    if (DateCalendar.SelectedDate != null)
                    {
                        currentDataset = parser.ParseIntoFileDataset(FileDatasetType.CurrentMonth, (DateTime)DateCalendar.SelectedDate);
                    }
                    else
                    {
                        currentDataset = parser.ParseIntoFileDataset(FileDatasetType.CurrentMonth);

                        if (DateCalendar.SelectedDate == null)
                        {
                            DateCalendar.SelectedDate = currentDataset.DateOfScores;
                        }
                        else
                        {
                            currentDataset.DateOfScores = (DateTime)DateCalendar.SelectedDate;
                        }
                    }
                    StatusTextBlock.Text = $"File successfully read.";
                    PopulateDataGrid();

                    DateCalendar.SelectedDateChanged    += DateCalendar_SelectedDateChanged;
                    PreviousFileNameTextBox.TextChanged += PreviousFileNameTextBox_TextChanged;

                    PreviousChooseFileButton.IsEnabled = true;
                    PreviousFileNameTextBox.IsEnabled  = true;
                    ExportToExcelButton.IsEnabled      = true;
                }
                else
                {
                    StatusTextBlock.Text = "File can't be read.";
                    //ExportToExcelButton.IsEnabled = false;

                    if (!string.IsNullOrEmpty(result))
                    {
                        StatusTextBlock.Text += $" Error:{Environment.NewLine}{result}";
                    }
                }
            }
            if (currentDataset != null)
            {
                StatusTextBlock.Text += $"{Environment.NewLine}Dataset: {currentDataset.ToString()}";
                SetCurrentDatasetPreviousAverages();
            }
        }