vb.net - Hotel Booking System (Room Available,(Buttons)) -


i'm making hotel booking system. have 15 buttons representing each room. once date in has been selected, if room has been booked, need button number on turn red , cannot selected. however, need button red time in-between date in , date out.

this code have far. i'm not sure start.

 dim date1 datetime = dtpdatein.value.date     dim date2 datetime = dtpdateout.value.date     dim da oledbdataadapter = new oledbdataadapter     dim bookingfound string = false      myconn = new oledbconnection       myconn.connectionstring = connstring       myconn.open()       str1 = ("select * bookinginformation [date in] >= '" & date1 & "' , [date out] <= '" & date2 & "'")       '("select * [bookinginformation] [date in] = #" & dtpdatein.value.date & "#")       dim cmd1 oledbcommand = new oledbcommand(str1, myconn)      dr = cmd1.executereader       while dr.read()          bookingfound = true           strdateout = dr("date out").tostring          strdatein = dr("date in").tostring          strroomnumber = dr("room number").tostring           cmbrooms.items.remove(strroomnumber)     end while     myconn.close()  end sub 

first of all, little easier if collect room buttons list , order them room number. ideally, button name btnroom01. if make sure single digit numbers start zero, method of ordering used in sample work. if not, you'll need re-write requirements.

create form wide list -

dim roombuttons new list(of button) 

here's code collect buttons

private sub addbuttonstocollection()     roombuttons.clear()     each ctl control in me.controls         dim btn button         if ctl.gettype = gettype(button)             btn = ctype(ctl, button)             if btn.name.contains("btnroom")                 roombuttons.add(btn)                 roombuttons = roombuttons.orderby(function(x) x.name).tolist             end if         end if     next end sub 

and while loop should this

while dr.read()     dim bookingdatein, bookingdateout date     bookingfound = true     date.tryparse(dr("date out").tostring, bookingdatein)     date.tryparse(dr("date in").tostring, bookingdatein)     dim roomnumber integer = cint(dr("room number").tostring)     if (bookingdatein <= date2) , (bookingdateout >= date1)         roombuttons(roomnumber - 1).backcolor = color.red         roombuttons(roomnumber - 1).text = roomnumber.tostring & vbcrlf & bookingdatein.toshortdatestring & vbcrlf & bookingdateout.toshortdatestring     end if end while 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -