public override DocumentPage GetPage(int pageNumber)
        {
            DocumentPage page = null;
            List<object> itemsSource = new List<object>();

            ICollectionView viewSource = CollectionViewSource.GetDefaultView(_documentSource.ItemsSource);

            if (viewSource != null)
            {
                StatuteReportViewModel temp = new StatuteReportViewModel();
                temp.Name = "=======";
                temp.FileNo = "=======";
                temp.Date = "============";
                temp.Date = "============";
                temp.Attorney = "============";
                itemsSource.Add(temp);

                foreach (object item in viewSource)
                    itemsSource.Add(item);
            }

            viewSource = CollectionViewSource.GetDefaultView(_dg180Days.ItemsSource);
            if (viewSource != null)
            {
                StatuteReportViewModel temp = new StatuteReportViewModel();
                temp.Name = "Name";
                temp.FileNo = "File No";
                temp.Date = "180 Days";
                temp.Attorney = "Attorney";
                itemsSource.Add(temp);

                temp = new StatuteReportViewModel();
                temp.Name = "=======";
                temp.FileNo = "=======";
                temp.Date = "============";
                temp.Attorney = "============";
                itemsSource.Add(temp);

                foreach (object item in viewSource)
                    itemsSource.Add(item);
            }

            viewSource = CollectionViewSource.GetDefaultView(_dg1Year.ItemsSource);
            if (viewSource != null)
            {
                StatuteReportViewModel temp = new StatuteReportViewModel();
                temp.Name = "Name";
                temp.FileNo = "File No";
                temp.Date = "1 Year";
                temp.Attorney = "Attorney";
                itemsSource.Add(temp);

                temp = new StatuteReportViewModel();
                temp.Name = "=======";
                temp.FileNo = "=======";
                temp.Date = "============";
                temp.Attorney = "============";
                itemsSource.Add(temp);

                foreach (object item in viewSource)
                    itemsSource.Add(item);
            }

            viewSource = CollectionViewSource.GetDefaultView(_dg2Years.ItemsSource);
            if (viewSource != null)
            {
                StatuteReportViewModel temp = new StatuteReportViewModel();
                temp.Name = "Name";
                temp.FileNo = "File No";
                temp.Date = "2 Years";
                temp.Attorney = "Attorney";
                itemsSource.Add(temp);

                temp = new StatuteReportViewModel();
                temp.Name = "=======";
                temp.FileNo = "=======";
                temp.Date = "============";
                temp.Attorney = "============";
                itemsSource.Add(temp);

                foreach (object item in viewSource)
                    itemsSource.Add(item);
            }

            viewSource = CollectionViewSource.GetDefaultView(_dg3Years.ItemsSource);
            if (viewSource != null)
            {
                StatuteReportViewModel temp = new StatuteReportViewModel();
                temp.Name = "Name";
                temp.FileNo = "File No";
                temp.Date = "3 Years";
                temp.Attorney = "Attorney";
                itemsSource.Add(temp);

                temp = new StatuteReportViewModel();
                temp.Name = "=======";
                temp.FileNo = "=======";
                temp.Date = "============";
                temp.Attorney = "============";
                itemsSource.Add(temp);
                foreach (object item in viewSource)
                    itemsSource.Add(item);
            }

            viewSource = CollectionViewSource.GetDefaultView(_dg5Years.ItemsSource);
            if (viewSource != null)
            {
                StatuteReportViewModel temp = new StatuteReportViewModel();
                temp.Name = "Name";
                temp.FileNo = "File No";
                temp.Date = "5 Years";
                temp.Attorney = "Attorney";
                itemsSource.Add(temp);

                temp = new StatuteReportViewModel();
                temp.Name = "=======";
                temp.FileNo = "=======";
                temp.Date = "============";
                temp.Attorney = "============";
                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;
        }
Пример #2
0
        internal static ObservableCollection<StatuteReportViewModel> GetStatuteReportData(string sql)
        {
            ObservableCollection<StatuteReportViewModel> reportItems = new ObservableCollection<StatuteReportViewModel>();
            try
            {
                var allClientDetails = DBHelper.GetSelectDataSet(sql);
                if (allClientDetails == null || allClientDetails.Tables.Count == 0 || allClientDetails.Tables[0].Rows.Count == 0)
                    return null;
                for (int rowIndex = 0; rowIndex < allClientDetails.Tables[0].Rows.Count; rowIndex++)
                {
                    StatuteReportViewModel newTransaction = new StatuteReportViewModel()
                    {
                        Name = allClientDetails.Tables[0].Rows[rowIndex][Constants.NAME].ToString(),
                        FileNo = allClientDetails.Tables[0].Rows[rowIndex][Constants.FILE_ID].ToString(),
                        Date = allClientDetails.Tables[0].Rows[rowIndex][Constants.DATE].ToString(),
                        Attorney = allClientDetails.Tables[0].Rows[rowIndex][Constants.ASSIGNEDATTORNY].ToString(),

                    };
                    reportItems.Add(newTransaction);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return reportItems;
        }