private void btnSave_Click(object sender, EventArgs e) { try { PersonRouteMaster model = new PersonRouteMaster(); model.PersonRouteID = this.PersonRouteMaster.PersonRouteID; model.RecordTypeId = (int)cbPersonRouteType.SelectedValue; Status status; Enum.TryParse <Status>(cbxStatus.SelectedValue.ToString(), out status); model.Status = status == Status.Active; model.PersonRouteName = tbPersonRouteName.Text; model.PersonRouteCode = this.PersonRouteMaster.PersonRouteCode; var result = this.PersonRouteMaster.RecordTypeId > 0 && this.PersonRouteMaster.PersonRouteID > 0 ? applicationFacade.UpdatePersonRoute(model) : applicationFacade.AddPersonRoute(model); if (result > 0) { this.PersonRouteID = result; } this.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }