Академический Документы
Профессиональный Документы
Культура Документы
Try a Search
(wiki?23736,AttractionTrnBC,)
Once we did it, a Business Component data type named Attraction is automatically created
in the KB. Then, we will be able to define in any object a variable based on the new data
type.
Let's suppose we define the &Attraction variable based on the Attraction data type in a
certain object (for example in a web panel, or other object) and we codify the following
basic samples in the section of the object that corresponds (events, source, etc.):
Sample a - Insert
To insert an Attraction, the code is:
https://wiki.genexus.com/commwiki/servlet/wiki?2278,Business+Component+samples, 1/6
31/5/2018 Business Component samples
Notes:
The CategoryId was ommited, but that foreing key allows nulls, so the record will be
inserted without fails.
The AttractionId has its Autonumber Property = True, so it will be autonumbered by
the database.
A er executing the Save() method, &Attraction.Mode() is set to Update ("UPD") and
all attributes are instanciated.
Sample b - Update
To update the Attraction (for example, its category), the code is:
&Attraction.Load(1)
&Attraction.CategoryId = 1 //Monument
&Customer.Save()
Commit
Sample c - Delete
To delete an Attraction, the code is:
&Attraction.Load(1)
&Attraction.Delete()
Commit
https://wiki.genexus.com/commwiki/servlet/wiki?2278,Business+Component+samples, 2/6
31/5/2018 Business Component samples
&Attraction.Load(1)
If &Attraction.Fail()
&Attraction.AttractionName = "Eiffel Tower"
&Attraction.CountryId = 2 //France
&Attraction.CityId = 1 //Paris
&Attraction.CategoryId = 1 //Monument
Else
&Attraction.CategoryId = 1 //Monument
Endif
&Attraction.Save()
Commit
From now on, let's asumme the Attraction transaction has 2 levels as the following image
shows:
(wiki?
23767,Attraction2LevelsTrn,)
The second level allows to store the different possible tickets to visit each attraction (with
different peculiarities, prices, etc.).
The transaction Business Component property was set with True value, so GeneXus has
created the Attraction data type associated with the first level transaction. And since it is a
2-level transaction, GeneXus also has created the Attraction.Ticket data type associated
with the lines (second level), which in this example corresponds to the attraction’s tickets.
&Attraction.AttractionId = 100
&Attraction.AttractionName = "Louvre Museum"
&Attraction.CategoryId = 2
&Attraction.CountryId = 2
&Attraction.CityId = 1
&Ticket.AttractionTicketId=1
&Ticket.AttractionTicketDescription="Without tour guide"
&Ticket.AttractionTicketPrice=100
&Attraction.Ticket.Add(&Ticket)
&Ticket = new()
&Ticket.AttractionTicketId=2
&Ticket.AttractionTicketDescription="With tour guide"
&Ticket.AttractionTicketPrice=150
&Atraction.Ticket.Add(&Ticket)
&Attraction.Save()
If &Attraction.success()
commit
else
rollback
endif
&Attraction.load(100)
&Attraction.Ticket.Item(1).AttractionTicketPrice = 130
&Attraction.Save()
Commit
2. To update the price of the ticket with description="Without tour guide", the code is:
&Attraction.load(100)
For &Ticket in &Attraction.Ticket
If &Ticket.AttractionTicketDescription="Without tour guide"
&Ticket.AttractionTicketPrice=110
Endif
Endfor
&Attraction.Save()
commit
&Attraction.load(15)
&Attraction.Ticket.Remove(1)
&Attraction.Save()
Commit
http://localhost:8080/basename/servlet/invoce_bc_ws?wsdl
http://localhost/basename/invoce_bc.aspx?wsdl
Backlinks
Business Component (wiki?5846,Business+Component,)
Business Component Samples (Xpz files) (wiki?
11309,Business+Component+Samples+%28Xpz+files%29,)
Forward links
See all
Business Component (wiki?5846,Business+Component,)
Business Component property (wiki?9548,Business+Component+property,)
AttractionTrnBC (wiki?23736,AttractionTrnBC,)
More from mshuster
See all
SRC Messages (wiki?38589,SRC+Messages,)
Picture Properties Group (wiki?6800,Picture+Properties%C2%A0Group,)
Date format property (for Date/DateTime ... (wiki?
39441,Date+format+property+%28for+Date%2FDateTime+attributes%2Fvariables%29,)
https://wiki.genexus.com/commwiki/servlet/wiki?2278,Business+Component+samples, 5/6
31/5/2018 Business Component samples
J BY JLARROSA
— CREATED: 17 APRIL 2006 10:20 AM - LAST UPDATE: 5 AUGUST 2016 08:28 AM BY MSHUSTER
https://wiki.genexus.com/commwiki/servlet/wiki?2278,Business+Component+samples, 6/6