private void btnSave_Click(object sender, EventArgs e) { try { DialogResult dialogResult = MessageBox.Show("SAVE DATA? \nMAKE SURE ALL THE FORM FIELDS FILLED CORRECTLY", "DATA ENTRY", MessageBoxButtons.YesNo, MessageBoxIcon.Information); if (dialogResult == DialogResult.Yes) { if (tbEmpPassword.Text != tbEmpRepeatPassword.Text) { MessageBox.Show("PASSWORD MISSMATCH", "INCORECT PASSWORD", MessageBoxButtons.OK, MessageBoxIcon.Warning); tbEmpPassword.Clear(); tbEmpRepeatPassword.Clear(); tbEmpPassword.Focus(); } else { if (tbEmpNIP.Text == "" || tbEmpName.Text == "" || tbEmpEmail.Text == "" || tbEmpPhone.Text == "" || tbEmpPhoto.Text == "" || dtpEmpDOB.Text == DateTime.Today.ToShortDateString() || cbEmpGender.Text == "-----SELECT GENDER-----" || cbEmpDivision.Text == "-----SELECT DIVISION-----" || cbEmpPosition.Text == "-----SELECT POSITION-----") { MessageBox.Show("FORM FIELD(S) CAN NOT BE LEFT EMPTY. PLEASE COMPLETE THE FORM TO SAVE DATA", "DATA ENTRY ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning); tbEmpNIP.Focus(); } else { string EmployeeNIP = tbEmpNIP.Text; string EmployeePassword = tbEmpRepeatPassword.Text; string EmployeeName = tbEmpName.Text; string EmployeeGender = cbEmpGender.Text; string EmployeeDOB = dtpEmpDOB.Text; string EmployeeEmail = tbEmpEmail.Text; string EmployeePhone = tbEmpPhone.Text; string EmployeePhoto = tbEmpPhoto.Text; string DivisionID = cbEmpDivision.Text.Substring(0, 1); string PositionID = cbEmpPosition.Text.Substring(0, 1); Admin A = new Admin(); A.AddEmployee(EmployeeNIP, EmployeePassword, EmployeeName, EmployeeGender, EmployeeDOB, EmployeeEmail, EmployeePhone, EmployeePhoto, DivisionID, PositionID); tbEmpNIP.Clear(); tbEmpName.Clear(); cbEmpGender.Text = "-----SELECT GENDER-----"; dtpEmpDOB.Text = DateTime.Today.ToShortDateString(); tbEmpEmail.Clear(); tbEmpPhone.Clear(); tbEmpPhoto.Clear(); cbEmpDivision.Text = "-----SELECT DIVISION-----"; cbEmpPosition.Text = "-----SELECT POSITION-----"; tbEmpPassword.Clear(); tbEmpRepeatPassword.Clear(); MessageBox.Show("DATA SAVED", "ENTRY 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); } }