mercredi 30 mars 2016

How to compare timespan before and after?

I wanted to compare a timespan before and after 3 hours. For example, a cinema halls, I wanted to check the hall on the specific date is the hours chosen can fit into it. If that day has movie on that hall, then the hours can only be 3 hours before or 3 hours after the movie.

I know that timespan can add but I can't think of a way to actually do the algorithm.Here's the part of the code I'm trying to figure out TimeSpan.Parse(cbxTime.Text) part what should be added

  If hall1.Checked = True Then
                For Each g In db.Shows

                    If g.hallId = "H1" Then
                        If g.showDate = CDate(dtpDate.Text) Then
                            If g.showTime > TimeSpan.Parse(cbxTime.Text) 3 hours OR < TimeSpan.Parse(cbxTime.Text)3 hours   Then
                                Can proceed to Adding Show Time
                            End If
                        End If
                    End If
                Next
                a.hallId = "H1"

Any help will be much appreciated.

Aucun commentaire:

Enregistrer un commentaire