Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Item by location (Read 5142 times)
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Item by location
Dec 18th, 2007 at 8:53am
Print Post  
Can anyone supply me with a simple small block of code that allows one to switch the datasource of a calendar to a different location please?

I am having a hell of a time trying to figurre this out?

I thought the eay way would be just to set the location field in the item table to 1 or 2 respectivle and filter by that, but it right requires a location object.

I have created two locations in the location table with name equal again to 1 and 2 respectively.

But again no joy as the app.location.name = does not seem to do anything at all.

I even tried using the Tag field but get an error saying I cannot use the = operator on datatype nText.

I see there is a sample in the demo that comes with planner but this is in C# and I dont know this and also I see nowhere where the C# saves to database so I could at least try to track what goes on???

Thnx.

I have this as ticket too so will post any reply from the tech guys here too.

  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Item by location
Reply #1 - Dec 18th, 2007 at 9:12am
Print Post  
Here is the entire block of code I now have working in a sort of way, well it gets further than before anyhow!

Code
Select All
 Private Sub CalTimeTableView_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles calTimeTableView.DragDrop

	  If Not e.Data.GetDataPresent(DataFormats.StringFormat) Then

		Return

	  End If

	  ' only drop an appointment on the calendar if the date is in the present
	  ' user is not permitted to book deliveries in the past

	  If Not dtPointedDate < Date.Today Then

		Dim app As Appointment = New Appointment

		Dim l As Location = New Location

		Dim i As Item = Nothing

		With l

		    .Id = Me.PlannerSQLDataSet.Location.Rows(0).Item("id").ToString
		    .Name = Me.PlannerSQLDataSet.Location.Rows(0).Item("Name").ToString

		End With

		' set appointment detail

		app.HeaderText = strHeader
		app.DescriptionText = strDetail
		app.StartTime = dtPointedDate
		app.EndTime = dtPointedDate.Add(New TimeSpan(30 * TimeSpan.TicksPerMinute))
		app.Location = l

		' add the new appointment to the schedule

		calTimeTableView.Schedule.Items.Add(app)

		' no date is pointed to at present

		dtPointedDate = DateTime.MinValue

		' process new item

		ProcessItemCreated(app)

		' get the item just created so we can access its id field to add to po table

		i = calTimeTableView.Schedule.Items.Item(calTimeTableView.Schedule.Items.Count - 1)

		If Not LinkedPO(i.Id, True) Then

		    Exit Sub

		End If

		WriteLog("create", String.Empty, app.HeaderText & " " & app.DescriptionText & " start time:" & app.StartTime & " end time:" & app.EndTime, app.HeaderText)

		Try

		    ' update calendar tables in database

		    Me.calTimeTableView.SaveToDataSource(Me.ReminderTableAdapter1, Me.StyleTableAdapter1, Me.CustomBrushesTableAdapter1, Me.ContactTableAdapter1, Me.LocationTableAdapter1, Me.ResourceTableAdapter1, Me.TaskTableAdapter1, Me.ItemTableAdapter1, Me.ItemContactsTableAdapter1, Me.ItemResourcesTableAdapter1, Me.RecurrenceTableAdapter1, Me.RecurrenceExceptionTableAdapter1, Me.RecurrenceExceptionsTableAdapter1)

		    ' force calendar to redraw

		    calTimeTableView.Invalidate()

		Catch objError As Exception

		    MessageBox.Show("Location: CalTimeTableView_DragDrop" & System.Environment.NewLine & System.Environment.NewLine & _
					 "The following error occurred whilst saving delivery data" & _
					 System.Environment.NewLine & System.Environment.NewLine & objError.Message & _
					 System.Environment.NewLine & System.Environment.NewLine & _
					 "Please contact Distribution IT Support, the PO and Delivery are not synchronised.", _
					 "Save Error", MessageBoxButtons.OK, MessageBoxIcon.Error)


		End Try

	  End If

    End Sub
 



I now get an error on the save to datasource line whereas I din not before?


"index -1 is either negative or above rows count"

????
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Item by location
Reply #2 - Dec 18th, 2007 at 9:34am
Print Post  
I now find if I include this line:

  calTimeTableView.Schedule.Locations.Add(l)


It works, but this is not what I want or need as this creates a new row in the location table which is not required????

If I have two rows in the location table for building1 and building2 can I not just assign each of these as required to the Item table location field?

I tried omitting the location table adapter parameterr in the save to datasource call but still get the error???

My head hurts!  Sad









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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Item by location
Reply #3 - Dec 18th, 2007 at 10:24am
Print Post  
When you load the schedule data from the database, the locations should be loaded as well in the Calendar.Schedule.Locations collection. Then, when dropping a new item, you don't have to create a new Location object, but simply get a reference to one of the existing locations in the above collection, then assign it to the Appointment.Location property.

Have you tried it this way?

Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Item by location
Reply #4 - Dec 18th, 2007 at 10:30am
Print Post  
I have this in my code:

Me.LocationTableAdapter1.Fill(Me.PlannerSQLDataSet.Location)

But I am getting totally confused!! Sad

This alone would return the 2 rows in the table.

So I modified the .Fill sql to accept a pararmeter.

So if i do this:

Me.LocationTableAdapter1.Fill(Me.PlannerSQLDataSet.Location, intBuilding)

only one row will be returned.

But I have obvioulsy lost the plot as how do I assgn this datarow to a location object?

See my early block of code I did this but still get error?












  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Item by location
Reply #5 - Dec 18th, 2007 at 10:41am
Print Post  
Oooooh like this of course!

app.Location = Me.calTimeTableView.Schedule.Locations.Item(0)

it is sort of working will get back to you Smiley

thanks Meppy!
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Item by location
Reply #6 - Dec 18th, 2007 at 12:19pm
Print Post  
Hi Meppy,

this works as I hoped for to a point.

It now successfully links the relevant Item to the desired Location.

So I do something like this:

Me.calTimeTableView.Schedule.Locations.Item(intBuilding).Name

to obtain the name of the building, whse1 or whse2.

Great I am almost there ..... but

The calendar on my form has all its datamembers set to all the tables in the planner database.

Can you throw me a tip on how I would flick the calendar display to either location in response to the user clicking a radio button?

I know how to do the main bit it is just getting the calendar to refresh its display and data based on where the item.location.name = [users choice]

Thanks

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


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Item by location
Reply #7 - Dec 18th, 2007 at 12:27pm
Print Post  
You can perform grouping by the desired location (certain views do not support grouping). For example, to group by the first location in the schedule, effectively displaying all items associated with that location, you should do something similar to the following (assuming calendar references your Calendar control):

Code
Select All
calendar.BeginInit()
calendar.Locations.Clear()
calendar.Locations.Add(calendar.Schedule.Locations(0))
calendar.GroupType = GroupType.GroupByLocation
calendar.EndInit() 


Meppy
  
Back to top
 
IP Logged
 
elpuerco
Junior Member
**
Offline


Time?  What's time matta
to a pig?

Posts: 94
Joined: Oct 2nd, 2007
Re: Item by location
Reply #8 - Dec 18th, 2007 at 12:50pm
Print Post  
OMG!!!!

This control is the dog B's  Grin

Thanks Meppy u r a star !!!!
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint