Ejemplo n.º 1
0
            //Constructors
            #region InvoiceLayout
            public InvoiceLayout(Sale sale)
            {
                this.Sale = sale;

                List <SaleItem> itemsWithShipping = new List <SaleItem>(this.Sale.SaleItems.ToArray());

                Int32 pageCount =
                    itemsWithShipping.Count % InvoiceLayout.InvoiceItemsPerPage == 0 ?
                    itemsWithShipping.Count / InvoiceLayout.InvoiceItemsPerPage :
                    itemsWithShipping.Count / InvoiceLayout.InvoiceItemsPerPage + 1;

                Int32 pageIndex = 0;

                this.InvoiceLayoutPages = new List <InvoiceLayoutPage>();
                while (pageIndex < pageCount)
                {
                    InvoiceLayoutPage lastPage = this.InvoiceLayoutPages.LastOrDefault();
                    InvoiceLayoutPage newPage  = new InvoiceLayoutPage(
                        this,
                        lastPage,
                        itemsWithShipping.Skip(pageIndex * InvoiceLayout.InvoiceItemsPerPage).Take(InvoiceLayout.InvoiceItemsPerPage));

                    if (lastPage != null)
                    {
                        lastPage.NextPage = newPage;
                    }

                    this.InvoiceLayoutPages.Add(newPage);
                    pageIndex++;
                }
            }
            //Constructors
            #region InvoiceLayout
            public InvoiceLayout(Invoice invoice, DocumentTypes documentType, Boolean isCopy)
            {
                this.Invoice      = invoice;
                this.DocumentType = documentType;
                this.IsCopy       = isCopy;

                List <InvoiceItem> itemsWithShipping = new List <InvoiceItem>(this.Invoice.InvoiceItems.OrderBy(runner => runner.ArticleNumber).ToArray());

                itemsWithShipping.Add(InvoiceItem.CreateShippingCosts(this.Invoice));

                Int32 pageCount =
                    itemsWithShipping.Count % InvoiceLayout.InvoiceItemsPerPage == 0 ?
                    itemsWithShipping.Count / InvoiceLayout.InvoiceItemsPerPage :
                    itemsWithShipping.Count / InvoiceLayout.InvoiceItemsPerPage + 1;

                Int32 pageIndex = 0;

                this.InvoiceLayoutPages = new List <InvoiceLayoutPage>();
                while (pageIndex < pageCount)
                {
                    InvoiceLayoutPage lastPage = this.InvoiceLayoutPages.LastOrDefault();
                    InvoiceLayoutPage newPage  = new InvoiceLayoutPage(
                        this,
                        lastPage,
                        itemsWithShipping.Skip(pageIndex * InvoiceLayout.InvoiceItemsPerPage).Take(InvoiceLayout.InvoiceItemsPerPage));

                    if (lastPage != null)
                    {
                        lastPage.NextPage = newPage;
                    }

                    this.InvoiceLayoutPages.Add(newPage);
                    pageIndex++;
                }
            }
Ejemplo n.º 3
0
 //Constructors
 #region InvoiceLayoutPage
 public InvoiceLayoutPage(
     InvoiceLayout parent,
     InvoiceLayoutPage previousPage,
     IEnumerable <SaleItem> items)
 {
     this.parent       = parent;
     this.PreviousPage = previousPage;
     this.SaleItems    = new List <SaleItem>(items);
 }