private void btnEdit_Click(object sender, EventArgs e) { try { DialogResult dialogResult = MessageBox.Show("DO YOU WANT TO EDIT THIS EMPLOYEE DATA?", "EDIT EMPLOYEE DETAILS", MessageBoxButtons.YesNo, MessageBoxIcon.Warning); if (dialogResult == DialogResult.Yes) { if (tbEditEmpNIP.Text == "" || tbEditEmpName.Text == "" || tbEditEmpEmail.Text == "" || tbEditEmpPhone.Text == "" || dtpEditEmpDOB.Text == DateTime.Today.ToShortDateString() || cbEditEmpGender.Text == "-----SELECT GENDER-----" || cbEditEmpDivision.Text == "-----SELECT DIVISION-----" || cbEditEmpPosition.Text == "-----SELECT POSITION-----") { MessageBox.Show("FORM FIELD(S) CAN NOT BE LEFT EMPTY. PLEASE COMPLETE THE FORM TO EDIT DATA", "DATA UPDATION ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning); tbEditEmpEmail.Focus(); } else { string EmployeeNIP = tbEditEmpNIP.Text; string EmployeeName = tbEditEmpName.Text; string EmployeeGender = cbEditEmpGender.Text; string EmployeeDOB = dtpEditEmpDOB.Text; string EmployeeEmail = tbEditEmpEmail.Text; string EmployeePhone = tbEditEmpPhone.Text; string DivisionID = cbEditEmpDivision.Text.Substring(0, 1); string PositionID = cbEditEmpPosition.Text.Substring(0, 1); Admin A = new Admin(); A.EditEmployee(EmployeeNIP, EmployeeName, EmployeeGender, EmployeeDOB, EmployeeEmail, EmployeePhone, DivisionID, PositionID); tbEditEmpNIP.Clear(); tbEditEmpName.Clear(); cbEditEmpGender.Text = "-----SELECT GENDER-----"; dtpEditEmpDOB.Text = DateTime.Today.ToShortDateString(); tbEditEmpEmail.Clear(); tbEditEmpPhone.Clear(); cbEditEmpDivision.Text = "-----SELECT DIVISION-----"; cbEditEmpPosition.Text = "-----SELECT POSITION-----"; MessageBox.Show("DATA UPDATED", "UPDATE DATA SUCCESSFUL", MessageBoxButtons.OK, MessageBoxIcon.Information); RefreshFormEmployee(); } } } catch (SqlException) { MessageBox.Show("MICROSOFT SQL SERVER DATABASE ERROR!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (InvalidOperationException) { MessageBox.Show("INVALID OPERATION!", "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.ToString(), "ERROR OCCURS", MessageBoxButtons.OK, MessageBoxIcon.Error); } }