Esempio n. 1
0
        private void AddBtn_Click(object sender, EventArgs e) {
            string prefixInput = PrefixTxtBox.Text;
            prefixInput += "-";
            string descriptionInput = DescriptionTxtBox.Text;

            if (!repo.containsPrefixByName(prefixInput)) {
                #region insert new prefix

                Prefix prefix = new Prefix { Name = prefixInput, Description = descriptionInput };

                //because PrefixRepository can implement > 1 interface, need to specify which interface we want to call from to remove ambiguity.
                // not entirely sure why i need this as i'm only implementing one interface... but oh well.
                //http://stackoverflow.com/questions/2669031/compilation-error-the-modifier-public-is-not-valid-for-this-item-while-expl
                (repo as IRepository<Prefix>).add(prefix);

                //TODO: maybe send added prefix to previous window? or reload list?

                this.Close();

                #endregion
            } else {
                #region display "not unique name" message to user.
                MessageBox.Show("This prefix name is not unique!", "Not unique", MessageBoxButtons.OK, MessageBoxIcon.Error);

                PrefixTxtBox.Focus();
                #endregion
            }

        }
Esempio n. 2
0
        private void addBtn_Click(object sender, EventArgs e)
        {
            AddPrefixForm form = new AddPrefixForm();

            Prefix newPrefix = new Prefix();
            form.NewPrefix = newPrefix;

            form.Show();

            

            //TODO: figure out binding newly added item back to list. 
            //TODO: maybe using this? https://msdn.microsoft.com/en-us/library/ms366768.aspx
            //TODO: or this https://msdn.microsoft.com/en-us/library/ms173171.aspx
        }