Public Class frmAddmitting
 
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Try

            sql = "INSERT  `tblnewborn` " & _
                  " (CASENUM,`CNAME`,MCASENUM,  `DBIRTH`, `TYPOFBIRTH`, `CSEX`, `WEIGHTBIRTH`, `TIMEBIRTH`, `DOCID`, `BIRTHORDER`, " & _
                  "  `CITIZENFATHER`,   `RELIGONFATHER`, `CHILDRENBORNALIVE`, " & _
                  " `NOCHILDRENSTILLLIVING`, `NOCHILDRENDEAD`,   `FOCCUPATION`, `FAGE`,   `RADDRESS`," & _
                  "`INFORMAL`, `RELATIONCHILD`) VALUES " & _
                  " ('" & txtHostCode.Text & "','" & txtname.Text & "','" & txtMocaseNum.Text & _
                  "','" & INSERTMYSQLDATE(dtpDateBirth, "yyyy-MM-dd") & _
                  "','" & cboTypeOfBirth.Text & "','" & INSERTGENDER(rdoFemale, rdoMale) & _
                  "','" & txtbirthwieght.Text & "','" & INSERTMYSQLDATE(dtpTime, "hh:mm:ss") & _
                  "','" & cboAttendingPhysiscian.SelectedValue & "','" & txtBirthorder.Text & _
                  "', '" & txtCFather.Text & "', '" & txtRfather.Text & "','" & txtChildAlive.Text & _
                  "','" & txtStillliving.Text & _
                  "','" & txtChildDead.Text & "' ,'" & txtoFather.Text & _
                  "','" & txtFage.Text & "', '" & txtAddress.Text & _
                  "','" & txtInformal.Text & "','" & txtRelationToChild.Text & "')"
            CUD(sql)

            MsgBox("New record has been saved")

            updateautonumbercateg("casenum")
            loadautonumbercateg("casenum", txtHostCode)
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try 
    End Sub

    'Private Sub txtHostCode_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtHostCode.TextChanged
    '    Try



    '        sql = "SELECT * FROM `tblnewborn` WHERE `CASENUM`=" & txtHostCode.Text
    '        result = RETRIEVESINGLE(sql)
    '        If result = True Then
    '            With dt.Rows(0)
    '                txtname.Text = .Item("CNAME")
    '                dtpDateBirth.Text = .Item("DBIRTH")
    '                cboTypeOfBirth.Text = .Item("TYPOFBIRTH")
    '                If .Item("CSEX") = "Male" Then
    '                    rdoMale.Checked = True
    '                Else
    '                    rdoFemale.Checked = True
    '                End If
    '                txtbirthwieght.Text = .Item("WEIGHTBIRTH")
    '                dtpTime.Text = .Item("TIMEBIRTH")
    '                cboAttendingPhysiscian.Text = .Item("DOCID")
    '                txtMocaseNum.Text = .Item("MCASENUM")
    '                txtBirthorder.Text = .Item("BIRTHORDER") 
    '                txtCFather.Text = .Item("CITIZENFATHER") 
    '                txtRfather.Text = .Item("RELIGONFATHER")
    '                txtChildAlive.Text = .Item("CHILDRENBORNALIVE")
    '                txtStillliving.Text = .Item("NOCHILDRENSTILLLIVING")
    '                txtChildDead.Text = .Item("NOCHILDRENDEAD") 
    '                txtoFather.Text = .Item("FOCCUPATION")
    '                txtFage.Text = .Item("FAGE") 
    '                txtAddress.Text = .Item("RADDRESS")
    '                txtInformal.Text = .Item("INFORMAL")
    '                txtRelationToChild.Text = .Item("RELATIONCHILD")


    '            End With
    '        End If

    '    Catch ex As Exception
    '        MsgBox(ex.Message)
    '    End Try
    'End Sub

    Private Sub frmAddmitting_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            sql = "SELECT * FROM `tbldoctor` WHERE `DOCFIELDS` LIKE '%OB-GYNE%'"
            fillcbo(sql, cboAttendingPhysiscian, "DOCNAME", "DOCID")

            loadautonumbercateg("casenum", txtHostCode)
 
            autocompletetxt("SELECT CASENUM FROM `tblpatient` WHERE GENDER='Female'", txtMocaseNum)
        Catch ex As Exception

        End Try
      
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Try
            With frmPatient
                .Show()
                .Focus()
            End With
        Catch ex As Exception

        End Try
    End Sub

    Private Sub Label4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Label4.Click

    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Me.Close()

    End Sub
End Class