Fixed some crash bugs related to the front page renderer recieving empty (null) table records. Twaeked both renderers' formatting.

This commit is contained in:
2017-09-26 13:59:50 -05:00
parent 945324f418
commit db555d80fe
3 changed files with 109 additions and 51 deletions
+25 -8
View File
@@ -190,7 +190,6 @@ namespace AdvertsingProfitControl
var adSpecialIndex = -1;
for (var i = 0; i < 25; i++)
{
var skipCheck = false;
if (i < projections.Count)
{
if (projections[i].FkAdSpecialId != null)
@@ -203,7 +202,6 @@ namespace AdvertsingProfitControl
writer.RenderBeginTag(HtmlTextWriterTag.Td);
writer.Write(projections[i].AdSpecial.Name);
writer.RenderEndTag(); //ad special cell
skipCheck = true;
SelectCostAnalysisCell(i, ref writer, actualA, actualB, departmentRecord, comments);
writer.RenderEndTag(); //end ad special row
}
@@ -276,7 +274,7 @@ namespace AdvertsingProfitControl
//Pad
AppendPaddingRow(ref writer);
}
if(!skipCheck) SelectCostAnalysisCell(adSpecialIndex != -1 ? i + 1 : i, ref writer, actualA, actualB, departmentRecord, comments);
SelectCostAnalysisCell(adSpecialIndex != -1 ? i + 1 : i, ref writer, actualA, actualB, departmentRecord, comments);
writer.RenderEndTag();//tr
}
//Create the totals row
@@ -312,7 +310,7 @@ namespace AdvertsingProfitControl
writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-right:double");
writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
writer.RenderBeginTag(HtmlTextWriterTag.Td);//actual sales B (total profit return)
writer.Write("(B) " + $"{actualB:N2}");
writer.Write("(B) " + $"{actualB:N2}");
writer.RenderEndTag();//end actual sales A (total profit return)
writer.RenderEndTag();//end totals row
//end totals row
@@ -402,25 +400,44 @@ namespace AdvertsingProfitControl
private void SelectCostAnalysisCell(int rowIndex, ref HtmlTextWriter writer, decimal? actualA, decimal? actualB, WeeklySale departmentRecord, Note comments)
{
if (actualA == null)
{
actualA = 0;
}
if (actualB == null)
{
actualB = 0;
}
if (comments == null)
{
comments = new Note { Remark = string.Empty };
}
if (departmentRecord == null)
{
departmentRecord = new WeeklySale {TotalSales = 0};
}
switch (rowIndex)
{
case 0:
RenderCostsAnalysisCell(CostAnalysisCells.SalesProduced, ref writer, actualA, "3");
break;
case 3:
if (departmentRecord != null)
RenderCostsAnalysisCell(CostAnalysisCells.RemainingSales, ref writer, departmentRecord.TotalSales - actualA, "4");
RenderCostsAnalysisCell(CostAnalysisCells.RemainingSales, ref writer, departmentRecord.TotalSales - actualA, "4");
break;
case 7:
RenderCostsAnalysisCell(CostAnalysisCells.ProfitReturnFromAdItems, ref writer, actualB, "3");
break;
case 10:
//get cross profit return
var s = (decimal) 0.3;
var s = (decimal) 0.3; //0.3 is the shrink TODO:Change the shrink into a variable.
RenderCostsAnalysisCell(CostAnalysisCells.ProfitReturnFromRemainingSales, ref writer, s * (departmentRecord.TotalSales - actualA), "5");
break;
case 15:
var x = (decimal) 0.3 * (departmentRecord.TotalSales - actualA);
var x = (decimal) 0.3 * (departmentRecord.TotalSales - actualA); //0.3 is the shrink
RenderCostsAnalysisCell(CostAnalysisCells.TotalProfitReturn, ref writer, x + actualB, "4");
break;
case 19: