private void btnOK_Click(object sender, EventArgs e) { TBL_MP_Master_Employee_Qualification model = null; ServiceEmployee _service = new ServiceEmployee(); try { if (!this.ValidateChildren()) { return; } if (this.EmployeeQualificationID == 0) { model = new TBL_MP_Master_Employee_Qualification(); } else { model = _service.GetEmployeeQualificationDBRecordByID(EmployeeQualificationID); } model.Qualification = txtQualification.Text.Trim(); model.NameOfInstitute = txtNameOfInstitute.Text.Trim(); model.Grade = txtGradeClass.Text.Trim(); if (this.EmployeeQualificationID == 0) { model.FK_EmployeeId = SelectedEmployeeID; this.EmployeeQualificationID = _service.AddNewEmployeeQualification(model); } else { _service.UpdateEmployeeQualification(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, "frmAddEditEmployeeQualification::btnOK_Click", MessageBoxButtons.OK, MessageBoxIcon.Error); } }