Example #1
0
 public void Execute(object parameter)
 {
     if (specifiedImport.bankChoice != "Add new Type" || specifiedImport.newBankTextbox.Text.ToString() != "")
     {
         List <string> currentFile = new List <string>();
         currentFile.Add(currentFileName);
         new ImportReadIn("Stock", currentFile, specifiedImport.mainWindow, true);
         if (SpecifiedImportStock.folderPath.Count < specifiedImport.getCurrentFileIndex())
         {
             specifiedImport.incrementNumberofFile();
             string   nextFileName     = SpecifiedImportStock.folderPath[specifiedImport.getCurrentFileIndex()];
             string[] splittedFileName = nextFileName.Split('\\');
             int      lastSplitIndex   = nextFileName.Length - 1;
             specifiedImport.currentFileLabel.Content = "File: " + splittedFileName[lastSplitIndex];
             StoredStockColumnChecker columnChecker = new StoredStockColumnChecker();
             columnChecker.getDataTableFromSql(specifiedImport.mainWindow);
             columnChecker.setAnalyseWorksheet(nextFileName);
             columnChecker.setMostMatchesRow(columnChecker.findMostMatchingRow());
             columnChecker.setSpecifiedImportPageTextBoxes();
         }
     }
     else//didn't typed in the new banks name
     {
         MessageBox.Show("Type in the new Bank name first, to the TextBox under the Type ComboBox!");
         specifiedImport.newBankTextbox.Focus();
     }
 }
Example #2
0
        private void FileBrowser_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxResult messageBoxResult = CustomMessageBox.ShowYesNo(
                "\tPlease choose an import type!",
                "Import type alert!",
                "Automatized",
                "User specified");

            if (messageBoxResult == MessageBoxResult.Yes || messageBoxResult == MessageBoxResult.No)
            {
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.DefaultExt  = ".xls,.csv";
                dlg.Filter      = "Excel files (*.xls)|*.xls|Excel Files (*.xlsx)|*.xlsx|Excel Files (*.xlsm)|*.xlsm|CSV Files (*.csv)|*.csv";
                dlg.Multiselect = true;
                Nullable <bool> result = dlg.ShowDialog();
                if (result == true)
                {
                    List <string> fileAdresses = dlg.FileNames.ToList();
                    for (int i = 0; i < dlg.FileNames.ToList().Count; i++)
                    {
                        check_if_csv(i, ref fileAdresses);
                    }
                    if (messageBoxResult == MessageBoxResult.Yes)
                    {
                        if (CheckForInternetConnection())
                        {
                            new ImportReadIn("Stock", fileAdresses, mainWindow, false);
                        }
                        else
                        {
                            MessageBox.Show("The Automazied import for Stocks transactions requires internet connection!");
                        }
                    }
                    else if (messageBoxResult == MessageBoxResult.No)
                    {
                        string[] fileName      = dlg.FileNames.ToList()[0].Split('\\');
                        int      lastPartIndex = fileName.Length - 1; // to see which file the user immporting first
                        SpecifiedImportStock.getInstance(fileAdresses, mainWindow).setCurrentFileLabel(fileName[lastPartIndex]);
                        SpecifiedImportStock.getInstance(null, mainWindow).setBoxValuesToZero();
                        StoredStockColumnChecker columnChecker = new StoredStockColumnChecker();
                        columnChecker.getDataTableFromSql(mainWindow);
                        columnChecker.addDistinctBanksToCB();
                        columnChecker.setAnalyseWorksheet(dlg.FileNames.ToList()[0]);
                        columnChecker.setMostMatchesRow(columnChecker.findMostMatchingRow());
                        columnChecker.setSpecifiedImportPageTextBoxes();
                        mainWindow.MainFrame.Content = SpecifiedImportStock.getInstance(fileAdresses, mainWindow);
                    }
                }
            }
        }