Ejemplo n.º 1
0
        private void btnOK_Click(object sender, EventArgs e)
        {
            try
            {
                string sType        = cmbDataTypes.SelectedItem as string,
                       name         = txtFieldName.Text.Trim(),
                       defaultValue = chkNull.Checked ? null : txtDefaultValue.Text.Trim();

                if (name.Length == 0)
                {
                    throw new Exception("You must provide a name for the new field");
                }

                this.Cursor = Cursors.WaitCursor;
                this.Update();

                DataTypeEnum dataType = (DataTypeEnum)Enum.Parse(typeof(DataTypeEnum), sType);
                Field        newField = new Field(name, dataType);
                _fileDb.AddField(newField, defaultValue);

                this.Cursor       = Cursors.Default;
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                this.Cursor = Cursors.Default;
                MessageBox.Show(this, ex.Message, null, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }