01.
if
(comboBox5.SelectedIndex != -1)
02.
{
03.
command.CommandText =
"select date_rental,date_rentalend,time_rental,time_rentalend from Lorry_rental where Lorry_id='"
+ comboBox5.Text +
"' and date_rental <='"
+ dateTimePicker1.Text +
"' and date_rentalend >='"
+ dateTimePicker3.Text +
"' and time_rental <='"
+ comboBox6.Text +
"' and time_rentalend >='"
+ comboBox7.Text +
"' "
;
04.
command.Connection = conn;
05.
conn.Open();
06.
OdbcDataReader red = command.ExecuteReader();
07.
if
(red.HasRows)
08.
{
09.
red.Read();
10.
MessageBox.Show(
"รถไม่ว่าง กรุณาเปลี่ยนรถคันใหม่ หรือ เปลี่ยนวันเวลาในการเช่า"
);
11.
text5.Text =
""
;
12.
comboBox5.Text =
""
;
13.
comboBox5.Focus();
14.
}
15.
red.Close();
16.
conn.Close();
17.
}