Вы находитесь на странице: 1из 11

Option Explicit Dim certificateNo As String Dim getYear As String Dim xray As String Dim physical As String Dim

tempDate As Date Dim no As Integer Dim k As Integer Dim healthNo As Integer Dim Dim Dim Dim yesNo As Integer flag As Boolean flagPhysical As Boolean flagXRay As Boolean

Public Function checkSex() As Boolean checkSex = True cboSex.Text = Trim(UCase(cboSex.Text)) If (cboSex.Text <> "MALE" And cboSex.Text <> "FEMALE") Then cboSex.SetFocus checkSex = False MsgBox "Sex is not in the choices.", , "HEALTH CERTIFICATE" End If End Function Private Sub cboSex_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If (checkSex = True) Then txtOccupation.Text = "" txtOccupation.SetFocus Else cboSex.Text = "" End If End If 'keyascii End Sub Private Sub cboType_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If Trim(cboType.Text) = "" Then cboType.SetFocus MsgBox "You should fill-up the Type.", , "HEALTH CERTIFICATE" ElseIf (checkType = True) Then txtKind.Text = "" txtKind.SetFocus Else cboType.Text = "" MsgBox "Type is not in the choices.", , "HEALTH CERTIFICATE" End If End If 'keyascii End Sub Private Sub cmbClear_Click() txtIssuanceNo.Text = "" txtFName.Text = "" txtMidInit.Text = "" txtLName.Text = "" txtAge.Text = ""

txtPlaceOfWork.Text = "" txtNationality.Text = "" txtOccupation.Text = "" txtDateIssuance.Text = "" txtSIEmpNo.Text = "" txtMHOEmpNo.Text = "" lblDateExpiration.Caption = "" lblSIFName.Caption = "" lblMHOFName.Caption = "" cboSex.Text = "" Call clearSecondTxtCbo grd.Rows = 1 grd.Rows = 2 no = 1 flag = False End Sub Private Sub cmbExit_Click() db.Close End End Sub Public Function checkRequirement() As Boolean flagPhysical = False flagXRay = False For k = 1 To no - 1 If (UCase(Trim(grd.TextMatrix(k, 3))) = "PHYSICAL") Then flagPhysical = True ElseIf (UCase(Trim(grd.TextMatrix(k, 3))) = "X-RAY") Then flagXRay = True End If If (flagPhysical = True And flagXRay = True) Then Exit For End If Next physical = IIf(flagPhysical = True, "ok", "x") xray = IIf(flagXRay = True, "ok", "x") checkRequirement = IIf(flagPhysical = True And flagXRay = True, True, False) End Function Private Sub cmbSave_Click() flag = False If checkIssuanceNo = False Then flag = True ElseIf checkSex = False Then flag = True End If If flag = False Then If checkNumber = False Then flag = True

Else If CInt(txtAge.Text) < 1 Then flag = True End If End If End If If flag = False Then If Trim(txtFName.Text) = "" Then txtFName.SetFocus MsgBox "You should fill-up the First Name.", , "HEALTH CERTIFICATE" ElseIf Trim(txtMidInit.Text) = "" Then txtMidInit.SetFocus MsgBox "You should fill-up the Middle Initial.", , "HEALTH CERTIFICA TE" ElseIf Trim(txtLName.Text) = "" Then txtLName.SetFocus MsgBox "Youd should fill-up the Last Name.", , "HEALTH CERTIFICATE" ElseIf Trim(txtOccupation.Text) = "" Then txtOccupation.SetFocus MsgBox "You should fill-up the Occupation.", , "HEALTH CERTIFICATE" ElseIf Trim(txtNationality.Text) = "" Then txtNationality.SetFocus MsgBox "You should fill-up the Nationality.", , "HEALTH CERTIFICATE" ElseIf Trim(txtPlaceOfWork.Text) = "" Then txtPlaceOfWork.SetFocus MsgBox "You should fill-up the Place of Work", , "HEALTH CERTIFICATE " ElseIf Trim(lblDateExpiration.Caption) = "" Then txtDateIssuance.Text = "" txtDateIssuance.SetFocus MsgBox "You should fill-up the Date Issuance.", , "HEALTH CERTIFICAT E" ElseIf Trim(lblSIFName.Caption) = "" Then txtSIEmpNo.Text = "" txtSIEmpNo.SetFocus MsgBox "You should fill-up the Sanitary Inspector Number.", , "HEALT H CERTIFICATE" ElseIf Trim(lblMHOFName.Caption) = "" Then txtMHOEmpNo.Text = "" txtMHOEmpNo.SetFocus MsgBox "You should fill-up the Medical Health Officer Number.", , "H EALTH CERTIFICATE" ElseIf checkRequirement = False Then txtDateExam.SetFocus MsgBox "Necessary Requirements: " & vbCrLf & _ "[ " & xray & " ] <-- X-RAY" & vbCrLf & _ "[ " & physical & " ] <-- PHYSICAL", , "HEALTH CERTIFICATE" Else 'save statement If CheckCertificateNo(lblHealthCertificateNo.Caption) Then MsgBox "The Health Certificate Number would change to the Availa ble Number because its already exist.", , "HEALTH CERTIFICATE" lblHealthCertificateNo.Caption = LastCertificateNumber End If rsHCH.AddNew rsHCH!HCHCERTIFICATENO = lblHealthCertificateNo.Caption rsHCH!HCHISSUANCENO = Trim(txtIssuanceNo.Text) rsHCH!HCHSI = Trim(UCase(txtSIEmpNo.Text))

rsHCH!HCHMHO = Trim(UCase(txtMHOEmpNo.Text)) rsHCH!HCHDATEISSUED = Format(txtDateIssuance.Text, "mm/dd/yyyy") rsHCH!HCHDATEEXPIRY = Format(lblDateExpiration.Caption, "mm/dd/y yyy") rsHCH!HCHFIRSTNAME = Trim(UCase(txtFName.Text)) rsHCH!HCHMIDINIT = Trim(UCase(txtMidInit.Text)) rsHCH!HCHLASTNAME = Trim(UCase(txtLName.Text)) rsHCH!HCHAGE = CInt(Trim(txtAge.Text)) rsHCH!HCHGENDER = Left(Trim(cboSex.Text), 1) rsHCH!HCHNATIONALITY = Trim(UCase(txtNationality.Text)) rsHCH!HCHWORKPLACE = Trim(UCase(txtPlaceOfWork.Text)) rsHCH!HCHOCCUPATION = Trim(UCase(txtOccupation.Text)) rsHCH!HCHSTATUS = "AC" rsHCH.Update For k = 1 To no - 1 If CheckHealthRecordNo(lblHealthCertificateNo.Caption, k) = Fals e Then rsHCD.AddNew rsHCD!HCDFHEALTHNO = lblHealthCertificateNo.Caption rsHCD!HCDFRECORDNO = k rsHCD!HCDFEXAMTYPE = Trim(UCase(grd.TextMatrix(k, 3))) rsHCD!HCDFKIND = Trim(UCase(grd.TextMatrix(k, 4))) rsHCD!HCDFDATE = Format(Trim(grd.TextMatrix(k, 2)), "mm/ dd/yyyy") rsHCD!HCDFRESULT = Trim(UCase(grd.TextMatrix(k, 5))) rsHCD!HCDFCONDUCTEDBY = Trim(UCase(grd.TextMatrix(k, 6)) ) rsHCD!HCDFSTATUS = "AC" rsHCD.Update End If Next MsgBox "Successfully Added.", , "HEALTH CERTIFICATE" Call cmbClear_Click lblHealthCertificateNo.Caption = LastCertificateNumber txtIssuanceNo.SetFocus End If 'inner end if End If 'outer inner if End Sub Private Sub Form_Load() Call SetAllDetail no = 1 grd.Rows = 1 grd.Rows = 2 flag = False flagPhysical = False flagXRay = False xray = "" physical = "" lblHealthCertificateNo.Caption = LastCertificateNumber cboSex.AddItem "Male" cboSex.AddItem "Female"

cboType.AddItem cboType.AddItem cboType.AddItem cboType.AddItem End Sub

"PHYSICAL" "IMMUNIZATION" "X-RAY" "STOOL"

'area below - menu Private Sub mnuHealthCertificateReport_Click() frmHealthCertificateEntry.Hide frmHealthCertificateReport.Show End Sub Private Sub mnuHelathCertificateUpdate_Click() frmHealthCertificateEntry.Hide frmHealthCertificateUpdate.Show End Sub Private Sub mnuClear_Click() Call cmbClear_Click End Sub Private Sub mnuExit_Click() Call cmbExit_Click End Sub Private Sub mnuSave_Click() Call cmbSave_Click End Sub 'area above - menu Private Sub txtAge_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If (checkNumber = True) Then If CInt(txtAge.Text) < 1 Then txtAge.Text = "" txtAge.SetFocus MsgBox "Age should be above Zero.", , "HEALTH CERTIFICATE" Else cboSex.SetFocus End If End If End If 'keyascii End Sub Public Function checkNumber() As Boolean checkNumber = True txtAge.Text = Trim(txtAge.Text) If (txtAge.Text = "") Then checkNumber = False txtAge.Text = "" txtAge.SetFocus MsgBox "You should fill-up the Age.", , "HEALTH CERTIFICATE" End If For k = 1 To Len(txtAge.Text) If Asc(Mid(txtAge.Text, k, 1)) < 48 Or Asc(Mid(txtAge.Text, k, 1)) > 57 Then checkNumber = False

txtAge.Text = "" txtAge.SetFocus MsgBox "Age should be Number", , "HEALTH CERTIFICATE" Exit For End If Next End Function Private Sub txtConductedBy_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtConductedBy.Text = Trim(txtConductedBy.Text) If (txtConductedBy.Text = "") Then MsgBox "You should fill-up the Conducted By.", , "HEALTH CERTIFICATE " Else cboType.SetFocus End If End If 'keyascii End Sub Private Sub txtDateExam_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtDateExam.Text = Trim(txtDateExam.Text) If (checkDate = True) Then txtDateExam.Text = Format(txtDateExam.Text, "mm/dd/yy") txtResult.Text = "" txtResult.SetFocus Else txtDateExam.Text = "" End If End If 'keyascii End Sub Public Function checkDate() As Boolean checkDate = True If (txtDateExam.Text = "") Then checkDate = False MsgBox "You should fill-up the Date Exam.", , "HEALTH CERTIFICATE" ElseIf (IsDate(txtDateExam.Text) = False) Then checkDate = False MsgBox "The Date entered was not valid.", , "HEALTH CERTIFICATE" End If End Function Private Sub txtDateExam_LostFocus() txtDateExam.Text = Trim(txtDateExam.Text) If (txtDateExam.Text <> "") Then If (IsDate(txtDateExam.Text) = False) Then txtDateExam.Text = "" End If End If End Sub Private Sub txtDateIssuance_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtDateIssuance.Text = Trim(txtDateIssuance.Text) If (IsDate(txtDateIssuance.Text) = False) Then txtDateIssuance.Text = "" lblDateExpiration.Caption = ""

MsgBox "The Date entered was not valid.", , "HEALTH CERTIFICATE" Else Call dateCorrection txtDateIssuance.Text = Format(txtDateIssuance.Text, "mm/dd/yy") txtSIEmpNo.Text = "" txtSIEmpNo.SetFocus End If End If End Sub Public Function dateCorrection() getYear = Format(txtDateIssuance, "yy") lblDateExpiration.Caption = Format(Format("12/31/00", "mm/dd/yy") + getYear, "mm/dd/yyyy") End Function Private Sub txtDateIssuance_LostFocus() txtDateIssuance.Text = Trim(txtDateIssuance.Text) If (IsDate(txtDateIssuance.Text) = False) Then lblDateExpiration.Caption = "" Else Call dateCorrection End If End Sub Private Sub txtFName_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtFName.Text = Trim(txtFName.Text) If (txtFName.Text = "") Then MsgBox "You should fill-up the First Name.", , "HEALTH CERTIFICATE" Else txtMidInit.Text = "" txtMidInit.SetFocus End If End If 'keyascii End Sub Private Sub txtIssuanceNo_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then If (checkIssuanceNo = True) Then txtFName.Text = "" txtFName.SetFocus Else txtIssuanceNo.Text = "" End If End If 'keyascii End Sub 'check if the user entered valid number Public Function checkIssuanceNo() As Boolean checkIssuanceNo = False txtIssuanceNo.Text = Trim(txtIssuanceNo.Text) If (txtIssuanceNo.Text = "") Then txtIssuanceNo.SetFocus MsgBox = "You should fill-up the Issuance Number.", , "HEALTH CERTIFICAT E" ElseIf (txtIssuanceNo.Text <> "1" And txtIssuanceNo.Text <> "0") Then txtIssuanceNo.Text = ""

txtIssuanceNo.SetFocus MsgBox "Issuance Number :" & vbCrLf & "0 - Not issued in Municipal Healt h Center " & vbCrLf & "1 - Issued in Municipal Health Center.", , "HEALTH CERTIF ICATE" Else checkIssuanceNo = True End If End Function Private Sub txtKind_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtKind.Text = Trim(txtKind.Text) If (txtKind.Text = "") Then MsgBox "You should fill-up the Kind.", , "HEALTH CERTIFICATE" Else 'need to check the date of exam, result, conducted by, type, kind 'to display/entered in the grd If (checkDate = False) Then txtDateExam.Text = "" txtDateExam.SetFocus ElseIf (Trim(txtResult.Text) = "") Then txtResult.SetFocus MsgBox "You should fill-up the Result.", , "HEALTH CERTIFICATE" ElseIf (Trim(txtConductedBy.Text) = "") Then txtConductedBy.SetFocus MsgBox "You should fill-up the Conducted By.", , "HEALTH CERTIFI CATE" ElseIf checkType = False Then cboType.SetFocus MsgBox "Type is not in the choices.", , "HEALTH CERTIFICATE" Else grd.TextMatrix(no, 1) = no grd.TextMatrix(no, 2) = Format(txtDateExam.Text, "mm/dd/yyyy") grd.TextMatrix(no, 3) = cboType.Text grd.TextMatrix(no, 4) = txtKind.Text grd.TextMatrix(no, 5) = txtResult.Text grd.TextMatrix(no, 6) = txtConductedBy.Text no = no + 1 grd.Rows = grd.Rows + 1 yesNo = MsgBox("Dou want to Add other Examination?", vbYesNo, "H ealth Certificate") If yesNo = vbYes Then txtDateExam.SetFocus Else cmbSave.SetFocus End If Call clearSecondTxtCbo End If End If End If 'keyascii End Sub Public Function clearSecondTxtCbo() txtDateExam.Text = "" txtResult.Text = "" txtConductedBy.Text = "" txtKind.Text = "" cboType.Text = "" End Function

Public Function checkType() As Boolean cboType.Text = UCase(Trim(cboType.Text)) checkType = IIf(cboType.Text <> "PHYSICAL" And cboType.Text <> "IMMUNIZATION " And cboType.Text <> "X-RAY" And cboType.Text <> "STOOL", False, True) End Function Private Sub txtLName_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtLName.Text = Trim(txtLName.Text) If (txtLName.Text = "") Then MsgBox "You should fill-up the Last Name.", , "HEALTH CERTIFICATE" Else txtAge.Text = "" txtAge.SetFocus End If End If 'keyascii End Sub 'middle initial Private Sub txtMidInit_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtMidInit.Text = Trim(txtMidInit.Text) If (txtMidInit.Text = "") Then MsgBox "You should fill-up the Middle Initial.", , "HEALTH CERTIFICA TE" Else txtLName.Text = "" txtLName.SetFocus End If End If 'keyascii End Sub Private Sub txtNationality_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtNationality.Text = Trim(txtNationality.Text) If (txtNationality.Text = "") Then MsgBox "You should fill-up the nationality.", , "HEALTH CERTIFICATE" Else txtPlaceOfWork.Text = "" txtPlaceOfWork.SetFocus End If End If 'keyascii End Sub 'Occupation Private Sub txtOccupation_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtOccupation.Text = Trim(txtOccupation.Text) If (txtOccupation.Text = "") Then MsgBox "You should fill-up the Occupation.", , "HEALTH CERTIFICATE" Else txtNationality.Text = "" txtNationality.SetFocus End If End If 'keyascii End Sub Private Sub txtPlaceOfWork_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then

txtPlaceOfWork.Text = Trim(txtPlaceOfWork.Text) If (txtPlaceOfWork.Text = "") Then MsgBox "You should fill-up the Place of Work.", , "HEALTH CERTIFICAT E" Else txtDateIssuance.Text = "" txtDateIssuance.SetFocus End If End If 'keyascii End Sub Private Sub txtMHOEmpNo_Change() txtMHOEmpNo.Text = Trim(txtMHOEmpNo.Text) If (txtMHOEmpNo.Text <> "") Then If (CheckEmpNo(txtMHOEmpNo.Text) = False) Then lblMHOFName.Caption = "" End If End If End Sub Private Sub txtMHOEmpNo_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtMHOEmpNo.Text = Trim(txtMHOEmpNo.Text) If (txtMHOEmpNo.Text = "") Then MsgBox "You should fill-up the Medical Health Officer Number.", , "H EALTH CERTIFICATE" ElseIf (CheckEmpNo(txtMHOEmpNo.Text) = False) Then MsgBox "Medical Health Officer Number not found in Record.", , "HEAL TH CERTIFICATE" Else If (checkEmployeeData(rsEmpPro) = True) Then If (UCase(Trim(rsEmpPro!EPPOSITION)) = "MEDICAL HEALTH OFFICER") Then If (UCase(Trim(rsEmpPro!EPSTATUS)) = "AC") Then lblMHOFName.Caption = rsEmpPro!EPLNAME + ", " + rsEmpPro !EPFNAME + " " + rsEmpPro!EPMIDINIT + "." txtDateExam.Text = "" txtDateExam.SetFocus Else txtMHOEmpNo.Text = "" MsgBox "Employee is no longer in the service.", , "HEALT H CERTIFICATE" End If Else txtMHOEmpNo.Text = "" MsgBox "Employee Position should be Medical Health Officer o nly.", , "HEALTH CERTIFICATE" End If Else txtMHOEmpNo.Text = "" MsgBox "Employee has an incomplete informations.", , "HEALTH CER TIFICATE" End If 'checkemployeedata End If End If 'keyascii End Sub Private Sub txtResult_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtResult.Text = Trim(txtResult.Text)

If (txtResult.Text = "") Then MsgBox "You should fill-up the Result.", , "HEALTH CERTIFICATE" Else txtConductedBy.Text = "" txtConductedBy.SetFocus End If End If 'keyascii End Sub Private Sub txtSIEmpNo_Change() txtSIEmpNo.Text = Trim(txtSIEmpNo.Text) If (txtSIEmpNo.Text <> "") Then If (CheckEmpNo(txtSIEmpNo.Text) = False) Then lblSIFName.Caption = "" End If End If End Sub Private Sub txtSIEmpNo_KeyPress(KeyAscii As Integer) If KeyAscii = 13 Then txtSIEmpNo.Text = Trim(txtSIEmpNo.Text) If (txtSIEmpNo.Text = "") Then MsgBox "You should fill-up the Sanitary Inspector Number.", , "HEALT H CERTIFICATE" ElseIf (CheckEmpNo(txtSIEmpNo.Text) = False) Then MsgBox "Sanitary Inspector Number not Found in Record.", , "HEALTH C ERTIFICATE" Else If (checkEmployeeData(rsEmpPro) = True) Then If (UCase(Trim(rsEmpPro!EPPOSITION)) = "SANITARY INSPECTOR") The n If (UCase(Trim(rsEmpPro!EPSTATUS)) = "AC") Then lblSIFName.Caption = rsEmpPro!EPLNAME + ", " + rsEmpPro! EPFNAME + " " + rsEmpPro!EPMIDINIT + "." txtMHOEmpNo.Text = "" txtMHOEmpNo.SetFocus Else txtSIEmpNo.Text = "" MsgBox "Employee is no longer in the service.", , "HEALT H CERTIFICATE" End If Else txtSIEmpNo.Text = "" MsgBox "Employee Position should be Sanitary Inspector only. ", , "HEALTH CERTIFICATE" End If Else txtSIEmpNo.Text = "" MsgBox "Employee has an incomplete informations.", , "HEALTH CER TIFICATE" End If 'checkValidData End If ' ="" End If 'keyascii End Sub

Вам также может понравиться