public override DocumentPage GetPage(int pageNumber) { DocumentPage page = null; List <object> itemsSource = new List <object>(); ICollectionView viewSource = CollectionViewSource.GetDefaultView(_documentSource.ItemsSource); if (viewSource != null) { AllClientBillingReportViewModel temp = new AllClientBillingReportViewModel(); temp.Name = "=================="; temp.FileNo = "========"; temp.GenAccountTotal = "==========="; temp.TrustAccountTotal = "==========="; temp.AssignedAttorney = "============="; 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<AllClientBillingReportViewModel> GetAllClientBillingTransactionDetails(string sql) { ObservableCollection<AllClientBillingReportViewModel> reportItems = new ObservableCollection<AllClientBillingReportViewModel>(); try { float genAccountGrandTotal = 0; float trustAccountGrandTotal = 0; var allClientDetails = DBHelper.GetSelectDataSet(sql); if (allClientDetails == null || allClientDetails.Tables.Count == 0 || allClientDetails.Tables[0].Rows.Count == 0) return null; var allTransactionTotal = DBHelper.GetSelectDataSet(Constants.ALL_CLIENTS_TRANSACTION_TOTAL_QUERY); if (allTransactionTotal == null || allTransactionTotal.Tables.Count == 0 || allTransactionTotal.Tables[0].Rows.Count == 0) return null; for (int rowIndex = 0; rowIndex < allClientDetails.Tables[0].Rows.Count; rowIndex++) { AllClientBillingReportViewModel newTransaction = new AllClientBillingReportViewModel() { Name = allClientDetails.Tables[0].Rows[rowIndex][Constants.NAME].ToString(), FileNo = allClientDetails.Tables[0].Rows[rowIndex][Constants.FILEID].ToString(), GenAccountTotal = "0.00", TrustAccountTotal = "0.00", AssignedAttorney = allClientDetails.Tables[0].Rows[rowIndex][Constants.ASSIGNEDATTORNY].ToString() }; reportItems.Add(newTransaction); } string tempFileNo = string.Empty; AllClientBillingReportViewModel tempItem = null; for (int rowIndex = 0; rowIndex < allTransactionTotal.Tables[0].Rows.Count; rowIndex++) { tempFileNo = allTransactionTotal.Tables[0].Rows[rowIndex][Constants.FILEID].ToString(); tempItem = reportItems.FirstOrDefault(item => item.FileNo == tempFileNo); if (tempItem != null) { tempItem.GenAccountTotal = float.Parse(allTransactionTotal.Tables[0].Rows[rowIndex][Constants.GENTOTAL].ToString()).ToString("0.00"); genAccountGrandTotal += float.Parse(allTransactionTotal.Tables[0].Rows[rowIndex][Constants.GENTOTAL].ToString()); tempItem.TrustAccountTotal = float.Parse(allTransactionTotal.Tables[0].Rows[rowIndex][Constants.TRUSTTOTAL].ToString()).ToString("0.00"); trustAccountGrandTotal += float.Parse(allTransactionTotal.Tables[0].Rows[rowIndex][Constants.TRUSTTOTAL].ToString()); } } AllClientBillingReportViewModel emptyRow = new AllClientBillingReportViewModel(); reportItems.Add(emptyRow); emptyRow = new AllClientBillingReportViewModel(); emptyRow.FileNo = "-----------------"; emptyRow.GenAccountTotal = "-----------------"; emptyRow.TrustAccountTotal = "-----------------"; reportItems.Add(emptyRow); AllClientBillingReportViewModel footer = new AllClientBillingReportViewModel(); footer.FileNo = "Grand Total:"; footer.GenAccountTotal = genAccountGrandTotal.ToString("0.00"); footer.TrustAccountTotal = trustAccountGrandTotal.ToString("0.00"); reportItems.Add(footer); emptyRow = new AllClientBillingReportViewModel(); emptyRow.FileNo = "-----------------"; emptyRow.GenAccountTotal = "-----------------"; emptyRow.TrustAccountTotal = "-----------------"; reportItems.Add(emptyRow); } catch (Exception ex) { throw ex; } return reportItems; }
public override DocumentPage GetPage(int pageNumber) { DocumentPage page = null; List<object> itemsSource = new List<object>(); ICollectionView viewSource = CollectionViewSource.GetDefaultView(_documentSource.ItemsSource); if (viewSource != null) { AllClientBillingReportViewModel temp = new AllClientBillingReportViewModel(); temp.Name = "=================="; temp.FileNo = "========"; temp.GenAccountTotal = "==========="; temp.TrustAccountTotal = "==========="; temp.AssignedAttorney= "============="; 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; }