Hi all
I have a quite complex problem and I don't exactly know how to "step into it" so I really need your help.
Little briefing: lets say I go on a business trip. My company gives me up to 2 advances in different currencys (but there also could be no advance) i.e. some amount in EUR and another in USD. Now I go on a trip and there are usually (but not necessary) some expenses-there could be more expenses but never in more than 2 different currencies.
I have 6 variables:
-advance = dt.Rows(i).Item(4).ToString (this is the money I get in advance)
-currency = dt.Rows(i).Item(5).ToString (this is the currency belonging to "advance")
-advance1 = dt.Rows(i).Item(14).ToString (this is also money I get in advance)
-currency1 = dt.Rows(i).Item(15).ToString (is currency belonging to "advance1" and is different from "currency")
-expense = dt.Rows(i).Item(23).ToString (this is the money I've spent on a trip)
-currency2 = dt.Rows(i).Item(24).ToString (this is the currency belonging the money I've spent)
Now I want to know:
-how much money did I spent (sum of all expenses but for every currency sepparated) - have this done!
-if the "advance" if higher than "expense", I must know how much money I need to return, If it is smaller, I must know how much I need to get back
-if there is no match found between "currency"/"currency1" and "currency2", then I should return "advance"/advance1" and receive "expense"
-the program sould compare "currency" and "currency1" with "currency2" and if match is found, it should
SUM the belonging "advance", "advance1" and "expense".
If i.e. "advance" is "100", "currency" is "EUR", "expense" is "50" and "currency2" is "EUR", the program should SUM "100 - 50" & "currency" and result should be "50 EUR" to return.
This is my foundation so far:
'if match between "advance" currency and "expense" currency is found, then all "expense" with the same currency are put into "AryCurrencyValue"
Dim currencyPosition As Double
For Each currency In Ary
If Not currency = "" Then
For i = 0 To dt.Rows.Count - 1
If dt.Rows(i).Item(24).ToString.Replace(" ", "") = currency Then
AryCurrencyValue(currencyPosition) = CDbl(AryCurrencyValue(currencyPosition)) + CDbl(dt.Rows(i).Item(23).ToString)
End If
Next
currencyPosition = currencyPosition + 1
End If
Next
'every record in "AryCurrencyValue" (all the expense) with the same currency has to we printed
Dim q As Integer = y + 20
Dim position As Double
For Each position In AryCurrencyValue
If Not position = 0 Then
'MsgBox(position)
e.Graphics.DrawString(position, fnt, Brushes.Black, 370, q)
e.Graphics.DrawLine(Pens.Black, 365, q + 20, 820, q + 20)
q = q + 25
End If
Next
'every record (currency) in "Ary" is printed
q = y + 20
For Each currency In Ary
e.Graphics.DrawString(currency, fnt, Brushes.Black, 460, q)
q = q + 25
Next
'if "advance" has some value, print it out along with it's belonging currency
If Not advance = Nothing Then
e.Graphics.DrawString("ADVANCE", fnt1, Brushes.Black, 200, w + 40)
e.Graphics.DrawString(advance & " " & currency, fnt, Brushes.Black, 420, w + 40)
End If
'if "advance1" has some value, print it out along with it's belonging currency
If Not advance1 = Nothing Then
e.Graphics.DrawString("and", fnt, Brushes.Black, 390, w + 65)
e.Graphics.DrawString(advance1 & " " & currency1, fnt, Brushes.Black, 420, w + 65)
End If
Every suggestion is more than welcome.