public void RestoreTradeDialog() { DateTime tradeDate = _selectedTransaction.TradeDate; int tradeFundId = _selectedTransaction.FundId; MessageBoxResult result = MessageBox.Show("Are you sure that you want to restore this trade?", "Restore Trade", button: MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: if (!_staticReferences.GetPeriod(tradeDate, tradeFundId).isLocked) { if (_selectedTransaction.Security.AssetClass.Name == "FXForward") { _transactionService.RestoreFXTransaction(_selectedTransaction); } else { _transactionService.RestoreTransaction(_selectedTransaction); } SelectFundCommand.Execute(_currentFund.Symbol); } else { MessageBox.Show($"To Restore this trade the period of {tradeDate.ToString("dd-MM-yyyy")} must be unlocked", "Unable to Restore"); } break; case MessageBoxResult.No: break; } }
public void OpenFundInitialisationWindow() { if (_currentFund == null) { MessageBox.Show("You need to create a fund first", "Information"); } else { _windowFactory.CreateFundInitialisationWindow(_currentFund); SelectFundCommand.Execute(_currentFund.Symbol); } }
public void DeleteTradeDialog() { string n = Environment.NewLine; string message; DateTime tradeDate = _selectedTransaction.TradeDate; int tradeFundId = _selectedTransaction.FundId; if (!_selectedTransaction.isCashTransaction) { string secSymbol = _selectedTransaction.Security.Symbol; string secName = _selectedTransaction.Security.SecurityName; decimal quantity = _selectedTransaction.Quantity; decimal price = _selectedTransaction.Price; message = $"Are you sure you want to delete the following Trade:{n}Security: {secName} ({secSymbol}){n}Quantity: {quantity}{n}Price: {price}"; } else { string tradeType = _selectedTransaction.TransactionType.TypeName; string cashSymbol = _selectedTransaction.Currency.Symbol; decimal amount = _selectedTransaction.TradeAmount; message = $"Are you sure you want to delete the following Trade:{n}Type: {tradeType}{n}Security: {cashSymbol}{n}Transaction Amount: {amount}{n}"; } MessageBoxResult result = MessageBox.Show(message, "Delete Trade", button: MessageBoxButton.YesNo); switch (result) { case MessageBoxResult.Yes: // A bug that crashes the application is caused here if the period does not exist (i.e. fund is monthly...) TODO if (!_staticReferences.GetPeriod(tradeDate, tradeFundId).isLocked) { if (_selectedTransaction.Security.AssetClass.Name == "FXForward") { _transactionService.DeleteFXTransaction(_selectedTransaction); } else { _transactionService.DeleteTransaction(_selectedTransaction); } SelectFundCommand.Execute(_currentFund.Symbol); } else { MessageBox.Show($"To Delete this trade the period of {tradeDate.ToString("dd-MM-yyyy")} must be unlocked", "Unable to Restore"); } break; case MessageBoxResult.No: break; } }