Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic resource view (Read 3408 times)
alanmcgeough
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 34
Joined: Dec 17th, 2007
resource view
Apr 2nd, 2008 at 2:52pm
Print Post  
Hi all i am just working on a new project using the resource view, i have a hireItem table which i use to pull in all items but instead of pulling all the items everytime from the server i only want to get items between the start date and end date, i have a function on the change event of a text box which is linked to the scroll the line of code is


where valDate is the Current Date

strSql = "SELECT * fROM HireItem Where DateDiff(d,'" & ValDateStr & "', CAST(FLOOR(CAST(StartTime AS float)) AS datetime)) <= 0 AND DateDiff(d,'" & ValDateStr & "',CAST(FLOOR(CAST(EndTime AS float)) AS datetime)) >= 0 "


any help would be great!!
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: resource view
Reply #1 - Apr 2nd, 2008 at 3:02pm
Print Post  
Once you have obtained the items in the specified time interval in a dataset, you can traverse this dataset and create a new Appointment object for each row in it. Then add the newly created appointments to the Calendar.Schedule.Items collection.

Meppy
  
Back to top
 
IP Logged
 
alanmcgeough
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 34
Joined: Dec 17th, 2007
Re: resource view
Reply #2 - Apr 2nd, 2008 at 3:34pm
Print Post  
strSql = "SELECT * fROM HireItem Where DateDiff(d,'" & ValDateStr & "', CAST(FLOOR(CAST(StartTime AS float)) AS datetime)) <= 0 AND DateDiff(d,'" & ValDateStr & "',CAST(FLOOR(CAST(EndTime AS float)) AS datetime)) >= 0 "

its getting the items in the interval im having probelms with

for example i have a resource view which shows 20days

the line above on the Hscroll depending on if increment or decrement i add or subtract for the

If e.Type = ScrollEventType.SmallDecrement Then


txtDate.Text = CDate(txtDate.Text).Subtract(TimeSpan.FromDays(1))

if i have a item with a startdate of 31/03/08 and EndDate 11/04/08

if i scroll in for the 31, right up the the end date the item shows on the planner but if i if i scroll to date 30/03/08 the item does not show on the planner even though it should show up
its my query not right

i could do select * from hireItems but as the application builds up this could be hard on the server

what i need the query to select items that have start date on of after the calendar.date and which have enddate on or before the calendar.endDate. and everything in between.

thanks again
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: resource view
Reply #3 - Apr 3rd, 2008 at 6:49am
Print Post  
I was wondering why you are using the same date in both comparisons. Your check as far as I understand it is similar to the following (I'm using a pseudo-code to avoid the several casts in the SQL statement):

Code
Select All
itemStartTime <= someDate AND someDate <= itemEndTime 


If you intend to obtain all items in an interval, aren't you supposed to use the start and end time of this interval? Something similar to the following:

Code
Select All
itemStartTime <= intervalEndTime AND intervalStartTime <= itemEndTime 


Can you try this and let me know if it works?

Meppy
  
Back to top
 
IP Logged
 
alanmcgeough
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 34
Joined: Dec 17th, 2007
Re: resource view
Reply #4 - Apr 3rd, 2008 at 10:42am
Print Post  
hi meppy still having probs with the query i have two dates to work with now which represent the visible start and end date on the calendar

for example 03/04/2008 startdate to the 25/04/2008 enddate

when the user scrolls left or right the two dates are incremented or decremented accordinly by 1 day if user scrolls left the start date and enddate will be 04/04/2008 to 26/04/2008



i just want to be able to call all the items within the two dates the query is not quite working

any help would be great thanks again
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: resource view
Reply #5 - Apr 3rd, 2008 at 11:22am
Print Post  
I am not much into SQL so the code below might not be as accurate as to actually work. I presume, in your query, the start and end of the time interval of interest are being supplied as parameters (lets say IntervalStart and IntervalEnd). In this case I would write a query similar to the following:

Code
Select All
SELECT * FROM HireItem WHERE DateDiff(d, '" & IntervalEnd & "', CAST(FLOOR(CAST(StartTime AS float)) AS datetime)) <= 0 AND DateDiff(d, '" & IntervalStart & "', CAST(FLOOR(CAST(EndTime AS float)) AS datetime)) >= 0; 


Hope this helps.

Meppy
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint