コード例 #1
0
        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;
            }
        }
コード例 #2
0
 public void OpenFundInitialisationWindow()
 {
     if (_currentFund == null)
     {
         MessageBox.Show("You need to create a fund first", "Information");
     }
     else
     {
         _windowFactory.CreateFundInitialisationWindow(_currentFund);
         SelectFundCommand.Execute(_currentFund.Symbol);
     }
 }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        public AllFundsViewModel(IFundService fundService,
                                 ITransactionService transactionService, IPortfolioService portfolioService,
                                 IStaticReferences staticReferences, IWindowFactory windowFactory)
        {
            _fundService        = fundService;
            _portfolioService   = portfolioService;
            _transactionService = transactionService;
            _staticReferences   = staticReferences;
            _windowFactory      = windowFactory;

            _lbFunds            = _fundService.GetAllFundSymbols();
            _currentFund        = (lbFunds.Count != 0) ? _fundService.GetFund(_lbFunds[0]) : null;
            _asOfDate           = (_currentFund != null) ? _staticReferences.GetMostRecentLockedDate(_currentFund.FundId) : DateTime.Today;
            _priceTable         = _staticReferences.GetPriceTable(_asOfDate);
            SelectFundCommand   = new SelectFundCommand(this, fundService, staticReferences);
            ShowNewTradeCommand = new ActionCommand(OpenNewTradeWindow);

            ShowEditTradeCommand = new ActionCommand(OpenEditTradeWindow);

            ShowDeleteTradeCommand = new ActionCommand(DeleteTradeDialog);

            ShowRestoreTradeCommand = new ActionCommand(RestoreTradeDialog);

            ShowNewFXTradeCommand         = new ActionCommand(OpenNewFxTradeWindow);
            ShowNewCashTradeCommand       = new ActionCommand(OpenNewCashTradeWindow);
            ShowEditCashTradeCommand      = new ActionCommand(OpenEditCashTradeWindow);
            ShowNewInvestorActionCommand  = new ActionCommand(OpenInvestorActionWindow);
            ShowFundInitialisationCommand = new ActionCommand(OpenFundInitialisationWindow);
            ShowFundPropertiesCommand     = new ActionCommand(OpenFundPropertiesWindow);

            ShowFundMetricsCommand = new ActionCommand(OpenMetricsWindow);

            ShowPositionDetailsCommand = new ActionCommand(OpenPositionDetailWindow);

            ShowNavSummaryCommand       = new ActionCommand(OpenNavSummaryWindow);
            DateSelectionChangedCommand = new ActionCommand(ChangeDateCommand);
            RefreshFundCommand          = new ActionCommand(RefreshCurrentFund);
        }