1) design page
<table width="90%" cellpadding="10" cellspacing="1" style="padding-top: 10px; margin-top: 10px;
height: auto;">
<%=getWhileLoopData() %>
<tr>
<td bgcolor="#FCEBCF" class="text">
Your Investment Need
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblinvestmentneed" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#FCEBCF" class="text">
Your Current Income
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblincome" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#FCEBCF" class="text">
Monthly Balance After Investments
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblresult" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="lblwarning" runat="server" Style="color: Red; font-weight: bold; float: right;"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
2) code behind
public string getWhileLoopData()
{
string htmlStr = "", cmdstr = "";
double LumpSum;
string LeadId = Convert.ToString(Session["LeadId"]);
if (LeadId != "")
{
cmdstr = @"SELECT CalculatorName, saveEveryMon
FROM GoalPlanning
WHERE (ClientId = '" + Session["LeadId"] + "')";
}
else
{
cmdstr = @"SELECT CalculatorName, saveEveryMon
FROM GoalPlanningForGuest";
}
myConnection.Open();
SqlCommand cmd = new SqlCommand(cmdstr, myConnection);
SqlDataReader reader = cmd.ExecuteReader();
double investmentNeed = 0;
double Result = 0;
while (reader.Read())
{
string calculatorName = reader.GetString(0);
string GoalAmount = reader.GetString(1);
investmentNeed = investmentNeed + Convert.ToDouble(GoalAmount);
htmlStr += "<tr><td width='40%' bgcolor='#FCEBCF' class='text'>" + calculatorName + "</td><td width='60%' bgcolor='#FCEBCF' class='text'>" + GoalAmount + "</td></tr>";
}
myConnection.Close();
balanceDetails(investmentNeed, LeadId);
return htmlStr;
}
<table width="90%" cellpadding="10" cellspacing="1" style="padding-top: 10px; margin-top: 10px;
height: auto;">
<%=getWhileLoopData() %>
<tr>
<td bgcolor="#FCEBCF" class="text">
Your Investment Need
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblinvestmentneed" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#FCEBCF" class="text">
Your Current Income
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblincome" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td bgcolor="#FCEBCF" class="text">
Monthly Balance After Investments
</td>
<td bgcolor="#FCEBCF" class="text">
<asp:Label ID="lblresult" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Label ID="lblwarning" runat="server" Style="color: Red; font-weight: bold; float: right;"></asp:Label>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
</table>
2) code behind
public string getWhileLoopData()
{
string htmlStr = "", cmdstr = "";
double LumpSum;
string LeadId = Convert.ToString(Session["LeadId"]);
if (LeadId != "")
{
cmdstr = @"SELECT CalculatorName, saveEveryMon
FROM GoalPlanning
WHERE (ClientId = '" + Session["LeadId"] + "')";
}
else
{
cmdstr = @"SELECT CalculatorName, saveEveryMon
FROM GoalPlanningForGuest";
}
myConnection.Open();
SqlCommand cmd = new SqlCommand(cmdstr, myConnection);
SqlDataReader reader = cmd.ExecuteReader();
double investmentNeed = 0;
double Result = 0;
while (reader.Read())
{
string calculatorName = reader.GetString(0);
string GoalAmount = reader.GetString(1);
investmentNeed = investmentNeed + Convert.ToDouble(GoalAmount);
htmlStr += "<tr><td width='40%' bgcolor='#FCEBCF' class='text'>" + calculatorName + "</td><td width='60%' bgcolor='#FCEBCF' class='text'>" + GoalAmount + "</td></tr>";
}
myConnection.Close();
balanceDetails(investmentNeed, LeadId);
return htmlStr;
}
No comments:
Post a Comment