public void setTableAttributes() { bankChoices = new List <string>(); List <Transaction> allTransactions = SavedTransactions.getSavedTransactionsBank(); List <Transaction> reference = new List <Transaction>(); string[] splittedAccountNumbers = mainWindow.getCurrentUser().getAccountNumber().Split(','); foreach (var tableAttribute in allTransactions) { for (int i = 0; i < splittedAccountNumbers.Length; i++) { if (tableAttribute.getAccountNumber() == splittedAccountNumbers[i]) { reference.Add(tableAttribute); break; } } } tableAttributes = reference; foreach (var x in tableAttributes) { if (!bankChoices.Contains(x.getBankname())) { bankChoices.Add(x.getBankname()); } } }
public void setTableAttributes() { List <Transaction> allTransactions = SavedTransactions.getSavedTransactionsBank(); List <Transaction> reference = new List <Transaction>(); foreach (var tableAttribute in allTransactions) { string[] splittedAccountNumbers = mainWindow.getCurrentUser().getAccountNumber().Split(','); for (int i = 0; i < splittedAccountNumbers.Length; i++) { if (tableAttribute.getAccountNumber() == splittedAccountNumbers[i]) { reference.Add(tableAttribute); break; } } } tableAttributes = new List <Transaction>(reference); if (tableAttributes != null) { foreach (var transaction in tableAttributes) { if (transaction.getWriteDate() != null && transaction.getWriteDate().Length >= 12) { transaction.setWriteDate(transaction.getWriteDate().Substring(0, 12)); } else { transaction.setWriteDate(DateTime.Now.ToString("yyyy/MM/dd")); } } } }
public void setTableAttributes() { //Binding is the reason for .ToList() , the count changed - it freezes it is not there List <Stock> allTransactions = SavedTransactions.getSavedTransactionsStock(); List <Stock> reference = new List <Stock>(); foreach (var tableAttribute in allTransactions) { if (tableAttribute.getImporter() == mainWindow.getCurrentUser().getUsername()) { reference.Add(tableAttribute); } } tableAttributes = new List <Stock>(reference); if (tableAttributes != null) { foreach (var transaction in tableAttributes) { if (transaction.getWriteDate() != null && transaction.getWriteDate().Length >= 12) { transaction.setWriteDate(transaction.getWriteDate().Substring(0, 12)); } else { transaction.setWriteDate(DateTime.Now.ToString("yyyy/MM/dd")); } } } }
public void Execute(object parameter) { mainWindow.tableDock.Background = new SolidColorBrush(Color.FromRgb(217, 133, 59)); mainWindow.importDock.Background = new SolidColorBrush(Color.FromRgb(217, 133, 59)); mainWindow.stockChartDock.Background = new SolidColorBrush(Color.FromRgb(217, 133, 59)); mainWindow.tableMenuTop.Visibility = System.Windows.Visibility.Hidden; mainWindow.importMenuTop.Visibility = System.Windows.Visibility.Hidden; mainWindow.portfolioMenuTop.Visibility = System.Windows.Visibility.Hidden; if (buttonContent.Equals("Import")) { ImportMainPage.getInstance(mainWindow).setUserStatistics(mainWindow.getCurrentUser()); mainWindow.MainFrame.Content = ImportMainPage.getInstance(mainWindow); mainWindow.importMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.importDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); } else if (buttonContent.Equals("Database")) { TransactionMain.getInstance(mainWindow).setTableAttributes(); mainWindow.MainFrame.Content = TransactionMain.getInstance(mainWindow); mainWindow.tableMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.tableDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); } else if (buttonContent.Equals("stockMarketData")) { if (mainWindow.webStockStopwatch.Elapsed == TimeSpan.FromMilliseconds(0)) { mainWindow.webStockStopwatch.Start(); StockChart stockChart = new StockChart(); mainWindow.MainFrame.Content = stockChart; mainWindow.portfolioMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.stockChartDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); } else { if (mainWindow.webStockStopwatch.Elapsed <= TimeSpan.FromMinutes(1.5)) { MessageBox.Show("Please wait for " + (TimeSpan.FromMinutes(1.5) - mainWindow.webStockStopwatch.Elapsed) + " seconds!"); } else { mainWindow.webStockStopwatch.Stop(); mainWindow.webStockStopwatch.Reset(); } } } else if (buttonContent.Equals("Exit")) { mainWindow.Close(); } }
private void addAtribuesToTable() { foreach (var attribute in tableAttributes) { string[] splittedAccountNumbers = mainWindow.getCurrentUser().getAccountNumber().Split(','); for (int i = 0; i < splittedAccountNumbers.Length; i++) { if (attribute.getAccountNumber() == splittedAccountNumbers[i]) { TransactionTableXAML.Items.Add(attribute); } } } }
public void setTableAttributes() { //Binding is the reason for .ToList() , the count changed - it freezes it is not there List <Stock> allTransactions = SavedTransactions.getSavedTransactionsStock(); List <Stock> reference = new List <Stock>(); stockChoices = new List <string>(); foreach (var tableAttribute in allTransactions) { if (tableAttribute.getImporter() == mainWindow.getCurrentUser().getUsername()) { reference.Add(tableAttribute); } if (!stockChoices.Contains(tableAttribute.getStockName())) { stockChoices.Add(tableAttribute.getStockName()); } } tableAttributes = new List <Stock>(reference); if (tableAttributes != null) { foreach (var transaction in tableAttributes) { if (transaction.getProfit() != null && transaction.getProfit() != "-") { try { double profit = double.Parse(transaction.getProfit()); var f = new NumberFormatInfo { NumberGroupSeparator = "." }; var s = profit.ToString("n", f); transaction.setProfit(s); } catch (Exception e) { } } else { transaction.setProfit("-"); } } } }
private ImportMainPage(MainWindow mainWindow) { DataContext = this; InitializeComponent(); neverAskCB.IsChecked = true; descriptionComboBox.Visibility = System.Windows.Visibility.Hidden; this.mainWindow = mainWindow; this.currentUser = mainWindow.getCurrentUser(); if (currentUser.getAccountNumber().Equals(mainWindow.getAccounNumber())) { getUserStatistics(currentUser); } else { getUserStatistics(mainWindow.getAccounNumber()); } FolderAddressLabel.Visibility = System.Windows.Visibility.Hidden; }
public void MyAction(string commandName) { mainWindow.tableDock.Background = new SolidColorBrush(Color.FromRgb(217, 133, 59)); mainWindow.importDock.Background = new SolidColorBrush(Color.FromRgb(217, 133, 59)); mainWindow.stockChartDock.Background = new SolidColorBrush(Color.FromRgb(217, 133, 59)); mainWindow.tableMenuTop.Visibility = System.Windows.Visibility.Hidden; mainWindow.importMenuTop.Visibility = System.Windows.Visibility.Hidden; mainWindow.portfolioMenuTop.Visibility = System.Windows.Visibility.Hidden; mainWindow.bankImport.Background = Brushes.Transparent; mainWindow.stockImport.Background = Brushes.Transparent; mainWindow.bankDatabase.Background = Brushes.Transparent; mainWindow.stockDatabase.Background = Brushes.Transparent; mainWindow.stockChart.Background = Brushes.Transparent; mainWindow.stockDatagrid.Background = Brushes.Transparent; if (commandName == "bankImportPushed") { ImportPageBank.getInstance(mainWindow).setUserStatistics(mainWindow.getCurrentUser()); mainWindow.MainFrame.Content = ImportPageBank.getInstance(mainWindow); mainWindow.importMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.importDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); mainWindow.bankImport.Background = new SolidColorBrush(Color.FromRgb(255, 140, 105)); } else if (commandName == "stockImportPushed") { ImportPageStock.getInstance(mainWindow).setUserStatistics(mainWindow.getCurrentUser()); mainWindow.MainFrame.Content = ImportPageStock.getInstance(mainWindow); mainWindow.importMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.importDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); mainWindow.stockImport.Background = new SolidColorBrush(Color.FromRgb(255, 140, 105)); } else if (commandName == "bankDatabasePushed") { DatabaseDataBank.getInstance(mainWindow).setTableAttributes(); mainWindow.MainFrame.Content = DatabaseDataBank.getInstance(mainWindow); mainWindow.tableMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.tableDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); mainWindow.bankDatabase.Background = new SolidColorBrush(Color.FromRgb(255, 140, 105)); } else if (commandName == "stockDatabasePushed") { DatabaseDataStock.getInstance(mainWindow).setTableAttributes(); mainWindow.MainFrame.Content = DatabaseDataStock.getInstance(mainWindow); mainWindow.tableMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.tableDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); mainWindow.stockDatabase.Background = new SolidColorBrush(Color.FromRgb(255, 140, 105)); } else if (commandName == "stockChartPushed") { StockChart stockChart = new StockChart(mainWindow); mainWindow.MainFrame.Content = stockChart; mainWindow.portfolioMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.stockChartDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); mainWindow.stockChart.Background = new SolidColorBrush(Color.FromRgb(255, 140, 105)); } else if (commandName == "stockDatagridPushed") { mainWindow.MainFrame.Content = new StockDataGrid(mainWindow); mainWindow.portfolioMenuTop.Visibility = System.Windows.Visibility.Visible; mainWindow.stockChartDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); mainWindow.stockChart.Background = new SolidColorBrush(Color.FromRgb(255, 140, 105)); } else if (commandName == "Exit") { mainWindow.Close(); } }
public ExportTransactions(List <Transaction> transactions, MainWindow mainWindow, string currentFileName) { for (int i = 0; i < transactions.Count; i++) { string [] spaceSplitted = transactions[i].getTransactionDate().Split(' '); string dateString = ""; for (int j = 0; j < spaceSplitted.Length; j++) { dateString += spaceSplitted[j]; } Console.WriteLine(dateString.Substring(0, 11)); } this.mainWindow = mainWindow; MessageBox.Show("Exporting data from: " + currentFileName, "", MessageBoxButton.OK); //BUT FIRST - check if the transaction is already exported or not List <Transaction> neededTransactions = newTransactions(transactions); SavedTransactions.addToSavedTransactions(neededTransactions);//adding the freshyl imported transactions to the saved WriteWorkbook = excel.Workbooks.Open(@"C:\Users\Tocki\Desktop\Kimutatas.xlsx"); WriteWorksheet = WriteWorkbook.Worksheets[1]; if (neededTransactions != null) { string todaysDate = DateTime.Now.ToString("yyyy-MM-dd"); int row_number = 1; while (WriteWorksheet.Cells[row_number, 1].Value != null) { row_number++; // get the current last row } foreach (var transctn in neededTransactions) { WriteWorksheet.Cells[row_number, 1].Value = todaysDate; WriteWorksheet.Cells[row_number, 2].Value = transctn.getTransactionDate(); WriteWorksheet.Cells[row_number, 3].Value = transctn.getBalance_rn(); WriteWorksheet.Cells[row_number, 7].Value = transctn.getTransactionPrice(); if (transctn.getTransactionPrice() < 0) { WriteWorksheet.Cells[row_number, 9].Value = transctn.getTransactionPrice(); WriteWorksheet.Cells[row_number, 11].Value = transctn.getTransactionPrice(); WriteWorksheet.Cells[row_number, 15].Value = "havi"; } else { WriteWorksheet.Cells[row_number, 8].Value = transctn.getTransactionPrice(); WriteWorksheet.Cells[row_number, 10].Value = transctn.getTransactionPrice(); WriteWorksheet.Cells[row_number, 11].Value = transctn.getTransactionPrice(); WriteWorksheet.Cells[row_number, 15].Value = "havi"; } WriteWorksheet.Cells[row_number, 14].Value = transctn.getTransactionDescription(); WriteWorksheet.Cells[row_number, 16].Value = transctn.getAccountNumber(); row_number++; Range line = (Range)WriteWorksheet.Rows[row_number]; line.Insert(); } try { //WriteWorkbook.SaveAs(@"C:\Users\Tocki\Desktop\Kimutatas.xlsx"); excel.ActiveWorkbook.Save(); excel.Workbooks.Close(); excel.Quit(); } catch (Exception e) { } ImportMainPage.getInstance(mainWindow).setUserStatistics(mainWindow.getCurrentUser()); } else { return; } }
private void writeAccountNumberToSql(string accountNumber) { string storedAccountNumber = "-"; //alapértelmezett érték ha valaki regisztrált és még nem importált SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=LoginDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); string accountNumberQuery = "Select * From [UserDatas] where Username = '******'"; SqlDataAdapter sda = new SqlDataAdapter(accountNumberQuery, sqlConn); System.Data.DataTable dtb = new System.Data.DataTable(); sda.Fill(dtb); if (dtb.Rows.Count == 1) { foreach (System.Data.DataRow row in dtb.Rows) { storedAccountNumber = row["AccountNumber"].ToString(); } } string [] splittedAccountNumber = storedAccountNumber.Split(','); bool stored = false; for (int i = 0; i < splittedAccountNumber.Length; i++) { if (splittedAccountNumber[i] == accountNumber) { stored = true; break; } } if (!stored && storedAccountNumber != "-") { storedAccountNumber += "," + accountNumber; using (SqlCommand command = sqlConn.CreateCommand()) { command.CommandText = "UPDATE UserDatas SET AccountNumber = '" + storedAccountNumber + "' Where Username = '******'"; sqlConn.Open(); command.ExecuteNonQuery(); sqlConn.Close(); } } else if (storedAccountNumber == "-") { storedAccountNumber = accountNumber; using (SqlCommand command = sqlConn.CreateCommand()) { command.CommandText = "UPDATE UserDatas SET AccountNumber = '" + storedAccountNumber + "' Where Username = '******'"; sqlConn.Open(); command.ExecuteNonQuery(); sqlConn.Close(); } } }
private void Button_Click(object sender, RoutedEventArgs e) { mConn.Open(); using (SQLiteCommand mCmd = new SQLiteCommand("CREATE TABLE IF NOT EXISTS [UserInfo] " + "(id INTEGER PRIMARY KEY AUTOINCREMENT, 'Username' TEXT, 'Password' TEXT, 'AccountNumber' TEXT);", mConn)) { mCmd.ExecuteNonQuery(); } string usernameInUseQuery = "select * from [UserInfo] where Username= '******'"; SQLiteCommand command = new SQLiteCommand(usernameInUseQuery, mConn); DataTable dtb = new DataTable(); SQLiteDataAdapter adapter = new SQLiteDataAdapter(command); adapter.Fill(dtb); if (dtb.Rows.Count == 1) { string decryptedPassword = decryptString(dtb.Rows[0][2].ToString()); if (decryptedPassword == passwordTextbox.Password.ToString()) { failedLogins = 0; User currentUser = new User(); currentUser.setUsername(usernameTextbox.Text.ToString()); currentUser.setAccountNumber(dtb.Rows[0][3].ToString()); mainWindow.currentUserLabel.Content = currentUser.getUsername(); //notification label mainWindow.setCurrentUser(currentUser); this.Visibility = Visibility.Hidden; ImportPageBank.getInstance(mainWindow).setUserStatistics(mainWindow.getCurrentUser()); mainWindow.MainFrame.Content = ImportPageBank.getInstance(mainWindow); mainWindow.importMenuTop.Visibility = Visibility.Visible; mainWindow.importDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); mainWindow.bankImport.Background = new SolidColorBrush(Color.FromRgb(255, 140, 105)); } else { failedLogins++; if (failedLogins >= 3) { timer1 = new DispatcherTimer(); tik = 30; timer1.Interval = new TimeSpan(0, 0, 0, 1); timer1.Tick += new EventHandler(timer1_Tick); timer1.Start(); } MessageBox.Show("Wrong username or password!"); } } else { failedLogins++; if (failedLogins >= 3) { timer1 = new DispatcherTimer(); tik = 30; timer1.Interval = new TimeSpan(0, 0, 0, 1); timer1.Tick += new EventHandler(timer1_Tick); timer1.Start(); } MessageBox.Show("Wrong username or password!"); } mConn.Close(); /* * SqlConnection sqlConn = new SqlConnection("Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=LoginDB;Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False"); * string loginQuery = "Select * From [UserDatas] where username = '******'"; * SqlDataAdapter sda = new SqlDataAdapter(loginQuery,sqlConn); * DataTable dtb = new DataTable(); * sda.Fill(dtb); * if(dtb.Rows.Count==1) * { * string decryptedPassword = decryptString(dtb.Rows[0][1].ToString()); * if (decryptedPassword == passwordTextbox.Password.ToString()) * { * failedLogins = 0; * User currentUser = new User(); * currentUser.setUsername(usernameTextbox.Text.ToString()); * currentUser.setAccountNumber(dtb.Rows[0][2].ToString()); * mainWindow.currentUserLabel.Content = currentUser.getUsername(); //notification label * mainWindow.setCurrentUser(currentUser); * Visibility = System.Windows.Visibility.Hidden; * ImportPageBank.getInstance(mainWindow).setUserStatistics(mainWindow.getCurrentUser()); * mainWindow.MainFrame.Content = ImportPageBank.getInstance(mainWindow); * mainWindow.importMenuTop.Visibility = System.Windows.Visibility.Visible; * mainWindow.importDock.Background = new SolidColorBrush(Color.FromRgb(198, 61, 15)); * mainWindow.bankImport.Background = new SolidColorBrush(Color.FromRgb(255, 140, 105)); * } * else * { * MessageBox.Show("Wrong username or password!"); * failedLogins++; * if (failedLogins > 3) * { * timer1 = new DispatcherTimer(); * tik = 30; * timer1.Interval = new TimeSpan(0, 0, 0, 1); * timer1.Tick += new EventHandler(timer1_Tick); * timer1.Start(); * } * } * } * else * { * MessageBox.Show("Wrong username or password!"); * failedLogins++; * if (failedLogins > 3) * { * timer1 = new DispatcherTimer(); * tik = 30; * timer1.Interval = new TimeSpan(0, 0, 0, 1); * timer1.Tick += new EventHandler(timer1_Tick); * timer1.Start(); * } * } */ }
public ExportTransactions(List <Stock> customTransactions, MainWindow mainWindow, string currentFileName, string customEarning) { for (int i = 0; i < customTransactions.Count; i++) { customTransactions[i].setImporter(mainWindow.getCurrentUser().getUsername()); customTransactions[i].setEarningMethod(customEarning); } MessageBox.Show("Exporting data from: " + currentFileName, "", MessageBoxButton.OK); SavedTransactions.addToSavedTransactionsStock(customTransactions); //adding the freshyl imported transactions to the saved WriteWorkbook = excel.Workbooks.Open(@"C:\Users\Tocki\Desktop\Kimutatas.xlsx"); WriteWorksheet = WriteWorkbook.Worksheets[2]; string todaysDate = DateTime.Now.ToString("yyyy-MM-dd"); int row_number = 1; while (WriteWorksheet.Cells[row_number, 1].Value != null) { row_number++; // get the current last row } for (int i = 0; i < customTransactions.Count; i++) { WriteWorksheet.Cells[row_number, 1].Value = todaysDate; WriteWorksheet.Cells[row_number, 2].Value = customTransactions[i].getTransactionDate(); WriteWorksheet.Cells[row_number, 3].Value = customTransactions[i].getStockName(); WriteWorksheet.Cells[row_number, 4].Value = customTransactions[i].getStockPrice(); Regex typeRegex1 = new Regex(@"Eladott"); Regex typeRegex2 = new Regex(@"Sold"); Regex typeRegex3 = new Regex(@"Sell"); Regex typeRegex4 = new Regex(@"Vásárolt"); Regex typeRegex5 = new Regex(@"Bought"); Regex typeRegex6 = new Regex(@"Buy"); if (typeRegex1.IsMatch(customTransactions[i].getTransactionType()) || typeRegex2.IsMatch(customTransactions[i].getTransactionType()) || typeRegex3.IsMatch(customTransactions[i].getTransactionType())) //Eladott { WriteWorksheet.Cells[row_number, 5].Value = customTransactions[i].getOriginalQuantityForCustomEarning(); //!! eredeti quantity WriteWorksheet.Cells[row_number, 9].Value = customTransactions[i].getProfit(); WriteWorksheet.Cells[row_number, 10].Value = customEarning; } else if (typeRegex4.IsMatch(customTransactions[i].getTransactionType()) || typeRegex5.IsMatch(customTransactions[i].getTransactionType()) || typeRegex6.IsMatch(customTransactions[i].getTransactionType())) //Vásárolt { WriteWorksheet.Cells[row_number, 6].Value = customTransactions[i].getOriginalQuantityForCustomEarning(); //! eredeti quantity WriteWorksheet.Cells[row_number, 8].Value = customTransactions[i].getOriginalQuantityForCustomEarning() * customTransactions[i].getStockPrice(); //!! eredeti quantity } WriteWorksheet.Cells[row_number, 7].Value = customTransactions[i].getQuantity(); //!! mostani quantity WriteWorksheet.Cells[row_number, 11].Value = mainWindow.getCurrentUser().getUsername(); row_number++; Range line = (Range)WriteWorksheet.Rows[row_number]; line.Insert(); } try { excel.ActiveWorkbook.Save(); excel.Workbooks.Close(); excel.Quit(); } catch (Exception e) { } ImportPageStock.getInstance(mainWindow).setUserStatistics(mainWindow.getCurrentUser()); }
public ExportTransactions(List <Stock> transactions, MainWindow mainWindow, string currentFileName) { string earningMethod = ImportPageStock.getInstance(mainWindow).getMethod(); //we need the original quantity that's we going to get it from the original transactions List //(after the switch it is zero for every object) List <int> quantities = new List <int>(); for (int i = 0; i < transactions.Count; i++) { quantities.Add(transactions[i].getQuantity()); } //but we need the profits too , which we going to get from the tempTransactions switch (earningMethod) { case "FIFO": stockExportFIFO(ref transactions); break; case "LIFO": stockExportLIFO(ref transactions); break; case "CUSTOM": mainWindow.MainFrame.Content = new CustomStockExportPage(mainWindow, transactions, currentFileName); break; } if (earningMethod == "FIFO" || earningMethod == "LIFO") { //for DataBaseDataStock for (int i = 0; i < transactions.Count; i++) { string value = quantities[i] + " (" + transactions[i].getQuantity() + ")"; transactions[i].setOriginalAndSellQuantity(value); transactions[i].setImporter(mainWindow.getCurrentUser().getUsername()); transactions[i].setEarningMethod(earningMethod); } MessageBox.Show("Exporting data from: " + currentFileName, "", MessageBoxButton.OK); SavedTransactions.addToSavedTransactionsStock(transactions);//adding the freshyl imported transactions to the saved WriteWorkbook = excel.Workbooks.Open(@"C:\Users\Tocki\Desktop\Kimutatas.xlsx"); WriteWorksheet = WriteWorkbook.Worksheets[2]; string todaysDate = DateTime.Now.ToString("yyyy-MM-dd"); int row_number = 1; while (WriteWorksheet.Cells[row_number, 1].Value != null) { row_number++; // get the current last row } for (int i = 0; i < transactions.Count; i++) { WriteWorksheet.Cells[row_number, 1].Value = todaysDate; WriteWorksheet.Cells[row_number, 2].Value = transactions[i].getTransactionDate(); WriteWorksheet.Cells[row_number, 3].Value = transactions[i].getStockName(); WriteWorksheet.Cells[row_number, 4].Value = transactions[i].getStockPrice(); Regex typeRegex1 = new Regex(@"Eladott"); Regex typeRegex2 = new Regex(@"Sold"); Regex typeRegex3 = new Regex(@"Sell"); Regex typeRegex4 = new Regex(@"Vásárolt"); Regex typeRegex5 = new Regex(@"Bought"); Regex typeRegex6 = new Regex(@"Buy"); if (typeRegex1.IsMatch(transactions[i].getTransactionType()) || typeRegex2.IsMatch(transactions[i].getTransactionType()) || typeRegex3.IsMatch(transactions[i].getTransactionType())) //Eladott { WriteWorksheet.Cells[row_number, 5].Value = quantities[i]; //!! eredeti quantity WriteWorksheet.Cells[row_number, 9].Value = transactions[i].getProfit(); WriteWorksheet.Cells[row_number, 10].Value = earningMethod; } else if (typeRegex4.IsMatch(transactions[i].getTransactionType()) || typeRegex5.IsMatch(transactions[i].getTransactionType()) || typeRegex6.IsMatch(transactions[i].getTransactionType())) //Vásárolt { WriteWorksheet.Cells[row_number, 6].Value = quantities[i]; //! eredeti quantity WriteWorksheet.Cells[row_number, 8].Value = quantities[i] * transactions[i].getStockPrice(); //!! eredeti quantity } WriteWorksheet.Cells[row_number, 7].Value = transactions[i].getQuantity(); //!! mostani quantity WriteWorksheet.Cells[row_number, 11].Value = mainWindow.getCurrentUser().getUsername(); row_number++; Range line = (Range)WriteWorksheet.Rows[row_number]; line.Insert(); } try { excel.ActiveWorkbook.Save(); excel.Workbooks.Close(); excel.Quit(); } catch (Exception e) { } ImportPageStock.getInstance(mainWindow).setUserStatistics(mainWindow.getCurrentUser()); } }