Hi , I need help in Calculation logic

We are developing a hotel application where user selects a room type and selects the number of rooms with those details rate has to be calculated. For example if number of room is 1 then it should be 300 and this 300 comes from database if number of room is 2 then it should be 600 . i have tried using switch case but couldnt load .I have attached the OML also 

Hi Ummel,

Without looking at the Module (no time, sorry), but what exactly is your problem? If you have the price per room and the numer of rooms then just multiply?

Kilian Hekhuis wrote:

Hi Ummel,

Without looking at the Module (no time, sorry), but what exactly is your problem? If you have the price per room and the numer of rooms then just multiply?


Hi kilian ,

Yeah but number of room is a from user side not in database and price is from database

Hello Ummul Fazaria,

Based on your code, you do not need a Switch statement.  In your Onquantity2Change, I would recommend:

  1. Use an aggregate to select the HotelRate based on the type the user selected in the drop down
  2. Take your aggregate's Rate and multiply by quantity (e.g. GetHotelRatesById.List.Current.Rate * Quantity)
    1. Set the total amount to his and AJAX refresh

Does this make sense and why it works?

Craig St.Jean wrote:

Hello Ummul Fazaria,

Based on your code, you do not need a Switch statement.  In your Onquantity2Change, I would recommend:

  1. Use an aggregate to select the HotelRate based on the type the user selected in the drop down
  2. Take your aggregate's Rate and multiply by quantity (e.g. GetHotelRatesById.List.Current.Rate * Quantity)
    1. Set the total amount to his and AJAX refresh

Does this make sense and why it works?

Hi Criag 

I tried but i didnt get the output 

Thanks



Can you show a screenshot or an updated OML of what you tried?  If you think through the logic that you need, can you tell what is missing?

Solution

Ummul Fazaria wrote:

We are developing a hotel application where user selects a room type and selects the number of rooms with those details rate has to be calculated. For example if number of room is 1 then it should be 300 and this 300 comes from database if number of room is 2 then it should be 600 . i have tried using switch case but couldnt load .I have attached the OML also 

Hi Ummul, you dont need the switch, you need to make the math calculation based on you choices, check the oml and you can copy or adapt the ways that fit you better

and any changes on this 2 inputs would trigger the onChange and recalculate

Hope I could help you.

Solution

Carlos Lessa wrote:

Ummul Fazaria wrote:

We are developing a hotel application where user selects a room type and selects the number of rooms with those details rate has to be calculated. For example if number of room is 1 then it should be 300 and this 300 comes from database if number of room is 2 then it should be 600 . i have tried using switch case but couldnt load .I have attached the OML also 

Hi Ummul, you dont need the switch, you need to make the math calculation based on you choices, check the oml and you can copy or adapt the ways that fit you better

and any changes on this 2 inputs would trigger the onChange and recalculate

Hope I could help you.

Hi Carlos ,

It worked and thankyou for helping me with the logic


Ummul Fazaria wrote:

Carlos Lessa wrote:

Ummul Fazaria wrote:

We are developing a hotel application where user selects a room type and selects the number of rooms with those details rate has to be calculated. For example if number of room is 1 then it should be 300 and this 300 comes from database if number of room is 2 then it should be 600 . i have tried using switch case but couldnt load .I have attached the OML also 

Hi Ummul, you dont need the switch, you need to make the math calculation based on you choices, check the oml and you can copy or adapt the ways that fit you better

and any changes on this 2 inputs would trigger the onChange and recalculate

Hope I could help you.

Hi Carlos ,

It worked and thankyou for helping me with the logic


Glad I could help you, good code