Private Sub ButtonOk_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ButtonOk.Click
If txtHour.Text = 0 Then
MsgBox("โปรดเลือกเวลาให้ถูกต้อง!!!")
Exit Sub
ElseIf txtPrice.Text = "" Then
MsgBox("โปรดใส่เวลาให้ถูกต้อง!!!")
Exit Sub
End If
Dim CheckTime As Integer
Dim CheckDate As String = GetDateTime(DateTimePicker1)
sql = "SELECT COUNT(*) FROM RentStu WHERE (TimeIn BETWEEN '" & ComboTime1.Text & "' AND '" &
ComboTime2.Text & "') or (TimeOut BETWEEN '" & ComboTime1.Text & "' AND '" &
ComboTime2.Text & "') or (RTStuDate = '" & CheckDate & "')"
command = New SqlCommand(sql, connection)
CheckTime = command.ExecuteScalar()
If CheckTime > 0 Then
MsgBox("เวลานี้มีคนจองแล้ว!!!")
Else
sql = "INSERT INTO RentStu(CusID, CusTitle, CusName, StuName, RTStuDate, TimeIn, TimeOut, RTStuPrice)" & _
"VALUES(@cusID, @cusTitle, @cusName, @stuName, @date, @timein, @timeout, @price)"
AddParameters(sql)
Dim r As Integer = command.ExecuteNonQuery()
If r > 0 Then
MessageBox.Show("บันทึกข้อมูลแล้ว")
UpdateBinding()
Else
MessageBox.Show("เกิดข้อผิดพลาดในการบันทึกข้อมูล")
End If
End If
End Sub
ALTER PROCEDURE [dbo].[SPWeb_CheckRoomForAdd] --Without conference request reservation
@Room int,
@Starttime datetime,
@Endtime datetime
AS
BEGIN
SET NOCOUNT ON;
SELECT rID,Room, StartTime, EndTime,ReserveBy
FROM RoomReservation
WHERE (ROOM=@ROOM AND (CONVERT(VARCHAR(19),@Starttime,120) BETWEEN starttime AND endtime OR
CONVERT(VARCHAR(19),@Endtime,120) BETWEEN starttime AND endtime ))
OR (ROOM=@ROOM AND @Endtime > endtime AND @Starttime < starttime) AND rStatus = '1'
END