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); } }
private bool MergeFundProperties() { TableUtility tableUtility = new TableUtility(); Fund newFund = new Fund { Index = fund.Index, Name = textBoxFundName.Text, CustodyAccountNumber = textBoxCustodyNr.Text, Isin = textBoxIsin.Text }; List <Range> currencyRange = tableUtility.ReadTableRow(Currency.GetDefaultValue(), new Dictionary <string, string> { { "IsoCode", textBoxCurrency.Text.ToUpper() } }, QueryOperator.OR); if (currencyRange.Count != 0) { Currency currency = tableUtility.ConvertRangesToObjects <Currency>(currencyRange)[0]; newFund.Currency = currency; } else { newFund.Currency = fund.Currency; } if (!fund.Equals(newFund)) { tableUtility.MergeTableRow(newFund); return(true); } return(true); }
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); }
/// <summary> /// Initialization of self-added controls /// </summary> private void InitializeCustomComponents() { tableLayoutPanel = FormUtility.CreateTableLayoutPanel(50, 80, 300, 800); tableLayoutPanel.BackColor = SystemColors.Control; textBoxAssetId = FormUtility.CreateTextBox(); textBoxIsin = FormUtility.CreateTextBox(); textBoxName = FormUtility.CreateTextBox(); submitButton = FormUtility.CreateButton("Bestätigen", 80, 460); cancelButton = FormUtility.CreateButton("Abbrechen", 780, 460); FormUtility.AddValidation(submitButton, textBoxAssetId, () => { bool isInt = int.TryParse(textBoxAssetId.Text, out int assetId); if (isInt) { if (asset != null) { asset.AssetId = assetId; asset.Isin = textBoxIsin.Text; asset.Name = textBoxName.Text; TableUtility tableUtility = new TableUtility(); tableUtility.MergeTableRow(asset); Close(); return(true); } Asset createdAsset = new Asset(assetId, textBoxIsin.Text, textBoxName.Text); passedObject.OnSubmit(createdAsset); Close(); return(true); } return(false); }); cancelButton.Click += (sender, e) => Close(); tableLayoutPanel.RowCount = 3; tableLayoutPanel.ColumnCount = 2; tableLayoutPanel.Controls.Add(new Label { Text = "Asset-ID", Height = 80, Width = 200 }, 0, 0); tableLayoutPanel.Controls.Add(textBoxAssetId, 1, 0); tableLayoutPanel.Controls.Add(new Label { Text = "ISIN", Height = 80, Width = 200 }, 0, 1); tableLayoutPanel.Controls.Add(textBoxIsin, 1, 1); tableLayoutPanel.Controls.Add(new Label { Text = "Name", Height = 80, Width = 200 }, 0, 2); tableLayoutPanel.Controls.Add(textBoxName, 1, 2); FormUtility.AddControlsToForm(this, tableLayoutPanel, submitButton, cancelButton); }
private bool AddCountry() { if (country != null) { country.Name = textBoxName.Text; country.IsoCode = textBoxIsoCode.Text; TableUtility tableUtility = new TableUtility(); tableUtility.MergeTableRow(country); Close(); return(true); } Country createdCountry = new Country(textBoxName.Text, textBoxIsoCode.Text); passedObject.OnSubmit(createdCountry); Close(); return(true); }
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; } }
/// <summary> /// Called method when the user clicks on the submit button. /// At first, all checkboxes are inspected, if they are checked or not. Then the rules will be merged in the database. /// They can be merged directly. It is imopossible to add new rules directly in the table. Therefore they must already /// be persisted. /// </summary> /// <param name="sender">Clicked button</param> /// <param name="e"><see cref="EventArgs"/></param> private void ButtonSubmitClick(object sender, EventArgs e) { TableUtility tableUtility = new TableUtility(); for (int row = 1; row < tableLayoutPanel.RowCount; row++) { Rule boundRule = tableLayoutPanel.GetControlFromPosition(0, row).DataBindings[0].DataSource as Rule; boundRule.FundList.Clear(); for (int col = 1; col < tableLayoutPanel.ColumnCount; col++) { Fund boundFund = tableLayoutPanel.GetControlFromPosition(col, 0).DataBindings[0].DataSource as Fund; CheckBox checkBox = tableLayoutPanel.GetControlFromPosition(col, row) as CheckBox; if (checkBox.Checked) { boundRule.FundList.Add(boundFund); } } tableUtility.MergeTableRow(boundRule); } Close(); }