Exemplo n.º 1
0
        private void BuildReport(List <MahalluManager.Model.Contribution> contributions, List <ContributionDetail> contributionDetails)
        {
            var x = contributionDetails.Join(contributions, detail => detail.Contribution_Id, contribution => contribution.Id, (detail, contribution) =>
                                             new {
                CategoryName = contribution.CategoryName,
                HouserNumber = detail.HouserNumber,
                HouseName    = detail.HouserName,
                Member       = detail.MemberName,
                Amount       = detail.Amount,
                CreatedOn    = detail.CreatedOn.ToShortDateString(),
                ReceiptNo    = detail.ReceiptNo,
                CareOf       = detail.CareOf
            });

            if (x.Count() == 0 && category != null && !Category.DetailsRequired)
            {
                MessageBox.Show("Details are not available for category " + Category.Name);
                return;
            }
            if (x != null && x.Count() > 0)
            {
                SearchStatus = x.Count() + " Found";
            }
            else
            {
                SearchStatus = "No Result Found";
            }
            for (int i = 0; i < x.Count(); i += 38)
            {
                var list = (from c in x
                            select c).Skip(i).Take(38);

                ListView l = new ListView();
                l.ItemsSource = list;
                GridView g = new GridView();
                l.Width    = 700; //690
                l.MaxWidth = 700;
                if (SelectedContributionColumns.Contains("Category Name"))
                {
                    GridViewColumn categoryName = new GridViewColumn()
                    {
                        Header = "Category", DisplayMemberBinding = new Binding("CategoryName"), Width = 180
                    };
                    g.Columns.Add(categoryName);
                }
                if (SelectedContributionColumns.Contains("House Number"))
                {
                    GridViewColumn houseNumber = new GridViewColumn()
                    {
                        Header = "House#", DisplayMemberBinding = new Binding("HouserNumber"), Width = 60
                    };
                    g.Columns.Add(houseNumber);
                }

                if (SelectedContributionColumns.Contains("House Name"))
                {
                    var houseName = new GridViewColumn()
                    {
                        Header = "House Name",
                        DisplayMemberBinding = new Binding("HouseName"),
                        Width = 120
                    };
                    g.Columns.Add(houseName);
                }

                if (SelectedContributionColumns.Contains("Member"))
                {
                    var member = new GridViewColumn()
                    {
                        Header = "Member Name",
                        DisplayMemberBinding = new Binding("Member"),
                        Width = 120
                    };
                    g.Columns.Add(member);
                }

                if (SelectedContributionColumns.Contains("Amount"))
                {
                    var amount = new GridViewColumn()
                    {
                        Header = "Amount",
                        DisplayMemberBinding = new Binding("Amount"),
                        Width = 100
                    };
                    g.Columns.Add(amount);
                }
                if (SelectedContributionColumns.Contains("Date"))
                {
                    var createdOn = new GridViewColumn()
                    {
                        Header = "Date",
                        DisplayMemberBinding = new Binding("CreatedOn"),
                        Width = 100
                    };
                    g.Columns.Add(createdOn);
                }
                if (SelectedContributionColumns.Contains("Receipt No"))
                {
                    var receiptNo = new GridViewColumn()
                    {
                        Header = "Receipt No",
                        DisplayMemberBinding = new Binding("ReceiptNo"),
                        Width = 80
                    };
                    g.Columns.Add(receiptNo);
                }
                if (SelectedContributionColumns.Contains("Care Of"))
                {
                    var careOf = new GridViewColumn()
                    {
                        Header = "Care Of",
                        DisplayMemberBinding = new Binding("CareOf"),
                        Width = 80
                    };
                    g.Columns.Add(careOf);
                }
                l.View                = g;
                inlineContainer       = new InlineUIContainer();
                inlineContainer.Child = l;
                p = new Paragraph(inlineContainer);
                if (ShowHeader)
                {
                    Paragraph header = new Paragraph();
                    header.Inlines.Add(HeaderText);
                    Result.Blocks.Add(header);
                }
                Result.Blocks.Add(p);
                if (i + 38 < x.Count())
                {
                    p = new Paragraph();
                    Result.Blocks.Add(p);
                }
            }
            if (SelectedContributionColumns.Contains("Amount") && x.Count() > 0)
            {
                decimal totalAmount = 0;
                foreach (var item in x)
                {
                    totalAmount += item.Amount;
                }
                Paragraph totalAmountPara = new Paragraph();
                totalAmountPara.Inlines.Add("Total = " + totalAmount);
                Result.Blocks.Add(totalAmountPara);
            }
        }
Exemplo n.º 2
0
        private void BuildReport(List <MahalluManager.Model.Contribution> contributions)
        {
            var x = contributions.Select(contribution =>
                                         new {
                CategoryName = contribution.CategoryName,
                ToatalAmount = contribution.ToatalAmount,
                CreatedOn    = contribution.CreatedOn.ToShortDateString(),
                ReceiptNo    = contribution.ReceiptNo
            });

            if (x != null && x.Count() > 0)
            {
                SearchStatus = x.Count() + " Found";
            }
            else
            {
                SearchStatus = "No Result Found";
            }
            for (int i = 0; i < x.Count(); i += 38)
            {
                var list = (from c in x
                            select c).Skip(i).Take(38);

                ListView l = new ListView();
                l.ItemsSource = list;
                GridView g = new GridView();
                l.Width    = 700; //690
                l.MaxWidth = 700;
                if (SelectedContributionColumns.Contains("Category Name"))
                {
                    GridViewColumn categoryName = new GridViewColumn()
                    {
                        Header = "Category", DisplayMemberBinding = new Binding("CategoryName"), Width = 180
                    };
                    g.Columns.Add(categoryName);
                }

                if (SelectedContributionColumns.Contains("Amount"))
                {
                    var amount = new GridViewColumn()
                    {
                        Header = "Amount",
                        DisplayMemberBinding = new Binding("ToatalAmount"),
                        Width = 120
                    };
                    g.Columns.Add(amount);
                }
                if (SelectedContributionColumns.Contains("Date"))
                {
                    var createdOn = new GridViewColumn()
                    {
                        Header = "Date",
                        DisplayMemberBinding = new Binding("CreatedOn"),
                        Width = 100
                    };
                    g.Columns.Add(createdOn);
                }
                if (SelectedContributionColumns.Contains("Receipt No"))
                {
                    var receiptNo = new GridViewColumn()
                    {
                        Header = "Receipt No",
                        DisplayMemberBinding = new Binding("ReceiptNo"),
                        Width = 80
                    };
                    g.Columns.Add(receiptNo);
                }

                l.View                = g;
                inlineContainer       = new InlineUIContainer();
                inlineContainer.Child = l;
                p = new Paragraph(inlineContainer);
                if (ShowHeader)
                {
                    Paragraph header = new Paragraph();
                    header.Inlines.Add(HeaderText);
                    Result.Blocks.Add(header);
                }
                Result.Blocks.Add(p);
                if (i + 38 < x.Count())
                {
                    p = new Paragraph();
                    Result.Blocks.Add(p);
                }
            }
            if (SelectedContributionColumns.Contains("Amount") && x.Count() > 0)
            {
                decimal totalAmount = 0;
                foreach (var item in x)
                {
                    totalAmount += item.ToatalAmount;
                }
                Paragraph totalAmountPara = new Paragraph();
                totalAmountPara.Inlines.Add("Total = " + totalAmount);
                Result.Blocks.Add(totalAmountPara);
            }
        }