Public Overrides Function Obtenir_pes_canal() As Double
Dim cadena As String, taula As MySqlDataReader
Dim pes As Double
Dim data As Date, hora As Date
pes = 0
Try
cadena = "SELECT * FROM T_PES WHERE PESDAT='" & Format(data_sistema, "yyyy-MM-dd") & "' AND PESMAT<>'X' ORDER BY PESDAT, PESHOR"
taula = con.eXecutaReader(cadena)
If taula.Read() Then
pes = taula("PESVAL")
data = taula("PESDAT")
hora = CType(taula("PESHOR"), String)
cadena = "UPDATE T_PES SET PESMAT = 'X' WHERE PESDAT='" & Format(data, "yyyy-MM-dd") & "' AND PESHOR='" & Format(hora, "HH:mm:ss") & "'"
con.eXecutaInst(cadena)
If taula.Read() Then
pes = pes + taula("PESVAL")
cadena = "UPDATE T_PES SET PESMAT = 'X' WHERE PESDAT='" & taula("PESDAT") & "' AND PESHOR='" & taula("PESHOR") & "'"
con.eXecutaInst(cadena)
End If
End If
taula.Close()
con.Tanca()
Catch ex As Exception
MsgBox(ex.Message)
End Try
Return pes
End Function
|