public override DocumentPage GetPage(int pageNumber) { DocumentPage page = null; List<object> itemsSource = new List<object>(); ICollectionView viewSource = CollectionViewSource.GetDefaultView(_documentSource.ItemsSource); if (viewSource != null) { BillingReportViewModel temp = new BillingReportViewModel(); temp.ItemNo = "====="; temp.Date = "===="; temp.Description = "==========="; temp.BillingType = "==========="; temp.GeneralAccountFunds = "==========="; temp.TrustAccountFunds = "==============="; temp.TrustAccountFunds = "========="; temp.CheckNo = "========="; itemsSource.Add(temp); foreach (object item in viewSource) itemsSource.Add(item); } if (itemsSource != null) { int rowIndex = 1; int startPos = pageNumber * _rowsPerPage; int endPos = startPos + _rowsPerPage; //Create a new grid Grid tableGrid = CreateTable(true) as Grid; for (int index = startPos; index < endPos && index < itemsSource.Count; index++) { Console.WriteLine("Adding: " + index); if (rowIndex > 0) { object item = itemsSource[index]; int columnIndex = 0; if (_documentSource.Columns != null) { foreach (DataGridColumn column in _documentSource.Columns) { if (column.Visibility == Visibility.Visible) { AddTableCell(tableGrid, column, item, columnIndex, rowIndex); columnIndex++; } } } if (this.AlternatingRowBorderStyle != null && rowIndex % 2 == 0) { Border alernatingRowBorder = new Border(); alernatingRowBorder.Style = this.AlternatingRowBorderStyle; alernatingRowBorder.SetValue(Grid.RowProperty, rowIndex); alernatingRowBorder.SetValue(Grid.ColumnSpanProperty, columnIndex); alernatingRowBorder.SetValue(Grid.ZIndexProperty, -1); tableGrid.Children.Add(alernatingRowBorder); } } rowIndex++; } page = ConstructPage(tableGrid, pageNumber); } return page; }
internal static ObservableCollection<BillingReportViewModel> GetAllBillingTransactionDetails(string sql) { ObservableCollection<BillingReportViewModel> reportItems = new ObservableCollection<BillingReportViewModel>(); try { var result = DBHelper.GetSelectDataSet(sql); if (result == null) return null; float genAccountGrandTotal = 0; float trustAccountGrandTotal = 0; for (int rowIndex = 0; rowIndex < result.Tables[0].Rows.Count; rowIndex++) { BillingReportViewModel newTransaction = new BillingReportViewModel() { ItemNo = (rowIndex + 1).ToString(), //ItemNo = result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_ID].ToString(), Date = DateTime.Parse(result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_DATE].ToString()).ToShortDateString(), Description = result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_DESCRIPTION].ToString(), BillingType = result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_BILLING_TYPE].ToString(), GeneralAccountFunds = float.Parse(result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_GENERAL_FUND].ToString()).ToString("0.00"), //GeneralAccountFunds = result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_GENERAL_FUND].ToString(), TrustAccountFunds = float.Parse(result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_TRUST_FUND].ToString()).ToString("0.00"), //TrustAccountFunds = result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_TRUST_FUND].ToString(), CheckNo = result.Tables[0].Rows[rowIndex][Constants.TRANSACTION_CHECK_NO].ToString(), }; genAccountGrandTotal += float.Parse(newTransaction.GeneralAccountFunds); trustAccountGrandTotal += float.Parse(newTransaction.TrustAccountFunds); reportItems.Add(newTransaction); } BillingReportViewModel emptyRow = new BillingReportViewModel(); reportItems.Add(emptyRow); emptyRow = new BillingReportViewModel(); emptyRow.BillingType = "-----------------"; emptyRow.GeneralAccountFunds = "-----------------"; emptyRow.TrustAccountFunds = "-----------------"; reportItems.Add(emptyRow); BillingReportViewModel footer = new BillingReportViewModel(); footer.BillingType = "Grand Total:"; footer.GeneralAccountFunds = genAccountGrandTotal.ToString("0.00"); footer.TrustAccountFunds = trustAccountGrandTotal.ToString("0.00"); reportItems.Add(footer); emptyRow = new BillingReportViewModel(); emptyRow.BillingType = "-----------------"; emptyRow.GeneralAccountFunds = "-----------------"; emptyRow.TrustAccountFunds = "-----------------"; reportItems.Add(emptyRow); } catch (Exception ex) { throw ex; } return reportItems; }