private void ListEditLoad() { errorIndex = -1; blr = new BankListReader(false); bl = blr.Results; for (int i = 0; i < bl.Length; i++) { if (bl[i].ErrorOut) { errorIndex = i; break; } } }
private bool GenerateTables() { topTitle.InnerHtml = String.Format("Banking Summary - <strong>{0}</strong>", DateTime.Now.ToShortDateString()); BankListReader blr; BankChequeReader bcr; try { blr = new BankListReader(); } catch (BankListException ex) { reportAlert.Attributes["class"] = "alert alert-danger"; reportAlert.InnerHtml = String.Format("<strong>ERROR!</strong> The totals for cash/cheque on the following line do not add up correctly!<br/>JobNo: {0}<br/>Booking: {1}<br/>Collection: {2}<br/>School: {3}<br/>Pack: {4}</br>{5}", ex.JobNo, ex.Booking, ex.Collection, ex.School, ex.PackType, "<a href=\"Edit.aspx?mode=list\" class=\"btn btn-danger\"><span class=\"glyphicon glyphicon-wrench\"></span> Fix Errors</a>"); return(false); } catch (DenominationException ex) { reportAlert.Attributes["class"] = "alert alert-danger"; reportAlert.InnerHtml = String.Format("<strong>ERROR!</strong> The {6} denomination does not add up correctly for the following job!<br/>JobNo: {0}<br/>Booking: {1}<br/>Collection: {2}<br/>School: {3}<br/>Pack: {4}</br>{5}", ex.JobNo, ex.Booking, ex.Collection, ex.School, ex.PackType, "<a href=\"Edit.aspx?mode=list\" class=\"btn btn-danger\"><span class=\"glyphicon glyphicon-wrench\"></span> Fix Errors</a>", ex.Denomination); return(false); } try { bcr = new BankChequeReader(); } catch (BankChequeException ex) { reportAlert.Attributes["class"] = "alert alert-danger"; reportAlert.InnerHtml = String.Format("<strong>ERROR!</strong> The cheques on the following line do not add up correctly!<br/>JobNo: {0}<br/>Booking: {1}<br/>Collection: {2}<br/>Index {3}<br/>{4}", ex.JobNo, ex.Booking, ex.Collection, ex.Index, "<a href=\"Edit.aspx?mode=chq\" class=\"btn btn-danger\"><span class=\"glyphicon glyphicon-wrench\"></span> Fix Errors</a>"); return(false); } schoolList.DataSource = blr.SchoolListTable(); schoolList.RowDataBound += SchoolList_RowDataBound; schoolList.DataBind(); BoldRow(schoolList, schoolList.Rows.Count - 1); cashList.DataSource = blr.CashListTable(); cashList.RowDataBound += CashList_RowDataBound; cashList.DataBind(); BoldRow(cashList, cashList.Rows.Count - 1); visaList.DataSource = blr.VisaListTable(); visaList.RowDataBound += VisaList_RowDataBound; visaList.DataBind(); BoldRow(visaList, visaList.Rows.Count - 1); ChqBatch[] cba = bcr.ChequeBatch(bcr.Results); int count = 1; double sumCount = 0; double sumTotal = 0; DataTable sumDt = new DataTable(); sumDt.Columns.Add("Batch", typeof(int)); sumDt.Columns.Add("Number", typeof(double)); sumDt.Columns.Add("Total", typeof(double)); foreach (ChqBatch cb in cba) { DataTable dt = cb.Table; HtmlGenericControl row = new HtmlGenericControl("div"); row.Attributes["class"] = "row"; batchTables.Controls.Add(row); HtmlGenericControl col = new HtmlGenericControl("div"); col.Attributes["class"] = "col-xs-12"; row.Controls.Add(col); col.Controls.Add(new LiteralControl(String.Format("<h2>CHEQUE LIST Batch No. {0}</h2>", count))); GridView gv = new GridView(); gv.GridLines = GridLines.None; gv.ShowFooter = true; gv.CssClass = "table table-striped table-condensed"; gv.DataSource = dt; gv.RowDataBound += Gv_RowDataBound; gv.DataBind(); gv.FooterRow.Cells[0].Text = "<strong>TOTAL</strong>"; gv.FooterRow.Cells[1].Text = String.Format("<strong>{0}</strong>", cb.TotalAmount); gv.FooterRow.Cells[2].Text = String.Format("<strong>{0}</strong>", cb.TotalValue.ToString("C2")); col.Controls.Add(gv); sumDt.Rows.Add(count, cb.TotalAmount, cb.TotalValue); sumCount += cb.TotalAmount; sumTotal += cb.TotalValue; count++; } SummaryTable(sumDt, count, sumCount, sumTotal); return(true); }