Пример #1
0
        public void getDataTableFromSql(MainWindow mainWindow)
        {
            mConn.Open();
            this.mainWindow = mainWindow;
            using (SQLiteCommand mCmd = new SQLiteCommand("CREATE TABLE IF NOT EXISTS [StoredColumnsStock] " +
                                                          "(id INTEGER PRIMARY KEY AUTOINCREMENT, 'BankName' TEXT, 'TransStartRow' INTEGER, " +
                                                          "'StockName' TEXT, 'PriceColumn' TEXT, 'QuantityColumn' TEXT, 'DateColumn' TEXT, " +
                                                          "'TypeColumn' TEXT);", mConn))
            {
                mCmd.ExecuteNonQuery();
            }
            string        storedQuery = "select * from [StoredColumnsStock]";
            SQLiteCommand command     = new SQLiteCommand(storedQuery, mConn);

            System.Data.DataTable datatable = new System.Data.DataTable();
            SQLiteDataAdapter     adapter   = new SQLiteDataAdapter(command);

            adapter.Fill(datatable);

            /*
             * SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ImportFileData;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
             * sqlConn.Open();
             * string getEveryRow = "Select * From [StoredColumns_Stock]";
             * SqlDataAdapter sda = new SqlDataAdapter(getEveryRow, sqlConn);
             * System.Data.DataTable datatable = new System.Data.DataTable();
             * sda.Fill(datatable);
             */
            dtb = datatable;
            SpecifiedImportStock.getInstance(null, mainWindow).setDataTableFromSql(datatable);
            mConn.Close();
        }
        public void addDistinctBanksToCB()
        {
            foreach (var item in SpecifiedImportStock.getInstance(null, mainWindow).bankChoices.ToList())
            {
                if (item != "Add new Type")
                {
                    SpecifiedImportStock.getInstance(null, mainWindow).bankChoices.Remove(item);
                }
            }
            SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ImportFileData;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");

            sqlConn.Open();
            string         getEveryRow = "Select distinct BankName From [StoredColumns_Stock]";
            SqlDataAdapter sda         = new SqlDataAdapter(getEveryRow, sqlConn);

            System.Data.DataTable datatable = new System.Data.DataTable();
            sda.Fill(datatable);
            if (datatable.Rows.Count > 0)
            {
                foreach (DataRow row in dtb.Rows)
                {
                    SpecifiedImportStock.getInstance(null, mainWindow).bankChoices.Add(row["BankName"].ToString());
                }
            }
        }
 public ImportReadIn(string _importType, List <string> _path, MainWindow _mainWindow, bool specifiedByUser)
 {
     path       = _path;
     importType = _importType;
     mainWindow = _mainWindow;
     if (path[0] != "FolderAdress")//a path wasn't choosen, useless ( not in use )
     {
         for (int i = 0; i < path.Count; i++)
         {
             string [] splittedFileName = path[i].Split('\\');
             int       lastSplitIndex   = splittedFileName.Length - 1;
             currentFileName = splittedFileName[lastSplitIndex];
             if (importType == "Bank")
             {
                 ReadWorkbook  = excel.Workbooks.Open(path[i]);
                 ReadWorksheet = ReadWorkbook.Worksheets[1];
                 if (!specifiedByUser)
                 {
                     TemplateBankReadIn templateBank = new TemplateBankReadIn(this, ReadWorkbook, ReadWorksheet, mainWindow, false);
                     //so far we got the Starting Row(of the transactions),Number of Columns, account number
                     templateBank.readOutTransactionColumns(templateBank.getStartingRow(), templateBank.getNumberOfColumns());
                 }
                 else //userSpecified==true
                 {
                     TemplateBankReadIn templateBank          = new TemplateBankReadIn(this, ReadWorkbook, ReadWorksheet, mainWindow, true);
                     string             startingRow           = SpecifiedImportBank.getInstance(null, mainWindow).transactionsRowTextBox.Text.ToString();
                     string             dateColumn            = SpecifiedImportBank.getInstance(null, mainWindow).dateColumnTextBox.Text.ToString();
                     string             commentColumn         = SpecifiedImportBank.getInstance(null, mainWindow).commentColumnTextBox.Text.ToString();
                     string             accountNumberCB       = SpecifiedImportBank.getInstance(null, mainWindow).accountNumberCB.SelectedItem.ToString();
                     string             transactionPriceCB    = SpecifiedImportBank.getInstance(null, mainWindow).priceColumnCB.SelectedItem.ToString();
                     string             balanceCB             = SpecifiedImportBank.getInstance(null, mainWindow).balanceColumnCB.SelectedItem.ToString();
                     string             balanceComboBocString = SpecifiedImportBank.getInstance(null, mainWindow).balanceColumnTextBox.Text.ToString();
                     templateBank.readOutUserspecifiedTransactions(startingRow, dateColumn, commentColumn, accountNumberCB, transactionPriceCB, balanceCB, balanceComboBocString);
                 }
             }
             else if (importType == "Stock")
             {
                 if (!specifiedByUser)
                 {
                     TemplateStockReadIn templateStock = new TemplateStockReadIn(this, path[i]);
                     templateStock.analyzeStockTransactionFile();
                     templateStock.readOutTransactions();
                 }
                 else//userSpecified==true
                 {
                     TemplateStockReadIn templateStock = new TemplateStockReadIn(this, path[i]);
                     string startingRowString          = SpecifiedImportStock.getInstance(null, mainWindow).transactionsRowTextBox.ToString();
                     string nameColumnString           = SpecifiedImportStock.getInstance(null, mainWindow).stockNameColumnTextBox.ToString();
                     string priceColumnString          = SpecifiedImportStock.getInstance(null, mainWindow).priceColumnTextBox.ToString();
                     string quantityColumnString       = SpecifiedImportStock.getInstance(null, mainWindow).quantityColumnTextBox.ToString();
                     string dateColumnString           = SpecifiedImportStock.getInstance(null, mainWindow).dateColumnTextBox.ToString();
                     string transactionTypeString      = SpecifiedImportStock.getInstance(null, mainWindow).transactionTypeTextBox.ToString();
                     templateStock.readOutUserspecifiedTransactions(startingRowString, nameColumnString, priceColumnString, quantityColumnString, dateColumnString, transactionTypeString);
                 }
             }
         }
         excel.Application.Quit();
         excel.Quit();
     }
 }
Пример #4
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);
                    }
                }
            }
        }
        public void getDataTableFromSql(MainWindow mainWindow)
        {
            this.mainWindow = mainWindow;
            SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ImportFileData;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");

            sqlConn.Open();
            string         getEveryRow = "Select * From [StoredColumns_Stock]";
            SqlDataAdapter sda         = new SqlDataAdapter(getEveryRow, sqlConn);

            System.Data.DataTable datatable = new System.Data.DataTable();
            sda.Fill(datatable);
            dtb = datatable;
            SpecifiedImportStock.getInstance(null, mainWindow).setDataTableFromSql(datatable);
        }
Пример #6
0
        public void addDistinctBanksToCB()
        {
            mConn.Open();
            foreach (var item in SpecifiedImportStock.getInstance(null, mainWindow).bankChoices.ToList())
            {
                if (item != "Add new Type")
                {
                    SpecifiedImportStock.getInstance(null, mainWindow).bankChoices.Remove(item);
                }
            }
            using (SQLiteCommand mCmd = new SQLiteCommand("CREATE TABLE IF NOT EXISTS [StoredColumnsStock] " +
                                                          "(id INTEGER PRIMARY KEY AUTOINCREMENT, 'BankName' TEXT, 'TransStartRow' INTEGER, " +
                                                          "'StockName' TEXT, 'PriceColumn' TEXT, 'QuantityColumn' TEXT, 'DateColumn' TEXT, " +
                                                          "'TypeColumn' TEXT);", mConn))
            {
                mCmd.ExecuteNonQuery();
            }
            string        storedQuery = "select distinct BankName from [StoredColumnsStock]";
            SQLiteCommand command     = new SQLiteCommand(storedQuery, mConn);

            System.Data.DataTable datatable = new System.Data.DataTable();
            SQLiteDataAdapter     adapter   = new SQLiteDataAdapter(command);

            adapter.Fill(datatable);
            if (datatable.Rows.Count > 0)
            {
                foreach (DataRow row in dtb.Rows)
                {
                    SpecifiedImportStock.getInstance(null, mainWindow).bankChoices.Add(row["BankName"].ToString());
                }
            }
            mConn.Close();

            /*
             * SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ImportFileData;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
             * sqlConn.Open();
             * string getEveryRow = "Select distinct BankName From [StoredColumns_Stock]";
             * SqlDataAdapter sda = new SqlDataAdapter(getEveryRow, sqlConn);
             * System.Data.DataTable datatable = new System.Data.DataTable();
             * sda.Fill(datatable);
             * if (datatable.Rows.Count > 0)
             * {
             *  foreach (DataRow row in dtb.Rows)
             *  {
             *      SpecifiedImportStock.getInstance(null, mainWindow).bankChoices.Add(row["BankName"].ToString());
             *  }
             * }
             */
        }
 public void setSpecifiedImportPageTextBoxes()
 {
     if (mostMatchingRow != null)
     {
         SpecifiedImportStock.getInstance(null, mainWindow).bankChoice = mostMatchingRow["BankName"].ToString();
         SpecifiedImportStock.getInstance(null, mainWindow).transactionsRowTextBox.Text = mostMatchingRow["TransStartRow"].ToString();
         SpecifiedImportStock.getInstance(null, mainWindow).stockNameColumnTextBox.Text = mostMatchingRow["StockName"].ToString();
         SpecifiedImportStock.getInstance(null, mainWindow).priceColumnTextBox.Text     = mostMatchingRow["PriceColumn"].ToString();
         SpecifiedImportStock.getInstance(null, mainWindow).quantityColumnTextBox.Text  = mostMatchingRow["QuantityColumn"].ToString();
         SpecifiedImportStock.getInstance(null, mainWindow).dateColumnTextBox.Text      = mostMatchingRow["DateColumn"].ToString();
         SpecifiedImportStock.getInstance(null, mainWindow).transactionTypeTextBox.Text = mostMatchingRow["TypeColumn"].ToString();
     }
     else//no data in sql
     {
         SpecifiedImportStock.getInstance(null, mainWindow).bankChoice = "Add new Type";
     }
 }
Пример #8
0
        private void addImportFileDataToDB(int startingRow, string nameColumnString, string priceColumnString,
                                           string quantityColumnString, string dateColumnString, string transactionTypeColumnString)
        {
            SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ImportFileData;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");

            sqlConn.Open();

            string storedQuery = "";

            storedQuery = "Select * From [StoredColumns_Stock] where TransStartRow = '" + startingRow + "'" +
                          " AND StockName = '" + nameColumnString + "'" +
                          " AND PriceColumn = '" + priceColumnString + "'" +
                          " AND QuantityColumn = '" + quantityColumnString + "'" +
                          " AND DateColumn = '" + dateColumnString + "'" +
                          " AND TypeColumn = '" + transactionTypeColumnString + "'";
            SqlDataAdapter sda = new SqlDataAdapter(storedQuery, sqlConn);

            System.Data.DataTable dtb = new System.Data.DataTable();
            sda.Fill(dtb);
            if (dtb.Rows.Count == 0)
            {
                SqlCommand sqlCommand = new SqlCommand("insertNewStockColumns", sqlConn);//insertNewStockColumns2
                sqlCommand.CommandType = CommandType.StoredProcedure;
                if (SpecifiedImportStock.getInstance(null, mainWindow).storedTypesCB.SelectedItem.ToString() == "Add new Type")
                {
                    string newBankName = SpecifiedImportStock.getInstance(null, mainWindow).newBankTextbox.Text.ToString();
                    sqlCommand.Parameters.AddWithValue("@bankName", newBankName);
                }
                else
                {
                    string bankName = SpecifiedImportStock.getInstance(null, mainWindow).storedTypesCB.SelectedItem.ToString();
                    sqlCommand.Parameters.AddWithValue("@bankName", bankName);
                }
                sqlCommand.Parameters.AddWithValue("@transStartRow", startingRow);
                sqlCommand.Parameters.AddWithValue("@stockName", nameColumnString);
                sqlCommand.Parameters.AddWithValue("@priceColumn", priceColumnString);
                sqlCommand.Parameters.AddWithValue("@quantityColumn", quantityColumnString);
                sqlCommand.Parameters.AddWithValue("@dateColumn", dateColumnString);
                sqlCommand.Parameters.AddWithValue("@typeColumn", transactionTypeColumnString);
                sqlCommand.ExecuteNonQuery();
            }
        }
Пример #9
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)
                    {
                        new ImportReadIn("Stock", fileAdresses, mainWindow, false);
                    }
                    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]);
                        mainWindow.MainFrame.Content = SpecifiedImportStock.getInstance(fileAdresses, mainWindow);
                    }
                }
            }
        }
        private void addImportFileDataToDB(int startingRow, string nameColumnString, string priceColumnString,
                                           string quantityColumnString, string dateColumnString, string transactionTypeColumnString)
        {
            mConn.Open();
            using (SQLiteCommand mCmd = new SQLiteCommand("CREATE TABLE IF NOT EXISTS [StoredColumnsStock] " +
                                                          "(id INTEGER PRIMARY KEY AUTOINCREMENT, 'BankName' TEXT, 'TransStartRow' INTEGER, " +
                                                          "'StockName' TEXT, 'PriceColumn' TEXT, 'QuantityColumn' TEXT, 'DateColumn' TEXT, " +
                                                          "'TypeColumn' TEXT);", mConn))
            {
                mCmd.ExecuteNonQuery();
            }
            string storedQuery = "";

            storedQuery = "Select * From [StoredColumnsStock] where TransStartRow = '" + startingRow + "'" +
                          " AND StockName = '" + nameColumnString + "'" +
                          " AND PriceColumn = '" + priceColumnString + "'" +
                          " AND QuantityColumn = '" + quantityColumnString + "'" +
                          " AND DateColumn = '" + dateColumnString + "'" +
                          " AND TypeColumn = '" + transactionTypeColumnString + "'";
            SQLiteCommand command = new SQLiteCommand(storedQuery, mConn);

            System.Data.DataTable dtb     = new System.Data.DataTable();
            SQLiteDataAdapter     adapter = new SQLiteDataAdapter(command);

            adapter.Fill(dtb);
            if (dtb.Rows.Count == 0)
            {
                string insertQuery = "insert into [StoredColumnsStock](BankName, TransStartRow, StockName,PriceColumn,QuantityColumn,DateColumn,TypeColumn) " +
                                     "values(";
                if (SpecifiedImportStock.getInstance(null, mainWindow).storedTypesCB.SelectedItem.ToString() == "Add new Type")
                {
                    string newBankName = SpecifiedImportStock.getInstance(null, mainWindow).newBankTextbox.Text.ToString();
                    insertQuery += "'" + newBankName + "'";
                }
                else
                {
                    string bankName = SpecifiedImportStock.getInstance(null, mainWindow).storedTypesCB.SelectedItem.ToString();
                    insertQuery += "'" + bankName + "'";
                }
                insertQuery += ",'" + startingRow + "','" + nameColumnString +
                               "','" + priceColumnString + "','" + quantityColumnString +
                               "','" + dateColumnString + "','" + transactionTypeColumnString + "')";
                SQLiteCommand insercommand = new SQLiteCommand(insertQuery, mConn);
                insercommand.CommandType = CommandType.Text;
                insercommand.ExecuteNonQuery();
                mConn.Close();
            }

            /*
             * SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ImportFileData;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False");
             * sqlConn.Open();
             *
             * string storedQuery = "";
             * storedQuery = "Select * From [StoredColumns_Stock] where TransStartRow = '" + startingRow + "'" +
             * " AND StockName = '" + nameColumnString + "'" +
             * " AND PriceColumn = '" + priceColumnString + "'" +
             * " AND QuantityColumn = '" + quantityColumnString + "'" +
             * " AND DateColumn = '" + dateColumnString + "'" +
             * " AND TypeColumn = '" + transactionTypeColumnString + "'";
             * SqlDataAdapter sda = new SqlDataAdapter(storedQuery, sqlConn);
             * System.Data.DataTable dtb = new System.Data.DataTable();
             * sda.Fill(dtb);
             * if (dtb.Rows.Count == 0)
             * {
             *  SqlCommand sqlCommand = new SqlCommand("insertNewStockColumns", sqlConn);//insertNewStockColumns2
             *  sqlCommand.CommandType = CommandType.StoredProcedure;
             *  if (SpecifiedImportStock.getInstance(null, mainWindow).storedTypesCB.SelectedItem.ToString() == "Add new Type")
             *  {
             *      string newBankName = SpecifiedImportStock.getInstance(null, mainWindow).newBankTextbox.Text.ToString();
             *      sqlCommand.Parameters.AddWithValue("@bankName", newBankName);
             *  }
             *  else
             *  {
             *      string bankName = SpecifiedImportStock.getInstance(null, mainWindow).storedTypesCB.SelectedItem.ToString();
             *      sqlCommand.Parameters.AddWithValue("@bankName", bankName);
             *  }
             *  sqlCommand.Parameters.AddWithValue("@transStartRow", startingRow);
             *  sqlCommand.Parameters.AddWithValue("@stockName", nameColumnString);
             *  sqlCommand.Parameters.AddWithValue("@priceColumn", priceColumnString);
             *  sqlCommand.Parameters.AddWithValue("@quantityColumn", quantityColumnString);
             *  sqlCommand.Parameters.AddWithValue("@dateColumn", dateColumnString);
             *  sqlCommand.Parameters.AddWithValue("@typeColumn", transactionTypeColumnString);
             *  sqlCommand.ExecuteNonQuery();
             * }
             */
        }
        public void readOutUserspecifiedTransactions(string startingRowString, string nameColumnString, string priceColumnString,
                                                     string quantityColumnString, string dateColumnString, string transactionTypeColumnString)
        {
            int startingRow = 0;

            try
            {
                startingRow = int.Parse(startingRowString);
            }
            catch (Exception e)
            {
                startingRow = ExcelColumnNameToNumber(startingRowString);
            }
            int nameColumn = 0;

            try
            {
                nameColumn = int.Parse(nameColumnString);
            }
            catch (Exception e)
            {
                nameColumn = ExcelColumnNameToNumber(nameColumnString);
            }
            int priceColumn = 0;

            try
            {
                priceColumn = int.Parse(priceColumnString);
            }
            catch (Exception e)
            {
                priceColumn = ExcelColumnNameToNumber(priceColumnString);
            }
            int quantityColumn = 0;

            try
            {
                quantityColumn = int.Parse(quantityColumnString);
            }
            catch (Exception e)
            {
                quantityColumn = ExcelColumnNameToNumber(quantityColumnString);
            }
            int dateColumn = 0;

            try
            {
                dateColumn = int.Parse(dateColumnString);
            }
            catch (Exception e)
            {
                dateColumn = ExcelColumnNameToNumber(dateColumnString);
            }
            int transactionTypeColumn = 0;

            try
            {
                transactionTypeColumn = int.Parse(transactionTypeColumnString);
            }
            catch (Exception e)
            {
                transactionTypeColumn = ExcelColumnNameToNumber(transactionTypeColumnString);
            }
            Console.WriteLine(startingRow + " - " + nameColumn + " - " + dateColumn + " - " + priceColumn);
            if ((nameColumn != 0) && (dateColumn != 0) && (priceColumn != 0))
            {
                importedStocks = new List <Stock>();
                int blank_cell_counter = 0;
                while (blank_cell_counter < 2)
                {
                    if ((stockWorksheet.Cells[startingRow, nameColumn].Value != null) &&
                        (stockWorksheet.Cells[startingRow, dateColumn].Value != null) &&
                        (stockWorksheet.Cells[startingRow, priceColumn].Value != null))
                    {
                        blank_cell_counter = 0;
                        string companyName            = stockWorksheet.Cells[startingRow, nameColumn].Value.ToString();
                        string transactionDate        = stockWorksheet.Cells[startingRow, dateColumn].Value.ToString();
                        string transactionPriceString = stockWorksheet.Cells[startingRow, priceColumn].Value.ToString().Replace(',', '.');
                        double transactionPrice       = 0;
                        try
                        {
                            transactionPrice = double.Parse(transactionPriceString, CultureInfo.InvariantCulture);
                        }
                        catch (Exception e)
                        {
                        }
                        string transactionType = "-";
                        string quantityString  = "";
                        int    quantity        = 1;
                        if (stockWorksheet.Cells[startingRow, transactionTypeColumn].Value != null)
                        {
                            transactionType = stockWorksheet.Cells[startingRow, transactionTypeColumn].Value.ToString();
                        }
                        if (stockWorksheet.Cells[startingRow, quantityColumn].Value != null)
                        {
                            quantityString = stockWorksheet.Cells[startingRow, quantityColumn].Value.ToString();
                            try
                            {
                                quantity = int.Parse(quantityString);
                            }
                            catch (Exception e)
                            {
                            }
                        }
                        Stock stock = new Stock(companyName, transactionPrice.ToString(), quantity, transactionDate, transactionType);
                        importedStocks.Add(stock);
                    }
                    else
                    {
                        blank_cell_counter++;
                    }
                    startingRow++;
                }
            }
            if (importedStocks.Count > 0)
            {
                string bankName = "";
                if (SpecifiedImportStock.getInstance(null, mainWindow).storedTypesCB.SelectedItem.ToString() != "Add new Type")
                {
                    bankName = SpecifiedImportStock.getInstance(null, mainWindow).storedTypesCB.SelectedItem.ToString();
                }
                else
                {
                    bankName = SpecifiedImportStock.getInstance(null, mainWindow).newBankTextbox.Text.ToString();
                }

                /*
                 * for (int i = 0; i < importedStocks.Count; i++)
                 *  importedStocks[i].setBankname(bankName);
                 */
                stockHandler.addTransactions(importedStocks);
                //todo another thread
                addImportFileDataToDB(int.Parse(startingRowString), nameColumnString,
                                      priceColumnString, quantityColumnString, dateColumnString, transactionTypeColumnString);
            }
        }