private void RenderCCSummary(List <OrderTransaction> tranData)
        {
            var     data             = new List <CCSummaryItem>();
            var     cardtype         = string.Empty;
            decimal totalType        = 0;
            var     transactionCount = 0;

            foreach (var dataitem in tranData)
            {
                if (!ActionTypeUtils.IsCreditCardTransaction(dataitem.Action))
                {
                    continue;
                }

                if (dataitem.CreditCard.CardTypeName != cardtype)
                {
                    if (cardtype != string.Empty)
                    {
                        data.Add(new CCSummaryItem(cardtype, transactionCount, totalType));
                    }
                    totalType        = 0;
                    transactionCount = 0;
                    cardtype         = dataitem.CreditCard.CardTypeName;
                }

                if (dataitem.AmountAppliedToOrder != 0)
                {
                    totalType        += dataitem.AmountAppliedToOrder;
                    RepCCGrandTotal  += dataitem.AmountAppliedToOrder;
                    transactionCount += 1;
                }
            }

            if (!string.IsNullOrEmpty(cardtype))
            {
                data.Add(new CCSummaryItem(cardtype, transactionCount, totalType));
            }

            rpCCSummary.DataSource = data;
            rpCCSummary.DataBind();
        }
        private void RenderReport(IOrderedEnumerable <OrderTransaction> data)
        {
            decimal TotalGrand = 0;
            var     cardtype   = "?";
            decimal totalType  = 0;

            foreach (var dataitem in data)
            {
                if (!ActionTypeUtils.IsCreditCardTransaction(dataitem.Action) &&
                    !ActionTypeUtils.IsGiftCardTransaction(dataitem.Action))
                {
                    continue;
                }

                var cardTypeName = dataitem.CreditCard.CardTypeName;

                if (ActionTypeUtils.IsGiftCardTransaction(dataitem.Action))
                {
                    cardTypeName = Localization.GetString("GiftCard");
                }

                if (cardTypeName != cardtype)
                {
                    if (cardtype != "?")
                    {
                        RenderPreviousTotal(totalType);
                    }
                    totalType = 0;
                    RenderHeader(cardTypeName);
                    cardtype = cardTypeName;
                }

                if (dataitem.AmountAppliedToOrder != 0)
                {
                    totalType  += dataitem.AmountAppliedToOrder;
                    TotalGrand += dataitem.AmountAppliedToOrder;
                    TotalCount++;

                    var row = new TableRow {
                        CssClass = "hcGridRow hcRight"
                    };

                    row.Cells.AddRange(new[]
                    {
                        new TableCell
                        {
                            Text = DateHelper.ConvertUtcToStoreTime(HccApp, dataitem.TimeStampUtc).ToString()
                        },
                        new TableCell {
                            Text = dataitem.OrderNumber
                        },
                        new TableCell {
                            Text = dataitem.Id.ToString()
                        },
                        new TableCell {
                            Text = "XXXX XXXX XXXX " + dataitem.CreditCard.CardNumberLast4Digits
                        },
                        new TableCell {
                            Text = dataitem.AmountAppliedToOrder.ToString("C")
                        }
                    });

                    tblReport.Rows.Add(row);
                }
            }

            if (cardtype != string.Empty)
            {
                RenderPreviousTotal(totalType);
            }

            var footer = new TableRow {
                CssClass = "hcGridFooter"
            };

            footer.Cells.AddRange(new[]
            {
                new TableCell {
                    Text = Localization.GetString("TotalForAllCards"), ColumnSpan = 4
                },
                new TableCell {
                    Text = TotalGrand.ToString("C")
                }
            });

            tblReport.Rows.Add(footer);
        }
        private void RenderTransaction(OrderTransaction t, StringBuilder sb, TimeZoneInfo timezone, bool showCardNumbers)
        {
            sb.Append("<div class=\"controlarea1");
            if (t.Voided)
            {
                sb.Append(" transactionvoided");
            }
            else
            {
                if (t.Success)
                {
                    sb.Append(" transactionsuccess");
                }
                else
                {
                    sb.Append(" transactionfailed");
                }
            }
            sb.Append("\"><div style=\"overflow:auto;width:100%;\">");

            if (t.Voided)
            {
                sb.Append("VOIDED<br />");
            }
            sb.Append(t.Amount.ToString("c") + " - ");

            var paymentMethod = PaymentMethods.Find(t.MethodId);
            var methodName    = paymentMethod != null ? paymentMethod.MethodName : string.Empty;
            var methodInfo    = LocalizationUtils.GetActionType(t.Action, methodName);

            sb.Append(methodInfo + "<br />");
            sb.Append(TimeZoneInfo.ConvertTimeFromUtc(t.TimeStampUtc, timezone) + "<br />");
            if (t.Success)
            {
                sb.Append("OK<br />");
            }
            else
            {
                sb.Append("FAILED<br />");
            }
            if (t.Action == ActionType.PurchaseOrderInfo || t.Action == ActionType.PurchaseOrderAccepted)
            {
                sb.Append("PO # " + t.PurchaseOrderNumber + "<br />");
            }
            if (t.Action == ActionType.CheckReceived || t.Action == ActionType.CheckReturned)
            {
                sb.Append("Check # " + t.CheckNumber + "<br />");
            }
            if (ActionTypeUtils.IsCreditCardTransaction(t.Action))
            {
                if (t.CreditCard.IsCardNumberValid())
                {
                    if (showCardNumbers)
                    {
                        sb.Append(t.CreditCard.CardTypeName + " " + t.CreditCard.CardNumber + "<br />");
                    }
                    else
                    {
                        sb.Append(t.CreditCard.CardTypeName + " xxxx-xxxx-xxxx-" + t.CreditCard.CardNumberLast4Digits +
                                  "<br />");
                    }
                    sb.Append("exp: " + t.CreditCard.ExpirationMonth + "/" + t.CreditCard.ExpirationYear + "<br />");
                }
                else
                {
                    sb.Append("Unknown or Invalid Card Number Entered" + "<br/>");
                }
            }
            if (ActionTypeUtils.IsGiftCardTransaction(t.Action))
            {
                sb.Append("Gift Card " + t.GiftCard.CardNumber + "<br />");
            }
            if (!string.IsNullOrEmpty(t.RefNum1))
            {
                sb.Append("Ref#: " + t.RefNum1 + "<br />");
            }
            if (!string.IsNullOrEmpty(t.RefNum2))
            {
                sb.Append("Ref2#: " + t.RefNum2 + "<br />");
            }
            if (!string.IsNullOrEmpty(t.RMABvin))
            {
                sb.Append("RMA: " + t.RMABvin + "<br />");
            }
            sb.Append(t.Messages);
            sb.Append("</div></div>");
        }