Public Class frmNurseryDischarge
 

    Private Sub txtDiagnosi_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtDiagnosi.KeyPress
        Try
            e.Handled = True
        Catch ex As Exception

        End Try
    End Sub

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

    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
 
        Try
            sql = "  INSERT INTO `tblnurserydischargesummary` " & _
              " (`CASENUM` ,  `HEADCERCUMFERENCE`,`BIRTHHEIGHT`, `CHESTCERCUMFERENCE`, " & _
              " `DIAGNOSIS`, `DATEDISCHARGE`) VALUES ('" & txtHostCode.Text & "', '" & txtHeadCescumtances.Text & _
              "','" & txtBHieght.Text & "','" & txtcheastCercumtances.Text & "','" & txtDiagnosi.Text & "','" & dtpDischarge.Value & "')"
            CUD(sql)
            MsgBox("Patient has been discharge.")
        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

            If txtHostCode.Text <> "" Then
                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")
                        dtpTime.Text = .Item("TIMEBIRTH").ToString
                        txtAdd.Text = .Item("RADDRESS")
                        txtDateAdmit.Text = .Item("DBIRTH")
                        txtsex.Text = .Item("CSEX")
                        txtbirthwieght.Text = .Item("WEIGHTBIRTH")
                    End With
                Else
                    txtname.Clear()
                    dtpDateBirth.Clear()
                    dtpTime.Clear()
                    txtAdd.Clear()
                    txtDateAdmit.Clear()
                    txtsex.Clear()
                    txtbirthwieght.Clear()
                    txtBHieght.Clear() 
                    txtcheastCercumtances.Clear()

                 
                End If
            Else
                cleartext(Me)
                Call frmNurseryDischarge_Load(sender, e)
            End If
     
        Catch ex As Exception
            '    MsgBox(ex.Message)
        End Try
    End Sub

    Private Sub dtpTime_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtsex.KeyPress, txtname.KeyPress, txtDateAdmit.KeyPress, txtAdd.KeyPress, dtpTime.KeyPress, dtpDateBirth.KeyPress
        e.Handled = True
    End Sub

    Private Sub txtbirthwieght_KeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtbirthwieght.KeyPress
        e.Handled = True
    End Sub

    Private Sub frmNurseryDischarge_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try

            fillcbo("SELECT * FROM `tbldiagnosis`", txtDiagnosi, "DIAGNOSIS", "DIAGNOSISID")

            autocompletetxt("SELECT CASENUM FROM `tblnewborn` ", txtHostCode)

        Catch ex As Exception

        End Try
    End Sub
End Class