コード例 #1
0
        public override DocumentPage GetPage(int pageNumber)
        {
            DocumentPage page = null;
            List<object> itemsSource = new List<object>();

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

            if (viewSource != null)
            {
                CommonReportViewModel temp = new CommonReportViewModel();
                temp.ClientName = "==============";
                temp.FileNo = "========";
                temp.ByAttorney = "==========";
                temp.AccidentDate = "==========";
                temp.CaseNo= "==========";
                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
        public override DocumentPage GetPage(int pageNumber)
        {
            DocumentPage  page        = null;
            List <object> itemsSource = new List <object>();

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

            if (viewSource != null)
            {
                CommonReportViewModel temp = new CommonReportViewModel();
                temp.ClientName   = "==============";
                temp.FileNo       = "========";
                temp.ByAttorney   = "==========";
                temp.AccidentDate = "==========";
                temp.CaseNo       = "==========";
                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);
        }
コード例 #3
0
ファイル: BusinessLogic.cs プロジェクト: ultrasonicsoft/css
        internal static ObservableCollection<CommonReportViewModel> GetClientReportData(string sql, AssignedBy criteria)
        {
            ObservableCollection<CommonReportViewModel> reportItems = new ObservableCollection<CommonReportViewModel>();
            try
            {
                var result = DBHelper.GetSelectDataSet(sql);
                if (result == null)
                    return null;

                string byAttorneyColumn = string.Empty;

                switch (criteria)
                {
                    case AssignedBy.AssignedAttorney:
                        byAttorneyColumn = Constants.CLIENT_ASSIGNEDATTORNY_COLUMN;
                        break;
                    case AssignedBy.OriginatingAttorney:
                        byAttorneyColumn = Constants.CLIENT_ORIGINATINGATTORNY_COLUMN;
                        break;
                    case AssignedBy.Referral:
                        byAttorneyColumn = Constants.CLIENT_REFERRAL_COLUMN;
                        break;
                }

                for (int rowIndex = 0; rowIndex < result.Tables[0].Rows.Count; rowIndex++)
                {
                    //CommonReportViewModel newTransaction = new CommonReportViewModel()
                    //{
                    //    ClientName = result.Tables[0].Rows[rowIndex][Constants.CLIENT_NAME].ToString(),
                    //    FileNo = result.Tables[0].Rows[rowIndex][Constants.FILE_ID].ToString(),
                    //    ByAttorney = result.Tables[0].Rows[rowIndex][byAttorneyColumn].ToString(),
                    //    AccidentDate = DateTime.Parse(result.Tables[0].Rows[rowIndex][Constants.ACCIDENT_DATE_COLUMN].ToString()).ToShortDateString(),
                    //    CaseNo = result.Tables[0].Rows[rowIndex][Constants.CLIENT_COURT_CASE_NUMBER_COLUMN].ToString()
                    //};
                    CommonReportViewModel newTransaction = new CommonReportViewModel();

                    newTransaction.ClientName = result.Tables[0].Rows[rowIndex][Constants.CLIENT_NAME].ToString();
                    newTransaction.FileNo = result.Tables[0].Rows[rowIndex][Constants.FILE_ID].ToString();
                    newTransaction.ByAttorney = result.Tables[0].Rows[rowIndex][byAttorneyColumn].ToString();
                    string date = result.Tables[0].Rows[rowIndex][Constants.ACCIDENT_DATE_COLUMN].ToString();
                    if (false == string.IsNullOrEmpty(date))
                    {
                        newTransaction.AccidentDate = DateTime.Parse(date).ToShortDateString();
                    }
                    newTransaction.CaseNo = result.Tables[0].Rows[rowIndex][Constants.CLIENT_COURT_CASE_NUMBER_COLUMN].ToString();

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