예제 #1
0
        static string GetMainInfo(TransactionReportGroupedDTO trans, FilterTransactionReport filter)
        {
            StringBuilder strBuilder = new StringBuilder();

            strBuilder.Append(trans.Name);
            //fill company
            if (!string.IsNullOrEmpty(trans.Company) &&
                filter.Columns.Any(r => r.TransactionColumn == TransactioReportColumns.Company && r.IsChecked))
            {
                strBuilder.AppendLine(trans.Company);
            }

            //fill contacts
            if (trans.FamilyDetails != null)
            {
                if (trans.FamilyDetails.Contacts.Any() && filter.Columns.Any(r => r.IsChecked && r.IsContact))
                {
                    strBuilder.AppendLine();
                    foreach (ContactReportContactInfo cont in trans.FamilyDetails.Contacts)
                    {
                        if (filter.Columns.Any(r => (int)r.TransactionColumn == cont.PhoneTypeID && r.IsChecked))
                        {
                            strBuilder.AppendFormat(" {0}: {1}; ",
                                                    Grouping.GetTranslation(GetContactName(cont.PhoneTypeID, cont.MemberType)),
                                                    cont.PhoneNumber);
                        }
                    }
                }
                if (trans.FamilyDetails.Addresses.Any() &&
                    filter.Columns.Any(e => e.TransactionColumn == TransactioReportColumns.Address && e.IsChecked))
                {
                    //home address
                    if (trans.FamilyDetails.Addresses.Any(e => e.AddressTypeID == 1))
                    {
                        strBuilder.AppendLine();
                        strBuilder.Append(Grouping.GetTranslation("trans_info_homeAddress"));
                        foreach (ContactReportAddress addr in trans.FamilyDetails.Addresses.Where(r => r.AddressTypeID == 1))
                        {
                            strBuilder.AppendFormat(" {0} {1},{2} {3} {4}; ", addr.Address, addr.City, addr.State, addr.Zip, addr.Country);
                        }
                    }
                    //work address
                    if (trans.FamilyDetails.Addresses.Any(e => e.AddressTypeID == 2))
                    {
                        strBuilder.AppendLine();
                        strBuilder.Append(Grouping.GetTranslation("trans_info_workAddress"));
                        foreach (ContactReportAddress addr in trans.FamilyDetails.Addresses.Where(r => r.AddressTypeID == 2))
                        {
                            strBuilder.AppendFormat(" {0} {1},{2} {3} {4}; ", addr.Address, addr.City, addr.State, addr.Zip, addr.Country);
                        }
                    }
                }
            }
            return(strBuilder.ToString());
        }
예제 #2
0
        static int CreateColumns(FilterContactReport filter, int colsCount, Unit?sectionWidth = null)
        {
            Unit?colWidth = null;

            if (sectionWidth != null)
            {
                colWidth = sectionWidth / colsCount;
            }
            List <ReportColumn> checkedCols = new List <ReportColumn>();
            Column column = _table.AddColumn();

            //first name col
            column.Format.Alignment = ParagraphAlignment.Center;
            if (colWidth != null)
            {
                column.Width = (Unit)colWidth;
            }
            //create cols obj
            checkedCols = filter.Columns.Where(r => r.IsChecked).ToList();
            //company
            if (checkedCols.Any(e => e.Column == ReportColumns.Company))
            {
                column = _table.AddColumn();
                if (colWidth != null)
                {
                    column.Width = (Unit)colWidth;
                }
                column.Format.Alignment = ParagraphAlignment.Right;
            }
            //Address
            if (checkedCols.Any(e => (int)e.Column >= 8 && (int)e.Column <= 12))
            {
                //col for address
                if (checkedCols.Any(r => r.Column == ReportColumns.Address && r.IsChecked))
                {
                    column = _table.AddColumn();
                    if (colWidth != null)
                    {
                        column.Width = (Unit)colWidth;
                    }
                    column.Format.Alignment = ParagraphAlignment.Right;
                }
                //col for city,state,zip, country
                if (checkedCols.Any(e => (int)e.Column >= 8 && (int)e.Column <= 12 && e.IsChecked))
                {
                    column = _table.AddColumn();
                    if (colWidth != null)
                    {
                        column.Width = (Unit)colWidth;
                    }
                    column.Format.Alignment = ParagraphAlignment.Right;
                }
            }
            //Contact data
            foreach (ReportColumn col in checkedCols.Where(e => (int)e.Column <= 7).OrderBy(e => e.Column))
            {
                column = _table.AddColumn();
                if (colWidth != null)
                {
                    column.Width = (Unit)colWidth;
                }
                column.Format.Alignment = ParagraphAlignment.Right;
            }



            //fill col obj
            var startedIsnex = 1;
            Row row          = _table.AddRow();

            //Name
            FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, 0, Grouping.GetTranslation("new_report_Name"), true, ParagraphAlignment.Left, VerticalAlignment.Bottom, true, TableHeaderFont, fontSize: 11);
            //Company
            if (checkedCols.Any(e => e.Column == ReportColumns.Company))
            {
                startedIsnex++;
                var col = checkedCols.First(e => e.Column == ReportColumns.Company);
                FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, 1,
                        Grouping.GetTranslation(Grouping.GetTranslation(col.Name)), true, ParagraphAlignment.Center, VerticalAlignment.Bottom, true, TableHeaderFont, fontSize: 11);
            }
            //Address
            if (checkedCols.Any(e => (int)e.Column >= 8 && (int)e.Column <= 12))
            {
                var colName     = "";
                var colPosition = checkedCols.Any(r => r.Column == ReportColumns.Company) ? 2 : 1;
                if (checkedCols.Any(e => e.Column == ReportColumns.Address && e.IsChecked))
                {
                    colName += Grouping.GetTranslation(checkedCols.First(e => e.Column == ReportColumns.Address).Name);
                    startedIsnex++;
                    FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, colPosition,
                            colName, true, ParagraphAlignment.Center, VerticalAlignment.Bottom, true, TableHeaderFont, fontSize: 11);
                    colPosition++;
                }
                colName = "";
                if (checkedCols.Any(e => (int)e.Column >= 8 && (int)e.Column <= 12 && e.IsChecked))
                {
                    if (checkedCols.Any(e => e.Column == ReportColumns.City))
                    {
                        colName +=
                            $"{Grouping.GetTranslation(checkedCols.First(e => e.Column == ReportColumns.City).Name)}";
                    }
                    if (checkedCols.Any(e => e.Column == ReportColumns.State))
                    {
                        colName +=
                            $"/{Grouping.GetTranslation(checkedCols.First(e => e.Column == ReportColumns.State).Name)}";
                    }
                    if (checkedCols.Any(e => e.Column == ReportColumns.Zip))
                    {
                        colName +=
                            $"/{Grouping.GetTranslation(checkedCols.First(e => e.Column == ReportColumns.Zip).Name)}";
                    }
                    if (checkedCols.Any(e => e.Column == ReportColumns.Country))
                    {
                        colName +=
                            $"/{Grouping.GetTranslation(checkedCols.First(e => e.Column == ReportColumns.Country).Name)}";
                    }
                    startedIsnex++;
                    FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, colPosition,
                            colName, true, ParagraphAlignment.Center, VerticalAlignment.Bottom, true, TableHeaderFont,
                            fontSize: 11);
                }
            }
            //Contact data
            checkedCols = checkedCols.Where(e => (int)e.Column <= 7).OrderBy(e => e.Column).ToList();

            for (var i = 0; i < checkedCols.Count; i++)
            {
                var          index = startedIsnex + i;
                ReportColumn col   = checkedCols[i];
                FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, index,
                        Grouping.GetTranslation(Grouping.GetTranslation(col.Name)), true, ParagraphAlignment.Center, VerticalAlignment.Bottom, true, TableHeaderFont, fontSize: 11);
            }

            var colCount = row.Cells.Count;


            return(colCount);
        }
예제 #3
0
        static int CreateColumns(FilterTransactionReport filter, Unit?sectionWidth = null)
        {
            //for total
            Unit?colWidth = null;

            if (sectionWidth != null)
            {
                colWidth = sectionWidth / (filter.ReportType == TransFilterType.Payment ? 2 : 5);
            }
            List <ReportColumn> checkedCols = new List <ReportColumn>();
            Column column = _table.AddColumn();

            //first empty col
            column.Format.Alignment = ParagraphAlignment.Center;
            if (colWidth != null)
            {
                column.Width = (Unit)colWidth;
            }
            //create cols obj
            if (filter.view == TransFilterView.Details)
            {
                checkedCols = filter.Columns.Where(r => r.IsChecked && r.ColumnOnly).ToList();
                for (var index = 0; index < checkedCols.Count; index++)
                {
                    column = _table.AddColumn();
                    column.Format.Alignment = ParagraphAlignment.Right;
                }
            }
            if (filter.ReportType == TransFilterType.Payment)
            {
                //amount
                column = _table.AddColumn();
                if (colWidth != null)
                {
                    column.Width = (Unit)colWidth;
                }
                column.Format.Alignment = ParagraphAlignment.Right;
            }
            if (filter.ReportType == TransFilterType.Bill)
            {
                //bill amount
                column = _table.AddColumn();
                if (colWidth != null)
                {
                    column.Width = (Unit)colWidth;
                }
                column.Format.Alignment = ParagraphAlignment.Right;
                //paid amount
                column = _table.AddColumn();
                if (colWidth != null)
                {
                    column.Width = (Unit)colWidth;
                }
                column.Format.Alignment = ParagraphAlignment.Right;
                //due amount
                column = _table.AddColumn();
                if (colWidth != null)
                {
                    column.Width = (Unit)colWidth;
                }
                column.Format.Alignment = ParagraphAlignment.Right;
                //unasignet amount
                column = _table.AddColumn();
                if (colWidth != null)
                {
                    column.Width = (Unit)colWidth;
                }
                column.Format.Alignment = ParagraphAlignment.Right;
            }

            //fill col obj
            Row row = _table.AddRow();

            FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, 0, "", true, ParagraphAlignment.Left, VerticalAlignment.Bottom, true, TableHeaderFont, fontSize: 11);

            if (filter.view == TransFilterView.Details)
            {
                for (var index = 0; index < checkedCols.Count; index++)
                {
                    ReportColumn col = checkedCols[index];
                    FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, index + 1,
                            Grouping.GetTranslation(Grouping.GetTranslation(col.Column.ToString())), true, ParagraphAlignment.Center, VerticalAlignment.Bottom, true, TableHeaderFont, fontSize: 11);
                    AddColToPositionList((TransactioReportColumns)col.TransactionColumn, index + 1);
                }
            }
            if (filter.ReportType == TransFilterType.Payment)
            {
                var index = checkedCols.Count + 1;
                FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, index, Grouping.GetTranslation("report_trans_amount"), true, ParagraphAlignment.Center, VerticalAlignment.Bottom, true, TableHeaderFont, fontSize: 11);
            }
            if (filter.ReportType == TransFilterType.Bill)
            {
                var index = checkedCols.Count + 1;
                FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, index, Grouping.GetTranslation("report_trans_billAmount"), true, ParagraphAlignment.Center, VerticalAlignment.Center, true, TableHeaderFont, fontSize: 11);
                FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, index + 1, Grouping.GetTranslation("report_trans_paidAmount"), true, ParagraphAlignment.Center, VerticalAlignment.Center, true, TableHeaderFont, fontSize: 11);
                FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, index + 2, Grouping.GetTranslation("report_trans_dueAmount"), true, ParagraphAlignment.Center, VerticalAlignment.Center, true, TableHeaderFont, fontSize: 11);
                FillRow(row, ParagraphAlignment.Center, true, TableHeaderBackground, index + 3, Grouping.GetTranslation("report_trans_unasignedAmount"), true, ParagraphAlignment.Center, VerticalAlignment.Center, true, TableHeaderFont, fontSize: 11);
            }


            var colCount = row.Cells.Count;


            return(colCount);
        }
예제 #4
0
        static int CreatePage(FilterTransactionReport filter, int countTransactions, List <TransactionMatrixColumn> matrixCols = null)
        {
            var colCount = filter.Columns.Count(r => r.IsChecked && r.ColumnOnly);

            if (filter.view == TransFilterView.Details)
            {
                if (filter.ReportType == TransFilterType.Bill)
                {
                    colCount += 5;
                }
                if (filter.ReportType == TransFilterType.Payment)
                {
                    colCount += 2;
                }
            }
            // Each MigraDoc document needs at least one section.
            _section = _document.AddSection();
            //_section.PageSetup = _document.DefaultPageSetup.Clone();
            var pageSize = _document.DefaultPageSetup.Clone();

            pageSize.Orientation = colCount < 5 ? Orientation.Portrait : Orientation.Landscape;
            pageSize.PageFormat  = PageFormat.A4;
            pageSize.LeftMargin  = new Unit {
                Centimeter = 1.5
            };
            _section.PageSetup = pageSize;

            Paragraph paragraph = _section.Headers.Primary.AddParagraph();

            paragraph.AddText(filter.Name);
            paragraph.Format.Font.Size = 9;
            paragraph.Format.Alignment = ParagraphAlignment.Center;

            // Create the item table
            _table       = _section.AddTable();
            _table.Style = "Table";

            _table.Borders.Color       = TableBorder;
            _table.Borders.Width       = 0.25;
            _table.Borders.Left.Width  = 0.5;
            _table.Borders.Right.Width = 0.5;
            _table.Rows.LeftIndent     = -20;
            _table.Rows.HeightRule     = RowHeightRule.AtLeast;
            _table.Rows.Height         = 12;
            int  colsCount = 0;
            Unit?pageWidth = null;

            if (filter.view == TransFilterView.Total)
            {
                pageWidth = _section.PageSetup.PageWidth - _section.PageSetup.LeftMargin - _section.PageSetup.RightMargin;
            }

            if (!string.Equals(filter.totalOnlyBy, "totalOnly", StringComparison.InvariantCultureIgnoreCase))
            {
                CreateMatrixColumns(matrixCols, pageWidth);
            }
            else
            {
                colsCount = CreateColumns(filter, pageWidth);
            }
            _table.SetEdge(0, 0, colsCount, 1, Edge.Box, BorderStyle.Single, 0.75, Color.Empty);
            Paragraph totalText = _section.AddParagraph();

            totalText.AddText($"{Grouping.GetTranslation("transaction_report_name")} \n " +
                              $"{Grouping.GetTranslation("transaction_report_numberOfTransactions")} {countTransactions}");
            totalText.Format.Font.Size  = 9;
            totalText.Format.Alignment  = ParagraphAlignment.Left;
            totalText.Format.LeftIndent = -20;
            return(colsCount);
        }