mercredi 18 mars 2020

Best/Most efficient vb.net programming technique/function for multiple options within multiple options (nested options)

I have the following scenario. Managing an auction environment. The attendees can spend money in various ways: live auction, silent auction, dessert auction, boutique sales, paddles up, donations, etc... They can also pay in multiple ways (cash, credit card, debit, check) and often use multiple types of payments at once (part in cash and part in credit, etc...). I have created a datatable with the various records of money owed. For instance they may have 2 records of things bought at live auction, 1 at silent auction, 3 items bought at the boutique, extra $100 donation, etc...)

Now at he end of the auction the user brings up a form which shows the amount owed in each category and the grand total owed (on the left side of the screen) and the amount paid with each type of payment and the grand total of the payments.

Now I need to loop through all of this and assign payment to each record.

So lets say a person owes a grand total of $800 and pays $400 in cash, $200 in check, and $200 on credit card (the totals on each side do have to match).

So I will process the cash first, check, second, and credit third. Within the cash I will lop through each record till all cash is gone, then process the next option, etc...

So my question is what is the most efficient technique/function to use?

If then else? Case within case? some other options?

The if statement seems to be a lot of duplicate code within each type of payment.

All advice, suggestions, thoughts, recommendations appreciated!

Aucun commentaire:

Enregistrer un commentaire