Beispiel #1
0
 public void Import_Clicked(object sender, RoutedEventArgs e)
 {
     if (comboBoxCriterias.SelectedItem != null && comboBoxOptions.SelectedItem != null && fileLocation != "")
     {
         Accord.IO.ExcelReader excelReader = new Accord.IO.ExcelReader(path: fileLocation);
         excelTable = excelReader.GetWorksheet(comboBoxCriterias.SelectedItem.ToString());
         Dictionary <string, Dictionary <string, double> > criterias = Parse(excelTable), options = Parse(excelReader.GetWorksheet(comboBoxOptions.SelectedItem.ToString()));
         Dictionary <string, double> avWeights = AverageWeights(criterias);
         Dictionary <string, double> ranks = RankOptions(options, avWeights);
         listBox.ItemsSource = ranks;
     }
     else if (fileLocation == "")
     {
         MessageBox.Show("Ooops, looks like a cat pushed your file away from me. Can you please select file again? And please, this time be aware of the cats.", "Wrong File Input", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else if (comboBoxCriterias.SelectedItem == null)
     {
         MessageBox.Show("Ooops, looks like a ninja stole your criterias sheet selection. Please select an excel sheet name again. I will guard you from unexpected ninjas.", "Wrong Sheet Name Input", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else if (comboBoxOptions.SelectedItem == null)
     {
         MessageBox.Show("Ooops, looks like a ninja stole your options sheet selection. Please select an excel sheet name again. I will guard you from unexpected ninjas.", "Wrong Sheet Name Input", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else if (textBoxPercentage.Text == null || textBoxPercentage.Text == "")
     {
         MessageBox.Show("Ooops, looks like a ninja stole your comparison percentage. Please write comparison percentage again. I will guard you from unexpected ninjas.", "Wrong Comparison Percentage Input", MessageBoxButton.OK, MessageBoxImage.Error);
     }
     else
     {
         MessageBox.Show("Something went wrong. Maybe there is some ghost which interfees with our system. Please get rid of this unexpected ghost and try again later.", "Error: Something Went Wrong", MessageBoxButton.OK, MessageBoxImage.Error);
     }
 }
Beispiel #2
0
        public void OpenFile_Clicked(object sender, RoutedEventArgs e)
        {
            OpenFileDialog openFileDialog = new OpenFileDialog();

            if (openFileDialog.ShowDialog() == true)
            {
                if (File.Exists(openFileDialog.FileName))
                {
                    Accord.IO.ExcelReader reader = new Accord.IO.ExcelReader(path: openFileDialog.FileName);
                    comboBoxCriterias.ItemsSource = reader.GetWorksheetList();
                    comboBoxOptions.ItemsSource   = comboBoxCriterias.ItemsSource;
                    fileLocation         = openFileDialog.FileName;
                    FilePathTextBox.Text = openFileDialog.FileName;
                }
                else
                {
                    MessageBox.Show("I can't pass the mighty passage of a white bearded man. Please give me another file.", "File Can't Opened", MessageBoxButton.OK, MessageBoxImage.Exclamation);
                }
            }
        }