I am retrieving records of different categories that make a salary package & the corresponding amounts from SQL Server. Egs. of the different categories are HRA, CCA etc. which fall under the 'E' category (EARNINGS) & PF, PT, ITDS etc. which fall under the 'D' category (DEDUCTIONS). This is what I have done:
<%
iTotalE=0
iTotalD=0
Do Until(objRS3.EOF)
For iCol1=8 To objRS3.Fields.Count-1
ReDim iAmountE(iCol1)
ReDim iAmountD(iCol1)
If(Right(objRS3(iCol1).Name,1)="E"
Then
iAmountE(iCol1)=Round(objRS3(iCol1))
Response.Write("<td valign=top>" & iAmountE(iCol1) & ".00<br>"
iTotalE=iAmountE(iCol1)+iTotalE
ElseIf(Right(objRS3(iCol1).Name,1)="D"
Then
iAmountD(iCol1)=Round(objRS3(iCol1))
Response.Write(iAmountD(iCol1) & ".00</td>"
iTotalD=iAmountD(iCol1)+iTotalD
End If
Next
Response.Write("<td>" & iTotalE & ".00<br>" & iTotalD & ".00</td>"
Response.Write("<th>" & iTotalE-iTotalD & ".00</th>"
objRS3.MoveNext
iTotalE=0
iTotalD=0
Loop
%>
The reason why I am using For....Next loop is because the alias column names are generated dynamically. To get the exact picture of how the records are displayed, please visit iTotalE & iTotalD generates the total of earnings & deductions respectively for each employee, say, iTotalE=HRA+CRE.. of each employee where as iTotalD=PF+PT
My question is how do I add up the, say, HRA of all employees, CRE of all employees, PF of all employees etc.? With respect to the above URL, how do I get the total 258786.00 under Basic (which is the total of Basic of all employees), 13500.00 under AD.SAL etc. Please note that in the <td>s where there are 2 categories shown, the categories which is at the top belong to the 'E' category where as those at the bottom belong to the 'D' category.
Thanks,
Arpan
<%
iTotalE=0
iTotalD=0
Do Until(objRS3.EOF)
For iCol1=8 To objRS3.Fields.Count-1
ReDim iAmountE(iCol1)
ReDim iAmountD(iCol1)
If(Right(objRS3(iCol1).Name,1)="E"
iAmountE(iCol1)=Round(objRS3(iCol1))
Response.Write("<td valign=top>" & iAmountE(iCol1) & ".00<br>"
iTotalE=iAmountE(iCol1)+iTotalE
ElseIf(Right(objRS3(iCol1).Name,1)="D"
iAmountD(iCol1)=Round(objRS3(iCol1))
Response.Write(iAmountD(iCol1) & ".00</td>"
iTotalD=iAmountD(iCol1)+iTotalD
End If
Next
Response.Write("<td>" & iTotalE & ".00<br>" & iTotalD & ".00</td>"
Response.Write("<th>" & iTotalE-iTotalD & ".00</th>"
objRS3.MoveNext
iTotalE=0
iTotalD=0
Loop
%>
The reason why I am using For....Next loop is because the alias column names are generated dynamically. To get the exact picture of how the records are displayed, please visit iTotalE & iTotalD generates the total of earnings & deductions respectively for each employee, say, iTotalE=HRA+CRE.. of each employee where as iTotalD=PF+PT
My question is how do I add up the, say, HRA of all employees, CRE of all employees, PF of all employees etc.? With respect to the above URL, how do I get the total 258786.00 under Basic (which is the total of Basic of all employees), 13500.00 under AD.SAL etc. Please note that in the <td>s where there are 2 categories shown, the categories which is at the top belong to the 'E' category where as those at the bottom belong to the 'D' category.
Thanks,
Arpan