private void btnSave_Click(object sender, EventArgs e) { string type = cmbType.SelectedItem.ToString(); string prefix = txtPrefix.Text.Trim(); string name = txtName.Text.Trim(); if (string.IsNullOrEmpty(name)) { MessageBox.Show("Name cannot be empty.", "Cannot Save Functiond Id", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtName.Focus(); return; } if (string.IsNullOrEmpty(prefix)) { MessageBox.Show("Prefix cannot be empty.", "Cannot Save Functiond Id", MessageBoxButtons.OK, MessageBoxIcon.Warning); txtPrefix.Focus(); return; } if (this.Model.FunctionalIds.FunctionalId.Any(functionalId => functionalId.Name == name)) { MessageBox.Show($"Name \"{name}\" already exists.", "Cannot Save Functiond Id", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtName.Focus(); return; } if (this.Model.FunctionalIds.FunctionalId.Any(functionalId => functionalId.Value == prefix)) { MessageBox.Show($"Prefix \"{prefix}\" already exists.", "Cannot Save Functiond Id", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); txtPrefix.Focus(); return; } FunctionalId funcId = new FunctionalId(Model); funcId.Type = type; funcId.Value = prefix; funcId.Name = name; funcId.Guid = Model.GenerateGuid(name).ToString(); this.Model.FunctionalIds.FunctionalId.Add(funcId); string displayName = string.Concat(string.Concat(name, " - "), prefix); ParentControl.RefreshEntity(); ParentControl.FunctionalIdComboBox.SelectedIndex = ParentControl.FunctionalIdComboBox.FindStringExact(displayName); this.Close(); MessageBox.Show("Functional Id saved in memory.", "Saved", MessageBoxButtons.OK, MessageBoxIcon.Information); }