private void LoadFundTable() { TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook); // List<Fund> fundList = tableUtility.ConvertRangeToFund(tableUtility.ReadAllRows(Fund.GetDefaultValue().GetTableName())); List <Fund> fundList = tableUtility.ConvertRangesToObjects <Fund>(tableUtility.ReadAllRows(Fund.GetDefaultValue().GetTableName())); foreach (Fund fund in fundList) { fundBindingSource.Add(fund); } }
/// <summary> /// Loading of the table content. 1st dimension <see cref="Rule"/>, 2nd dimension <see cref="Fund"/> /// </summary> private void LoadRules() { TableUtility tableUtility = new TableUtility(); List <Fund> fundList = tableUtility.ConvertRangesToObjects <Fund>(tableUtility.ReadAllRows(Fund.GetDefaultValue())); List <Rule> ruleList = tableUtility.ConvertRangesToObjects <Rule>(tableUtility.ReadAllRows(Rule.GetDefaultValue())); tableLayoutPanel.ColumnCount = fundList.Count + 1; Padding margin = new Padding(1, 0, 0, 1); tableLayoutPanel.Controls.Add(new Label { AutoSize = false, BackColor = Color.White, Width = 500, Height = 500, Margin = margin }, 0, 0); for (int col = 0; col < fundList.Count; col++) { // Adding fund labels (columns) Label fundLabel = new VerticalLabel(-90) { AutoSize = false, Height = 500, Width = 50, Text = fundList[col].Name, BackColor = Color.White, TextAlign = ContentAlignment.BottomLeft, Margin = margin }; FormUtility.BindObjectToControl(fundLabel, fundList[col]); tableLayoutPanel.Controls.Add(fundLabel, col + 1, 0); } foreach (Rule rule in ruleList) { AddRule(rule); } }
private void LoadFundTable() { FormUtility.GetBindingSource(dataGridFunds).Clear(); TableUtility tableUtility = new TableUtility(); tableUtility.CreateTable(Currency.GetDefaultValue()); tableUtility.CreateTable(Fund.GetDefaultValue()); List <Fund> fundList = tableUtility.ConvertRangesToObjects <Fund>(tableUtility.ReadAllRows(Fund.GetDefaultValue())); foreach (Fund fund in fundList) { FormUtility.GetBindingSource(dataGridFunds).Add(fund); } }
private void LoadAssetClasses() { TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook); // List<AssetClass> assetClassList = tableUtility.ConvertRangeToAssetClass(tableUtility.ReadAllRows(AssetClass.GetDefaultValue().GetTableName())); List <AssetClass> assetClassList = tableUtility.ConvertRangesToObjects <AssetClass>(tableUtility.ReadAllRows(AssetClass.GetDefaultValue().GetTableName())); foreach (AssetClass assetClass in assetClassList) { assetClassBindingSource.Add(assetClass); } }
private void LoadCurrencies() { TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook); // List<Currency> currencyList = tableUtility.ConvertRangeToCurrency(tableUtility.ReadAllRows(Currency.GetDefaultValue().GetTableName())); List <Currency> currencyList = tableUtility.ConvertRangesToObjects <Currency>(tableUtility.ReadAllRows(Currency.GetDefaultValue().GetTableName())); foreach (Currency currency in currencyList) { currencyBindingSource.Add(currency); } }
/// <summary> /// Loads the existing duration records into the DataGridView /// </summary> private void LoadDurationRecords() { TableUtility tableUtility = new TableUtility(); List <DurationRecord> list = tableUtility.ConvertRangesToObjects <DurationRecord>(tableUtility.ReadAllRows(DurationRecord.GetDefaultValue())); foreach (DurationRecord record in list) { FormUtility.GetBindingSource(dataGridView).Add(record); } }
private void LoadCurrencies() { TableUtility tableUtility = new TableUtility(); List <Currency> currencyList = tableUtility.ConvertRangesToObjects <Currency>(tableUtility.ReadAllRows(Currency.GetDefaultValue())); foreach (Currency currency in currencyList) { FormUtility.GetBindingSource(dataGridViewCurrencies).Add(currency); } }
private void LoadAssetClasses() { TableUtility tableUtility = new TableUtility(); List <AssetClass> assetClassList = tableUtility.ConvertRangesToObjects <AssetClass>(tableUtility.ReadAllRows(AssetClass.GetDefaultValue())); foreach (AssetClass assetClass in assetClassList) { FormUtility.GetBindingSource(dataGridViewAssetClasses).Add(assetClass); } }
private void LoadRatingAgencies() { TableUtility tableUtility = new TableUtility(); List <RatingAgency> agencyList = tableUtility.ConvertRangesToObjects <RatingAgency>(tableUtility.ReadAllRows(RatingAgency.GetDefaultValue())); foreach (RatingAgency agency in agencyList) { FormUtility.GetBindingSource(dataGridViewRatingAgencies).Add(agency); } }
private void LoadTable() { TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook); List <AssetClass> assetClasses = tableUtility.ConvertRangesToObjects <AssetClass>(tableUtility.ReadAllRows(AssetClass.GetDefaultValue().GetTableName())); List <Currency> currencies = tableUtility.ConvertRangesToObjects <Currency>(tableUtility.ReadAllRows(Currency.GetDefaultValue().GetTableName())); int numberOfColumns = assetClasses.Count + 1; int numberOfRows = currencies.Count + 1; tableLayoutPanel1.ColumnCount = numberOfColumns + 1; tableLayoutPanel1.RowCount = numberOfRows + 1; // First cell, should be empty tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>(string.Empty, null), 0, 0); Padding padding = Padding.Empty; // Add column labels for asset classes for (int col = 1; col < numberOfColumns; col++) { AssetClass assetClass = assetClasses[col - 1]; Label columnLabel = GenerateLabel(assetClass.Name, assetClass); tableLayoutPanel1.Controls.Add(columnLabel, col, 0); } // Add total column tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>("Total", null), numberOfColumns, 0); // Add row labels for currencies for (int row = 1; row < numberOfRows; row++) { Currency currency = currencies[row - 1]; Label rowLabel = GenerateLabel(currency.IsoCode, currency); tableLayoutPanel1.Controls.Add(rowLabel, 0, row); } // Add total row tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>("Total", null), 0, numberOfRows); // Add text boxes for (int row = 1; row < numberOfRows; row++) { for (int col = 1; col < numberOfColumns; col++) { TextBox textBox = new TextBox { AutoSize = false, Width = 200, Height = 50, Margin = new Padding(1, 0, 0, 0), BorderStyle = BorderStyle.None, TextAlign = HorizontalAlignment.Right }; textBox.KeyUp += (tb, keyUp) => { TableLayoutPanelCellPosition position = tableLayoutPanel1.GetPositionFromControl(tb as TextBox); Label totalAssetClass = tableLayoutPanel1.GetControlFromPosition(position.Column, numberOfRows) as Label; Label totalCurrency = tableLayoutPanel1.GetControlFromPosition(numberOfColumns, position.Row) as Label; Label total = tableLayoutPanel1.GetControlFromPosition(numberOfColumns, numberOfRows) as Label; double rowSum = GetRowSum(position.Row); double columnSum = GetColumnSum(position.Column); totalCurrency.Text = rowSum.ToString(); totalAssetClass.Text = columnSum.ToString(); double totalSum = GetTotalSum(); total.Text = totalSum.ToString(); }; textBox.KeyUp += (tb, keyUp) => { TextBox t = tb as TextBox; bool cellContentIsNumber = double.TryParse(t.Text, out _); if (!cellContentIsNumber) { t.Clear(); } }; tableLayoutPanel1.Controls.Add(textBox); } } // Add total labels in last column for (int row = 1; row < numberOfRows + 1; row++) { tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>("", null), numberOfColumns, row); } // Add total labels in last row for (int col = 1; col < numberOfColumns; col++) { tableLayoutPanel1.Controls.Add(GenerateLabel <Persistable>("", null), col, numberOfRows); } }
private void LoadRatingAgencies() { TableUtility tableUtility = new TableUtility(Globals.WatchdogAddIn.Application.ActiveWorkbook); List<RatingAgency> agencyList = tableUtility.ConvertRangesToObjects<RatingAgency>(tableUtility.ReadAllRows(RatingAgency.GetDefaultValue().GetTableName())); foreach (RatingAgency agency in agencyList) { ratingAgencyBindingSource.Add(agency); } }
private void LoadAssetAllocationTable() { TableUtility tableUtility = new TableUtility(); List <AssetClass> assetClasses = tableUtility.ConvertRangesToObjects <AssetClass>(tableUtility.ReadAllRows(AssetClass.GetDefaultValue())); List <Currency> currencies = tableUtility.ConvertRangesToObjects <Currency>(tableUtility.ReadAllRows(Currency.GetDefaultValue())); int numberOfColumns = assetClasses.Count + 1; int numberOfRows = currencies.Count + 1; tableLayoutPanelAA.ColumnCount = numberOfColumns + 1; tableLayoutPanelAA.RowCount = numberOfRows + 1; // First cell, should be empty tableLayoutPanelAA.Controls.Add(GenerateLabel(string.Empty, null), 0, 0); Padding padding = Padding.Empty; // Add column labels for asset classes for (int col = 1; col < numberOfColumns; col++) { AssetClass assetClass = assetClasses[col - 1]; Label columnLabel = GenerateLabel(assetClass.Name, assetClass); tableLayoutPanelAA.Controls.Add(columnLabel, col, 0); } // Add total column tableLayoutPanelAA.Controls.Add(GenerateLabel("Total", null), numberOfColumns, 0); // Add row labels for currencies for (int row = 1; row < numberOfRows; row++) { Currency currency = currencies[row - 1]; Label rowLabel = GenerateLabel(currency.IsoCode, currency); tableLayoutPanelAA.Controls.Add(rowLabel, 0, row); } // Add total row tableLayoutPanelAA.Controls.Add(GenerateLabel("Total", null), 0, numberOfRows); // Add text boxes for (int row = 1; row < numberOfRows; row++) { for (int col = 1; col < numberOfColumns; col++) { AssetClass assetClass = tableLayoutPanelAA.GetControlFromPosition(col, 0).DataBindings[0].DataSource as AssetClass; Currency currency = tableLayoutPanelAA.GetControlFromPosition(0, row).DataBindings[0].DataSource as Currency; Padding paddingOneLeft = new Padding(1, 0, 0, 0); FlowLayoutPanel panel = new FlowLayoutPanel { Margin = paddingOneLeft, Height = 50, Width = 150, }; for (int i = 0; i < 3; i++) { TextBox textBox = new TextBox { AutoSize = false, Width = 50, Height = 50, Margin = padding, BorderStyle = BorderStyle.FixedSingle, TextAlign = HorizontalAlignment.Right }; textBox.KeyUp += (tb, keyUp) => { TextBox t = tb as TextBox; bool cellContentIsNumber = double.TryParse(t.Text, out _); if (!cellContentIsNumber) { t.Clear(); } }; panel.Controls.Add(textBox); } panel.Controls[1].KeyUp += (tb, keyUp) => { TextBox textBox = tb as TextBox; FlowLayoutPanel flowPanel = ((TextBox)tb).Parent as FlowLayoutPanel; CalcTotals(flowPanel); }; AssetAllocationEntry entry = GetAssetAllocationEntry(assetClass, currency); if (entry != null) { panel.Controls[0].Text = entry.StrategicMinValue.ToString(); panel.Controls[1].Text = entry.StrategicOptValue.ToString(); panel.Controls[2].Text = entry.StrategicMaxValue.ToString(); FormUtility.BindObjectToControl(panel, entry); } tableLayoutPanelAA.Controls.Add(panel); } } // Add total labels in last column for (int row = 1; row < numberOfRows + 1; row++) { tableLayoutPanelAA.Controls.Add(GenerateLabel("", null), numberOfColumns, row); } // Add total labels in last row for (int col = 1; col < numberOfColumns; col++) { tableLayoutPanelAA.Controls.Add(GenerateLabel("", null), col, numberOfRows); } }
private AssetAllocationEntry GetAssetAllocationEntry(AssetClass assetClass, Currency currency) { TableUtility tableUtility = new TableUtility(); List <AssetAllocationEntry> entries = tableUtility.ConvertRangesToObjects <AssetAllocationEntry>(tableUtility.ReadAllRows(AssetAllocationEntry.GetDefaultValue())); var entryQuery = from entry in entries where entry.AssetClass.Name.Equals(assetClass.Name) where entry.Currency.IsoCode.Equals(currency.IsoCode) where entry.Fund.Index == fund.Index select entry; List <AssetAllocationEntry> list = entryQuery.ToList(); if (list.Count == 0) { return(null); } return(entryQuery.ToList()[0]); }