Hello,
I'm using Selfservicing.
I have a form where a customer can be entered.
On the same form, I also have a grid with contact info for that customer.
the entity customer and the collection contactinfo have the necessary relations.
What I want to reach is the following:
Scenario 1:
The user enters a customer, he also enters multiple contact info records.
He clicks save, this should save the customer and the contact info records in a transaction.
Scenario 2:
The user enters a customer, he also enters multiple contact info records.
He clicks cancel, this should not save the information for customer and contact info records.
Scenario 3:
The user enters a customer, he also enters multiple contact info records, but he also deletes some of those contact info records in the grid. The grid should be updated, but not the database until the user clicks the save button. If the user clicks the cancel button, nothing should have changed in the customer or contact records.
It's the third scenario that is giving me a lot of problems. I've tried several options, but I don't seem to get the grid updating without saving the contact info to the database, but that gives me constraint errors when the user is entering a new customer.
Also when adding a new contact info record to the grid, how can I resort the grid, so that the new contact info is in the correct location?
Some code I have been trying:
to fill the contactgrid:
IPredicateExpression predicatecontact = new PredicateExpression();
ISortExpression sorter5 = new SortExpression(
SortClauseFactory.Create(TravelAgent.Dal.ContactFieldIndex.Contactlabel, SortOperator.Ascending));
fileEntry.SetCollectionParametersContacts(0, sorter5);
gridContacts.DataSource = fileEntry.GetMultiContacts(false);
to delete a contact in the grid:
TravelAgent.Dal.EntityClasses.ContactEntity contact = fileEntry.Contacts[BindingContext[fileEntry.Contacts].Position];
IPredicateExpression selectFilter = new PredicateExpression(
PredicateFactory.CompareValue(TravelAgent.Dal.ContactinfoFieldIndex.Autonumber, ComparisonOperator.Equal, contact.Autonumber));
fileEntry.Passengers.DeleteMulti(selectFilter);
This does remove the contact, but does not update the grid, also when the cancel button is pressed then, the record is removed anyway.
Can somebody give me a complete example of something like this?
_I've been searching for days, but I don't seem to get there. _
Thx,
Bernaert Dominique.