Public Class frmPRMmed
 
    Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
        Try
            sql = "INSERT INTO `tblprnmedication` " & _
                                " (`CASENUM`, `ADMITTINGID`, `PRNDATE`, `PRNTIME`, `DRUGSNAME`, `DOSAGE`, `ROUTE`, `REMARKS` ) " & _
                                " VALUES (" & lblCaseNum.Text & _
                                "," & lblAdmitting.Text & _
                                ",'" & INSERTMYSQLDATE(dtpDate, "yyyy-MM-dd") & _
                                "','" & Format(dtpTime.Value, "HH:mm:ss") & _
                                "','" & txtNameDrug.Text & "','" & txtDosage.Text & _
                                "','" & txtRoute.Text & "','" & txtRemarks.Text & "')"
            result = CUD(sql)
            If result = False Then
                MsgBox("error to save tblprnmedication", MsgBoxStyle.Exclamation)
            Else
                MsgBox("New Record has been saved.")




                With frmStation1
                    'sql = "SELECT  `MEDECATION` as 'Medication',`TREATMENT` as 'Nursing-Procedure-and-Treatment'  " & _
                    '" FROM `tblmedication` M, `tbladmitting` A " & _
                    '" WHERE `ADMITTINGSTATUS`=1 AND M.`ADMITTINGID`=A.`ADMITTINGID` AND A.CASENUM= " & lblCaseNum.Text
                    'RETRIEVEDTG(.dtgListmedication, sql)
                    ''dtgListmedication.Columns(0).Visible = False
                    '.dtgListmedication.Columns(1).Width = 100
                    '.dtgListmedication.SelectionMode = DataGridViewSelectionMode.FullRowSelect
                    '.dtgListmedication.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells)
                    '.dtgListmedication.EditMode = DataGridViewEditMode.EditProgrammatically
                    '.dtgListmedication.AllowUserToAddRows = False
                    '.dtgListmedication.SelectionMode = False


                    sql = "SELECT `PRN_MED_ID`,PRNDATE as 'Date'  ,PRNTIME as 'Time' ,`DRUGSNAME` AS 'NameofDrugs', `DOSAGE` AS 'Dosage', `ROUTE` AS 'Route', `REMARKS` AS 'Remarks'  " & _
                    " FROM `tblprnmedication` M, `tbladmitting` A " & _
                    " WHERE M.`ADMITTINGID`=A.`ADMITTINGID` AND `ADMITTINGSTATUS`=1 AND A.CASENUM=" & lblCaseNum.Text
                    result = dtgAddRec(.dtgListPRNRec, sql)


                    .dtgListPRNRec.Columns(0).Visible = False

                    sql = "SELECT BPID, `BPDATE` AS 'DATE',BPTIME as 'Time', `BP`, `PR`, `RR` FROM `tblbprecord` WHERE CASENUM=" & lblCaseNum.Text
                    dtgAddRec(.dtgListBPRec, sql)
                    .dtgListPRNRec.SelectionMode = False
                    .dtgListBPRec.Columns(0).Visible = False



                    sql = "SELECT `IVFID`, `IVFDATE`  as 'Date/hrn', `BOTTLENUM` as 'Bottle #'," & _
                     " `KINDOFSOLUTION` as 'Kind of Solution', `IVFAMOUNT` AS 'Amount'," & _
                     " `MEDICATIONADDERT` as 'Meication/Addert', `IVFRATE` as 'Rate', `STARTEDTIME` as 'Time Started'," & _
                     " `STARTNURSE` as 'Nurse Id'," & _
                     " ( " & _
                   " CASE WHEN ( " & _
                   " `IVFREMARKS` =  '' " & _
                   " ) " & _
                   " THEN  `IVFREMARKS` " & _
                   " ELSE  `ENDEDTIME` " & _
                   " End " & _
                   " ) AS  'End Time', `ENDNURSE` as 'Nurse Id', ( " & _
                   " CASE WHEN ( " & _
                   " `IVFREMARKS` =  '' " & _
                   " ) " & _
                   " THEN  `IVFREMARKS` " & _
                   " ELSE  `ENDDATE` " & _
                   " End " & _
                   " ) AS  'End Date', `IVFREMARKS` as 'Remarks' FROM tblivfrecord WHERE CASENUM=" & lblCaseNum.Text
                    dtgAddRec(.dtgIVFRecord, sql)
                    dtgAddRec(.dtgIVFRecord, sql)

                    .btnBPrec.Visible = True
                    .btnIVFRecord.Visible = True
                    .btnPrmNew.Visible = True
                    .btnResultRec.Visible = True
                    .btnMedicalChecklist.Visible = True
                End With
            End If
        Catch ex As Exception

        End Try
    End Sub

    

    Private Sub frmPRMmed_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        showStationList(frmStation1)
    End Sub

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

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

    End Sub
End Class