I am working on a prices page with ASP.NET backed with C#, and am having problems getting my math to come out correctly. the output is:
<table style="border:thin solid #808080; text-align:center; vertical-align:middle;">
<tbody><tr>
<td>
<span id="MainContent_Label94" style="font-size:13pt;font-weight:bold;width: 135px;height: 21px;">Prices</span>
</td>
<td style="height: 21px;border-style: none solid solid solid; border-width: medium thin medium thin; border-color: #000000; width:125px;">
<span id="MainContent_Label44">Walls</span>
</td>
<td "215"="" style="border-style: none solid solid solid; border-width: medium thin medium thin; border-color: #000000; width:125px;">
<span id="MainContent_Label45">Roof</span>
</td>
<td "215"="" style="border-style: none solid solid solid; border-width: medium thin medium thin; border-color: #000000; width:125px;">
<span id="MainContent_Label46">Floor</span>
</td>
<td "215"="" style="border-style: none solid solid solid; border-width: medium thin medium thin; border-color: #000000; width:125px;">
<span id="MainContent_Label47">Hardware & Misc</span>
</td>
<td "215"="" style="border-style: none solid solid solid; border-width: medium thin medium thin; border-color: #000000; width:125px;">
<span id="MainContent_Label48">Total</span>
</td>
</tr>
<tr class="rowWhite">
<td "213"="" style="border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium;
border-bottom-width: thin; border-top-style: solid; border-top-width: thin;background-color: #EFEEEF;">
<span id="MainContent_Label35">Material</span>
</td>
<td class="white" style="border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblWallsMaterial">$101,998.00</span>
</td>
<td class="white" style="border-width: thin; border-color: #000000;border-right-style: solid;">
<span id="MainContent_lblRoofMaterial">$58,031.00</span>
</td>
<td class="white" style="border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblFloorMaterial">$0.00</span>
</td>
<td class="white" style="border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblHardwareMaterial">$3,082.00</span>
</td>
<td class="white" style="">
<span id="MainContent_lblTotalMaterial" style="font-weight:normal;">$163,111.00</span>
</td>
</tr>
<tr class="rowBlue">
<td "216"="" style="border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium; border-bottom-width: thin;background-color: #EFEEEF;">
<span id="MainContent_Label36">Labor</span>
</td>
<td class="blue" dir="ltr" style="height:23px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblWallsLabor">$10,328.00</span>
</td>
<td class="blue" style="height:23px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblRoofLabor">$12,592.00</span>
</td>
<td class="blue" style="height:23px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblFloorLabor">$0.00</span>
</td>
<td class="blue" style="height:23px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblHardwareLabor"></span>
</td>
<td class="blue" style="height:23px">
<span id="MainContent_lblTotalLabor" style="font-weight:normal;">$22,920.00</span>
</td>
</tr>
<tr class="rowWhite">
<td "213"="" style="border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium; border-bottom-width: thin;background-color: #EFEEEF;">
<span id="MainContent_Label37">Overhead</span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblWallsOverhead">$10,328.00</span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblRoofOverhead">$12,592.00</span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblFloorOverhead">$0.00</span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblHardwareOverhead"></span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000; border-bottom-style: solid;">
<span id="MainContent_lblTotalOverhead" style="font-weight:normal;">$22,920.00</span>
</td>
</tr>
<tr class="rowBlue">
<td style="width: 135px;height: 21px;border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium; border-bottom-width: thin;background-color: #EFEEEF;">
<span id="MainContent_Label38">Mfg. Cost</span>
</td>
<td class="blue" style="height: 21px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblWallsMfgCost">$122,654.00</span>
</td>
<td class="blue" style="height: 21px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblRoofMfgCost">$83,215.00</span>
</td>
<td class="blue" style="height: 21px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblFloorMfgCost">$0.00</span>
</td>
<td class="blue" style="height: 21px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblHardwareMfgCost">$3,082.00</span>
</td>
<td class="blue" style="height: 21px;">
<span id="MainContent_lblTotalMfgCost" style="font-weight:normal;">$208,951.00</span>
</td>
</tr>
<tr class="rowWhite">
<td "216"="" style="border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium; border-bottom-width: thin;background-color: #EFEEEF;">
<span id="MainContent_Label39">Freight</span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000;height:23px; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblWallsFreight">$14,838.00</span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000;height:23px; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblRoofFreight">$14,131.00</span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000;height:23px; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblFloorFreight">$0.00</span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000;height:23px; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblHardwareFreight"></span>
</td>
<td class="white" style="border-width: thin thin medium thin; border-color: #000000;height:23px; border-bottom-style: solid;">
<span id="MainContent_lblTotalFreight" style="font-weight:normal;">$28,969.00</span>
</td>
</tr>
<tr class="rowBlue">
<td "214"="" style="border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium; border-bottom-width: thin;background-color: #EFEEEF;">
<span id="MainContent_Label41">Mfg. and Frt.</span>
</td>
<td class="blue" style="height: 23px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblWallsMfgFreight">$137,492.00</span>
</td>
<td class="blue" style="height: 23px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblRoofMfgFreight">$97,346.00</span>
</td>
<td class="blue" style="height: 23px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblFloorMfgFreight">$0.00</span>
</td>
<td class="blue" style="height: 23px;border-width: thin; border-color: #000000; border-right-style: solid;">
<span id="MainContent_lblHardwareMfgFreight">$3,082.00</span>
</td>
<td class="blue" style="height: 23px;">
<span id="MainContent_lblTotalMfgFreight" style="font-weight:normal;">$237,920.00</span>
</td>
</tr>
<tr class="rowWhite">
<td "213"="" style="border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium; border-bottom-width: thin;background-color: #EFEEEF;">
<span id="MainContent_Label40">Margin</span>
</td>
<td class="white" style="border-color: #000000; border-bottom-style: double; border-right-style: solid; border-right-width: thin; border-bottom-width: thick;">
<span id="MainContent_lblWallsMargin1">$43,418.53</span>
</td>
<td class="white" style="border-color: #000000; border-bottom-style: double; border-right-style: solid; border-right-width: thin; border-bottom-width: thick;">
<span id="MainContent_lblRoofMargin1">$-98,125.27</span>
</td>
<td class="white" style="border-color: #000000; border-bottom-style: double; border-right-style: solid; border-right-width: thin; border-bottom-width: thick;">
<span id="MainContent_lblFloorMargin1"></span>
</td>
<td class="white" style="border-color: #000000; border-bottom-style: double; border-right-style: solid; border-right-width: thin; border-bottom-width: thick;">
<span id="MainContent_lblHardwareMargin1">$-3,106.67</span>
</td>
<td class="white" style="border-width: thin thin thick thick; border-color: #000000; border-bottom-style: double; border-right-style: none;">
<span id="MainContent_lblTotalMargin" style="font-weight:normal;">$-57,813.41</span>
</td>
</tr>
<tr class="rowBlue">
<td "214"="" style="border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium; border-bottom-width: thin; background-color: #EFEEEF;">
<span id="MainContent_Label42">Price</span>
</td>
<td "215"="" style="border-width: thin; border-right-style: solid;">
<span id="MainContent_lblWallsPrice" style="font-weight:bold;"></span>
</td>
<td "215"="" style="border-right: thin solid #000000; border-left-color: #000000; border-left-width: thin; border-top-color: #000000; border-top-width: thin; border-bottom-color: #000000; border-bottom-width: thin;">
<span id="MainContent_lblRoofPrice" style="font-weight:bold;"></span>
</td>
<td "215"="" style="border-right: thin solid #000000; border-left-color: #000000; border-left-width: thin; border-top-color: #000000; border-top-width: thin; border-bottom-color: #000000; border-bottom-width: thin;">
<span id="MainContent_lblFloorPrice" style="font-weight:bold;"></span>
</td>
<td "215"="" style="border-right: thin solid #000000; border-left-color: #000000; border-left-width: thin; border-top-color: #000000; border-top-width: thin; border-bottom-color: #000000; border-bottom-width: thin;">
<span id="MainContent_lblHardwarePrice" style="font-weight:bold;"></span>
</td>
<td "215"="">
<span id="MainContent_lblTotalPrice" style="font-weight:bold;"></span>
</td>
</tr>
<tr class="rowWhite">
<td "213"="" style="border-right-style: solid; border-color: #000000; border-bottom-style: solid; border-right-width: medium; border-bottom-width: thin;background-color: #EFEEEF;">
<span id="MainContent_Label43">LF</span>
</td>
<td class="white" style="border-width: thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblWallsLF"></span>
</td>
<td class="white" style="border-width: thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblRoofLF"></span>
</td>
<td class="white" style="border-width: thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblFloorLF"></span>
</td>
<td class="white" style="border-width: thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblHardwareLF"></span>
</td>
<td class="white" style="border-width: thin; border-color: #000000; border-bottom-style: solid; border-right-style: solid;">
<span id="MainContent_lblTotalLF" style="font-weight:bold;"></span>
</td>
</tr>
</tbody></table>
The "mgt & frt" line is used with a Margin number, in this case 24, to produce a number that is supposed to be a profit margin, i think. the problem though is that while the Walls column is acurate, the others are coming up WAY off and i cannot find why they arent parsing correctly. is there something y'all can find that i am screwing up?
decimal a = 0.01m;
var cmdWallMargin = new SqlCommand("Select cast(WallMargin as decimal) from estimate WHERE ProjectNumber = '" + ddlJobNumber.SelectedValue + "' and Estimate = '" + ddlEstimate.SelectedValue + "'", Class_Connection.cnn);
Decimal wallMargin = (decimal)cmdWallMargin.ExecuteScalar();
Decimal WallsMargin = wallMfgFreightCost / (((100 - (wallMargin)) * a)) - wallMfgFreightCost;
if (WallsMargin != 0)
{
lblWallsMargin1.Text = "$" + WallsMargin.ToString("###,###,###.00");
}
var cmdroofMargin = new SqlCommand("Select cast(roofMargin as decimal) from estimate WHERE ProjectNumber = '" + ddlJobNumber.SelectedValue + "' and Estimate = '" + ddlEstimate.SelectedValue + "'", Class_Connection.cnn);
Decimal roofMargin = (decimal)cmdRoofLabor.ExecuteScalar();
Decimal RoofMargin = roofMfgFreightCost / (((100 - (roofMargin)) * a)) - roofMfgFreightCost;
if (RoofMargin != 0)
{
lblRoofMargin1.Text = "$" + RoofMargin.ToString("###,###,###.00");
}
var cmdfloorMargin = new SqlCommand("Select cast(floorMargin as decimal) from estimate WHERE ProjectNumber = '" + ddlJobNumber.SelectedValue + "' and Estimate = '" + ddlEstimate.SelectedValue + "'", Class_Connection.cnn);
Decimal floorMargin = (decimal)cmdRoofLabor.ExecuteScalar();
Decimal FloorMargin = floorMfgFreightCost / (((100 - (floorMargin)) * a)) - floorMfgFreightCost;
if (FloorMargin != 0)
{
lblFloorMargin1.Text = "$" + FloorMargin.ToString("###,###,###.00");
}
var cmdmiscMargin = new SqlCommand("Select cast(miscMargin as decimal) from estimate WHERE ProjectNumber = '" + ddlJobNumber.SelectedValue + "' and Estimate = '" + ddlEstimate.SelectedValue + "'", Class_Connection.cnn);
Decimal miscMargin = (decimal)cmdRoofLabor.ExecuteScalar();
Decimal HardwareMargin = hardwareMfgFreightCost / (((100 - (miscMargin)) * a)) - hardwareMfgFreightCost;
if (HardwareMargin != 0)
{
lblHardwareMargin1.Text = "$" + HardwareMargin.ToString("###,###,###.00");
}
Decimal TotalMargin = WallsMargin + RoofMargin + FloorMargin + HardwareMargin;
if (TotalMargin != 0)
{
lblTotalMargin.Text = "$" + TotalMargin.ToString("###,###,###.00");
}
Aucun commentaire:
Enregistrer un commentaire