private void btnSave_Click(object sender, EventArgs e) { if (String.IsNullOrWhiteSpace(txtName.Text)) { MessageBox.Show("You must enter a fund name. Please correct and try again.", "Error", MessageBoxButtons.OK); return; } else if (String.IsNullOrWhiteSpace(txtTicker.Text)) { MessageBox.Show("You must enter a ticker. Please correct and try again.", "Error", MessageBoxButtons.OK); return; } Guid?_categoryId; int _recordType = 0; if (cboCategory.SelectedIndex == -1) { _categoryId = null; } else { _categoryId = new Guid(((ListItem)cboCategory.SelectedItem).HiddenValue); } if (cboRecordType.Text == "Fund") { _recordType = 1; } else if (cboRecordType.Text == "Index") { _recordType = 2; } else if (cboRecordType.Text == "Category") { _recordType = 3; } Fund _fund = new Fund(); _fund.FundName = txtName.Text; _fund.Ticker = txtTicker.Text; _fund.Family = txtFamily.Text; _fund.Cusip = txtCusip.Text; _fund.CategoryId = _categoryId; _fund.RecordType = _recordType; try { _fund.SaveToDatabase(frmMain_Parent.CurrentUser.UserId); this.Close(); } catch (Exception _exception) { frmError _frmError = new frmError(frmMain_Parent, _exception); } }