Exemplo n.º 1
0
        private void ButtonSubmit_Click(object sender, EventArgs e)
        {
            TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook);
            Currency     currency     = new Currency(textBoxCurrency.Text);
            Fund         newFund      = new Fund(textBoxFundName.Text, textBoxIsin.Text, textBoxCustodyNr.Text, currency);

            tableUtility.CreateMissingTable(currency);
            tableUtility.CreateMissingTable(newFund);

            List <string> currencyData = new List <string>()
            {
                currency.IsoCode
            };

            tableUtility.InsertTableRow(currency, currencyData);
            List <string> fundData = new List <string>()
            {
                newFund.Name,
                newFund.CustodyAccountNumber,
                newFund.Isin,
                currency.GetIndex().ToString()
            };

            tableUtility.InsertTableRow(newFund, fundData);
            fundBindingSource.Add(newFund);
        }
Exemplo n.º 2
0
        public void OnSubmit(Country obj)
        {
            TableUtility tableUtility = new TableUtility();

            tableUtility.InsertTableRow(obj);
            FormUtility.GetBindingSource(dataGridView).Add(obj);
        }
        private void InitializeCustomComponents()
        {
            dataGridFunds = FormUtility.CreateDataGridView(typeof(Fund), 80, 580);
            ToolStripMenuItem itemDelete   = FormUtility.CreateContextMenuItem("Löschen", DeleteFundClick);
            ToolStripMenuItem itemEditFund = FormUtility.CreateContextMenuItem("Fonds bearbeiten", EditFundClick);

            FormUtility.AddContextMenu(dataGridFunds, itemDelete, itemEditFund);
            FormUtility.GetBindingSource(dataGridFunds).Clear();
            FormUtility.AddValidation(buttonSubmit, textBoxCurrency, () =>
            {
                TableUtility tableUtility  = new TableUtility();
                List <Range> currencyRange = tableUtility.ReadTableRow(Currency.GetDefaultValue(), new Dictionary <string, string>
                {
                    { "IsoCode", textBoxCurrency.Text.ToUpper() }
                }, QueryOperator.OR);

                if (currencyRange.Count == 0 || currencyRange.Count > 1)
                {
                    return(false);
                }
                Currency currency = tableUtility.ConvertRangesToObjects <Currency>(currencyRange)[0];
                Fund newFund      = new Fund(textBoxFundName.Text, textBoxIsin.Text, textBoxCustodyNr.Text, currency);
                tableUtility.InsertTableRow(newFund);
                FormUtility.GetBindingSource(dataGridFunds).Add(newFund);
                return(true);
            });
            FormUtility.AddControlsToForm(this, dataGridFunds);
        }
        private void RowValidatedRatings(object sender, DataGridViewCellEventArgs e)
        {
            if (currentRatingAgency == null)
            {
                return;
            }
            TableUtility tableUtility = new TableUtility();
            Rating       newRating    = dataGridViewRatingCodes.Rows[e.RowIndex].DataBoundItem as Rating;

            if (newRating == null)
            {
                return;
            }
            newRating.Agency = currentRatingAgency;
            if (newRating.Index == 0)
            {
                tableUtility.InsertTableRow(newRating);
                return;
            }
            if (currentRow == null)
            {
                return;
            }

            if (!currentRow.Equals(newRating))
            {
                tableUtility.MergeTableRow(newRating);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Implementation of <see cref="IPassedObject{T}"/>
        ///
        /// Takes the newly created <see cref="DurationRecord"/>, persists it and adds it to the DataGridView.
        /// </summary>
        /// <param name="obj">Passed DurationRecord</param>
        public void OnSubmit(DurationRecord obj)
        {
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(DurationRecord.GetDefaultValue());
            tableUtility.InsertTableRow(obj);
            FormUtility.GetBindingSource(dataGridView).Add(obj);
        }
Exemplo n.º 6
0
        public Rule InvokeSubmission(RuleKind ruleKind)
        {
            Rule         rule         = new Rule(ruleKind, textBoxName.Text);
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(rule);
            tableUtility.InsertTableRow(rule);
            return(rule);
        }
Exemplo n.º 7
0
        public void OnSubmit(List<string> passedValue, string reference)
        {
            TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook);
            RatingAgency ratingAgency = new RatingAgency(passedValue[0]);
            tableUtility.CreateMissingTable(RatingAgency.GetDefaultValue());
            tableUtility.InsertTableRow(ratingAgency, new List<string>
            {
                passedValue[0]
            });
            ratingAgencyBindingSource.Add(ratingAgency);

        }
Exemplo n.º 8
0
        private void AddCurrency(string currencyIsoCode)
        {
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(Currency.GetDefaultValue());
            Currency currency = new Currency
            {
                IsoCode = currencyIsoCode
            };

            tableUtility.InsertTableRow(currency);
            FormUtility.GetBindingSource(dataGridViewCurrencies).Add(currency);
        }
Exemplo n.º 9
0
        private void AddAssetClass(string assetClassName)
        {
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(AssetClass.GetDefaultValue());
            AssetClass assetClass = new AssetClass
            {
                Name = assetClassName
            };

            tableUtility.InsertTableRow(assetClass);
            FormUtility.GetBindingSource(dataGridViewAssetClasses).Add(assetClass);
        }
        public void OnSubmit(List <string> passedValue, string reference)
        {
            dataGridViewRatingAgencies.ClearSelection();
            TableUtility tableUtility = new TableUtility();
            RatingAgency ratingAgency = new RatingAgency(passedValue[0]);

            tableUtility.InsertTableRow(ratingAgency);
            int index = FormUtility.GetBindingSource(dataGridViewRatingAgencies).Add(ratingAgency);

            dataGridViewRatingAgencies.Rows[index].Selected = true;
            currentRatingAgency    = ratingAgency;
            ratingAgenciesRowIndex = index;
            LoadRatings(ratingAgenciesRowIndex);
        }
        private bool MergeAssetAllocation()
        {
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(AssetAllocationEntry.GetDefaultValue());
            CalcTotals();
            if (totalRow != 100 || totalCol != 100)
            {
                MessageBox.Show("Gesamttotal muss 100% sein.");
                return(false);
            }
            for (int col = 1; col < tableLayoutPanelAA.ColumnCount - 1; col++)
            {
                for (int row = 1; row < tableLayoutPanelAA.RowCount - 1; row++)
                {
                    FlowLayoutPanel panel = tableLayoutPanelAA.GetControlFromPosition(col, row) as FlowLayoutPanel;
                    double[]        assetAllocationRange = new double[3];

                    for (int i = 0; i < 3; i++)
                    {
                        bool parsingSuccessful = double.TryParse(panel.Controls[i].Text, out double value);
                        if (!parsingSuccessful)
                        {
                            value = 0;
                        }
                        assetAllocationRange[i] = value;
                    }

                    try
                    {
                        AssetAllocationEntry entry = panel.DataBindings[0].DataSource as AssetAllocationEntry;
                        tableUtility.MergeTableRow(entry);
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        AssetAllocationEntry assetAllocationEntry = new AssetAllocationEntry
                        {
                            AssetClass        = tableLayoutPanelAA.GetControlFromPosition(col, 0).DataBindings[0].DataSource as AssetClass,
                            Currency          = tableLayoutPanelAA.GetControlFromPosition(0, row).DataBindings[0].DataSource as Currency,
                            StrategicMinValue = assetAllocationRange[0],
                            StrategicOptValue = assetAllocationRange[1],
                            StrategicMaxValue = assetAllocationRange[2],
                            Fund = fund
                        };
                        tableUtility.InsertTableRow(assetAllocationEntry);
                    }
                }
            }
            return(true);
        }
Exemplo n.º 12
0
        private void AddCurrency(string currencyIsoCode)
        {
            TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook);

            tableUtility.CreateMissingTable(Currency.GetDefaultValue());
            Currency currency = new Currency
            {
                IsoCode = currencyIsoCode
            };

            tableUtility.InsertTableRow(currency, new List <string>()
            {
                currency.IsoCode
            });
            currencyBindingSource.Add(currency);
        }
Exemplo n.º 13
0
        private void AddAssetClass(string assetClassName)
        {
            TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook);

            tableUtility.CreateMissingTable(AssetClass.GetDefaultValue());
            AssetClass assetClass = new AssetClass
            {
                Name = assetClassName
            };

            tableUtility.InsertTableRow(assetClass, new List <string>()
            {
                assetClass.Name
            });
            assetClassBindingSource.Add(assetClass);
        }
        public void OnSubmit(List <string> passedValue = null, string reference = null)
        {
            TableUtility tableUtility = new TableUtility();

            switch (reference)
            {
            case "asset_kind":
                tableUtility.CreateTable(AssetKind.GetDefaultValue());
                AssetKind newAssetKind = new AssetKind(passedValue[0]);
                tableUtility.InsertTableRow(newAssetKind);
                FormUtility.GetBindingSource(dataGridView).Add(newAssetKind);
                break;

            case "asset_kind_edit":
                selectedAssetKind.Description = passedValue[0];
                tableUtility.MergeTableRow(selectedAssetKind);
                break;
            }
        }
        public Rule InvokeSubmission(RuleKind ruleKind)
        {
            if (passedRule != null)
            {
                passedRule.Name = ruleName.Text;
                BindingList <AssetKind> changedBanList = (BindingList <AssetKind>)FormUtility.GetBindingSource(dataGridView).List;
                passedRule.Banned = changedBanList.ToList();
                return(passedRule);
            }
            BanList <AssetKind> newBanList = new BanList <AssetKind>(RuleKind.RESTRICTED_INSTRUMENT_TYPE, ruleName.Text);

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                newBanList.Banned.Add(row.DataBoundItem as AssetKind);
            }
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(newBanList);
            tableUtility.InsertTableRow(newBanList);
            return(newBanList);
        }
        /// <summary>
        /// Implementation of <see cref="IRuleUserControl"/>
        /// </summary>
        /// <param name="ruleKind">Selected <see cref="RuleKind"/></param>
        /// <returns>Newly created rule, in that case an <see cref="AllowList"/></returns>
        public Rule InvokeSubmission(RuleKind ruleKind)
        {
            if (passedRule != null)
            {
                passedRule.Name = ruleName.Text;
                BindingList <Asset> changedAllowList = (BindingList <Asset>)FormUtility.GetBindingSource(dataGridView).List;
                passedRule.Allowed = changedAllowList.ToList();
                return(passedRule);
            }
            AllowList newAllowList = new AllowList(RuleKind.RULE_EXCEPTION, ruleName.Text);

            foreach (DataGridViewRow row in dataGridView.Rows)
            {
                newAllowList.Allowed.Add(row.DataBoundItem as Asset);
            }
            TableUtility tableUtility = new TableUtility();

            tableUtility.CreateTable(newAllowList);
            tableUtility.InsertTableRow(newAllowList);
            return(newAllowList);
        }
        /// <summary>
        /// Implementation of <see cref="IRuleUserControl"/>. This method is called by the parent form
        /// for invoking the addition of a new rule.
        /// </summary>
        /// <param name="ruleKind"><see cref="RuleKind"/></param>
        /// <returns>New <see cref="Rule"/></returns>
        public Rule InvokeSubmission(RuleKind ruleKind)
        {
            bool parsingSuccessful = double.TryParse(textBoxValue.Text, out double value);

            if (!parsingSuccessful)
            {
                MessageBox.Show("Bitte eine gültige Zahl eingeben.");
                return(null);
            }
            if (passedRule != null)
            {
                passedRule.Name         = textBoxDescription.Text;
                passedRule.NumericValue = value;
                return(passedRule);
            }
            TableUtility tableUtility = new TableUtility();
            Rule         newRule      = new NumericRule(value, ruleKind, textBoxDescription.Text);

            tableUtility.CreateTable(newRule);
            tableUtility.InsertTableRow(newRule);
            return(newRule);
        }
Exemplo n.º 18
0
        private void RowValidatedRatings(object sender, DataGridViewCellEventArgs e)
        {

            if (currentRatingAgency == null)
            {
                return;
            }
            TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook);
            tableUtility.CreateMissingTable(Rating.GetDefaultValue());
            Rating newRating = dataGridViewRatingCodes.Rows[e.RowIndex].DataBoundItem as Rating;
            if (newRating == null)
            {
                return;
            }
            if (newRating.Index == 0)
            {
                tableUtility.InsertTableRow(newRating, new List<string>
                {
                    newRating.RatingCode,
                    newRating.RatingNumericValue.ToString(),
                    currentRatingAgency.Index.ToString()
                });
                return;
            }

            if (!currentRow.RatingCode.Equals(newRating.RatingCode))
            {
                TableUpdateWrapper update = new TableUpdateWrapper(currentRow.Index, "rating_code", newRating.RatingCode);
                tableUtility.UpdateTableRow(currentRow, update);
            }

            if (currentRow.RatingNumericValue != newRating.RatingNumericValue)
            {
                TableUpdateWrapper update = new TableUpdateWrapper(currentRow.Index, "numeric_value", newRating.RatingNumericValue.ToString());
                tableUtility.UpdateTableRow(currentRow, update);
            }

        }
        public Rule InvokeSubmission(RuleKind ruleKind)
        {
            bool parsingSuccessfulRatingClass  = double.TryParse(textBoxRatingClass.Text, out double ratingClass);
            bool parsingSuccessfulNumericValue = double.TryParse(textBoxNumericValue.Text, out double numericValue);

            if (!parsingSuccessfulNumericValue || !parsingSuccessfulRatingClass)
            {
                MessageBox.Show("Bitte eine gültige Zahl eingeben.");
                return(null);
            }
            if (passedRule != null)
            {
                passedRule.Name        = textBoxName.Text;
                passedRule.MaxRatio    = numericValue;
                passedRule.RatingClass = ratingClass;
                return(passedRule);
            }
            RatingQuoteRule newRatingQuoteRule = new RatingQuoteRule(ratingClass, numericValue, RuleKind.MAX_RATING_RATIO, textBoxName.Text);
            TableUtility    tableUtility       = new TableUtility();

            tableUtility.CreateTable(newRatingQuoteRule);
            tableUtility.InsertTableRow(newRatingQuoteRule);
            return(newRatingQuoteRule);
        }