private void btnOK_Click(object sender, EventArgs e) { TBL_MP_Master_Employee_MedicalDetail model = null; ServiceEmployee serviceEmployee = new ServiceEmployee(); try { if (!this.ValidateChildren()) { return; } if (this.EmployeeMedicalID == 0) { model = new TBL_MP_Master_Employee_MedicalDetail(); } else { model = serviceEmployee.GetEmployeeMedicalInfoDbRecord(this.EmployeeMedicalID); } model.fk_EmployeeId = this.EmployeeID; #region GATHER DATA INTO MODEL FROM VIEW model.MedicalName = txtMedicalName.Text; model.FK_UL_RelationID = ((SelectListItem)cboRelation.SelectedItem).ID; model.CardNo = txtCardNo.Text; model.CardType = txtCardType.Text; model.CompanyName = txtCompanyName.Text; model.IssueDate = dtIssueDate.Value; model.ExpiryDate = dtExpieryDate.Value; model.Remark = txtRemark.Text; model.IsActive = chkIsActive.Checked; #endregion if (this.EmployeeMedicalID == 0) { this.EmployeeMedicalID = serviceEmployee.AddNewEmployeeMedicalnfo(model); } else { serviceEmployee.UpdateEmployeeMedicalnfo(model); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { string errMessage = ex.Message; if (ex.InnerException != null) { errMessage += string.Format("\n{0}", ex.InnerException.Message); } MessageBox.Show(errMessage, "frmAddEditMedicalInfo::btnOK_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }