private void ButtonSubmit_Click(object sender, EventArgs e) { IRuleUserControl userControl = panelUserControl.Controls[0] as IRuleUserControl; DropDownItem <RuleKind> ruleKindItem = comboBoxRuleKind.SelectedItem as DropDownItem <RuleKind>; Rule newRule = userControl.InvokeSubmission(ruleKindItem.Value); parentForm.OnSubmit(newRule); Close(); }
/// <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); }